| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return NULL; | 106 return NULL; |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 class Breakable; | 110 class Breakable; |
| 111 class Iteration; | 111 class Iteration; |
| 112 class TryCatch; | 112 class TryCatch; |
| 113 class TryFinally; | 113 class TryFinally; |
| 114 class Finally; | 114 class Finally; |
| 115 class ForIn; | 115 class ForIn; |
| 116 class TestContext; | |
| 117 | 116 |
| 118 class NestedStatement BASE_EMBEDDED { | 117 class NestedStatement BASE_EMBEDDED { |
| 119 public: | 118 public: |
| 120 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { | 119 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { |
| 121 // Link into codegen's nesting stack. | 120 // Link into codegen's nesting stack. |
| 122 previous_ = codegen->nesting_stack_; | 121 previous_ = codegen->nesting_stack_; |
| 123 codegen->nesting_stack_ = this; | 122 codegen->nesting_stack_ = this; |
| 124 } | 123 } |
| 125 virtual ~NestedStatement() { | 124 virtual ~NestedStatement() { |
| 126 // Unlink from codegen's nesting stack. | 125 // Unlink from codegen's nesting stack. |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // parameter slot. | 291 // parameter slot. |
| 293 int SlotOffset(Slot* slot); | 292 int SlotOffset(Slot* slot); |
| 294 | 293 |
| 295 // Determine whether or not to inline the smi case for the given | 294 // Determine whether or not to inline the smi case for the given |
| 296 // operation. | 295 // operation. |
| 297 bool ShouldInlineSmiCase(Token::Value op); | 296 bool ShouldInlineSmiCase(Token::Value op); |
| 298 | 297 |
| 299 // Helper function to convert a pure value into a test context. The value | 298 // Helper function to convert a pure value into a test context. The value |
| 300 // is expected on the stack or the accumulator, depending on the platform. | 299 // is expected on the stack or the accumulator, depending on the platform. |
| 301 // See the platform-specific implementation for details. | 300 // See the platform-specific implementation for details. |
| 302 void DoTest(Expression* condition, | 301 void DoTest(Label* if_true, Label* if_false, Label* fall_through); |
| 303 Label* if_true, | |
| 304 Label* if_false, | |
| 305 Label* fall_through); | |
| 306 void DoTest(const TestContext* context); | |
| 307 | 302 |
| 308 // Helper function to split control flow and avoid a branch to the | 303 // Helper function to split control flow and avoid a branch to the |
| 309 // fall-through label if it is set up. | 304 // fall-through label if it is set up. |
| 310 #ifdef V8_TARGET_ARCH_MIPS | 305 #ifdef V8_TARGET_ARCH_MIPS |
| 311 void Split(Condition cc, | 306 void Split(Condition cc, |
| 312 Register lhs, | 307 Register lhs, |
| 313 const Operand& rhs, | 308 const Operand& rhs, |
| 314 Label* if_true, | 309 Label* if_true, |
| 315 Label* if_false, | 310 Label* if_false, |
| 316 Label* fall_through); | 311 Label* fall_through); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 345 | 340 |
| 346 void VisitForStackValue(Expression* expr) { | 341 void VisitForStackValue(Expression* expr) { |
| 347 StackValueContext context(this); | 342 StackValueContext context(this); |
| 348 VisitInCurrentContext(expr); | 343 VisitInCurrentContext(expr); |
| 349 } | 344 } |
| 350 | 345 |
| 351 void VisitForControl(Expression* expr, | 346 void VisitForControl(Expression* expr, |
| 352 Label* if_true, | 347 Label* if_true, |
| 353 Label* if_false, | 348 Label* if_false, |
| 354 Label* fall_through) { | 349 Label* fall_through) { |
| 355 TestContext context(this, expr, if_true, if_false, fall_through); | 350 TestContext context(this, if_true, if_false, fall_through); |
| 356 VisitInCurrentContext(expr); | 351 VisitInCurrentContext(expr); |
| 357 } | 352 } |
| 358 | 353 |
| 359 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 354 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 360 void DeclareGlobals(Handle<FixedArray> pairs); | 355 void DeclareGlobals(Handle<FixedArray> pairs); |
| 361 | 356 |
| 362 // Try to perform a comparison as a fast inlined literal compare if | 357 // Try to perform a comparison as a fast inlined literal compare if |
| 363 // the operands allow it. Returns true if the compare operations | 358 // the operands allow it. Returns true if the compare operations |
| 364 // has been matched and all code generated; false otherwise. | 359 // has been matched and all code generated; false otherwise. |
| 365 bool TryLiteralCompare(Token::Value op, | 360 bool TryLiteralCompare(Token::Value op, |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 virtual void PrepareTest(Label* materialize_true, | 663 virtual void PrepareTest(Label* materialize_true, |
| 669 Label* materialize_false, | 664 Label* materialize_false, |
| 670 Label** if_true, | 665 Label** if_true, |
| 671 Label** if_false, | 666 Label** if_false, |
| 672 Label** fall_through) const; | 667 Label** fall_through) const; |
| 673 virtual bool IsStackValue() const { return true; } | 668 virtual bool IsStackValue() const { return true; } |
| 674 }; | 669 }; |
| 675 | 670 |
| 676 class TestContext : public ExpressionContext { | 671 class TestContext : public ExpressionContext { |
| 677 public: | 672 public: |
| 678 TestContext(FullCodeGenerator* codegen, | 673 explicit TestContext(FullCodeGenerator* codegen, |
| 679 Expression* condition, | 674 Label* true_label, |
| 680 Label* true_label, | 675 Label* false_label, |
| 681 Label* false_label, | 676 Label* fall_through) |
| 682 Label* fall_through) | |
| 683 : ExpressionContext(codegen), | 677 : ExpressionContext(codegen), |
| 684 condition_(condition), | |
| 685 true_label_(true_label), | 678 true_label_(true_label), |
| 686 false_label_(false_label), | 679 false_label_(false_label), |
| 687 fall_through_(fall_through) { } | 680 fall_through_(fall_through) { } |
| 688 | 681 |
| 689 static const TestContext* cast(const ExpressionContext* context) { | 682 static const TestContext* cast(const ExpressionContext* context) { |
| 690 ASSERT(context->IsTest()); | 683 ASSERT(context->IsTest()); |
| 691 return reinterpret_cast<const TestContext*>(context); | 684 return reinterpret_cast<const TestContext*>(context); |
| 692 } | 685 } |
| 693 | 686 |
| 694 Expression* condition() const { return condition_; } | |
| 695 Label* true_label() const { return true_label_; } | 687 Label* true_label() const { return true_label_; } |
| 696 Label* false_label() const { return false_label_; } | 688 Label* false_label() const { return false_label_; } |
| 697 Label* fall_through() const { return fall_through_; } | 689 Label* fall_through() const { return fall_through_; } |
| 698 | 690 |
| 699 virtual void Plug(bool flag) const; | 691 virtual void Plug(bool flag) const; |
| 700 virtual void Plug(Register reg) const; | 692 virtual void Plug(Register reg) const; |
| 701 virtual void Plug(Label* materialize_true, Label* materialize_false) const; | 693 virtual void Plug(Label* materialize_true, Label* materialize_false) const; |
| 702 virtual void Plug(Slot* slot) const; | 694 virtual void Plug(Slot* slot) const; |
| 703 virtual void Plug(Handle<Object> lit) const; | 695 virtual void Plug(Handle<Object> lit) const; |
| 704 virtual void Plug(Heap::RootListIndex) const; | 696 virtual void Plug(Heap::RootListIndex) const; |
| 705 virtual void PlugTOS() const; | 697 virtual void PlugTOS() const; |
| 706 virtual void DropAndPlug(int count, Register reg) const; | 698 virtual void DropAndPlug(int count, Register reg) const; |
| 707 virtual void PrepareTest(Label* materialize_true, | 699 virtual void PrepareTest(Label* materialize_true, |
| 708 Label* materialize_false, | 700 Label* materialize_false, |
| 709 Label** if_true, | 701 Label** if_true, |
| 710 Label** if_false, | 702 Label** if_false, |
| 711 Label** fall_through) const; | 703 Label** fall_through) const; |
| 712 virtual bool IsTest() const { return true; } | 704 virtual bool IsTest() const { return true; } |
| 713 | 705 |
| 714 private: | 706 private: |
| 715 Expression* condition_; | |
| 716 Label* true_label_; | 707 Label* true_label_; |
| 717 Label* false_label_; | 708 Label* false_label_; |
| 718 Label* fall_through_; | 709 Label* fall_through_; |
| 719 }; | 710 }; |
| 720 | 711 |
| 721 class EffectContext : public ExpressionContext { | 712 class EffectContext : public ExpressionContext { |
| 722 public: | 713 public: |
| 723 explicit EffectContext(FullCodeGenerator* codegen) | 714 explicit EffectContext(FullCodeGenerator* codegen) |
| 724 : ExpressionContext(codegen) { } | 715 : ExpressionContext(codegen) { } |
| 725 | 716 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 752 | 743 |
| 753 friend class NestedStatement; | 744 friend class NestedStatement; |
| 754 | 745 |
| 755 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 746 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 756 }; | 747 }; |
| 757 | 748 |
| 758 | 749 |
| 759 } } // namespace v8::internal | 750 } } // namespace v8::internal |
| 760 | 751 |
| 761 #endif // V8_FULL_CODEGEN_H_ | 752 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |