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"
31 #include "BytecodeConventions.h"
33 #include "Instruction.h"
34 #include "LowLevelInterpreter.h"
37 namespace JSC
{ namespace LLInt
{
40 : m_exceptionInstructions(new Instruction
[maxOpcodeLength
+ 1])
41 , m_opcodeMap(new Opcode
[numOpcodeIDs
])
43 for (int i
= 0; i
< maxOpcodeLength
+ 1; ++i
)
44 m_exceptionInstructions
[i
].u
.pointer
= bitwise_cast
<void*>(&llint_throw_from_slow_path_trampoline
);
45 #define OPCODE_ENTRY(opcode, length) m_opcodeMap[opcode] = bitwise_cast<void*>(&llint_##opcode);
46 FOR_EACH_OPCODE_ID(OPCODE_ENTRY
);
51 #pragma clang diagnostic push
52 #pragma clang diagnostic ignored "-Wmissing-noreturn"
54 void Data::performAssertions(JSGlobalData
& globalData
)
56 UNUSED_PARAM(globalData
);
58 // Assertions to match LowLevelInterpreter.asm. If you change any of this code, be
59 // prepared to change LowLevelInterpreter.asm as well!!
60 ASSERT(RegisterFile::CallFrameHeaderSize
* 8 == 48);
61 ASSERT(RegisterFile::ArgumentCount
* 8 == -48);
62 ASSERT(RegisterFile::CallerFrame
* 8 == -40);
63 ASSERT(RegisterFile::Callee
* 8 == -32);
64 ASSERT(RegisterFile::ScopeChain
* 8 == -24);
65 ASSERT(RegisterFile::ReturnPC
* 8 == -16);
66 ASSERT(RegisterFile::CodeBlock
* 8 == -8);
67 ASSERT(CallFrame::argumentOffsetIncludingThis(0) == -RegisterFile::CallFrameHeaderSize
- 1);
69 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.tag
) == 0);
70 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.payload
) == 4);
72 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.tag
) == 4);
73 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor
, asBits
.payload
) == 0);
76 ASSERT(JSValue::Int32Tag
== -1);
77 ASSERT(JSValue::BooleanTag
== -2);
78 ASSERT(JSValue::NullTag
== -3);
79 ASSERT(JSValue::UndefinedTag
== -4);
80 ASSERT(JSValue::CellTag
== -5);
81 ASSERT(JSValue::EmptyValueTag
== -6);
82 ASSERT(JSValue::DeletedValueTag
== -7);
83 ASSERT(JSValue::LowestTag
== -7);
85 ASSERT(TagBitTypeOther
== 0x2);
86 ASSERT(TagBitBool
== 0x4);
87 ASSERT(TagBitUndefined
== 0x8);
88 ASSERT(ValueEmpty
== 0x0);
89 ASSERT(ValueFalse
== (TagBitTypeOther
| TagBitBool
));
90 ASSERT(ValueTrue
== (TagBitTypeOther
| TagBitBool
| 1));
91 ASSERT(ValueUndefined
== (TagBitTypeOther
| TagBitUndefined
));
92 ASSERT(ValueNull
== TagBitTypeOther
);
94 ASSERT(StringType
== 5);
95 ASSERT(ObjectType
== 13);
96 ASSERT(MasqueradesAsUndefined
== 1);
97 ASSERT(ImplementsHasInstance
== 2);
98 ASSERT(ImplementsDefaultHasInstance
== 8);
100 ASSERT(&globalData
.heap
.allocatorForObjectWithoutDestructor(sizeof(JSFinalObject
)) - &globalData
.heap
.firstAllocatorWithoutDestructors() == 1);
102 ASSERT(&globalData
.heap
.allocatorForObjectWithoutDestructor(sizeof(JSFinalObject
)) - &globalData
.heap
.firstAllocatorWithoutDestructors() == 3);
104 ASSERT(FirstConstantRegisterIndex
== 0x40000000);
105 ASSERT(GlobalCode
== 0);
106 ASSERT(EvalCode
== 1);
107 ASSERT(FunctionCode
== 2);
109 // FIXME: make these assertions less horrible.
111 Vector
<int> testVector
;
112 testVector
.resize(42);
113 ASSERT(bitwise_cast
<size_t*>(&testVector
)[0] == 42);
114 ASSERT(bitwise_cast
<int**>(&testVector
)[1] == testVector
.begin());
117 ASSERT(StringImpl::s_hashFlag8BitBuffer
== 64);
120 #pragma clang diagnostic pop
125 delete[] m_exceptionInstructions
;
126 delete[] m_opcodeMap
;
129 } } // namespace JSC::LLInt
131 #endif // ENABLE(LLINT)