| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_COMPILER_CODE_GENERATOR_H_ | 5 #ifndef V8_COMPILER_CODE_GENERATOR_H_ |
| 6 #define V8_COMPILER_CODE_GENERATOR_H_ | 6 #define V8_COMPILER_CODE_GENERATOR_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "src/compiler/gap-resolver.h" | 10 #include "src/compiler/gap-resolver.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 Zone* zone() const { return code()->zone(); } | 39 Zone* zone() const { return code()->zone(); } |
| 40 | 40 |
| 41 // Checks if {block} will appear directly after {current_block_} when | 41 // Checks if {block} will appear directly after {current_block_} when |
| 42 // assembling code, in which case, a fall-through can be used. | 42 // assembling code, in which case, a fall-through can be used. |
| 43 bool IsNextInAssemblyOrder(const BasicBlock* block) const { | 43 bool IsNextInAssemblyOrder(const BasicBlock* block) const { |
| 44 return block->rpo_number_ == (current_block_->rpo_number_ + 1) && | 44 return block->rpo_number_ == (current_block_->rpo_number_ + 1) && |
| 45 block->deferred_ == current_block_->deferred_; | 45 block->deferred_ == current_block_->deferred_; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Record a safepoint with the given pointer map. | 48 // Record a safepoint with the given pointer map. |
| 49 Safepoint::Id RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind, | 49 void RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind, |
| 50 int arguments, Safepoint::DeoptMode deopt_mode); | 50 int arguments, Safepoint::DeoptMode deopt_mode); |
| 51 | 51 |
| 52 // Assemble code for the specified instruction. | 52 // Assemble code for the specified instruction. |
| 53 void AssembleInstruction(Instruction* instr); | 53 void AssembleInstruction(Instruction* instr); |
| 54 void AssembleSourcePosition(SourcePositionInstruction* instr); | 54 void AssembleSourcePosition(SourcePositionInstruction* instr); |
| 55 void AssembleGap(GapInstruction* gap); | 55 void AssembleGap(GapInstruction* gap); |
| 56 | 56 |
| 57 // =========================================================================== | 57 // =========================================================================== |
| 58 // ============= Architecture-specific code generation methods. ============== | 58 // ============= Architecture-specific code generation methods. ============== |
| 59 // =========================================================================== | 59 // =========================================================================== |
| 60 | 60 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 77 | 77 |
| 78 // Interface used by the gap resolver to emit moves and swaps. | 78 // Interface used by the gap resolver to emit moves and swaps. |
| 79 virtual void AssembleMove(InstructionOperand* source, | 79 virtual void AssembleMove(InstructionOperand* source, |
| 80 InstructionOperand* destination) OVERRIDE; | 80 InstructionOperand* destination) OVERRIDE; |
| 81 virtual void AssembleSwap(InstructionOperand* source, | 81 virtual void AssembleSwap(InstructionOperand* source, |
| 82 InstructionOperand* destination) OVERRIDE; | 82 InstructionOperand* destination) OVERRIDE; |
| 83 | 83 |
| 84 // =========================================================================== | 84 // =========================================================================== |
| 85 // Deoptimization table construction | 85 // Deoptimization table construction |
| 86 void AddSafepointAndDeopt(Instruction* instr); | 86 void AddSafepointAndDeopt(Instruction* instr); |
| 87 void EmitLazyDeoptimizationCallTable(); | |
| 88 void PopulateDeoptimizationData(Handle<Code> code); | 87 void PopulateDeoptimizationData(Handle<Code> code); |
| 89 int DefineDeoptimizationLiteral(Handle<Object> literal); | 88 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 90 FrameStateDescriptor* GetFrameStateDescriptor(Instruction* instr, | 89 FrameStateDescriptor* GetFrameStateDescriptor(Instruction* instr, |
| 91 int frame_state_offset); | 90 int frame_state_offset); |
| 92 int BuildTranslation(Instruction* instr, int frame_state_offset, | 91 int BuildTranslation(Instruction* instr, int pc_offset, |
| 92 int frame_state_offset, |
| 93 OutputFrameStateCombine state_combine); | 93 OutputFrameStateCombine state_combine); |
| 94 void BuildTranslationForFrameStateDescriptor( | 94 void BuildTranslationForFrameStateDescriptor( |
| 95 FrameStateDescriptor* descriptor, Instruction* instr, | 95 FrameStateDescriptor* descriptor, Instruction* instr, |
| 96 Translation* translation, int frame_state_offset, | 96 Translation* translation, int frame_state_offset, |
| 97 OutputFrameStateCombine state_combine); | 97 OutputFrameStateCombine state_combine); |
| 98 void AddTranslationForOperand(Translation* translation, Instruction* instr, | 98 void AddTranslationForOperand(Translation* translation, Instruction* instr, |
| 99 InstructionOperand* op); | 99 InstructionOperand* op); |
| 100 void AddNopForSmiCodeInlining(); | 100 void AddNopForSmiCodeInlining(); |
| 101 // =========================================================================== | 101 // =========================================================================== |
| 102 | 102 |
| 103 class DeoptimizationPoint : public ZoneObject { | |
| 104 public: | |
| 105 int state_id() const { return state_id_; } | |
| 106 int lazy_state_id() const { return lazy_state_id_; } | |
| 107 FrameStateDescriptor* descriptor() const { return descriptor_; } | |
| 108 Safepoint::Id safepoint() const { return safepoint_; } | |
| 109 | |
| 110 DeoptimizationPoint(int state_id, int lazy_state_id, | |
| 111 FrameStateDescriptor* descriptor, | |
| 112 Safepoint::Id safepoint) | |
| 113 : state_id_(state_id), | |
| 114 lazy_state_id_(lazy_state_id), | |
| 115 descriptor_(descriptor), | |
| 116 safepoint_(safepoint) {} | |
| 117 | |
| 118 private: | |
| 119 int state_id_; | |
| 120 int lazy_state_id_; | |
| 121 FrameStateDescriptor* descriptor_; | |
| 122 Safepoint::Id safepoint_; | |
| 123 }; | |
| 124 | |
| 125 struct DeoptimizationState : ZoneObject { | 103 struct DeoptimizationState : ZoneObject { |
| 126 public: | 104 public: |
| 127 BailoutId bailout_id() const { return bailout_id_; } | 105 BailoutId bailout_id() const { return bailout_id_; } |
| 128 int translation_id() const { return translation_id_; } | 106 int translation_id() const { return translation_id_; } |
| 107 int pc_offset() const { return pc_offset_; } |
| 129 | 108 |
| 130 DeoptimizationState(BailoutId bailout_id, int translation_id) | 109 DeoptimizationState(BailoutId bailout_id, int translation_id, int pc_offset) |
| 131 : bailout_id_(bailout_id), translation_id_(translation_id) {} | 110 : bailout_id_(bailout_id), |
| 111 translation_id_(translation_id), |
| 112 pc_offset_(pc_offset) {} |
| 132 | 113 |
| 133 private: | 114 private: |
| 134 BailoutId bailout_id_; | 115 BailoutId bailout_id_; |
| 135 int translation_id_; | 116 int translation_id_; |
| 117 int pc_offset_; |
| 136 }; | 118 }; |
| 137 | 119 |
| 138 InstructionSequence* code_; | 120 InstructionSequence* code_; |
| 139 BasicBlock* current_block_; | 121 BasicBlock* current_block_; |
| 140 SourcePosition current_source_position_; | 122 SourcePosition current_source_position_; |
| 141 MacroAssembler masm_; | 123 MacroAssembler masm_; |
| 142 GapResolver resolver_; | 124 GapResolver resolver_; |
| 143 SafepointTableBuilder safepoints_; | 125 SafepointTableBuilder safepoints_; |
| 144 ZoneDeque<DeoptimizationPoint*> deoptimization_points_; | |
| 145 ZoneDeque<DeoptimizationState*> deoptimization_states_; | 126 ZoneDeque<DeoptimizationState*> deoptimization_states_; |
| 146 ZoneDeque<Handle<Object> > deoptimization_literals_; | 127 ZoneDeque<Handle<Object> > deoptimization_literals_; |
| 147 TranslationBuffer translations_; | 128 TranslationBuffer translations_; |
| 148 }; | 129 }; |
| 149 | 130 |
| 150 } // namespace compiler | 131 } // namespace compiler |
| 151 } // namespace internal | 132 } // namespace internal |
| 152 } // namespace v8 | 133 } // namespace v8 |
| 153 | 134 |
| 154 #endif // V8_COMPILER_CODE_GENERATOR_H | 135 #endif // V8_COMPILER_CODE_GENERATOR_H |
| OLD | NEW |