]>
Commit | Line | Data |
---|---|---|
6fe7ccc8 A |
1 | /* |
2 | * Copyright (C) 2011 Apple Inc. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
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. | |
12 | * | |
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. | |
24 | */ | |
25 | ||
26 | #include "config.h" | |
27 | #include "LLIntData.h" | |
28 | ||
29 | #if ENABLE(LLINT) | |
30 | ||
31 | #include "BytecodeConventions.h" | |
32 | #include "CodeType.h" | |
33 | #include "Instruction.h" | |
93a37866 | 34 | #include "LLIntCLoop.h" |
6fe7ccc8 A |
35 | #include "Opcode.h" |
36 | ||
37 | namespace JSC { namespace LLInt { | |
38 | ||
93a37866 A |
39 | Instruction* Data::s_exceptionInstructions = 0; |
40 | Opcode* Data::s_opcodeMap = 0; | |
41 | ||
42 | void initialize() | |
6fe7ccc8 | 43 | { |
93a37866 A |
44 | Data::s_exceptionInstructions = new Instruction[maxOpcodeLength + 1]; |
45 | Data::s_opcodeMap = new Opcode[numOpcodeIDs]; | |
46 | ||
47 | #if ENABLE(LLINT_C_LOOP) | |
48 | CLoop::initialize(); | |
49 | ||
50 | #else // !ENABLE(LLINT_C_LOOP) | |
6fe7ccc8 | 51 | for (int i = 0; i < maxOpcodeLength + 1; ++i) |
93a37866 A |
52 | Data::s_exceptionInstructions[i].u.pointer = |
53 | LLInt::getCodePtr(llint_throw_from_slow_path_trampoline); | |
54 | #define OPCODE_ENTRY(opcode, length) \ | |
55 | Data::s_opcodeMap[opcode] = LLInt::getCodePtr(llint_##opcode); | |
6fe7ccc8 | 56 | FOR_EACH_OPCODE_ID(OPCODE_ENTRY); |
93a37866 A |
57 | #undef OPCODE_ENTRY |
58 | #endif // !ENABLE(LLINT_C_LOOP) | |
6fe7ccc8 A |
59 | } |
60 | ||
61 | #if COMPILER(CLANG) | |
62 | #pragma clang diagnostic push | |
63 | #pragma clang diagnostic ignored "-Wmissing-noreturn" | |
64 | #endif | |
93a37866 | 65 | void Data::performAssertions(VM& vm) |
6fe7ccc8 | 66 | { |
93a37866 | 67 | UNUSED_PARAM(vm); |
6fe7ccc8 A |
68 | |
69 | // Assertions to match LowLevelInterpreter.asm. If you change any of this code, be | |
70 | // prepared to change LowLevelInterpreter.asm as well!! | |
93a37866 A |
71 | ASSERT(JSStack::CallFrameHeaderSize * 8 == 48); |
72 | ASSERT(JSStack::ArgumentCount * 8 == -48); | |
73 | ASSERT(JSStack::CallerFrame * 8 == -40); | |
74 | ASSERT(JSStack::Callee * 8 == -32); | |
75 | ASSERT(JSStack::ScopeChain * 8 == -24); | |
76 | ASSERT(JSStack::ReturnPC * 8 == -16); | |
77 | ASSERT(JSStack::CodeBlock * 8 == -8); | |
78 | ASSERT(CallFrame::argumentOffsetIncludingThis(0) == -JSStack::CallFrameHeaderSize - 1); | |
6fe7ccc8 A |
79 | #if CPU(BIG_ENDIAN) |
80 | ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag) == 0); | |
81 | ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload) == 4); | |
82 | #else | |
83 | ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag) == 4); | |
84 | ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload) == 0); | |
85 | #endif | |
86 | #if USE(JSVALUE32_64) | |
93a37866 A |
87 | ASSERT(JSValue::Int32Tag == static_cast<unsigned>(-1)); |
88 | ASSERT(JSValue::BooleanTag == static_cast<unsigned>(-2)); | |
89 | ASSERT(JSValue::NullTag == static_cast<unsigned>(-3)); | |
90 | ASSERT(JSValue::UndefinedTag == static_cast<unsigned>(-4)); | |
91 | ASSERT(JSValue::CellTag == static_cast<unsigned>(-5)); | |
92 | ASSERT(JSValue::EmptyValueTag == static_cast<unsigned>(-6)); | |
93 | ASSERT(JSValue::DeletedValueTag == static_cast<unsigned>(-7)); | |
94 | ASSERT(JSValue::LowestTag == static_cast<unsigned>(-7)); | |
6fe7ccc8 A |
95 | #else |
96 | ASSERT(TagBitTypeOther == 0x2); | |
97 | ASSERT(TagBitBool == 0x4); | |
98 | ASSERT(TagBitUndefined == 0x8); | |
99 | ASSERT(ValueEmpty == 0x0); | |
100 | ASSERT(ValueFalse == (TagBitTypeOther | TagBitBool)); | |
101 | ASSERT(ValueTrue == (TagBitTypeOther | TagBitBool | 1)); | |
102 | ASSERT(ValueUndefined == (TagBitTypeOther | TagBitUndefined)); | |
103 | ASSERT(ValueNull == TagBitTypeOther); | |
104 | #endif | |
105 | ASSERT(StringType == 5); | |
93a37866 | 106 | ASSERT(ObjectType == 17); |
6fe7ccc8 A |
107 | ASSERT(MasqueradesAsUndefined == 1); |
108 | ASSERT(ImplementsHasInstance == 2); | |
109 | ASSERT(ImplementsDefaultHasInstance == 8); | |
6fe7ccc8 A |
110 | ASSERT(FirstConstantRegisterIndex == 0x40000000); |
111 | ASSERT(GlobalCode == 0); | |
112 | ASSERT(EvalCode == 1); | |
113 | ASSERT(FunctionCode == 2); | |
114 | ||
115 | // FIXME: make these assertions less horrible. | |
116 | #if !ASSERT_DISABLED | |
117 | Vector<int> testVector; | |
118 | testVector.resize(42); | |
93a37866 A |
119 | ASSERT(bitwise_cast<uint32_t*>(&testVector)[sizeof(void*)/sizeof(uint32_t) + 1] == 42); |
120 | ASSERT(bitwise_cast<int**>(&testVector)[0] == testVector.begin()); | |
6fe7ccc8 A |
121 | #endif |
122 | ||
123 | ASSERT(StringImpl::s_hashFlag8BitBuffer == 64); | |
124 | } | |
125 | #if COMPILER(CLANG) | |
126 | #pragma clang diagnostic pop | |
127 | #endif | |
128 | ||
6fe7ccc8 A |
129 | } } // namespace JSC::LLInt |
130 | ||
131 | #endif // ENABLE(LLINT) |