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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // parameter slot. | 291 // parameter slot. |
292 int SlotOffset(Slot* slot); | 292 int SlotOffset(Slot* slot); |
293 | 293 |
294 // 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 |
295 // operation. | 295 // operation. |
296 bool ShouldInlineSmiCase(Token::Value op); | 296 bool ShouldInlineSmiCase(Token::Value op); |
297 | 297 |
298 // 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 |
299 // 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. |
300 // See the platform-specific implementation for details. | 300 // See the platform-specific implementation for details. |
301 void DoTest(Label* if_true, Label* if_false, Label* fall_through); | 301 void DoTest(Expression* condition, |
| 302 Label* if_true, |
| 303 Label* if_false, |
| 304 Label* fall_through); |
302 | 305 |
303 // Helper function to split control flow and avoid a branch to the | 306 // Helper function to split control flow and avoid a branch to the |
304 // fall-through label if it is set up. | 307 // fall-through label if it is set up. |
305 #ifdef V8_TARGET_ARCH_MIPS | 308 #ifdef V8_TARGET_ARCH_MIPS |
306 void Split(Condition cc, | 309 void Split(Condition cc, |
307 Register lhs, | 310 Register lhs, |
308 const Operand& rhs, | 311 const Operand& rhs, |
309 Label* if_true, | 312 Label* if_true, |
310 Label* if_false, | 313 Label* if_false, |
311 Label* fall_through); | 314 Label* fall_through); |
(...skipping 28 matching lines...) Expand all Loading... |
340 | 343 |
341 void VisitForStackValue(Expression* expr) { | 344 void VisitForStackValue(Expression* expr) { |
342 StackValueContext context(this); | 345 StackValueContext context(this); |
343 VisitInCurrentContext(expr); | 346 VisitInCurrentContext(expr); |
344 } | 347 } |
345 | 348 |
346 void VisitForControl(Expression* expr, | 349 void VisitForControl(Expression* expr, |
347 Label* if_true, | 350 Label* if_true, |
348 Label* if_false, | 351 Label* if_false, |
349 Label* fall_through) { | 352 Label* fall_through) { |
350 TestContext context(this, if_true, if_false, fall_through); | 353 TestContext context(this, expr, if_true, if_false, fall_through); |
351 VisitInCurrentContext(expr); | 354 VisitInCurrentContext(expr); |
352 } | 355 } |
353 | 356 |
354 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 357 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
355 void DeclareGlobals(Handle<FixedArray> pairs); | 358 void DeclareGlobals(Handle<FixedArray> pairs); |
356 | 359 |
357 // Try to perform a comparison as a fast inlined literal compare if | 360 // Try to perform a comparison as a fast inlined literal compare if |
358 // the operands allow it. Returns true if the compare operations | 361 // the operands allow it. Returns true if the compare operations |
359 // has been matched and all code generated; false otherwise. | 362 // has been matched and all code generated; false otherwise. |
360 bool TryLiteralCompare(Token::Value op, | 363 bool TryLiteralCompare(Token::Value op, |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 virtual void PrepareTest(Label* materialize_true, | 666 virtual void PrepareTest(Label* materialize_true, |
664 Label* materialize_false, | 667 Label* materialize_false, |
665 Label** if_true, | 668 Label** if_true, |
666 Label** if_false, | 669 Label** if_false, |
667 Label** fall_through) const; | 670 Label** fall_through) const; |
668 virtual bool IsStackValue() const { return true; } | 671 virtual bool IsStackValue() const { return true; } |
669 }; | 672 }; |
670 | 673 |
671 class TestContext : public ExpressionContext { | 674 class TestContext : public ExpressionContext { |
672 public: | 675 public: |
673 explicit TestContext(FullCodeGenerator* codegen, | 676 TestContext(FullCodeGenerator* codegen, |
674 Label* true_label, | 677 Expression* condition, |
675 Label* false_label, | 678 Label* true_label, |
676 Label* fall_through) | 679 Label* false_label, |
| 680 Label* fall_through) |
677 : ExpressionContext(codegen), | 681 : ExpressionContext(codegen), |
| 682 condition_(condition), |
678 true_label_(true_label), | 683 true_label_(true_label), |
679 false_label_(false_label), | 684 false_label_(false_label), |
680 fall_through_(fall_through) { } | 685 fall_through_(fall_through) { } |
681 | 686 |
682 static const TestContext* cast(const ExpressionContext* context) { | 687 static const TestContext* cast(const ExpressionContext* context) { |
683 ASSERT(context->IsTest()); | 688 ASSERT(context->IsTest()); |
684 return reinterpret_cast<const TestContext*>(context); | 689 return reinterpret_cast<const TestContext*>(context); |
685 } | 690 } |
686 | 691 |
687 Label* true_label() const { return true_label_; } | 692 Label* true_label() const { return true_label_; } |
688 Label* false_label() const { return false_label_; } | 693 Label* false_label() const { return false_label_; } |
689 Label* fall_through() const { return fall_through_; } | 694 Label* fall_through() const { return fall_through_; } |
690 | 695 |
691 virtual void Plug(bool flag) const; | 696 virtual void Plug(bool flag) const; |
692 virtual void Plug(Register reg) const; | 697 virtual void Plug(Register reg) const; |
693 virtual void Plug(Label* materialize_true, Label* materialize_false) const; | 698 virtual void Plug(Label* materialize_true, Label* materialize_false) const; |
694 virtual void Plug(Slot* slot) const; | 699 virtual void Plug(Slot* slot) const; |
695 virtual void Plug(Handle<Object> lit) const; | 700 virtual void Plug(Handle<Object> lit) const; |
696 virtual void Plug(Heap::RootListIndex) const; | 701 virtual void Plug(Heap::RootListIndex) const; |
697 virtual void PlugTOS() const; | 702 virtual void PlugTOS() const; |
698 virtual void DropAndPlug(int count, Register reg) const; | 703 virtual void DropAndPlug(int count, Register reg) const; |
699 virtual void PrepareTest(Label* materialize_true, | 704 virtual void PrepareTest(Label* materialize_true, |
700 Label* materialize_false, | 705 Label* materialize_false, |
701 Label** if_true, | 706 Label** if_true, |
702 Label** if_false, | 707 Label** if_false, |
703 Label** fall_through) const; | 708 Label** fall_through) const; |
704 virtual bool IsTest() const { return true; } | 709 virtual bool IsTest() const { return true; } |
705 | 710 |
706 private: | 711 private: |
| 712 Expression* condition_; |
707 Label* true_label_; | 713 Label* true_label_; |
708 Label* false_label_; | 714 Label* false_label_; |
709 Label* fall_through_; | 715 Label* fall_through_; |
710 }; | 716 }; |
711 | 717 |
712 class EffectContext : public ExpressionContext { | 718 class EffectContext : public ExpressionContext { |
713 public: | 719 public: |
714 explicit EffectContext(FullCodeGenerator* codegen) | 720 explicit EffectContext(FullCodeGenerator* codegen) |
715 : ExpressionContext(codegen) { } | 721 : ExpressionContext(codegen) { } |
716 | 722 |
(...skipping 26 matching lines...) Expand all Loading... |
743 | 749 |
744 friend class NestedStatement; | 750 friend class NestedStatement; |
745 | 751 |
746 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 752 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
747 }; | 753 }; |
748 | 754 |
749 | 755 |
750 } } // namespace v8::internal | 756 } } // namespace v8::internal |
751 | 757 |
752 #endif // V8_FULL_CODEGEN_H_ | 758 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |