| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_FULL_CODEGEN_H_ | 5 #ifndef V8_FULL_CODEGEN_H_ |
| 6 #define V8_FULL_CODEGEN_H_ | 6 #define V8_FULL_CODEGEN_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 scope_(info->scope()), | 67 scope_(info->scope()), |
| 68 nesting_stack_(NULL), | 68 nesting_stack_(NULL), |
| 69 loop_depth_(0), | 69 loop_depth_(0), |
| 70 globals_(NULL), | 70 globals_(NULL), |
| 71 context_(NULL), | 71 context_(NULL), |
| 72 bailout_entries_(info->HasDeoptimizationSupport() | 72 bailout_entries_(info->HasDeoptimizationSupport() |
| 73 ? info->function()->ast_node_count() : 0, | 73 ? info->function()->ast_node_count() : 0, |
| 74 info->zone()), | 74 info->zone()), |
| 75 back_edges_(2, info->zone()), | 75 back_edges_(2, info->zone()), |
| 76 ic_total_count_(0) { | 76 ic_total_count_(0) { |
| 77 ASSERT(!info->IsStub()); | 77 DCHECK(!info->IsStub()); |
| 78 Initialize(); | 78 Initialize(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void Initialize(); | 81 void Initialize(); |
| 82 | 82 |
| 83 static bool MakeCode(CompilationInfo* info); | 83 static bool MakeCode(CompilationInfo* info); |
| 84 | 84 |
| 85 // Encode state and pc-offset as a BitField<type, start, size>. | 85 // Encode state and pc-offset as a BitField<type, start, size>. |
| 86 // Only use 30 bits because we encode the result as a smi. | 86 // Only use 30 bits because we encode the result as a smi. |
| 87 class StateField : public BitField<State, 0, 1> { }; | 87 class StateField : public BitField<State, 0, 1> { }; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 class NestedStatement BASE_EMBEDDED { | 131 class NestedStatement BASE_EMBEDDED { |
| 132 public: | 132 public: |
| 133 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { | 133 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { |
| 134 // Link into codegen's nesting stack. | 134 // Link into codegen's nesting stack. |
| 135 previous_ = codegen->nesting_stack_; | 135 previous_ = codegen->nesting_stack_; |
| 136 codegen->nesting_stack_ = this; | 136 codegen->nesting_stack_ = this; |
| 137 } | 137 } |
| 138 virtual ~NestedStatement() { | 138 virtual ~NestedStatement() { |
| 139 // Unlink from codegen's nesting stack. | 139 // Unlink from codegen's nesting stack. |
| 140 ASSERT_EQ(this, codegen_->nesting_stack_); | 140 DCHECK_EQ(this, codegen_->nesting_stack_); |
| 141 codegen_->nesting_stack_ = previous_; | 141 codegen_->nesting_stack_ = previous_; |
| 142 } | 142 } |
| 143 | 143 |
| 144 virtual Breakable* AsBreakable() { return NULL; } | 144 virtual Breakable* AsBreakable() { return NULL; } |
| 145 virtual Iteration* AsIteration() { return NULL; } | 145 virtual Iteration* AsIteration() { return NULL; } |
| 146 | 146 |
| 147 virtual bool IsContinueTarget(Statement* target) { return false; } | 147 virtual bool IsContinueTarget(Statement* target) { return false; } |
| 148 virtual bool IsBreakTarget(Statement* target) { return false; } | 148 virtual bool IsBreakTarget(Statement* target) { return false; } |
| 149 | 149 |
| 150 // Notify the statement that we are exiting it via break, continue, or | 150 // Notify the statement that we are exiting it via break, continue, or |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 void SetSourcePosition(int pos); | 574 void SetSourcePosition(int pos); |
| 575 | 575 |
| 576 // Non-local control flow support. | 576 // Non-local control flow support. |
| 577 void EnterFinallyBlock(); | 577 void EnterFinallyBlock(); |
| 578 void ExitFinallyBlock(); | 578 void ExitFinallyBlock(); |
| 579 | 579 |
| 580 // Loop nesting counter. | 580 // Loop nesting counter. |
| 581 int loop_depth() { return loop_depth_; } | 581 int loop_depth() { return loop_depth_; } |
| 582 void increment_loop_depth() { loop_depth_++; } | 582 void increment_loop_depth() { loop_depth_++; } |
| 583 void decrement_loop_depth() { | 583 void decrement_loop_depth() { |
| 584 ASSERT(loop_depth_ > 0); | 584 DCHECK(loop_depth_ > 0); |
| 585 loop_depth_--; | 585 loop_depth_--; |
| 586 } | 586 } |
| 587 | 587 |
| 588 MacroAssembler* masm() { return masm_; } | 588 MacroAssembler* masm() { return masm_; } |
| 589 | 589 |
| 590 class ExpressionContext; | 590 class ExpressionContext; |
| 591 const ExpressionContext* context() { return context_; } | 591 const ExpressionContext* context() { return context_; } |
| 592 void set_new_context(const ExpressionContext* context) { context_ = context; } | 592 void set_new_context(const ExpressionContext* context) { context_ = context; } |
| 593 | 593 |
| 594 Handle<Script> script() { return info_->script(); } | 594 Handle<Script> script() { return info_->script(); } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 Label* true_label, | 758 Label* true_label, |
| 759 Label* false_label, | 759 Label* false_label, |
| 760 Label* fall_through) | 760 Label* fall_through) |
| 761 : ExpressionContext(codegen), | 761 : ExpressionContext(codegen), |
| 762 condition_(condition), | 762 condition_(condition), |
| 763 true_label_(true_label), | 763 true_label_(true_label), |
| 764 false_label_(false_label), | 764 false_label_(false_label), |
| 765 fall_through_(fall_through) { } | 765 fall_through_(fall_through) { } |
| 766 | 766 |
| 767 static const TestContext* cast(const ExpressionContext* context) { | 767 static const TestContext* cast(const ExpressionContext* context) { |
| 768 ASSERT(context->IsTest()); | 768 DCHECK(context->IsTest()); |
| 769 return reinterpret_cast<const TestContext*>(context); | 769 return reinterpret_cast<const TestContext*>(context); |
| 770 } | 770 } |
| 771 | 771 |
| 772 Expression* condition() const { return condition_; } | 772 Expression* condition() const { return condition_; } |
| 773 Label* true_label() const { return true_label_; } | 773 Label* true_label() const { return true_label_; } |
| 774 Label* false_label() const { return false_label_; } | 774 Label* false_label() const { return false_label_; } |
| 775 Label* fall_through() const { return fall_through_; } | 775 Label* fall_through() const { return fall_through_; } |
| 776 | 776 |
| 777 virtual void Plug(bool flag) const; | 777 virtual void Plug(bool flag) const; |
| 778 virtual void Plug(Register reg) const; | 778 virtual void Plug(Register reg) const; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } | 859 } |
| 860 | 860 |
| 861 private: | 861 private: |
| 862 Zone* zone_; | 862 Zone* zone_; |
| 863 }; | 863 }; |
| 864 | 864 |
| 865 | 865 |
| 866 class BackEdgeTable { | 866 class BackEdgeTable { |
| 867 public: | 867 public: |
| 868 BackEdgeTable(Code* code, DisallowHeapAllocation* required) { | 868 BackEdgeTable(Code* code, DisallowHeapAllocation* required) { |
| 869 ASSERT(code->kind() == Code::FUNCTION); | 869 DCHECK(code->kind() == Code::FUNCTION); |
| 870 instruction_start_ = code->instruction_start(); | 870 instruction_start_ = code->instruction_start(); |
| 871 Address table_address = instruction_start_ + code->back_edge_table_offset(); | 871 Address table_address = instruction_start_ + code->back_edge_table_offset(); |
| 872 length_ = Memory::uint32_at(table_address); | 872 length_ = Memory::uint32_at(table_address); |
| 873 start_ = table_address + kTableLengthSize; | 873 start_ = table_address + kTableLengthSize; |
| 874 } | 874 } |
| 875 | 875 |
| 876 uint32_t length() { return length_; } | 876 uint32_t length() { return length_; } |
| 877 | 877 |
| 878 BailoutId ast_id(uint32_t index) { | 878 BailoutId ast_id(uint32_t index) { |
| 879 return BailoutId(static_cast<int>( | 879 return BailoutId(static_cast<int>( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 Code* unoptimized_code, | 923 Code* unoptimized_code, |
| 924 Address pc_after); | 924 Address pc_after); |
| 925 | 925 |
| 926 #ifdef DEBUG | 926 #ifdef DEBUG |
| 927 // Verify that all back edges of a certain loop depth are patched. | 927 // Verify that all back edges of a certain loop depth are patched. |
| 928 static bool Verify(Isolate* isolate, Code* unoptimized_code); | 928 static bool Verify(Isolate* isolate, Code* unoptimized_code); |
| 929 #endif // DEBUG | 929 #endif // DEBUG |
| 930 | 930 |
| 931 private: | 931 private: |
| 932 Address entry_at(uint32_t index) { | 932 Address entry_at(uint32_t index) { |
| 933 ASSERT(index < length_); | 933 DCHECK(index < length_); |
| 934 return start_ + index * kEntrySize; | 934 return start_ + index * kEntrySize; |
| 935 } | 935 } |
| 936 | 936 |
| 937 static const int kTableLengthSize = kIntSize; | 937 static const int kTableLengthSize = kIntSize; |
| 938 static const int kAstIdOffset = 0 * kIntSize; | 938 static const int kAstIdOffset = 0 * kIntSize; |
| 939 static const int kPcOffsetOffset = 1 * kIntSize; | 939 static const int kPcOffsetOffset = 1 * kIntSize; |
| 940 static const int kLoopDepthOffset = 2 * kIntSize; | 940 static const int kLoopDepthOffset = 2 * kIntSize; |
| 941 static const int kEntrySize = 3 * kIntSize; | 941 static const int kEntrySize = 3 * kIntSize; |
| 942 | 942 |
| 943 Address start_; | 943 Address start_; |
| 944 Address instruction_start_; | 944 Address instruction_start_; |
| 945 uint32_t length_; | 945 uint32_t length_; |
| 946 }; | 946 }; |
| 947 | 947 |
| 948 | 948 |
| 949 } } // namespace v8::internal | 949 } } // namespace v8::internal |
| 950 | 950 |
| 951 #endif // V8_FULL_CODEGEN_H_ | 951 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |