~ubuntu-branches/ubuntu/karmic/webkit/karmic-proposed

« back to all changes in this revision

Viewing changes to JavaScriptCore/interpreter/Register.h

  • Committer: Bazaar Package Importer
  • Author(s): Gustavo Noronha Silva
  • Date: 2009-05-15 18:30:58 UTC
  • mto: (4.4.1 sid) (1.2.2 upstream) (16.1.1 lucid)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20090515183058-35m5or0ufm5tutud
Tags: upstream-1.1.7
ImportĀ upstreamĀ versionĀ 1.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    class Register {
50
50
    public:
51
51
        Register();
52
 
        Register(JSValuePtr);
 
52
        Register(JSValue);
53
53
 
54
 
        JSValuePtr jsValue(CallFrame*) const;
55
 
        JSValuePtr getJSValue() const;
 
54
        JSValue jsValue() const;
56
55
 
57
56
        bool marked() const;
58
57
        void mark();
90
89
        union {
91
90
            intptr_t i;
92
91
            void* v;
93
 
            JSValueEncodedAsPointer* value;
 
92
            EncodedJSValue value;
94
93
 
95
94
            JSActivation* activation;
96
95
            Arguments* arguments;
101
100
            ScopeChainNode* scopeChain;
102
101
            Instruction* vPC;
103
102
        } u;
104
 
 
105
 
#ifndef NDEBUG
106
 
        enum {
107
 
            EmptyType,
108
 
 
109
 
            IntType,
110
 
            ValueType,
111
 
 
112
 
            ActivationType,
113
 
            ArgumentsType,
114
 
            CallFrameType,
115
 
            CodeBlockType,
116
 
            FunctionType,
117
 
            InstructionType,
118
 
            PropertyNameIteratorType,
119
 
            RegisterType,
120
 
            ScopeChainNodeType
121
 
        } m_type;
122
 
#endif
123
103
    };
124
104
 
125
 
#ifndef NDEBUG
126
 
    #define SET_TYPE(type) m_type = (type)
127
 
    // FIXME: The CTI code to put value into registers doesn't set m_type.
128
 
    // Once it does, we can turn this assertion back on.
129
 
    #define ASSERT_TYPE(type)
130
 
#else
131
 
    #define SET_TYPE(type)
132
 
    #define ASSERT_TYPE(type)
133
 
#endif
134
 
 
135
105
    ALWAYS_INLINE Register::Register()
136
106
    {
137
107
#ifndef NDEBUG
138
 
        SET_TYPE(EmptyType);
139
 
        u.value = JSValuePtr::encode(noValue());
 
108
        u.value = JSValue::encode(JSValue());
140
109
#endif
141
110
    }
142
111
 
143
 
    ALWAYS_INLINE Register::Register(JSValuePtr v)
 
112
    ALWAYS_INLINE Register::Register(JSValue v)
144
113
    {
145
 
        SET_TYPE(ValueType);
146
 
        u.value = JSValuePtr::encode(v);
 
114
        u.value = JSValue::encode(v);
147
115
    }
148
116
 
149
 
    // This function is scaffolding for legacy clients. It will eventually go away.
150
 
    ALWAYS_INLINE JSValuePtr Register::jsValue(CallFrame*) const
151
 
    {
152
 
        // Once registers hold doubles, this function will allocate a JSValue*
153
 
        // if the register doesn't hold one already. 
154
 
        ASSERT_TYPE(ValueType);
155
 
        return JSValuePtr::decode(u.value);
156
 
    }
157
 
    
158
 
    ALWAYS_INLINE JSValuePtr Register::getJSValue() const
159
 
    {
160
 
        ASSERT_TYPE(JSValueType);
161
 
        return JSValuePtr::decode(u.value);
 
117
    ALWAYS_INLINE JSValue Register::jsValue() const
 
118
    {
 
119
        return JSValue::decode(u.value);
162
120
    }
163
121
    
164
122
    ALWAYS_INLINE bool Register::marked() const
165
123
    {
166
 
        return getJSValue().marked();
 
124
        return jsValue().marked();
167
125
    }
168
126
 
169
127
    ALWAYS_INLINE void Register::mark()
170
128
    {
171
 
        getJSValue().mark();
 
129
        jsValue().mark();
172
130
    }
173
131
    
174
132
    // Interpreter functions
175
133
 
176
134
    ALWAYS_INLINE Register::Register(Arguments* arguments)
177
135
    {
178
 
        SET_TYPE(ArgumentsType);
179
136
        u.arguments = arguments;
180
137
    }
181
138
 
182
139
    ALWAYS_INLINE Register::Register(JSActivation* activation)
183
140
    {
184
 
        SET_TYPE(ActivationType);
185
141
        u.activation = activation;
186
142
    }
187
143
 
188
144
    ALWAYS_INLINE Register::Register(CallFrame* callFrame)
189
145
    {
190
 
        SET_TYPE(CallFrameType);
191
146
        u.callFrame = callFrame;
192
147
    }
193
148
 
194
149
    ALWAYS_INLINE Register::Register(CodeBlock* codeBlock)
195
150
    {
196
 
        SET_TYPE(CodeBlockType);
197
151
        u.codeBlock = codeBlock;
198
152
    }
199
153
 
200
154
    ALWAYS_INLINE Register::Register(JSFunction* function)
201
155
    {
202
 
        SET_TYPE(FunctionType);
203
156
        u.function = function;
204
157
    }
205
158
 
206
159
    ALWAYS_INLINE Register::Register(Instruction* vPC)
207
160
    {
208
 
        SET_TYPE(InstructionType);
209
161
        u.vPC = vPC;
210
162
    }
211
163
 
212
164
    ALWAYS_INLINE Register::Register(ScopeChainNode* scopeChain)
213
165
    {
214
 
        SET_TYPE(ScopeChainNodeType);
215
166
        u.scopeChain = scopeChain;
216
167
    }
217
168
 
218
169
    ALWAYS_INLINE Register::Register(JSPropertyNameIterator* propertyNameIterator)
219
170
    {
220
 
        SET_TYPE(PropertyNameIteratorType);
221
171
        u.propertyNameIterator = propertyNameIterator;
222
172
    }
223
173
 
224
174
    ALWAYS_INLINE Register::Register(intptr_t i)
225
175
    {
226
 
        SET_TYPE(IntType);
227
176
        u.i = i;
228
177
    }
229
178
 
230
179
    ALWAYS_INLINE intptr_t Register::i() const
231
180
    {
232
 
        ASSERT_TYPE(IntType);
233
181
        return u.i;
234
182
    }
235
183
    
240
188
 
241
189
    ALWAYS_INLINE JSActivation* Register::activation() const
242
190
    {
243
 
        ASSERT_TYPE(ActivationType);
244
191
        return u.activation;
245
192
    }
246
193
    
247
194
    ALWAYS_INLINE Arguments* Register::arguments() const
248
195
    {
249
 
        ASSERT_TYPE(ArgumentsType);
250
196
        return u.arguments;
251
197
    }
252
198
    
253
199
    ALWAYS_INLINE CallFrame* Register::callFrame() const
254
200
    {
255
 
        ASSERT_TYPE(CallFrameType);
256
201
        return u.callFrame;
257
202
    }
258
203
    
259
204
    ALWAYS_INLINE CodeBlock* Register::codeBlock() const
260
205
    {
261
 
        ASSERT_TYPE(CodeBlockType);
262
206
        return u.codeBlock;
263
207
    }
264
208
    
265
209
    ALWAYS_INLINE JSFunction* Register::function() const
266
210
    {
267
 
        ASSERT_TYPE(FunctionType);
268
211
        return u.function;
269
212
    }
270
213
    
271
214
    ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const
272
215
    {
273
 
        ASSERT_TYPE(PropertyNameIteratorType);
274
216
        return u.propertyNameIterator;
275
217
    }
276
218
    
277
219
    ALWAYS_INLINE ScopeChainNode* Register::scopeChain() const
278
220
    {
279
 
        ASSERT_TYPE(ScopeChainNodeType);
280
221
        return u.scopeChain;
281
222
    }
282
223
    
283
224
    ALWAYS_INLINE Instruction* Register::vPC() const
284
225
    {
285
 
        ASSERT_TYPE(InstructionType);
286
226
        return u.vPC;
287
227
    }
288
228
 
289
 
    #undef SET_TYPE
290
 
    #undef ASSERT_TYPE
291
 
 
292
229
} // namespace JSC
293
230
 
294
231
namespace WTF {