]>
git.saurik.com Git - apple/javascriptcore.git/blob - dfg/DFGAssemblyHelpers.cpp
2 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include "DFGAssemblyHelpers.h"
31 namespace JSC
{ namespace DFG
{
33 const double AssemblyHelpers::twoToThe32
= (double)0x100000000ull
;
35 Vector
<BytecodeAndMachineOffset
>& AssemblyHelpers::decodedCodeMapFor(CodeBlock
* codeBlock
)
37 ASSERT(codeBlock
== codeBlock
->baselineVersion());
38 ASSERT(codeBlock
->getJITType() == JITCode::BaselineJIT
);
39 ASSERT(codeBlock
->jitCodeMap());
41 HashMap
<CodeBlock
*, Vector
<BytecodeAndMachineOffset
> >::AddResult result
= m_decodedCodeMaps
.add(codeBlock
, Vector
<BytecodeAndMachineOffset
>());
43 if (result
.isNewEntry
)
44 codeBlock
->jitCodeMap()->decode(result
.iterator
->second
);
46 return result
.iterator
->second
;
49 #if ENABLE(SAMPLING_FLAGS)
50 void AssemblyHelpers::setSamplingFlag(int32_t flag
)
54 or32(TrustedImm32(1u << (flag
- 1)), AbsoluteAddress(SamplingFlags::addressOfFlags()));
57 void AssemblyHelpers::clearSamplingFlag(int32_t flag
)
61 and32(TrustedImm32(~(1u << (flag
- 1))), AbsoluteAddress(SamplingFlags::addressOfFlags()));
65 #if DFG_ENABLE(JIT_ASSERT)
67 void AssemblyHelpers::jitAssertIsInt32(GPRReg gpr
)
70 Jump checkInt32
= branchPtr(BelowOrEqual
, gpr
, TrustedImmPtr(reinterpret_cast<void*>(static_cast<uintptr_t>(0xFFFFFFFFu
))));
72 checkInt32
.link(this);
78 void AssemblyHelpers::jitAssertIsJSInt32(GPRReg gpr
)
80 Jump checkJSInt32
= branchPtr(AboveOrEqual
, gpr
, GPRInfo::tagTypeNumberRegister
);
82 checkJSInt32
.link(this);
85 void AssemblyHelpers::jitAssertIsJSNumber(GPRReg gpr
)
87 Jump checkJSNumber
= branchTestPtr(MacroAssembler::NonZero
, gpr
, GPRInfo::tagTypeNumberRegister
);
89 checkJSNumber
.link(this);
92 void AssemblyHelpers::jitAssertIsJSDouble(GPRReg gpr
)
94 Jump checkJSInt32
= branchPtr(AboveOrEqual
, gpr
, GPRInfo::tagTypeNumberRegister
);
95 Jump checkJSNumber
= branchTestPtr(MacroAssembler::NonZero
, gpr
, GPRInfo::tagTypeNumberRegister
);
96 checkJSInt32
.link(this);
98 checkJSNumber
.link(this);
101 void AssemblyHelpers::jitAssertIsCell(GPRReg gpr
)
103 Jump checkCell
= branchTestPtr(MacroAssembler::Zero
, gpr
, GPRInfo::tagMaskRegister
);
105 checkCell
.link(this);
107 #elif USE(JSVALUE32_64)
108 void AssemblyHelpers::jitAssertIsInt32(GPRReg gpr
)
113 void AssemblyHelpers::jitAssertIsJSInt32(GPRReg gpr
)
115 Jump checkJSInt32
= branch32(Equal
, gpr
, TrustedImm32(JSValue::Int32Tag
));
117 checkJSInt32
.link(this);
120 void AssemblyHelpers::jitAssertIsJSNumber(GPRReg gpr
)
122 Jump checkJSInt32
= branch32(Equal
, gpr
, TrustedImm32(JSValue::Int32Tag
));
123 Jump checkJSDouble
= branch32(Below
, gpr
, TrustedImm32(JSValue::LowestTag
));
125 checkJSInt32
.link(this);
126 checkJSDouble
.link(this);
129 void AssemblyHelpers::jitAssertIsJSDouble(GPRReg gpr
)
131 Jump checkJSDouble
= branch32(Below
, gpr
, TrustedImm32(JSValue::LowestTag
));
133 checkJSDouble
.link(this);
136 void AssemblyHelpers::jitAssertIsCell(GPRReg gpr
)
138 Jump checkCell
= branch32(Equal
, gpr
, TrustedImm32(JSValue::CellTag
));
140 checkCell
.link(this);
142 #endif // USE(JSVALUE32_64)
144 void AssemblyHelpers::jitAssertHasValidCallFrame()
146 Jump checkCFR
= branchTestPtr(Zero
, GPRInfo::callFrameRegister
, TrustedImm32(7));
150 #endif // DFG_ENABLE(JIT_ASSERT)
152 } } // namespace JSC::DFG
154 #endif // ENABLE(DFG_JIT)