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 "LLIntData.h"
28 #include "BytecodeConventions.h"
30 #include "Instruction.h"
32 #include "LLIntCLoop.h"
33 #include "MaxFrameExtentForSlowPathCall.h"
35 #include "PropertyOffset.h"
37 namespace JSC
{ namespace LLInt
{
39 Instruction
* Data::s_exceptionInstructions
= 0;
40 Opcode
Data::s_opcodeMap
[numOpcodeIDs
] = { };
43 extern "C" void llint_entry(void*);
48 Data::s_exceptionInstructions
= new Instruction
[maxOpcodeLength
+ 1];
54 llint_entry(&Data::s_opcodeMap
);
56 for (int i
= 0; i
< maxOpcodeLength
+ 1; ++i
)
57 Data::s_exceptionInstructions
[i
].u
.pointer
=
58 LLInt::getCodePtr(llint_throw_from_slow_path_trampoline
);
63 #pragma clang diagnostic push
64 #pragma clang diagnostic ignored "-Wmissing-noreturn"
66 void Data::performAssertions(VM
& vm
)
70 // Assertions to match LowLevelInterpreter.asm. If you change any of this code, be
71 // prepared to change LowLevelInterpreter.asm as well!!
75 const ptrdiff_t PtrSize
= 8;
76 const ptrdiff_t CallFrameHeaderSlots
= 6;
77 #else // USE(JSVALUE64) // i.e. 32-bit version
78 const ptrdiff_t PtrSize
= 4;
79 const ptrdiff_t CallFrameHeaderSlots
= 5;
81 const ptrdiff_t SlotSize
= 8;
84 ASSERT(sizeof(void*) == PtrSize
);
85 ASSERT(sizeof(Register
) == SlotSize
);
86 ASSERT(JSStack::CallFrameHeaderSize
== CallFrameHeaderSlots
);
88 ASSERT(!CallFrame::callerFrameOffset());
89 ASSERT(JSStack::CallerFrameAndPCSize
== (PtrSize
* 2) / SlotSize
);
90 ASSERT(CallFrame::returnPCOffset() == CallFrame::callerFrameOffset() + PtrSize
);
91 ASSERT(JSStack::CodeBlock
* sizeof(Register
) == CallFrame::returnPCOffset() + PtrSize
);
92 ASSERT(JSStack::ScopeChain
* sizeof(Register
) == JSStack::CodeBlock
* sizeof(Register
) + SlotSize
);
93 ASSERT(JSStack::Callee
* sizeof(Register
) == JSStack::ScopeChain
* sizeof(Register
) + SlotSize
);
94 ASSERT(JSStack::ArgumentCount
* sizeof(Register
) == JSStack::Callee
* sizeof(Register
) + SlotSize
);
95 ASSERT(JSStack::ThisArgument
* sizeof(Register
) == JSStack::ArgumentCount
* sizeof(Register
) + SlotSize
);
96 ASSERT(JSStack::CallFrameHeaderSize
== JSStack::ThisArgument
);
98 ASSERT(CallFrame::argumentOffsetIncludingThis(0) == JSStack::ThisArgument
);
101 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.tag
) == 0);
102 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.payload
) == 4);
104 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.tag
) == 4);
105 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.payload
) == 0);
107 #if USE(JSVALUE32_64)
108 ASSERT(JSValue::Int32Tag
== static_cast<unsigned>(-1));
109 ASSERT(JSValue::BooleanTag
== static_cast<unsigned>(-2));
110 ASSERT(JSValue::NullTag
== static_cast<unsigned>(-3));
111 ASSERT(JSValue::UndefinedTag
== static_cast<unsigned>(-4));
112 ASSERT(JSValue::CellTag
== static_cast<unsigned>(-5));
113 ASSERT(JSValue::EmptyValueTag
== static_cast<unsigned>(-6));
114 ASSERT(JSValue::DeletedValueTag
== static_cast<unsigned>(-7));
115 ASSERT(JSValue::LowestTag
== static_cast<unsigned>(-7));
117 ASSERT(TagBitTypeOther
== 0x2);
118 ASSERT(TagBitBool
== 0x4);
119 ASSERT(TagBitUndefined
== 0x8);
120 ASSERT(ValueEmpty
== 0x0);
121 ASSERT(ValueFalse
== (TagBitTypeOther
| TagBitBool
));
122 ASSERT(ValueTrue
== (TagBitTypeOther
| TagBitBool
| 1));
123 ASSERT(ValueUndefined
== (TagBitTypeOther
| TagBitUndefined
));
124 ASSERT(ValueNull
== TagBitTypeOther
);
126 #if (CPU(X86_64) && !OS(WINDOWS)) || CPU(ARM64) || !ENABLE(JIT)
127 ASSERT(!maxFrameExtentForSlowPathCall
);
128 #elif CPU(ARM) || CPU(SH4)
129 ASSERT(maxFrameExtentForSlowPathCall
== 24);
130 #elif CPU(X86) || CPU(MIPS)
131 ASSERT(maxFrameExtentForSlowPathCall
== 40);
132 #elif CPU(X86_64) && OS(WINDOWS)
133 ASSERT(maxFrameExtentForSlowPathCall
== 64);
135 ASSERT(StringType
== 5);
136 ASSERT(ObjectType
== 18);
137 ASSERT(FinalObjectType
== 19);
138 ASSERT(MasqueradesAsUndefined
== 1);
139 ASSERT(ImplementsHasInstance
== 2);
140 ASSERT(ImplementsDefaultHasInstance
== 8);
141 ASSERT(FirstConstantRegisterIndex
== 0x40000000);
142 ASSERT(GlobalCode
== 0);
143 ASSERT(EvalCode
== 1);
144 ASSERT(FunctionCode
== 2);
146 ASSERT(GlobalProperty
== 0);
147 ASSERT(GlobalVar
== 1);
148 ASSERT(ClosureVar
== 2);
149 ASSERT(GlobalPropertyWithVarInjectionChecks
== 3);
150 ASSERT(GlobalVarWithVarInjectionChecks
== 4);
151 ASSERT(ClosureVarWithVarInjectionChecks
== 5);
152 ASSERT(Dynamic
== 6);
154 ASSERT(ResolveModeAndType::mask
== 0xffff);
156 ASSERT(MarkedBlock::blockMask
== ~static_cast<decltype(MarkedBlock::blockMask
)>(0xffff));
158 // FIXME: make these assertions less horrible.
160 Vector
<int> testVector
;
161 testVector
.resize(42);
162 ASSERT(bitwise_cast
<uint32_t*>(&testVector
)[sizeof(void*)/sizeof(uint32_t) + 1] == 42);
163 ASSERT(bitwise_cast
<int**>(&testVector
)[0] == testVector
.begin());
166 ASSERT(StringImpl::s_hashFlag8BitBuffer
== 32);
169 #pragma clang diagnostic pop
172 } } // namespace JSC::LLInt