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(InstructionSequence* code); | 23 explicit CodeGenerator(Frame* frame, Linkage* linkage, |
24 InstructionSequence* code); | |
24 | 25 |
25 // Generate native code. | 26 // Generate native code. |
26 Handle<Code> GenerateCode(); | 27 Handle<Code> GenerateCode(); |
27 | 28 |
28 InstructionSequence* code() const { return code_; } | 29 InstructionSequence* code() const { return code_; } |
29 Frame* frame() const { return code()->frame(); } | 30 Frame* frame() const { return frame_; } |
30 Isolate* isolate() const { return zone()->isolate(); } | 31 Isolate* isolate() const { return zone()->isolate(); } |
31 Linkage* linkage() const { return code()->linkage(); } | 32 Linkage* linkage() const { return linkage_; } |
32 | 33 |
33 private: | 34 private: |
34 MacroAssembler* masm() { return &masm_; } | 35 MacroAssembler* masm() { return &masm_; } |
35 GapResolver* resolver() { return &resolver_; } | 36 GapResolver* resolver() { return &resolver_; } |
36 SafepointTableBuilder* safepoints() { return &safepoints_; } | 37 SafepointTableBuilder* safepoints() { return &safepoints_; } |
37 Zone* zone() const { return code()->zone(); } | 38 Zone* zone() const { return code()->zone(); } |
38 | 39 |
39 // Checks if {block} will appear directly after {current_block_} when | 40 // Checks if {block} will appear directly after {current_block_} when |
40 // assembling code, in which case, a fall-through can be used. | 41 // assembling code, in which case, a fall-through can be used. |
41 bool IsNextInAssemblyOrder(BasicBlock::RpoNumber block) const { | 42 bool IsNextInAssemblyOrder(BasicBlock::RpoNumber block) const { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 : bailout_id_(bailout_id), | 110 : bailout_id_(bailout_id), |
110 translation_id_(translation_id), | 111 translation_id_(translation_id), |
111 pc_offset_(pc_offset) {} | 112 pc_offset_(pc_offset) {} |
112 | 113 |
113 private: | 114 private: |
114 BailoutId bailout_id_; | 115 BailoutId bailout_id_; |
115 int translation_id_; | 116 int translation_id_; |
116 int pc_offset_; | 117 int pc_offset_; |
117 }; | 118 }; |
118 | 119 |
120 Frame* frame_; | |
Benedikt Meurer
2014/10/21 04:12:04
Nit: Frame* const frame_;
| |
121 Linkage* linkage_; | |
Benedikt Meurer
2014/10/21 04:12:04
Nit: Linkage* const linkage_;
| |
119 InstructionSequence* code_; | 122 InstructionSequence* code_; |
120 BasicBlock::RpoNumber current_block_; | 123 BasicBlock::RpoNumber current_block_; |
121 SourcePosition current_source_position_; | 124 SourcePosition current_source_position_; |
122 MacroAssembler masm_; | 125 MacroAssembler masm_; |
123 GapResolver resolver_; | 126 GapResolver resolver_; |
124 SafepointTableBuilder safepoints_; | 127 SafepointTableBuilder safepoints_; |
125 ZoneDeque<DeoptimizationState*> deoptimization_states_; | 128 ZoneDeque<DeoptimizationState*> deoptimization_states_; |
126 ZoneDeque<Handle<Object> > deoptimization_literals_; | 129 ZoneDeque<Handle<Object> > deoptimization_literals_; |
127 TranslationBuffer translations_; | 130 TranslationBuffer translations_; |
128 int last_lazy_deopt_pc_; | 131 int last_lazy_deopt_pc_; |
129 }; | 132 }; |
130 | 133 |
131 } // namespace compiler | 134 } // namespace compiler |
132 } // namespace internal | 135 } // namespace internal |
133 } // namespace v8 | 136 } // namespace v8 |
134 | 137 |
135 #endif // V8_COMPILER_CODE_GENERATOR_H | 138 #endif // V8_COMPILER_CODE_GENERATOR_H |
OLD | NEW |