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/compiler/unwinding-info-writer.h" | 10 #include "src/compiler/unwinding-info-writer.h" |
11 #include "src/deoptimizer.h" | 11 #include "src/deoptimizer.h" |
12 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
13 #include "src/safepoint-table.h" | 13 #include "src/safepoint-table.h" |
14 #include "src/source-position-table.h" | 14 #include "src/source-position-table.h" |
| 15 #include "src/trap-handler/trap-handler.h" |
15 | 16 |
16 namespace v8 { | 17 namespace v8 { |
17 namespace internal { | 18 namespace internal { |
18 | 19 |
19 class CompilationInfo; | 20 class CompilationInfo; |
20 | 21 |
21 namespace compiler { | 22 namespace compiler { |
22 | 23 |
23 // Forward declarations. | 24 // Forward declarations. |
24 class DeoptimizationExit; | 25 class DeoptimizationExit; |
(...skipping 20 matching lines...) Expand all Loading... |
45 private: | 46 private: |
46 Instruction* instr_; | 47 Instruction* instr_; |
47 size_t pos_; | 48 size_t pos_; |
48 }; | 49 }; |
49 | 50 |
50 | 51 |
51 // Generates native code for a sequence of instructions. | 52 // Generates native code for a sequence of instructions. |
52 class CodeGenerator final : public GapResolver::Assembler { | 53 class CodeGenerator final : public GapResolver::Assembler { |
53 public: | 54 public: |
54 explicit CodeGenerator(Frame* frame, Linkage* linkage, | 55 explicit CodeGenerator(Frame* frame, Linkage* linkage, |
55 InstructionSequence* code, CompilationInfo* info); | 56 InstructionSequence* code, CompilationInfo* info, |
| 57 ZoneVector<trap_handler::ProtectedInstructionData>* |
| 58 protected_instructions = nullptr); |
56 | 59 |
57 // Generate native code. | 60 // Generate native code. |
58 Handle<Code> GenerateCode(); | 61 Handle<Code> GenerateCode(); |
59 | 62 |
60 InstructionSequence* code() const { return code_; } | 63 InstructionSequence* code() const { return code_; } |
61 FrameAccessState* frame_access_state() const { return frame_access_state_; } | 64 FrameAccessState* frame_access_state() const { return frame_access_state_; } |
62 const Frame* frame() const { return frame_access_state_->frame(); } | 65 const Frame* frame() const { return frame_access_state_->frame(); } |
63 Isolate* isolate() const; | 66 Isolate* isolate() const; |
64 Linkage* linkage() const { return linkage_; } | 67 Linkage* linkage() const { return linkage_; } |
65 | 68 |
66 Label* GetLabel(RpoNumber rpo) { return &labels_[rpo.ToSize()]; } | 69 Label* GetLabel(RpoNumber rpo) { return &labels_[rpo.ToSize()]; } |
67 | 70 |
| 71 void AddProtectedInstruction(int instr_offset, int landing_offset); |
| 72 |
68 private: | 73 private: |
69 MacroAssembler* masm() { return &masm_; } | 74 MacroAssembler* masm() { return &masm_; } |
70 GapResolver* resolver() { return &resolver_; } | 75 GapResolver* resolver() { return &resolver_; } |
71 SafepointTableBuilder* safepoints() { return &safepoints_; } | 76 SafepointTableBuilder* safepoints() { return &safepoints_; } |
72 Zone* zone() const { return code()->zone(); } | 77 Zone* zone() const { return code()->zone(); } |
73 CompilationInfo* info() const { return info_; } | 78 CompilationInfo* info() const { return info_; } |
74 | 79 |
75 // Create the FrameAccessState object. The Frame is immutable from here on. | 80 // Create the FrameAccessState object. The Frame is immutable from here on. |
76 void CreateFrameAccessState(Frame* frame); | 81 void CreateFrameAccessState(Frame* frame); |
77 | 82 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 ZoneDeque<DeoptimizationExit*> deoptimization_exits_; | 278 ZoneDeque<DeoptimizationExit*> deoptimization_exits_; |
274 ZoneDeque<DeoptimizationState*> deoptimization_states_; | 279 ZoneDeque<DeoptimizationState*> deoptimization_states_; |
275 ZoneDeque<Handle<Object>> deoptimization_literals_; | 280 ZoneDeque<Handle<Object>> deoptimization_literals_; |
276 size_t inlined_function_count_; | 281 size_t inlined_function_count_; |
277 TranslationBuffer translations_; | 282 TranslationBuffer translations_; |
278 int last_lazy_deopt_pc_; | 283 int last_lazy_deopt_pc_; |
279 JumpTable* jump_tables_; | 284 JumpTable* jump_tables_; |
280 OutOfLineCode* ools_; | 285 OutOfLineCode* ools_; |
281 int osr_pc_offset_; | 286 int osr_pc_offset_; |
282 SourcePositionTableBuilder source_position_table_builder_; | 287 SourcePositionTableBuilder source_position_table_builder_; |
| 288 ZoneVector<trap_handler::ProtectedInstructionData>* protected_instructions_; |
283 }; | 289 }; |
284 | 290 |
285 } // namespace compiler | 291 } // namespace compiler |
286 } // namespace internal | 292 } // namespace internal |
287 } // namespace v8 | 293 } // namespace v8 |
288 | 294 |
289 #endif // V8_COMPILER_CODE_GENERATOR_H | 295 #endif // V8_COMPILER_CODE_GENERATOR_H |
OLD | NEW |