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

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);
59 } 60 }
60 61
61 Handle<Code> CodeGenerator::GenerateCode() { 62 Handle<Code> CodeGenerator::GenerateCode() {
62 CompilationInfo* info = this->info(); 63 CompilationInfo* info = this->info();
63 64
64 // Open a frame scope to indicate that there is a frame on the stack. The 65 // 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 66 // MANUAL indicates that the scope shouldn't actually generate code to set up
66 // the frame (that is done in AssemblePrologue). 67 // the frame (that is done in AssemblePrologue).
67 FrameScope frame_scope(masm(), StackFrame::MANUAL); 68 FrameScope frame_scope(masm(), StackFrame::MANUAL);
68 69
(...skipping 20 matching lines...) Expand all
89 90
90 // Define deoptimization literals for all unoptimized code objects of inlined 91 // Define deoptimization literals for all unoptimized code objects of inlined
91 // functions. This ensures unoptimized code is kept alive by optimized code. 92 // functions. This ensures unoptimized code is kept alive by optimized code.
92 for (const CompilationInfo::InlinedFunctionHolder& inlined : 93 for (const CompilationInfo::InlinedFunctionHolder& inlined :
93 info->inlined_functions()) { 94 info->inlined_functions()) {
94 if (!inlined.shared_info.is_identical_to(info->shared_info())) { 95 if (!inlined.shared_info.is_identical_to(info->shared_info())) {
95 DefineDeoptimizationLiteral(inlined.inlined_code_object_root); 96 DefineDeoptimizationLiteral(inlined.inlined_code_object_root);
96 } 97 }
97 } 98 }
98 99
99 // Finish the Frame
100 frame()->AlignFrame(kFrameAlignmentInBytes);
101 AssembleSetupStackPointer();
102 // Assemble all non-deferred blocks, followed by deferred ones. 100 // Assemble all non-deferred blocks, followed by deferred ones.
103 for (int deferred = 0; deferred < 2; ++deferred) { 101 for (int deferred = 0; deferred < 2; ++deferred) {
104 for (const InstructionBlock* block : code()->instruction_blocks()) { 102 for (const InstructionBlock* block : code()->instruction_blocks()) {
105 if (block->IsDeferred() == (deferred == 0)) { 103 if (block->IsDeferred() == (deferred == 0)) {
106 continue; 104 continue;
107 } 105 }
108 // Align loop headers on 16-byte boundaries. 106 // Align loop headers on 16-byte boundaries.
109 if (block->IsLoopHeader()) masm()->Align(16); 107 if (block->IsLoopHeader()) masm()->Align(16);
110 // Ensure lazy deopt doesn't patch handler entry points. 108 // Ensure lazy deopt doesn't patch handler entry points.
111 if (block->IsHandler()) EnsureSpaceForLazyDeopt(); 109 if (block->IsHandler()) EnsureSpaceForLazyDeopt();
(...skipping 24 matching lines...) Expand all
136 buffer = buffer.SubVector(next, buffer.length()); 134 buffer = buffer.SubVector(next, buffer.length());
137 } 135 }
138 SNPrintF(buffer, " --"); 136 SNPrintF(buffer, " --");
139 masm()->RecordComment(buffer_start); 137 masm()->RecordComment(buffer_start);
140 } 138 }
141 139
142 frame_access_state()->MarkHasFrame(block->needs_frame()); 140 frame_access_state()->MarkHasFrame(block->needs_frame());
143 141
144 masm()->bind(GetLabel(current_block_)); 142 masm()->bind(GetLabel(current_block_));
145 if (block->must_construct_frame()) { 143 if (block->must_construct_frame()) {
146 AssemblePrologue(); 144 AssembleConstructFrame();
147 // We need to setup the root register after we assemble the prologue, to 145 // 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 146 // avoid clobbering callee saved registers in case of C linkage and
149 // using the roots. 147 // using the roots.
150 // TODO(mtrofin): investigate how we can avoid doing this repeatedly. 148 // TODO(mtrofin): investigate how we can avoid doing this repeatedly.
151 if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) { 149 if (linkage()->GetIncomingDescriptor()->InitializeRootRegister()) {
152 masm()->InitializeRootRegister(); 150 masm()->InitializeRootRegister();
153 } 151 }
154 } 152 }
155 153
156 for (int i = block->code_start(); i < block->code_end(); ++i) { 154 for (int i = block->code_start(); i < block->code_end(); ++i) {
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) { 787 : frame_(gen->frame()), masm_(gen->masm()), next_(gen->ools_) {
790 gen->ools_ = this; 788 gen->ools_ = this;
791 } 789 }
792 790
793 791
794 OutOfLineCode::~OutOfLineCode() {} 792 OutOfLineCode::~OutOfLineCode() {}
795 793
796 } // namespace compiler 794 } // namespace compiler
797 } // namespace internal 795 } // namespace internal
798 } // namespace v8 796 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698