OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Full code generator. | 70 // Full code generator. |
71 | 71 |
72 class FullCodeGenerator: public AstVisitor { | 72 class FullCodeGenerator: public AstVisitor { |
73 public: | 73 public: |
74 enum State { | 74 enum State { |
75 NO_REGISTERS, | 75 NO_REGISTERS, |
76 TOS_REG | 76 TOS_REG |
77 }; | 77 }; |
78 | 78 |
79 explicit FullCodeGenerator(MacroAssembler* masm) | 79 explicit FullCodeGenerator(MacroAssembler* masm) |
80 : masm_(masm), | 80 : isolate_(Isolate::Current()), |
| 81 masm_(masm), |
81 info_(NULL), | 82 info_(NULL), |
82 nesting_stack_(NULL), | 83 nesting_stack_(NULL), |
83 loop_depth_(0), | 84 loop_depth_(0), |
84 context_(NULL), | 85 context_(NULL), |
85 bailout_entries_(0), | 86 bailout_entries_(0), |
86 stack_checks_(2), // There's always at least one. | 87 stack_checks_(2), // There's always at least one. |
87 forward_bailout_stack_(NULL), | 88 forward_bailout_stack_(NULL), |
88 forward_bailout_pending_(NULL) { | 89 forward_bailout_pending_(NULL) { |
89 } | 90 } |
90 | 91 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 void ExitFinallyBlock(); | 487 void ExitFinallyBlock(); |
487 | 488 |
488 // Loop nesting counter. | 489 // Loop nesting counter. |
489 int loop_depth() { return loop_depth_; } | 490 int loop_depth() { return loop_depth_; } |
490 void increment_loop_depth() { loop_depth_++; } | 491 void increment_loop_depth() { loop_depth_++; } |
491 void decrement_loop_depth() { | 492 void decrement_loop_depth() { |
492 ASSERT(loop_depth_ > 0); | 493 ASSERT(loop_depth_ > 0); |
493 loop_depth_--; | 494 loop_depth_--; |
494 } | 495 } |
495 | 496 |
| 497 Isolate* isolate() { return isolate_; } |
496 MacroAssembler* masm() { return masm_; } | 498 MacroAssembler* masm() { return masm_; } |
497 | 499 |
498 class ExpressionContext; | 500 class ExpressionContext; |
499 const ExpressionContext* context() { return context_; } | 501 const ExpressionContext* context() { return context_; } |
500 void set_new_context(const ExpressionContext* context) { context_ = context; } | 502 void set_new_context(const ExpressionContext* context) { context_ = context; } |
501 | 503 |
502 Handle<Script> script() { return info_->script(); } | 504 Handle<Script> script() { return info_->script(); } |
503 bool is_eval() { return info_->is_eval(); } | 505 bool is_eval() { return info_->is_eval(); } |
504 bool is_strict_mode() { return function()->strict_mode(); } | 506 bool is_strict_mode() { return function()->strict_mode(); } |
505 StrictModeFlag strict_mode_flag() { | 507 StrictModeFlag strict_mode_flag() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 public: | 548 public: |
547 explicit ExpressionContext(FullCodeGenerator* codegen) | 549 explicit ExpressionContext(FullCodeGenerator* codegen) |
548 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { | 550 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { |
549 codegen->set_new_context(this); | 551 codegen->set_new_context(this); |
550 } | 552 } |
551 | 553 |
552 virtual ~ExpressionContext() { | 554 virtual ~ExpressionContext() { |
553 codegen_->set_new_context(old_); | 555 codegen_->set_new_context(old_); |
554 } | 556 } |
555 | 557 |
| 558 Isolate* isolate() const { return codegen_->isolate(); } |
| 559 |
556 // Convert constant control flow (true or false) to the result expected for | 560 // Convert constant control flow (true or false) to the result expected for |
557 // this expression context. | 561 // this expression context. |
558 virtual void Plug(bool flag) const = 0; | 562 virtual void Plug(bool flag) const = 0; |
559 | 563 |
560 // Emit code to convert a pure value (in a register, slot, as a literal, | 564 // Emit code to convert a pure value (in a register, slot, as a literal, |
561 // or on top of the stack) into the result expected according to this | 565 // or on top of the stack) into the result expected according to this |
562 // expression context. | 566 // expression context. |
563 virtual void Plug(Register reg) const = 0; | 567 virtual void Plug(Register reg) const = 0; |
564 virtual void Plug(Slot* slot) const = 0; | 568 virtual void Plug(Slot* slot) const = 0; |
565 virtual void Plug(Handle<Object> lit) const = 0; | 569 virtual void Plug(Handle<Object> lit) const = 0; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 Label* done) const; | 726 Label* done) const; |
723 virtual void PrepareTest(Label* materialize_true, | 727 virtual void PrepareTest(Label* materialize_true, |
724 Label* materialize_false, | 728 Label* materialize_false, |
725 Label** if_true, | 729 Label** if_true, |
726 Label** if_false, | 730 Label** if_false, |
727 Label** fall_through) const; | 731 Label** fall_through) const; |
728 virtual void HandleExpression(Expression* expr) const; | 732 virtual void HandleExpression(Expression* expr) const; |
729 virtual bool IsEffect() const { return true; } | 733 virtual bool IsEffect() const { return true; } |
730 }; | 734 }; |
731 | 735 |
| 736 Isolate* isolate_; |
732 MacroAssembler* masm_; | 737 MacroAssembler* masm_; |
733 CompilationInfo* info_; | 738 CompilationInfo* info_; |
734 Label return_label_; | 739 Label return_label_; |
735 NestedStatement* nesting_stack_; | 740 NestedStatement* nesting_stack_; |
736 int loop_depth_; | 741 int loop_depth_; |
737 const ExpressionContext* context_; | 742 const ExpressionContext* context_; |
738 ZoneList<BailoutEntry> bailout_entries_; | 743 ZoneList<BailoutEntry> bailout_entries_; |
739 ZoneList<BailoutEntry> stack_checks_; | 744 ZoneList<BailoutEntry> stack_checks_; |
740 ForwardBailoutStack* forward_bailout_stack_; | 745 ForwardBailoutStack* forward_bailout_stack_; |
741 ForwardBailoutStack* forward_bailout_pending_; | 746 ForwardBailoutStack* forward_bailout_pending_; |
742 | 747 |
743 friend class NestedStatement; | 748 friend class NestedStatement; |
744 | 749 |
745 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 750 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
746 }; | 751 }; |
747 | 752 |
748 | 753 |
749 } } // namespace v8::internal | 754 } } // namespace v8::internal |
750 | 755 |
751 #endif // V8_FULL_CODEGEN_H_ | 756 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |