OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_IA32_VIRTUAL_FRAME_IA32_H_ | 28 #ifndef V8_IA32_VIRTUAL_FRAME_IA32_H_ |
29 #define V8_IA32_VIRTUAL_FRAME_IA32_H_ | 29 #define V8_IA32_VIRTUAL_FRAME_IA32_H_ |
30 | 30 |
31 #include "number-info.h" | 31 #include "type-info.h" |
32 #include "register-allocator.h" | 32 #include "register-allocator.h" |
33 #include "scopes.h" | 33 #include "scopes.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 namespace internal { | 36 namespace internal { |
37 | 37 |
38 // ------------------------------------------------------------------------- | 38 // ------------------------------------------------------------------------- |
39 // Virtual frames | 39 // Virtual frames |
40 // | 40 // |
41 // The virtual frame is an abstraction of the physical stack frame. It | 41 // The virtual frame is an abstraction of the physical stack frame. It |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // Construct a virtual frame as a clone of an existing one. | 78 // Construct a virtual frame as a clone of an existing one. |
79 explicit inline VirtualFrame(VirtualFrame* original); | 79 explicit inline VirtualFrame(VirtualFrame* original); |
80 | 80 |
81 CodeGenerator* cgen() { return CodeGeneratorScope::Current(); } | 81 CodeGenerator* cgen() { return CodeGeneratorScope::Current(); } |
82 | 82 |
83 MacroAssembler* masm() { return cgen()->masm(); } | 83 MacroAssembler* masm() { return cgen()->masm(); } |
84 | 84 |
85 // Create a duplicate of an existing valid frame element. | 85 // Create a duplicate of an existing valid frame element. |
86 FrameElement CopyElementAt(int index, | 86 FrameElement CopyElementAt(int index, |
87 NumberInfo info = NumberInfo::Uninitialized()); | 87 TypeInfo info = TypeInfo::Uninitialized()); |
88 | 88 |
89 // The number of elements on the virtual frame. | 89 // The number of elements on the virtual frame. |
90 int element_count() { return elements_.length(); } | 90 int element_count() { return elements_.length(); } |
91 | 91 |
92 // The height of the virtual expression stack. | 92 // The height of the virtual expression stack. |
93 int height() { return element_count() - expression_base_index(); } | 93 int height() { return element_count() - expression_base_index(); } |
94 | 94 |
95 int register_location(int num) { | 95 int register_location(int num) { |
96 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); | 96 ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters); |
97 return register_locations_[num]; | 97 return register_locations_[num]; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 Result Pop(); | 391 Result Pop(); |
392 | 392 |
393 // Pop and save an element from the top of the expression stack and | 393 // Pop and save an element from the top of the expression stack and |
394 // emit a corresponding pop instruction. | 394 // emit a corresponding pop instruction. |
395 void EmitPop(Register reg); | 395 void EmitPop(Register reg); |
396 void EmitPop(Operand operand); | 396 void EmitPop(Operand operand); |
397 | 397 |
398 // Push an element on top of the expression stack and emit a | 398 // Push an element on top of the expression stack and emit a |
399 // corresponding push instruction. | 399 // corresponding push instruction. |
400 void EmitPush(Register reg, | 400 void EmitPush(Register reg, |
401 NumberInfo info = NumberInfo::Unknown()); | 401 TypeInfo info = TypeInfo::Unknown()); |
402 void EmitPush(Operand operand, | 402 void EmitPush(Operand operand, |
403 NumberInfo info = NumberInfo::Unknown()); | 403 TypeInfo info = TypeInfo::Unknown()); |
404 void EmitPush(Immediate immediate, | 404 void EmitPush(Immediate immediate, |
405 NumberInfo info = NumberInfo::Unknown()); | 405 TypeInfo info = TypeInfo::Unknown()); |
406 | 406 |
407 // Push an element on the virtual frame. | 407 // Push an element on the virtual frame. |
408 inline void Push(Register reg, NumberInfo info = NumberInfo::Unknown()); | 408 inline void Push(Register reg, TypeInfo info = TypeInfo::Unknown()); |
409 inline void Push(Handle<Object> value); | 409 inline void Push(Handle<Object> value); |
410 inline void Push(Smi* value); | 410 inline void Push(Smi* value); |
411 | 411 |
412 void PushUntaggedElement(Handle<Object> value); | 412 void PushUntaggedElement(Handle<Object> value); |
413 | 413 |
414 // Pushing a result invalidates it (its contents become owned by the | 414 // Pushing a result invalidates it (its contents become owned by the |
415 // frame). | 415 // frame). |
416 void Push(Result* result) { | 416 void Push(Result* result) { |
417 // This assert will trigger if you try to push the same value twice. | 417 // This assert will trigger if you try to push the same value twice. |
418 ASSERT(result->is_valid()); | 418 ASSERT(result->is_valid()); |
419 if (result->is_register()) { | 419 if (result->is_register()) { |
420 Push(result->reg(), result->number_info()); | 420 Push(result->reg(), result->type_info()); |
421 } else { | 421 } else { |
422 ASSERT(result->is_constant()); | 422 ASSERT(result->is_constant()); |
423 Push(result->handle()); | 423 Push(result->handle()); |
424 } | 424 } |
425 if (cgen()->in_safe_int32_mode()) { | 425 if (cgen()->in_safe_int32_mode()) { |
426 ASSERT(result->is_untagged_int32()); | 426 ASSERT(result->is_untagged_int32()); |
427 elements_[element_count() - 1].set_untagged_int32(true); | 427 elements_[element_count() - 1].set_untagged_int32(true); |
428 } | 428 } |
429 result->Unuse(); | 429 result->Unuse(); |
430 } | 430 } |
431 | 431 |
432 // Pushing an expression expects that the expression is trivial (according | 432 // Pushing an expression expects that the expression is trivial (according |
433 // to Expression::IsTrivial). | 433 // to Expression::IsTrivial). |
434 void Push(Expression* expr); | 434 void Push(Expression* expr); |
435 | 435 |
436 // Nip removes zero or more elements from immediately below the top | 436 // Nip removes zero or more elements from immediately below the top |
437 // of the frame, leaving the previous top-of-frame value on top of | 437 // of the frame, leaving the previous top-of-frame value on top of |
438 // the frame. Nip(k) is equivalent to x = Pop(), Drop(k), Push(x). | 438 // the frame. Nip(k) is equivalent to x = Pop(), Drop(k), Push(x). |
439 inline void Nip(int num_dropped); | 439 inline void Nip(int num_dropped); |
440 | 440 |
441 // Check that the frame has no elements containing untagged int32 elements. | 441 // Check that the frame has no elements containing untagged int32 elements. |
442 bool HasNoUntaggedInt32Elements() { | 442 bool HasNoUntaggedInt32Elements() { |
443 for (int i = 0; i < element_count(); ++i) { | 443 for (int i = 0; i < element_count(); ++i) { |
444 if (elements_[i].is_untagged_int32()) return false; | 444 if (elements_[i].is_untagged_int32()) return false; |
445 } | 445 } |
446 return true; | 446 return true; |
447 } | 447 } |
448 | 448 |
449 // Update the type information of a variable frame element directly. | 449 // Update the type information of a variable frame element directly. |
450 inline void SetTypeForLocalAt(int index, NumberInfo info); | 450 inline void SetTypeForLocalAt(int index, TypeInfo info); |
451 inline void SetTypeForParamAt(int index, NumberInfo info); | 451 inline void SetTypeForParamAt(int index, TypeInfo info); |
452 | 452 |
453 private: | 453 private: |
454 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; | 454 static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; |
455 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; | 455 static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; |
456 static const int kContextOffset = StandardFrameConstants::kContextOffset; | 456 static const int kContextOffset = StandardFrameConstants::kContextOffset; |
457 | 457 |
458 static const int kHandlerSize = StackHandlerConstants::kSize / kPointerSize; | 458 static const int kHandlerSize = StackHandlerConstants::kSize / kPointerSize; |
459 static const int kPreallocatedElements = 5 + 8; // 8 expression stack slots. | 459 static const int kPreallocatedElements = 5 + 8; // 8 expression stack slots. |
460 | 460 |
461 ZoneList<FrameElement> elements_; | 461 ZoneList<FrameElement> elements_; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 inline bool Equals(VirtualFrame* other); | 623 inline bool Equals(VirtualFrame* other); |
624 | 624 |
625 // Classes that need raw access to the elements_ array. | 625 // Classes that need raw access to the elements_ array. |
626 friend class DeferredCode; | 626 friend class DeferredCode; |
627 friend class JumpTarget; | 627 friend class JumpTarget; |
628 }; | 628 }; |
629 | 629 |
630 } } // namespace v8::internal | 630 } } // namespace v8::internal |
631 | 631 |
632 #endif // V8_IA32_VIRTUAL_FRAME_IA32_H_ | 632 #endif // V8_IA32_VIRTUAL_FRAME_IA32_H_ |
OLD | NEW |