source: webkit/trunk/JavaScriptCore/interpreter/Register.h@ 45128

Last change on this file since 45128 was 45128, checked in by [email protected], 16 years ago

JavaScriptCore:

2009-06-24 David Levin <[email protected]>

Fix all builds.

  • bytecode/CodeBlock.h:
  • bytecompiler/BytecodeGenerator.h:
  • interpreter/Register.h:

WebCore:

2009-06-24 David Levin <[email protected]>

Fix all builds.

  • ForwardingHeaders/wtf/FastAllocBase.h: Added.
File size: 6.2 KB
Line 
1/*
2 * Copyright (C) 2008 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 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef Register_h
30#define Register_h
31
32#include "JSValue.h"
33#include <wtf/Assertions.h>
34#include <wtf/FastAllocBase.h>
35#include <wtf/VectorTraits.h>
36
37namespace JSC {
38
39 class Arguments;
40 class CodeBlock;
41 class ExecState;
42 class JSActivation;
43 class JSFunction;
44 class JSPropertyNameIterator;
45 class ScopeChainNode;
46
47 struct Instruction;
48
49 typedef ExecState CallFrame;
50
51 class Register : public WTF::FastAllocBase {
52 public:
53 Register();
54 Register(JSValue);
55 Register(Arguments*);
56
57 JSValue jsValue() const;
58
59 bool marked() const;
60 void mark();
61
62 int32_t i() const;
63 void* v() const;
64
65 private:
66 friend class ExecState;
67 friend class Interpreter;
68
69 // Only CallFrame, Interpreter, and JITStubs should use these functions.
70
71 Register(intptr_t);
72
73 Register(JSActivation*);
74 Register(CallFrame*);
75 Register(CodeBlock*);
76 Register(JSFunction*);
77 Register(JSPropertyNameIterator*);
78 Register(ScopeChainNode*);
79 Register(Instruction*);
80
81 JSActivation* activation() const;
82 Arguments* arguments() const;
83 CallFrame* callFrame() const;
84 CodeBlock* codeBlock() const;
85 JSFunction* function() const;
86 JSPropertyNameIterator* propertyNameIterator() const;
87 ScopeChainNode* scopeChain() const;
88 Instruction* vPC() const;
89
90 union {
91 intptr_t i;
92 void* v;
93 EncodedJSValue value;
94
95 JSActivation* activation;
96 Arguments* arguments;
97 CallFrame* callFrame;
98 CodeBlock* codeBlock;
99 JSFunction* function;
100 JSPropertyNameIterator* propertyNameIterator;
101 ScopeChainNode* scopeChain;
102 Instruction* vPC;
103 } u;
104 };
105
106 ALWAYS_INLINE Register::Register()
107 {
108#ifndef NDEBUG
109 u.value = JSValue::encode(JSValue());
110#endif
111 }
112
113 ALWAYS_INLINE Register::Register(JSValue v)
114 {
115 u.value = JSValue::encode(v);
116 }
117
118 ALWAYS_INLINE JSValue Register::jsValue() const
119 {
120 return JSValue::decode(u.value);
121 }
122
123 ALWAYS_INLINE bool Register::marked() const
124 {
125 return jsValue().marked();
126 }
127
128 ALWAYS_INLINE void Register::mark()
129 {
130 jsValue().mark();
131 }
132
133 // Interpreter functions
134
135 ALWAYS_INLINE Register::Register(Arguments* arguments)
136 {
137 u.arguments = arguments;
138 }
139
140 ALWAYS_INLINE Register::Register(JSActivation* activation)
141 {
142 u.activation = activation;
143 }
144
145 ALWAYS_INLINE Register::Register(CallFrame* callFrame)
146 {
147 u.callFrame = callFrame;
148 }
149
150 ALWAYS_INLINE Register::Register(CodeBlock* codeBlock)
151 {
152 u.codeBlock = codeBlock;
153 }
154
155 ALWAYS_INLINE Register::Register(JSFunction* function)
156 {
157 u.function = function;
158 }
159
160 ALWAYS_INLINE Register::Register(Instruction* vPC)
161 {
162 u.vPC = vPC;
163 }
164
165 ALWAYS_INLINE Register::Register(ScopeChainNode* scopeChain)
166 {
167 u.scopeChain = scopeChain;
168 }
169
170 ALWAYS_INLINE Register::Register(JSPropertyNameIterator* propertyNameIterator)
171 {
172 u.propertyNameIterator = propertyNameIterator;
173 }
174
175 ALWAYS_INLINE Register::Register(intptr_t i)
176 {
177 // See comment on 'i()' below.
178 ASSERT(i == static_cast<int32_t>(i));
179 u.i = i;
180 }
181
182 // Read 'i' as a 32-bit integer; we only use it to hold 32-bit values,
183 // and we only write 32-bits when writing the arg count from JIT code.
184 ALWAYS_INLINE int32_t Register::i() const
185 {
186 return static_cast<int32_t>(u.i);
187 }
188
189 ALWAYS_INLINE void* Register::v() const
190 {
191 return u.v;
192 }
193
194 ALWAYS_INLINE JSActivation* Register::activation() const
195 {
196 return u.activation;
197 }
198
199 ALWAYS_INLINE Arguments* Register::arguments() const
200 {
201 return u.arguments;
202 }
203
204 ALWAYS_INLINE CallFrame* Register::callFrame() const
205 {
206 return u.callFrame;
207 }
208
209 ALWAYS_INLINE CodeBlock* Register::codeBlock() const
210 {
211 return u.codeBlock;
212 }
213
214 ALWAYS_INLINE JSFunction* Register::function() const
215 {
216 return u.function;
217 }
218
219 ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const
220 {
221 return u.propertyNameIterator;
222 }
223
224 ALWAYS_INLINE ScopeChainNode* Register::scopeChain() const
225 {
226 return u.scopeChain;
227 }
228
229 ALWAYS_INLINE Instruction* Register::vPC() const
230 {
231 return u.vPC;
232 }
233
234} // namespace JSC
235
236namespace WTF {
237
238 template<> struct VectorTraits<JSC::Register> : VectorTraitsBase<true, JSC::Register> { };
239
240} // namespace WTF
241
242#endif // Register_h
Note: See TracBrowser for help on using the repository browser.