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
ExecutableBase* AssemblyHelpers::executableFor(const CodeOrigin& codeOrigin)
35
if (!codeOrigin.inlineCallFrame)
36
return m_codeBlock->ownerExecutable();
38
return codeOrigin.inlineCallFrame->executable.get();
41
Vector<BytecodeAndMachineOffset>& AssemblyHelpers::decodedCodeMapFor(CodeBlock* codeBlock)
43
ASSERT(codeBlock == codeBlock->baselineVersion());
44
ASSERT(codeBlock->getJITType() == JITCode::BaselineJIT);
45
ASSERT(codeBlock->jitCodeMap());
47
HashMap<CodeBlock*, Vector<BytecodeAndMachineOffset> >::AddResult result = m_decodedCodeMaps.add(codeBlock, Vector<BytecodeAndMachineOffset>());
49
if (result.isNewEntry)
50
codeBlock->jitCodeMap()->decode(result.iterator->value);
52
return result.iterator->value;
55
#if ENABLE(SAMPLING_FLAGS)
56
void AssemblyHelpers::setSamplingFlag(int32_t flag)
60
or32(TrustedImm32(1u << (flag - 1)), AbsoluteAddress(SamplingFlags::addressOfFlags()));
63
void AssemblyHelpers::clearSamplingFlag(int32_t flag)
67
and32(TrustedImm32(~(1u << (flag - 1))), AbsoluteAddress(SamplingFlags::addressOfFlags()));
71
#if DFG_ENABLE(JIT_ASSERT)
73
void AssemblyHelpers::jitAssertIsInt32(GPRReg gpr)
76
Jump checkInt32 = branch64(BelowOrEqual, gpr, TrustedImm64(static_cast<uintptr_t>(0xFFFFFFFFu)));
78
checkInt32.link(this);
84
void AssemblyHelpers::jitAssertIsJSInt32(GPRReg gpr)
86
Jump checkJSInt32 = branch64(AboveOrEqual, gpr, GPRInfo::tagTypeNumberRegister);
88
checkJSInt32.link(this);
91
void AssemblyHelpers::jitAssertIsJSNumber(GPRReg gpr)
93
Jump checkJSNumber = branchTest64(MacroAssembler::NonZero, gpr, GPRInfo::tagTypeNumberRegister);
95
checkJSNumber.link(this);
98
void AssemblyHelpers::jitAssertIsJSDouble(GPRReg gpr)
100
Jump checkJSInt32 = branch64(AboveOrEqual, gpr, GPRInfo::tagTypeNumberRegister);
101
Jump checkJSNumber = branchTest64(MacroAssembler::NonZero, gpr, GPRInfo::tagTypeNumberRegister);
102
checkJSInt32.link(this);
104
checkJSNumber.link(this);
107
void AssemblyHelpers::jitAssertIsCell(GPRReg gpr)
109
Jump checkCell = branchTest64(MacroAssembler::Zero, gpr, GPRInfo::tagMaskRegister);
111
checkCell.link(this);
113
#elif USE(JSVALUE32_64)
114
void AssemblyHelpers::jitAssertIsInt32(GPRReg gpr)
119
void AssemblyHelpers::jitAssertIsJSInt32(GPRReg gpr)
121
Jump checkJSInt32 = branch32(Equal, gpr, TrustedImm32(JSValue::Int32Tag));
123
checkJSInt32.link(this);
126
void AssemblyHelpers::jitAssertIsJSNumber(GPRReg gpr)
128
Jump checkJSInt32 = branch32(Equal, gpr, TrustedImm32(JSValue::Int32Tag));
129
Jump checkJSDouble = branch32(Below, gpr, TrustedImm32(JSValue::LowestTag));
131
checkJSInt32.link(this);
132
checkJSDouble.link(this);
135
void AssemblyHelpers::jitAssertIsJSDouble(GPRReg gpr)
137
Jump checkJSDouble = branch32(Below, gpr, TrustedImm32(JSValue::LowestTag));
139
checkJSDouble.link(this);
142
void AssemblyHelpers::jitAssertIsCell(GPRReg gpr)
144
Jump checkCell = branch32(Equal, gpr, TrustedImm32(JSValue::CellTag));
146
checkCell.link(this);
148
#endif // USE(JSVALUE32_64)
150
void AssemblyHelpers::jitAssertHasValidCallFrame()
152
Jump checkCFR = branchTestPtr(Zero, GPRInfo::callFrameRegister, TrustedImm32(7));
156
#endif // DFG_ENABLE(JIT_ASSERT)
158
} } // namespace JSC::DFG
160
#endif // ENABLE(DFG_JIT)