Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // Construct a frame element whose value is known at compile time. | 63 // Construct a frame element whose value is known at compile time. |
| 64 FrameElement(Handle<Object> value, SyncFlag is_synced) { | 64 FrameElement(Handle<Object> value, SyncFlag is_synced) { |
| 65 type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); | 65 type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); |
| 66 data_.handle_ = value.location(); | 66 data_.handle_ = value.location(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } | 69 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } |
| 70 | 70 |
| 71 void set_sync() { | 71 void set_sync() { |
| 72 ASSERT(type() != MEMORY); | 72 ASSERT(type() != MEMORY); |
| 73 type_ = type_ | SyncField::encode(SYNCED); | 73 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); |
|
William Hesse
2008/11/28 10:32:45
Why isn't there a set_field accessor for bit field
Kevin Millikin (Chromium)
2008/11/28 12:19:08
I don't know why there isn't such an accessor. It
| |
| 74 } | 74 } |
| 75 | 75 |
| 76 void clear_sync() { | 76 void clear_sync() { |
| 77 ASSERT(type() != MEMORY); | 77 ASSERT(type() != MEMORY); |
| 78 type_ = type_ & ~SyncField::mask(); | 78 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool is_memory() const { return type() == MEMORY; } | |
| 81 bool is_register() const { return type() == REGISTER; } | 82 bool is_register() const { return type() == REGISTER; } |
| 82 bool is_constant() const { return type() == CONSTANT; } | 83 bool is_constant() const { return type() == CONSTANT; } |
| 83 | 84 |
| 84 Register reg() const { | 85 Register reg() const { |
| 85 ASSERT(type() == REGISTER); | 86 ASSERT(type() == REGISTER); |
| 86 return data_.reg_; | 87 return data_.reg_; |
| 87 } | 88 } |
| 88 | 89 |
| 89 Handle<Object> handle() const { | 90 Handle<Object> handle() const { |
| 90 ASSERT(type() == CONSTANT); | 91 ASSERT(type() == CONSTANT); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 return Operand(esp, index * kPointerSize); | 179 return Operand(esp, index * kPointerSize); |
| 179 } | 180 } |
| 180 | 181 |
| 181 // A frame-allocated local as an assembly operand. | 182 // A frame-allocated local as an assembly operand. |
| 182 Operand LocalAt(int index) const { | 183 Operand LocalAt(int index) const { |
| 183 ASSERT(0 <= index); | 184 ASSERT(0 <= index); |
| 184 ASSERT(index < local_count_); | 185 ASSERT(index < local_count_); |
| 185 return Operand(ebp, kLocal0Offset - index * kPointerSize); | 186 return Operand(ebp, kLocal0Offset - index * kPointerSize); |
| 186 } | 187 } |
| 187 | 188 |
| 189 // Store the top value on the virtual frame into a local frame slot. The | |
| 190 // value is left in place on top of the frame. | |
| 191 void StoreToLocalAt(int index) { | |
| 192 StoreToFrameSlotAt(local0_index() + index); | |
| 193 } | |
| 194 | |
| 188 // The function frame slot. | 195 // The function frame slot. |
| 189 Operand Function() const { return Operand(ebp, kFunctionOffset); } | 196 Operand Function() const { return Operand(ebp, kFunctionOffset); } |
| 190 | 197 |
| 191 // The context frame slot. | 198 // The context frame slot. |
| 192 Operand Context() const { return Operand(ebp, kContextOffset); } | 199 Operand Context() const { return Operand(ebp, kContextOffset); } |
| 193 | 200 |
| 194 // A parameter as an assembly operand. | 201 // A parameter as an assembly operand. |
| 195 Operand ParameterAt(int index) const { | 202 Operand ParameterAt(int index) const { |
| 196 ASSERT(-1 <= index); // -1 is the receiver. | 203 ASSERT(-1 <= index); // -1 is the receiver. |
| 197 ASSERT(index < parameter_count_); | 204 ASSERT(index < parameter_count_); |
| 198 return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize); | 205 return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize); |
| 199 } | 206 } |
| 200 | 207 |
| 208 // Store the top value on the virtual frame into a parameter frame slot. | |
| 209 // The value is left in place on top of the frame. | |
| 210 void StoreToParameterAt(int index) { | |
| 211 StoreToFrameSlotAt(param0_index() + index); | |
| 212 } | |
| 213 | |
| 201 // The receiver frame slot. | 214 // The receiver frame slot. |
| 202 Operand Receiver() const { return ParameterAt(-1); } | 215 Operand Receiver() const { return ParameterAt(-1); } |
| 203 | 216 |
| 204 // Push a try-catch or try-finally handler on top of the virtual frame. | 217 // Push a try-catch or try-finally handler on top of the virtual frame. |
| 205 void PushTryHandler(HandlerType type); | 218 void PushTryHandler(HandlerType type); |
| 206 | 219 |
| 207 // Call a code stub, given the number of arguments it expects on (and | 220 // Call a code stub, given the number of arguments it expects on (and |
| 208 // removes from) the top of the physical frame. | 221 // removes from) the top of the physical frame. |
| 209 void CallStub(CodeStub* stub, int frame_arg_count); | 222 void CallStub(CodeStub* stub, int frame_arg_count); |
| 210 | 223 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 241 // Push an element on top of the expression stack and emit a corresponding | 254 // Push an element on top of the expression stack and emit a corresponding |
| 242 // push instruction. | 255 // push instruction. |
| 243 void EmitPush(Register reg); | 256 void EmitPush(Register reg); |
| 244 void EmitPush(Operand operand); | 257 void EmitPush(Operand operand); |
| 245 void EmitPush(Immediate immediate); | 258 void EmitPush(Immediate immediate); |
| 246 | 259 |
| 247 // Push an element on the virtual frame. | 260 // Push an element on the virtual frame. |
| 248 void Push(Register reg); | 261 void Push(Register reg); |
| 249 void Push(Handle<Object> value); | 262 void Push(Handle<Object> value); |
| 250 | 263 |
| 264 #ifdef DEBUG | |
| 265 bool IsSpilled(); | |
| 266 #endif | |
| 267 | |
| 251 private: | 268 private: |
| 252 // An illegal index into the virtual frame. | 269 // An illegal index into the virtual frame. |
| 253 static const int kIllegalIndex = -1; | 270 static const int kIllegalIndex = -1; |
| 254 | 271 |
| 255 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; | 272 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; |
| 256 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; | 273 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; |
| 257 static const int kContextOffset = StandardFrameConstants::kContextOffset; | 274 static const int kContextOffset = StandardFrameConstants::kContextOffset; |
| 258 | 275 |
| 259 static const int kHandlerSize = StackHandlerConstants::kSize / kPointerSize; | 276 static const int kHandlerSize = StackHandlerConstants::kSize / kPointerSize; |
| 260 | 277 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 | 346 |
| 330 // Spill the element at a particular index---write it to memory if | 347 // Spill the element at a particular index---write it to memory if |
| 331 // necessary, free any associated register, and forget its value if | 348 // necessary, free any associated register, and forget its value if |
| 332 // constant. Space should have already been allocated in the actual frame | 349 // constant. Space should have already been allocated in the actual frame |
| 333 // for all the elements below this one (at least). | 350 // for all the elements below this one (at least). |
| 334 void SpillElementAt(int index); | 351 void SpillElementAt(int index); |
| 335 | 352 |
| 336 // Sync all elements in the frame. | 353 // Sync all elements in the frame. |
| 337 void SyncAll(); | 354 void SyncAll(); |
| 338 | 355 |
| 356 // Store the value on top of the frame to a frame slot (typically a local | |
| 357 // or parameter). | |
| 358 void StoreToFrameSlotAt(int index); | |
| 359 | |
| 339 // Spill the topmost elements of the frame to memory (eg, they are the | 360 // Spill the topmost elements of the frame to memory (eg, they are the |
| 340 // arguments to a call) and all registers. | 361 // arguments to a call) and all registers. |
| 341 void PrepareForCall(int count); | 362 void PrepareForCall(int count); |
| 342 }; | 363 }; |
| 343 | 364 |
| 344 | 365 |
| 345 } } // namespace v8::internal | 366 } } // namespace v8::internal |
| 346 | 367 |
| 347 #endif // V8_VIRTUAL_FRAME_IA32_H_ | 368 #endif // V8_VIRTUAL_FRAME_IA32_H_ |
| OLD | NEW |