Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: src/compiler/code-generator.cc

Issue 1843143002: [turbofan] CodeGenerator: Frame setup refactoring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/pipeline.h" 10 #include "src/compiler/pipeline.h"
(...skipping 15 matching lines...) Expand all
26 26
27 private: 27 private:
28 Label label_; 28 Label label_;
29 JumpTable* const next_; 29 JumpTable* const next_;
30 Label** const targets_; 30 Label** const targets_;
31 size_t const target_count_; 31 size_t const target_count_;
32 }; 32 };
33 33
34 CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage, 34 CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
35 InstructionSequence* code, CompilationInfo* info) 35 InstructionSequence* code, CompilationInfo* info)
36 : frame_access_state_(new (code->zone()) FrameAccessState(frame)), 36 : frame_access_state_(nullptr),
37 linkage_(linkage), 37 linkage_(linkage),
38 code_(code), 38 code_(code),
39 info_(info), 39 info_(info),
40 labels_(zone()->NewArray<Label>(code->InstructionBlockCount())), 40 labels_(zone()->NewArray<Label>(code->InstructionBlockCount())),
41 current_block_(RpoNumber::Invalid()), 41 current_block_(RpoNumber::Invalid()),
42 current_source_position_(SourcePosition::Unknown()), 42 current_source_position_(SourcePosition::Unknown()),
43 masm_(info->isolate(), nullptr, 0, CodeObjectRequired::kYes), 43 masm_(info->isolate(), nullptr, 0, CodeObjectRequired::kYes),
44 resolver_(this), 44 resolver_(this),
45 safepoints_(code->zone()), 45 safepoints_(code->zone()),
46 handlers_(code->zone()), 46 handlers_(code->zone()),
47 deoptimization_exits_(code->zone()), 47 deoptimization_exits_(code->zone()),
48 deoptimization_states_(code->zone()), 48 deoptimization_states_(code->zone()),
49 deoptimization_literals_(code->zone()), 49 deoptimization_literals_(code->zone()),
50 inlined_function_count_(0), 50 inlined_function_count_(0),
51 translations_(code->zone()), 51 translations_(code->zone()),
52 last_lazy_deopt_pc_(0), 52 last_lazy_deopt_pc_(0),
53 jump_tables_(nullptr), 53 jump_tables_(nullptr),
54 ools_(nullptr), 54 ools_(nullptr),
55 osr_pc_offset_(-1) { 55 osr_pc_offset_(-1) {
56 for (int i = 0; i < code->InstructionBlockCount(); ++i) { 56 for (int i = 0; i < code->InstructionBlockCount(); ++i) {
57 new (&labels_[i]) Label; 57 new (&labels_[i]) Label;
58 } 58 }
59 CreateFrameAccessState(frame);
60 }
61
62 void CodeGenerator::CreateFrameAccessState(Frame* frame) {
63 FinishFrame(frame);
64 frame_access_state_ = new (code()->zone()) FrameAccessState(frame);
59 } 65 }
60 66
61 Handle<Code> CodeGenerator::GenerateCode() { 67 Handle<Code> CodeGenerator::GenerateCode() {
62 CompilationInfo* info = this->info(); 68 CompilationInfo* info = this->info();
63 69
64 // Open a frame scope to indicate that there is a frame on the stack. The 70 // Open a frame scope to indicate that there is a frame on the stack. The
65 // MANUAL indicates that the scope shouldn't actually generate code to set up 71 // MANUAL indicates that the scope shouldn't actually generate code to set up
66 // the frame (that is done in AssemblePrologue). 72 // the frame (that is done in AssemblePrologue).
67 FrameScope frame_scope(masm(), StackFrame::MANUAL); 73 FrameScope frame_scope(masm(), StackFrame::MANUAL);
68 74
(...skipping 20 matching lines...) Expand all
89 95
90 // Define deoptimization literals for all unoptimized code objects of inlined 96 // Define deoptimization literals for all unoptimized code objects of inlined
91 // functions. This ensures unoptimized code is kept alive by optimized code. 97 // functions. This ensures unoptimized code is kept alive by optimized code.
92 for (const CompilationInfo::InlinedFunctionHolder& inlined : 98 for (const CompilationInfo::InlinedFunctionHolder& inlined :
93 info->inlined_functions()) { 99 info->inlined_functions()) {
94 if (!inlined.shared_info.is_identical_to(info->shared_info())) { 100 if (!inlined.shared_info.is_identical_to(info->shared_info())) {
95 DefineDeoptimizationLiteral(inlined.inlined_code_object_root); 101 DefineDeoptimizationLiteral(inlined.inlined_code_object_root);
96 } 102 }
97 } 103 }
98 104
99 // Finish the Frame
100 frame()->AlignFrame(kFrameAlignmentInBytes);
101 AssembleSetupStackPointer();
102 // Assemble all non-deferred blocks, followed by deferred ones. 105 // Assemble all non-deferred blocks, followed by deferred ones.
103 for (int deferred = 0; deferred < 2; ++deferred) { 106 for (int deferred = 0; deferred < 2; ++deferred) {
104 for (const InstructionBlock* block : code()->instruction_blocks()) { 107 for (const InstructionBlock* block : code()->instruction_blocks()) {
105 if (block->IsDeferred() == (deferred == 0)) { 108 if (block->IsDeferred() == (deferred == 0)) {
106 continue; 109 continue;
107 } 110 }
108 // Align loop headers on 16-byte boundaries. 111 // Align loop headers on 16-byte boundaries.
109 if (block->IsLoopHeader()) masm()->Align(16); 112 if (block->IsLoopHeader()) masm()->Align(16);
110 // Ensure lazy deopt doesn't patch handler entry points. 113 // Ensure lazy deopt doesn't patch handler entry points.
111 if (block->IsHandler()) EnsureSpaceForLazyDeopt(); 114 if (block->IsHandler()) EnsureSpaceForLazyDeopt();
(...skipping 24 matching lines...) Expand all
136 buffer = buffer.SubVector(next, buffer.length()); 139 buffer = buffer.SubVector(next, buffer.length());
137 } 140 }
138 SNPrintF(buffer, " --"); 141 SNPrintF(buffer, " --");
139 masm()->RecordComment(buffer_start); 142 masm()->RecordComment(buffer_start);
140 } 143 }
141 144
142 frame_access_state()->MarkHasFrame(block->needs_frame()); 145 frame_access_state()->MarkHasFrame(block->needs_frame());
143 146
144 masm()->bind(GetLabel(current_block_)); 147 masm()->bind(GetLabel(current_block_));
145 if (block->must_construct_frame()) { 148 if (block->must_construct_frame()) {
146 AssemblePrologue(); 149 AssembleConstructFrame();
147 // We need to setup the root register after we assemble the prologue, to 150 // We need to setup the root register after we assemble the prologue, to
148 // avoid clobbering callee saved registers in case of C linkage and 151 // avoid clobbering callee saved registers in case of C linkage and
149 // using the roots. 152 // using the roots.
150 // TODO(mtrofin): investigate how we can avoid doing this repeatedly. 153 // TODO(mtrofin): investigate how we can avoid doing this repeatedly.
151 if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) { 154 if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) {
152 masm()->InitializeRootRegister(); 155 masm()->InitializeRootRegister();
153 } 156 }
154 } 157 }
155 158
156 if (FLAG_enable_embedded_constant_pool && !block->needs_frame()) { 159 if (FLAG_enable_embedded_constant_pool && !block->needs_frame()) {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { 804 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) {
802 gen->ools_ = this; 805 gen->ools_ = this;
803 } 806 }
804 807
805 808
806 OutOfLineCode::~OutOfLineCode() {} 809 OutOfLineCode::~OutOfLineCode() {}
807 810
808 } // namespace compiler 811 } // namespace compiler
809 } // namespace internal 812 } // namespace internal
810 } // namespace v8 813 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698