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