OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
8 #include "src/base/adapters.h" | 8 #include "src/base/adapters.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 Label** targets() const { return targets_; } | 26 Label** targets() const { return targets_; } |
27 size_t target_count() const { return target_count_; } | 27 size_t target_count() const { return target_count_; } |
28 | 28 |
29 private: | 29 private: |
30 Label label_; | 30 Label label_; |
31 JumpTable* const next_; | 31 JumpTable* const next_; |
32 Label** const targets_; | 32 Label** const targets_; |
33 size_t const target_count_; | 33 size_t const target_count_; |
34 }; | 34 }; |
35 | 35 |
36 CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage, | 36 CodeGenerator::CodeGenerator( |
37 InstructionSequence* code, CompilationInfo* info) | 37 Frame* frame, Linkage* linkage, InstructionSequence* code, |
| 38 CompilationInfo* info, |
| 39 ZoneVector<trap_handler::ProtectedInstructionData>* protected_instructions) |
38 : frame_access_state_(nullptr), | 40 : frame_access_state_(nullptr), |
39 linkage_(linkage), | 41 linkage_(linkage), |
40 code_(code), | 42 code_(code), |
41 unwinding_info_writer_(zone()), | 43 unwinding_info_writer_(zone()), |
42 info_(info), | 44 info_(info), |
43 labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), | 45 labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), |
44 current_block_(RpoNumber::Invalid()), | 46 current_block_(RpoNumber::Invalid()), |
45 current_source_position_(SourcePosition::Unknown()), | 47 current_source_position_(SourcePosition::Unknown()), |
46 masm_(info->isolate(), nullptr, 0, CodeObjectRequired::kNo), | 48 masm_(info->isolate(), nullptr, 0, CodeObjectRequired::kNo), |
47 resolver_(this), | 49 resolver_(this), |
48 safepoints_(code->zone()), | 50 safepoints_(code->zone()), |
49 handlers_(code->zone()), | 51 handlers_(code->zone()), |
50 deoptimization_exits_(code->zone()), | 52 deoptimization_exits_(code->zone()), |
51 deoptimization_states_(code->zone()), | 53 deoptimization_states_(code->zone()), |
52 deoptimization_literals_(code->zone()), | 54 deoptimization_literals_(code->zone()), |
53 inlined_function_count_(0), | 55 inlined_function_count_(0), |
54 translations_(code->zone()), | 56 translations_(code->zone()), |
55 last_lazy_deopt_pc_(0), | 57 last_lazy_deopt_pc_(0), |
56 jump_tables_(nullptr), | 58 jump_tables_(nullptr), |
57 ools_(nullptr), | 59 ools_(nullptr), |
58 osr_pc_offset_(-1), | 60 osr_pc_offset_(-1), |
59 source_position_table_builder_(code->zone(), | 61 source_position_table_builder_(code->zone(), |
60 info->SourcePositionRecordingMode()) { | 62 info->SourcePositionRecordingMode()), |
| 63 protected_instructions_(protected_instructions) { |
61 for (int i = 0; i < code->InstructionBlockCount(); ++i) { | 64 for (int i = 0; i < code->InstructionBlockCount(); ++i) { |
62 new (&labels_[i]) Label; | 65 new (&labels_[i]) Label; |
63 } | 66 } |
64 CreateFrameAccessState(frame); | 67 CreateFrameAccessState(frame); |
65 } | 68 } |
66 | 69 |
67 Isolate* CodeGenerator::isolate() const { return info_->isolate(); } | 70 Isolate* CodeGenerator::isolate() const { return info_->isolate(); } |
68 | 71 |
69 void CodeGenerator::CreateFrameAccessState(Frame* frame) { | 72 void CodeGenerator::CreateFrameAccessState(Frame* frame) { |
70 FinishFrame(frame); | 73 FinishFrame(frame); |
71 frame_access_state_ = new (code()->zone()) FrameAccessState(frame); | 74 frame_access_state_ = new (code()->zone()) FrameAccessState(frame); |
72 } | 75 } |
73 | 76 |
| 77 void CodeGenerator::AddProtectedInstruction(int instr_offset, |
| 78 int landing_offset) { |
| 79 if (protected_instructions_ != nullptr) { |
| 80 trap_handler::ProtectedInstructionData data = {instr_offset, |
| 81 landing_offset}; |
| 82 protected_instructions_->emplace_back(data); |
| 83 } |
| 84 } |
| 85 |
74 Handle<Code> CodeGenerator::GenerateCode() { | 86 Handle<Code> CodeGenerator::GenerateCode() { |
75 CompilationInfo* info = this->info(); | 87 CompilationInfo* info = this->info(); |
76 | 88 |
77 // Open a frame scope to indicate that there is a frame on the stack. The | 89 // Open a frame scope to indicate that there is a frame on the stack. The |
78 // MANUAL indicates that the scope shouldn't actually generate code to set up | 90 // MANUAL indicates that the scope shouldn't actually generate code to set up |
79 // the frame (that is done in AssemblePrologue). | 91 // the frame (that is done in AssemblePrologue). |
80 FrameScope frame_scope(masm(), StackFrame::MANUAL); | 92 FrameScope frame_scope(masm(), StackFrame::MANUAL); |
81 | 93 |
82 // Place function entry hook if requested to do so. | 94 // Place function entry hook if requested to do so. |
83 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { | 95 if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { |
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { | 973 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { |
962 gen->ools_ = this; | 974 gen->ools_ = this; |
963 } | 975 } |
964 | 976 |
965 | 977 |
966 OutOfLineCode::~OutOfLineCode() {} | 978 OutOfLineCode::~OutOfLineCode() {} |
967 | 979 |
968 } // namespace compiler | 980 } // namespace compiler |
969 } // namespace internal | 981 } // namespace internal |
970 } // namespace v8 | 982 } // namespace v8 |
OLD | NEW |