| 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" |
| 11 #include "src/compiler/instruction.h" | 11 #include "src/compiler/instruction.h" |
| 12 #include "src/deoptimizer.h" | 12 #include "src/deoptimizer.h" |
| 13 #include "src/macro-assembler.h" | 13 #include "src/macro-assembler.h" |
| 14 #include "src/safepoint-table.h" | 14 #include "src/safepoint-table.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 // Generates native code for a sequence of instructions. | 20 // Generates native code for a sequence of instructions. |
| 21 class CodeGenerator FINAL : public GapResolver::Assembler { | 21 class CodeGenerator FINAL : public GapResolver::Assembler { |
| 22 public: | 22 public: |
| 23 explicit CodeGenerator(Frame* frame, Linkage* linkage, | 23 explicit CodeGenerator(Frame* frame, Linkage* linkage, |
| 24 InstructionSequence* code); | 24 InstructionSequence* code, CompilationInfo* info); |
| 25 | 25 |
| 26 // Generate native code. | 26 // Generate native code. |
| 27 Handle<Code> GenerateCode(); | 27 Handle<Code> GenerateCode(); |
| 28 | 28 |
| 29 InstructionSequence* code() const { return code_; } | 29 InstructionSequence* code() const { return code_; } |
| 30 Frame* frame() const { return frame_; } | 30 Frame* frame() const { return frame_; } |
| 31 Isolate* isolate() const { return zone()->isolate(); } | 31 Isolate* isolate() const { return zone()->isolate(); } |
| 32 Linkage* linkage() const { return linkage_; } | 32 Linkage* linkage() const { return linkage_; } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 MacroAssembler* masm() { return &masm_; } | 35 MacroAssembler* masm() { return &masm_; } |
| 36 GapResolver* resolver() { return &resolver_; } | 36 GapResolver* resolver() { return &resolver_; } |
| 37 SafepointTableBuilder* safepoints() { return &safepoints_; } | 37 SafepointTableBuilder* safepoints() { return &safepoints_; } |
| 38 Zone* zone() const { return code()->zone(); } | 38 Zone* zone() const { return code()->zone(); } |
| 39 CompilationInfo* info() const { return info_; } |
| 39 | 40 |
| 40 // Checks if {block} will appear directly after {current_block_} when | 41 // Checks if {block} will appear directly after {current_block_} when |
| 41 // assembling code, in which case, a fall-through can be used. | 42 // assembling code, in which case, a fall-through can be used. |
| 42 bool IsNextInAssemblyOrder(BasicBlock::RpoNumber block) const; | 43 bool IsNextInAssemblyOrder(BasicBlock::RpoNumber block) const; |
| 43 | 44 |
| 44 // Record a safepoint with the given pointer map. | 45 // Record a safepoint with the given pointer map. |
| 45 void RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind, | 46 void RecordSafepoint(PointerMap* pointers, Safepoint::Kind kind, |
| 46 int arguments, Safepoint::DeoptMode deopt_mode); | 47 int arguments, Safepoint::DeoptMode deopt_mode); |
| 47 | 48 |
| 48 // Assemble code for the specified instruction. | 49 // Assemble code for the specified instruction. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 private: | 113 private: |
| 113 BailoutId bailout_id_; | 114 BailoutId bailout_id_; |
| 114 int translation_id_; | 115 int translation_id_; |
| 115 int pc_offset_; | 116 int pc_offset_; |
| 116 }; | 117 }; |
| 117 | 118 |
| 118 Frame* const frame_; | 119 Frame* const frame_; |
| 119 Linkage* const linkage_; | 120 Linkage* const linkage_; |
| 120 InstructionSequence* const code_; | 121 InstructionSequence* const code_; |
| 122 CompilationInfo* const info_; |
| 121 BasicBlock::RpoNumber current_block_; | 123 BasicBlock::RpoNumber current_block_; |
| 122 SourcePosition current_source_position_; | 124 SourcePosition current_source_position_; |
| 123 MacroAssembler masm_; | 125 MacroAssembler masm_; |
| 124 GapResolver resolver_; | 126 GapResolver resolver_; |
| 125 SafepointTableBuilder safepoints_; | 127 SafepointTableBuilder safepoints_; |
| 126 ZoneDeque<DeoptimizationState*> deoptimization_states_; | 128 ZoneDeque<DeoptimizationState*> deoptimization_states_; |
| 127 ZoneDeque<Handle<Object> > deoptimization_literals_; | 129 ZoneDeque<Handle<Object> > deoptimization_literals_; |
| 128 TranslationBuffer translations_; | 130 TranslationBuffer translations_; |
| 129 int last_lazy_deopt_pc_; | 131 int last_lazy_deopt_pc_; |
| 130 }; | 132 }; |
| 131 | 133 |
| 132 } // namespace compiler | 134 } // namespace compiler |
| 133 } // namespace internal | 135 } // namespace internal |
| 134 } // namespace v8 | 136 } // namespace v8 |
| 135 | 137 |
| 136 #endif // V8_COMPILER_CODE_GENERATOR_H | 138 #endif // V8_COMPILER_CODE_GENERATOR_H |
| OLD | NEW |