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

Side by Side Diff: src/compiler/pipeline.cc

Issue 1259203002: [turbofan] Implement tail calls with differing stack parameter counts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bugs in frameless tail calls Created 5 years, 4 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 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 #include "src/compiler/pipeline.h" 5 #include "src/compiler/pipeline.h"
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/base/adapters.h" 10 #include "src/base/adapters.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 loop_assignment_(nullptr), 80 loop_assignment_(nullptr),
81 machine_(nullptr), 81 machine_(nullptr),
82 common_(nullptr), 82 common_(nullptr),
83 javascript_(nullptr), 83 javascript_(nullptr),
84 jsgraph_(nullptr), 84 jsgraph_(nullptr),
85 js_type_feedback_(nullptr), 85 js_type_feedback_(nullptr),
86 schedule_(nullptr), 86 schedule_(nullptr),
87 instruction_zone_scope_(zone_pool_), 87 instruction_zone_scope_(zone_pool_),
88 instruction_zone_(instruction_zone_scope_.zone()), 88 instruction_zone_(instruction_zone_scope_.zone()),
89 sequence_(nullptr), 89 sequence_(nullptr),
90 frame_(nullptr), 90 frame_(!info->IsStub()),
91 register_allocation_zone_scope_(zone_pool_), 91 register_allocation_zone_scope_(zone_pool_),
92 register_allocation_zone_(register_allocation_zone_scope_.zone()), 92 register_allocation_zone_(register_allocation_zone_scope_.zone()),
93 register_allocation_data_(nullptr) { 93 register_allocation_data_(nullptr) {
94 PhaseScope scope(pipeline_statistics, "init pipeline data"); 94 PhaseScope scope(pipeline_statistics, "init pipeline data");
95 graph_ = new (graph_zone_) Graph(graph_zone_); 95 graph_ = new (graph_zone_) Graph(graph_zone_);
96 source_positions_.Reset(new SourcePositionTable(graph_)); 96 source_positions_.Reset(new SourcePositionTable(graph_));
97 machine_ = new (graph_zone_) MachineOperatorBuilder( 97 machine_ = new (graph_zone_) MachineOperatorBuilder(
98 graph_zone_, kMachPtr, 98 graph_zone_, kMachPtr,
99 InstructionSelector::SupportedMachineOperatorFlags()); 99 InstructionSelector::SupportedMachineOperatorFlags());
100 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); 100 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_);
(...skipping 19 matching lines...) Expand all
120 loop_assignment_(nullptr), 120 loop_assignment_(nullptr),
121 machine_(nullptr), 121 machine_(nullptr),
122 common_(nullptr), 122 common_(nullptr),
123 javascript_(nullptr), 123 javascript_(nullptr),
124 jsgraph_(nullptr), 124 jsgraph_(nullptr),
125 js_type_feedback_(nullptr), 125 js_type_feedback_(nullptr),
126 schedule_(schedule), 126 schedule_(schedule),
127 instruction_zone_scope_(zone_pool_), 127 instruction_zone_scope_(zone_pool_),
128 instruction_zone_(instruction_zone_scope_.zone()), 128 instruction_zone_(instruction_zone_scope_.zone()),
129 sequence_(nullptr), 129 sequence_(nullptr),
130 frame_(nullptr), 130 frame_(false),
131 register_allocation_zone_scope_(zone_pool_), 131 register_allocation_zone_scope_(zone_pool_),
132 register_allocation_zone_(register_allocation_zone_scope_.zone()), 132 register_allocation_zone_(register_allocation_zone_scope_.zone()),
133 register_allocation_data_(nullptr) {} 133 register_allocation_data_(nullptr) {}
134 134
135 // For register allocation testing entry point. 135 // For register allocation testing entry point.
136 PipelineData(ZonePool* zone_pool, CompilationInfo* info, 136 PipelineData(ZonePool* zone_pool, CompilationInfo* info,
137 InstructionSequence* sequence) 137 InstructionSequence* sequence)
138 : isolate_(info->isolate()), 138 : isolate_(info->isolate()),
139 info_(info), 139 info_(info),
140 outer_zone_(nullptr), 140 outer_zone_(nullptr),
141 zone_pool_(zone_pool), 141 zone_pool_(zone_pool),
142 pipeline_statistics_(nullptr), 142 pipeline_statistics_(nullptr),
143 compilation_failed_(false), 143 compilation_failed_(false),
144 code_(Handle<Code>::null()), 144 code_(Handle<Code>::null()),
145 graph_zone_scope_(zone_pool_), 145 graph_zone_scope_(zone_pool_),
146 graph_zone_(nullptr), 146 graph_zone_(nullptr),
147 graph_(nullptr), 147 graph_(nullptr),
148 loop_assignment_(nullptr), 148 loop_assignment_(nullptr),
149 machine_(nullptr), 149 machine_(nullptr),
150 common_(nullptr), 150 common_(nullptr),
151 javascript_(nullptr), 151 javascript_(nullptr),
152 jsgraph_(nullptr), 152 jsgraph_(nullptr),
153 js_type_feedback_(nullptr), 153 js_type_feedback_(nullptr),
154 schedule_(nullptr), 154 schedule_(nullptr),
155 instruction_zone_scope_(zone_pool_), 155 instruction_zone_scope_(zone_pool_),
156 instruction_zone_(sequence->zone()), 156 instruction_zone_(sequence->zone()),
157 sequence_(sequence), 157 sequence_(sequence),
158 frame_(nullptr), 158 frame_(false),
159 register_allocation_zone_scope_(zone_pool_), 159 register_allocation_zone_scope_(zone_pool_),
160 register_allocation_zone_(register_allocation_zone_scope_.zone()), 160 register_allocation_zone_(register_allocation_zone_scope_.zone()),
161 register_allocation_data_(nullptr) {} 161 register_allocation_data_(nullptr) {}
162 162
163 ~PipelineData() { 163 ~PipelineData() {
164 DeleteRegisterAllocationZone(); 164 DeleteRegisterAllocationZone();
165 DeleteInstructionZone(); 165 DeleteInstructionZone();
166 DeleteGraphZone(); 166 DeleteGraphZone();
167 } 167 }
168 168
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 Schedule* schedule() const { return schedule_; } 204 Schedule* schedule() const { return schedule_; }
205 void set_schedule(Schedule* schedule) { 205 void set_schedule(Schedule* schedule) {
206 DCHECK(!schedule_); 206 DCHECK(!schedule_);
207 schedule_ = schedule; 207 schedule_ = schedule;
208 } 208 }
209 209
210 Zone* instruction_zone() const { return instruction_zone_; } 210 Zone* instruction_zone() const { return instruction_zone_; }
211 InstructionSequence* sequence() const { return sequence_; } 211 InstructionSequence* sequence() const { return sequence_; }
212 Frame* frame() const { return frame_; } 212 Frame* frame() { return &frame_; }
213 213
214 Zone* register_allocation_zone() const { return register_allocation_zone_; } 214 Zone* register_allocation_zone() const { return register_allocation_zone_; }
215 RegisterAllocationData* register_allocation_data() const { 215 RegisterAllocationData* register_allocation_data() const {
216 return register_allocation_data_; 216 return register_allocation_data_;
217 } 217 }
218 218
219 void DeleteGraphZone() { 219 void DeleteGraphZone() {
220 // Destroy objects with destructors first. 220 // Destroy objects with destructors first.
221 source_positions_.Reset(nullptr); 221 source_positions_.Reset(nullptr);
222 if (graph_zone_ == nullptr) return; 222 if (graph_zone_ == nullptr) return;
223 // Destroy zone and clear pointers. 223 // Destroy zone and clear pointers.
224 graph_zone_scope_.Destroy(); 224 graph_zone_scope_.Destroy();
225 graph_zone_ = nullptr; 225 graph_zone_ = nullptr;
226 graph_ = nullptr; 226 graph_ = nullptr;
227 loop_assignment_ = nullptr; 227 loop_assignment_ = nullptr;
228 machine_ = nullptr; 228 machine_ = nullptr;
229 common_ = nullptr; 229 common_ = nullptr;
230 javascript_ = nullptr; 230 javascript_ = nullptr;
231 jsgraph_ = nullptr; 231 jsgraph_ = nullptr;
232 js_type_feedback_ = nullptr; 232 js_type_feedback_ = nullptr;
233 schedule_ = nullptr; 233 schedule_ = nullptr;
234 } 234 }
235 235
236 void DeleteInstructionZone() { 236 void DeleteInstructionZone() {
237 if (instruction_zone_ == nullptr) return; 237 if (instruction_zone_ == nullptr) return;
238 instruction_zone_scope_.Destroy(); 238 instruction_zone_scope_.Destroy();
239 instruction_zone_ = nullptr; 239 instruction_zone_ = nullptr;
240 sequence_ = nullptr; 240 sequence_ = nullptr;
241 frame_ = nullptr;
242 } 241 }
243 242
244 void DeleteRegisterAllocationZone() { 243 void DeleteRegisterAllocationZone() {
245 if (register_allocation_zone_ == nullptr) return; 244 if (register_allocation_zone_ == nullptr) return;
246 register_allocation_zone_scope_.Destroy(); 245 register_allocation_zone_scope_.Destroy();
247 register_allocation_zone_ = nullptr; 246 register_allocation_zone_ = nullptr;
248 register_allocation_data_ = nullptr; 247 register_allocation_data_ = nullptr;
249 } 248 }
250 249
251 void InitializeInstructionSequence() { 250 void InitializeInstructionSequence(Linkage* linkage) {
252 DCHECK(sequence_ == nullptr); 251 DCHECK(sequence_ == nullptr);
253 InstructionBlocks* instruction_blocks = 252 InstructionBlocks* instruction_blocks =
254 InstructionSequence::InstructionBlocksFor(instruction_zone(), 253 InstructionSequence::InstructionBlocksFor(instruction_zone(),
255 schedule()); 254 schedule());
256 sequence_ = new (instruction_zone()) InstructionSequence( 255 sequence_ = new (instruction_zone()) InstructionSequence(
257 info()->isolate(), instruction_zone(), instruction_blocks); 256 info()->isolate(), instruction_zone(), instruction_blocks, frame());
258 } 257 }
259 258
260 void InitializeRegisterAllocationData(const RegisterConfiguration* config, 259 void InitializeRegisterAllocationData(const RegisterConfiguration* config,
261 const char* debug_name) { 260 const char* debug_name) {
262 DCHECK(frame_ == nullptr);
263 DCHECK(register_allocation_data_ == nullptr); 261 DCHECK(register_allocation_data_ == nullptr);
264 frame_ = new (instruction_zone()) Frame();
265 register_allocation_data_ = new (register_allocation_zone()) 262 register_allocation_data_ = new (register_allocation_zone())
266 RegisterAllocationData(config, register_allocation_zone(), frame(), 263 RegisterAllocationData(config, register_allocation_zone(), frame(),
267 sequence(), debug_name); 264 sequence(), debug_name);
268 } 265 }
269 266
270 private: 267 private:
271 Isolate* isolate_; 268 Isolate* isolate_;
272 CompilationInfo* info_; 269 CompilationInfo* info_;
273 Zone* outer_zone_; 270 Zone* outer_zone_;
274 ZonePool* const zone_pool_; 271 ZonePool* const zone_pool_;
(...skipping 15 matching lines...) Expand all
290 JSGraph* jsgraph_; 287 JSGraph* jsgraph_;
291 JSTypeFeedbackTable* js_type_feedback_; 288 JSTypeFeedbackTable* js_type_feedback_;
292 Schedule* schedule_; 289 Schedule* schedule_;
293 290
294 // All objects in the following group of fields are allocated in 291 // All objects in the following group of fields are allocated in
295 // instruction_zone_. They are all set to NULL when the instruction_zone_ is 292 // instruction_zone_. They are all set to NULL when the instruction_zone_ is
296 // destroyed. 293 // destroyed.
297 ZonePool::Scope instruction_zone_scope_; 294 ZonePool::Scope instruction_zone_scope_;
298 Zone* instruction_zone_; 295 Zone* instruction_zone_;
299 InstructionSequence* sequence_; 296 InstructionSequence* sequence_;
300 Frame* frame_; 297 Frame frame_;
301 298
302 // All objects in the following group of fields are allocated in 299 // All objects in the following group of fields are allocated in
303 // register_allocation_zone_. They are all set to NULL when the zone is 300 // register_allocation_zone_. They are all set to NULL when the zone is
304 // destroyed. 301 // destroyed.
305 ZonePool::Scope register_allocation_zone_scope_; 302 ZonePool::Scope register_allocation_zone_scope_;
306 Zone* register_allocation_zone_; 303 Zone* register_allocation_zone_;
307 RegisterAllocationData* register_allocation_data_; 304 RegisterAllocationData* register_allocation_data_;
308 305
309 DISALLOW_COPY_AND_ASSIGN(PipelineData); 306 DISALLOW_COPY_AND_ASSIGN(PipelineData);
310 }; 307 };
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 1192
1196 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); 1193 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>();
1197 TraceSchedule(data->info(), data->schedule()); 1194 TraceSchedule(data->info(), data->schedule());
1198 1195
1199 BasicBlockProfiler::Data* profiler_data = NULL; 1196 BasicBlockProfiler::Data* profiler_data = NULL;
1200 if (FLAG_turbo_profiling) { 1197 if (FLAG_turbo_profiling) {
1201 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(), 1198 profiler_data = BasicBlockInstrumentor::Instrument(info(), data->graph(),
1202 data->schedule()); 1199 data->schedule());
1203 } 1200 }
1204 1201
1205 data->InitializeInstructionSequence(); 1202 Linkage linkage(call_descriptor);
1203 data->InitializeInstructionSequence(&linkage);
1206 1204
1207 // Select and schedule instructions covering the scheduled graph. 1205 // Select and schedule instructions covering the scheduled graph.
1208 Linkage linkage(call_descriptor);
1209 Run<InstructionSelectionPhase>(&linkage); 1206 Run<InstructionSelectionPhase>(&linkage);
1210 1207
1211 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { 1208 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) {
1212 TurboCfgFile tcf(isolate()); 1209 TurboCfgFile tcf(isolate());
1213 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(), 1210 tcf << AsC1V("CodeGen", data->schedule(), data->source_positions(),
1214 data->sequence()); 1211 data->sequence());
1215 } 1212 }
1216 1213
1217 std::ostringstream source_position_output; 1214 std::ostringstream source_position_output;
1218 if (FLAG_trace_turbo) { 1215 if (FLAG_trace_turbo) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 tcf << AsC1VRegisterAllocationData("CodeGen", 1357 tcf << AsC1VRegisterAllocationData("CodeGen",
1361 data->register_allocation_data()); 1358 data->register_allocation_data());
1362 } 1359 }
1363 1360
1364 data->DeleteRegisterAllocationZone(); 1361 data->DeleteRegisterAllocationZone();
1365 } 1362 }
1366 1363
1367 } // namespace compiler 1364 } // namespace compiler
1368 } // namespace internal 1365 } // namespace internal
1369 } // namespace v8 1366 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698