]> git.saurik.com Git - apple/javascriptcore.git/blob - llint/LLIntData.h
JavaScriptCore-1218.35.tar.gz
[apple/javascriptcore.git] / llint / LLIntData.h
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 #ifndef LLIntData_h
27 #define LLIntData_h
28
29 #include "JSCJSValue.h"
30 #include "Opcode.h"
31 #include <wtf/Platform.h>
32
33 namespace JSC {
34
35 class VM;
36 struct Instruction;
37
38 #if ENABLE(LLINT_C_LOOP)
39 typedef OpcodeID LLIntCode;
40 #else
41 typedef void (*LLIntCode)();
42 #endif
43
44 namespace LLInt {
45
46 #if ENABLE(LLINT)
47
48 class Data {
49 public:
50 static void performAssertions(VM&);
51
52 private:
53 static Instruction* s_exceptionInstructions;
54 static Opcode* s_opcodeMap;
55
56 friend void initialize();
57
58 friend Instruction* exceptionInstructions();
59 friend Opcode* opcodeMap();
60 friend Opcode getOpcode(OpcodeID);
61 friend void* getCodePtr(OpcodeID);
62 };
63
64 void initialize();
65
66 inline Instruction* exceptionInstructions()
67 {
68 return Data::s_exceptionInstructions;
69 }
70
71 inline Opcode* opcodeMap()
72 {
73 return Data::s_opcodeMap;
74 }
75
76 inline Opcode getOpcode(OpcodeID id)
77 {
78 #if ENABLE(COMPUTED_GOTO_OPCODES)
79 return Data::s_opcodeMap[id];
80 #else
81 return static_cast<Opcode>(id);
82 #endif
83 }
84
85 ALWAYS_INLINE void* getCodePtr(OpcodeID id)
86 {
87 return reinterpret_cast<void*>(getOpcode(id));
88 }
89
90 #else // !ENABLE(LLINT)
91
92 #if COMPILER(CLANG)
93 #pragma clang diagnostic push
94 #pragma clang diagnostic ignored "-Wmissing-noreturn"
95 #endif
96
97 class Data {
98 public:
99 static void performAssertions(VM&) { }
100 };
101
102 #if COMPILER(CLANG)
103 #pragma clang diagnostic pop
104 #endif
105
106 #endif // !ENABLE(LLINT)
107
108 ALWAYS_INLINE void* getOpcode(void llintOpcode())
109 {
110 return bitwise_cast<void*>(llintOpcode);
111 }
112
113 ALWAYS_INLINE void* getCodePtr(void glueHelper())
114 {
115 return bitwise_cast<void*>(glueHelper);
116 }
117
118 ALWAYS_INLINE void* getCodePtr(JSC::EncodedJSValue glueHelper())
119 {
120 return bitwise_cast<void*>(glueHelper);
121 }
122
123
124 } } // namespace JSC::LLInt
125
126 #endif // LLIntData_h
127