Chromium Code Reviews| 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 "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
| 9 #include "src/compiler/instruction.h" | 9 #include "src/compiler/instruction.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| 11 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
| 12 #include "src/safepoint-table.h" | 12 #include "src/safepoint-table.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 class Linkage; | 19 class Linkage; |
| 20 class OutOfLineCode; | 20 class OutOfLineCode; |
| 21 | 21 |
| 22 struct BranchInfo { | 22 struct BranchInfo { |
| 23 FlagsCondition condition; | 23 FlagsCondition condition; |
| 24 Label* true_label; | 24 Label* true_label; |
| 25 Label* false_label; | 25 Label* false_label; |
| 26 bool fallthru; | 26 bool fallthru; |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 | 29 |
| 30 struct HandlerInfo { | |
|
Benedikt Meurer
2015/02/19 18:31:19
I think this should be a private member of CodeGen
Michael Starzinger
2015/02/20 10:04:54
Done.
| |
| 31 Label* handler; | |
| 32 int pc_offset; | |
| 33 }; | |
| 34 | |
| 35 | |
| 30 // Generates native code for a sequence of instructions. | 36 // Generates native code for a sequence of instructions. |
| 31 class CodeGenerator FINAL : public GapResolver::Assembler { | 37 class CodeGenerator FINAL : public GapResolver::Assembler { |
| 32 public: | 38 public: |
| 33 explicit CodeGenerator(Frame* frame, Linkage* linkage, | 39 explicit CodeGenerator(Frame* frame, Linkage* linkage, |
| 34 InstructionSequence* code, CompilationInfo* info); | 40 InstructionSequence* code, CompilationInfo* info); |
| 35 | 41 |
| 36 // Generate native code. | 42 // Generate native code. |
| 37 Handle<Code> GenerateCode(); | 43 Handle<Code> GenerateCode(); |
| 38 | 44 |
| 39 InstructionSequence* code() const { return code_; } | 45 InstructionSequence* code() const { return code_; } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 | 105 |
| 100 class JumpTable; | 106 class JumpTable; |
| 101 // Adds a jump table that is emitted after the actual code. Returns label | 107 // Adds a jump table that is emitted after the actual code. Returns label |
| 102 // pointing to the beginning of the table. {targets} is assumed to be static | 108 // pointing to the beginning of the table. {targets} is assumed to be static |
| 103 // or zone allocated. | 109 // or zone allocated. |
| 104 Label* AddJumpTable(Label** targets, size_t target_count); | 110 Label* AddJumpTable(Label** targets, size_t target_count); |
| 105 // Emits a jump table. | 111 // Emits a jump table. |
| 106 void AssembleJumpTable(Label** targets, size_t target_count); | 112 void AssembleJumpTable(Label** targets, size_t target_count); |
| 107 | 113 |
| 108 // =========================================================================== | 114 // =========================================================================== |
| 109 // Deoptimization table construction | 115 // ================== Deoptimization table construction. ===================== |
| 110 void AddSafepointAndDeopt(Instruction* instr); | 116 // =========================================================================== |
| 117 | |
| 118 void AddSafepointAndDeoptAndHandler(Instruction* instr); | |
| 111 void PopulateDeoptimizationData(Handle<Code> code); | 119 void PopulateDeoptimizationData(Handle<Code> code); |
| 112 int DefineDeoptimizationLiteral(Handle<Object> literal); | 120 int DefineDeoptimizationLiteral(Handle<Object> literal); |
| 113 FrameStateDescriptor* GetFrameStateDescriptor(Instruction* instr, | 121 FrameStateDescriptor* GetFrameStateDescriptor(Instruction* instr, |
| 114 size_t frame_state_offset); | 122 size_t frame_state_offset); |
| 115 int BuildTranslation(Instruction* instr, int pc_offset, | 123 int BuildTranslation(Instruction* instr, int pc_offset, |
| 116 size_t frame_state_offset, | 124 size_t frame_state_offset, |
| 117 OutputFrameStateCombine state_combine); | 125 OutputFrameStateCombine state_combine); |
| 118 void BuildTranslationForFrameStateDescriptor( | 126 void BuildTranslationForFrameStateDescriptor( |
| 119 FrameStateDescriptor* descriptor, Instruction* instr, | 127 FrameStateDescriptor* descriptor, Instruction* instr, |
| 120 Translation* translation, size_t frame_state_offset, | 128 Translation* translation, size_t frame_state_offset, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 148 Frame* const frame_; | 156 Frame* const frame_; |
| 149 Linkage* const linkage_; | 157 Linkage* const linkage_; |
| 150 InstructionSequence* const code_; | 158 InstructionSequence* const code_; |
| 151 CompilationInfo* const info_; | 159 CompilationInfo* const info_; |
| 152 Label* const labels_; | 160 Label* const labels_; |
| 153 BasicBlock::RpoNumber current_block_; | 161 BasicBlock::RpoNumber current_block_; |
| 154 SourcePosition current_source_position_; | 162 SourcePosition current_source_position_; |
| 155 MacroAssembler masm_; | 163 MacroAssembler masm_; |
| 156 GapResolver resolver_; | 164 GapResolver resolver_; |
| 157 SafepointTableBuilder safepoints_; | 165 SafepointTableBuilder safepoints_; |
| 166 ZoneVector<HandlerInfo> handlers_; | |
| 158 ZoneDeque<DeoptimizationState*> deoptimization_states_; | 167 ZoneDeque<DeoptimizationState*> deoptimization_states_; |
| 159 ZoneDeque<Handle<Object> > deoptimization_literals_; | 168 ZoneDeque<Handle<Object>> deoptimization_literals_; |
| 160 TranslationBuffer translations_; | 169 TranslationBuffer translations_; |
| 161 int last_lazy_deopt_pc_; | 170 int last_lazy_deopt_pc_; |
| 162 JumpTable* jump_tables_; | 171 JumpTable* jump_tables_; |
| 163 OutOfLineCode* ools_; | 172 OutOfLineCode* ools_; |
| 164 int osr_pc_offset_; | 173 int osr_pc_offset_; |
| 165 }; | 174 }; |
| 166 | 175 |
| 167 } // namespace compiler | 176 } // namespace compiler |
| 168 } // namespace internal | 177 } // namespace internal |
| 169 } // namespace v8 | 178 } // namespace v8 |
| 170 | 179 |
| 171 #endif // V8_COMPILER_CODE_GENERATOR_H | 180 #endif // V8_COMPILER_CODE_GENERATOR_H |
| OLD | NEW |