]> git.saurik.com Git - apple/javascriptcore.git/blame - llint/LLIntData.cpp
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / llint / LLIntData.cpp
CommitLineData
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"
34#include "LowLevelInterpreter.h"
35#include "Opcode.h"
36
37namespace JSC { namespace LLInt {
38
39Data::Data()
40 : m_exceptionInstructions(new Instruction[maxOpcodeLength + 1])
41 , m_opcodeMap(new Opcode[numOpcodeIDs])
42{
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);
47#undef OPCODE_ENTRY
48}
49
50#if COMPILER(CLANG)
51#pragma clang diagnostic push
52#pragma clang diagnostic ignored "-Wmissing-noreturn"
53#endif
54void Data::performAssertions(JSGlobalData& globalData)
55{
56 UNUSED_PARAM(globalData);
57
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);
68#if CPU(BIG_ENDIAN)
69 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag) == 0);
70 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload) == 4);
71#else
72 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag) == 4);
73 ASSERT(OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload) == 0);
74#endif
75#if USE(JSVALUE32_64)
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);
84#else
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);
93#endif
94 ASSERT(StringType == 5);
95 ASSERT(ObjectType == 13);
96 ASSERT(MasqueradesAsUndefined == 1);
97 ASSERT(ImplementsHasInstance == 2);
98 ASSERT(ImplementsDefaultHasInstance == 8);
99#if USE(JSVALUE64)
100 ASSERT(&globalData.heap.allocatorForObjectWithoutDestructor(sizeof(JSFinalObject)) - &globalData.heap.firstAllocatorWithoutDestructors() == 1);
101#else
102 ASSERT(&globalData.heap.allocatorForObjectWithoutDestructor(sizeof(JSFinalObject)) - &globalData.heap.firstAllocatorWithoutDestructors() == 3);
103#endif
104 ASSERT(FirstConstantRegisterIndex == 0x40000000);
105 ASSERT(GlobalCode == 0);
106 ASSERT(EvalCode == 1);
107 ASSERT(FunctionCode == 2);
108
109 // FIXME: make these assertions less horrible.
110#if !ASSERT_DISABLED
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());
115#endif
116
117 ASSERT(StringImpl::s_hashFlag8BitBuffer == 64);
118}
119#if COMPILER(CLANG)
120#pragma clang diagnostic pop
121#endif
122
123Data::~Data()
124{
125 delete[] m_exceptionInstructions;
126 delete[] m_opcodeMap;
127}
128
129} } // namespace JSC::LLInt
130
131#endif // ENABLE(LLINT)