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

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

Issue 897883002: [turbofan]: Improved source position information (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 5 years, 10 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
« no previous file with comments | « src/compiler/graph.cc ('k') | src/compiler/simplified-lowering.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 285
286 class AstGraphBuilderWithPositions : public AstGraphBuilder { 286 class AstGraphBuilderWithPositions : public AstGraphBuilder {
287 public: 287 public:
288 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, 288 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info,
289 JSGraph* jsgraph, 289 JSGraph* jsgraph,
290 LoopAssignmentAnalysis* loop_assignment, 290 LoopAssignmentAnalysis* loop_assignment,
291 SourcePositionTable* source_positions) 291 SourcePositionTable* source_positions)
292 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment), 292 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment),
293 source_positions_(source_positions) {} 293 source_positions_(source_positions),
294 start_position_(info->shared_info()->start_position()) {}
294 295
295 bool CreateGraph() { 296 bool CreateGraph() {
296 SourcePositionTable::Scope pos(source_positions_, 297 SourcePositionTable::Scope pos_scope(source_positions_, start_position_);
297 SourcePosition::Unknown());
298 return AstGraphBuilder::CreateGraph(); 298 return AstGraphBuilder::CreateGraph();
299 } 299 }
300 300
301 #define DEF_VISIT(type) \ 301 #define DEF_VISIT(type) \
302 void Visit##type(type* node) OVERRIDE { \ 302 void Visit##type(type* node) OVERRIDE { \
303 SourcePositionTable::Scope pos(source_positions_, \ 303 SourcePositionTable::Scope pos(source_positions_, \
304 SourcePosition(node->position())); \ 304 SourcePosition(node->position())); \
305 AstGraphBuilder::Visit##type(node); \ 305 AstGraphBuilder::Visit##type(node); \
306 } 306 }
307 AST_NODE_LIST(DEF_VISIT) 307 AST_NODE_LIST(DEF_VISIT)
308 #undef DEF_VISIT 308 #undef DEF_VISIT
309 309
310 Node* GetFunctionContext() { return AstGraphBuilder::GetFunctionContext(); } 310 Node* GetFunctionContext() { return AstGraphBuilder::GetFunctionContext(); }
311 311
312 private: 312 private:
313 SourcePositionTable* source_positions_; 313 SourcePositionTable* source_positions_;
314 SourcePosition start_position_;
314 }; 315 };
315 316
316 317
318 namespace {
319
320 class SourcePositionWrapper : public Reducer {
321 public:
322 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table)
323 : reducer_(reducer), table_(table) {}
324 virtual ~SourcePositionWrapper() {}
325
326 virtual Reduction Reduce(Node* node) {
327 SourcePosition pos = table_->GetSourcePosition(node);
328 SourcePositionTable::Scope position(table_, pos);
329 return reducer_->Reduce(node);
330 }
331
332 private:
333 Reducer* reducer_;
334 SourcePositionTable* table_;
335
336 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper);
337 };
338
339
340 static void AddReducer(PipelineData* data, GraphReducer* graph_reducer,
341 Reducer* reducer) {
342 if (FLAG_turbo_source_positions) {
343 void* buffer = data->graph_zone()->New(sizeof(SourcePositionWrapper));
344 SourcePositionWrapper* wrapper =
345 new (buffer) SourcePositionWrapper(reducer, data->source_positions());
346 graph_reducer->AddReducer(wrapper);
347 } else {
348 graph_reducer->AddReducer(reducer);
349 }
350 }
351 } // namespace
352
317 class PipelineRunScope { 353 class PipelineRunScope {
318 public: 354 public:
319 PipelineRunScope(PipelineData* data, const char* phase_name) 355 PipelineRunScope(PipelineData* data, const char* phase_name)
320 : phase_scope_( 356 : phase_scope_(
321 phase_name == nullptr ? nullptr : data->pipeline_statistics(), 357 phase_name == nullptr ? nullptr : data->pipeline_statistics(),
322 phase_name), 358 phase_name),
323 zone_scope_(data->zone_pool()) {} 359 zone_scope_(data->zone_pool()) {}
324 360
325 Zone* zone() { return zone_scope_.zone(); } 361 Zone* zone() { return zone_scope_.zone(); }
326 362
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 411
376 struct ContextSpecializerPhase { 412 struct ContextSpecializerPhase {
377 static const char* phase_name() { return "context specializing"; } 413 static const char* phase_name() { return "context specializing"; }
378 414
379 void Run(PipelineData* data, Zone* temp_zone) { 415 void Run(PipelineData* data, Zone* temp_zone) {
380 SourcePositionTable::Scope pos(data->source_positions(), 416 SourcePositionTable::Scope pos(data->source_positions(),
381 SourcePosition::Unknown()); 417 SourcePosition::Unknown());
382 JSContextSpecializer spec(data->info(), data->jsgraph(), 418 JSContextSpecializer spec(data->info(), data->jsgraph(),
383 data->context_node()); 419 data->context_node());
384 GraphReducer graph_reducer(data->graph(), temp_zone); 420 GraphReducer graph_reducer(data->graph(), temp_zone);
385 graph_reducer.AddReducer(&spec); 421 AddReducer(data, &graph_reducer, &spec);
386 graph_reducer.ReduceGraph(); 422 graph_reducer.ReduceGraph();
387 } 423 }
388 }; 424 };
389 425
390 426
391 struct InliningPhase { 427 struct InliningPhase {
392 static const char* phase_name() { return "inlining"; } 428 static const char* phase_name() { return "inlining"; }
393 429
394 void Run(PipelineData* data, Zone* temp_zone) { 430 void Run(PipelineData* data, Zone* temp_zone) {
395 SourcePositionTable::Scope pos(data->source_positions(), 431 SourcePositionTable::Scope pos(data->source_positions(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 SourcePositionTable::Scope pos(data->source_positions(), 464 SourcePositionTable::Scope pos(data->source_positions(),
429 SourcePosition::Unknown()); 465 SourcePosition::Unknown());
430 ValueNumberingReducer vn_reducer(temp_zone); 466 ValueNumberingReducer vn_reducer(temp_zone);
431 LoadElimination load_elimination; 467 LoadElimination load_elimination;
432 JSBuiltinReducer builtin_reducer(data->jsgraph()); 468 JSBuiltinReducer builtin_reducer(data->jsgraph());
433 JSTypedLowering typed_lowering(data->jsgraph(), temp_zone); 469 JSTypedLowering typed_lowering(data->jsgraph(), temp_zone);
434 JSIntrinsicLowering intrinsic_lowering(data->jsgraph()); 470 JSIntrinsicLowering intrinsic_lowering(data->jsgraph());
435 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); 471 SimplifiedOperatorReducer simple_reducer(data->jsgraph());
436 CommonOperatorReducer common_reducer; 472 CommonOperatorReducer common_reducer;
437 GraphReducer graph_reducer(data->graph(), temp_zone); 473 GraphReducer graph_reducer(data->graph(), temp_zone);
438 graph_reducer.AddReducer(&vn_reducer); 474 AddReducer(data, &graph_reducer, &vn_reducer);
439 graph_reducer.AddReducer(&builtin_reducer); 475 AddReducer(data, &graph_reducer, &builtin_reducer);
440 graph_reducer.AddReducer(&typed_lowering); 476 AddReducer(data, &graph_reducer, &typed_lowering);
441 graph_reducer.AddReducer(&intrinsic_lowering); 477 AddReducer(data, &graph_reducer, &intrinsic_lowering);
442 graph_reducer.AddReducer(&load_elimination); 478 AddReducer(data, &graph_reducer, &load_elimination);
443 graph_reducer.AddReducer(&simple_reducer); 479 AddReducer(data, &graph_reducer, &simple_reducer);
444 graph_reducer.AddReducer(&common_reducer); 480 AddReducer(data, &graph_reducer, &common_reducer);
445 graph_reducer.ReduceGraph(); 481 graph_reducer.ReduceGraph();
446 } 482 }
447 }; 483 };
448 484
449 485
450 struct SimplifiedLoweringPhase { 486 struct SimplifiedLoweringPhase {
451 static const char* phase_name() { return "simplified lowering"; } 487 static const char* phase_name() { return "simplified lowering"; }
452 488
453 void Run(PipelineData* data, Zone* temp_zone) { 489 void Run(PipelineData* data, Zone* temp_zone) {
454 SourcePositionTable::Scope pos(data->source_positions(), 490 SourcePositionTable::Scope pos(data->source_positions(),
455 SourcePosition::Unknown()); 491 SourcePosition::Unknown());
456 SimplifiedLowering lowering(data->jsgraph(), temp_zone); 492 SimplifiedLowering lowering(data->jsgraph(), temp_zone,
493 data->source_positions());
457 lowering.LowerAllNodes(); 494 lowering.LowerAllNodes();
458 ValueNumberingReducer vn_reducer(temp_zone); 495 ValueNumberingReducer vn_reducer(temp_zone);
459 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); 496 SimplifiedOperatorReducer simple_reducer(data->jsgraph());
460 MachineOperatorReducer machine_reducer(data->jsgraph()); 497 MachineOperatorReducer machine_reducer(data->jsgraph());
461 CommonOperatorReducer common_reducer; 498 CommonOperatorReducer common_reducer;
462 GraphReducer graph_reducer(data->graph(), temp_zone); 499 GraphReducer graph_reducer(data->graph(), temp_zone);
463 graph_reducer.AddReducer(&vn_reducer); 500 AddReducer(data, &graph_reducer, &vn_reducer);
464 graph_reducer.AddReducer(&simple_reducer); 501 AddReducer(data, &graph_reducer, &simple_reducer);
465 graph_reducer.AddReducer(&machine_reducer); 502 AddReducer(data, &graph_reducer, &machine_reducer);
466 graph_reducer.AddReducer(&common_reducer); 503 AddReducer(data, &graph_reducer, &common_reducer);
467 graph_reducer.ReduceGraph(); 504 graph_reducer.ReduceGraph();
468 } 505 }
469 }; 506 };
470 507
471 508
472 struct ChangeLoweringPhase { 509 struct ChangeLoweringPhase {
473 static const char* phase_name() { return "change lowering"; } 510 static const char* phase_name() { return "change lowering"; }
474 511
475 void Run(PipelineData* data, Zone* temp_zone) { 512 void Run(PipelineData* data, Zone* temp_zone) {
476 SourcePositionTable::Scope pos(data->source_positions(), 513 SourcePositionTable::Scope pos(data->source_positions(),
477 SourcePosition::Unknown()); 514 SourcePosition::Unknown());
478 Linkage linkage(data->graph_zone(), data->info()); 515 Linkage linkage(data->graph_zone(), data->info());
479 ValueNumberingReducer vn_reducer(temp_zone); 516 ValueNumberingReducer vn_reducer(temp_zone);
480 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); 517 SimplifiedOperatorReducer simple_reducer(data->jsgraph());
481 ChangeLowering lowering(data->jsgraph(), &linkage); 518 ChangeLowering lowering(data->jsgraph(), &linkage);
482 MachineOperatorReducer machine_reducer(data->jsgraph()); 519 MachineOperatorReducer machine_reducer(data->jsgraph());
483 CommonOperatorReducer common_reducer; 520 CommonOperatorReducer common_reducer;
484 GraphReducer graph_reducer(data->graph(), temp_zone); 521 GraphReducer graph_reducer(data->graph(), temp_zone);
485 graph_reducer.AddReducer(&vn_reducer); 522 graph_reducer.AddReducer(&vn_reducer);
486 graph_reducer.AddReducer(&simple_reducer); 523 AddReducer(data, &graph_reducer, &simple_reducer);
487 graph_reducer.AddReducer(&lowering); 524 AddReducer(data, &graph_reducer, &lowering);
488 graph_reducer.AddReducer(&machine_reducer); 525 AddReducer(data, &graph_reducer, &machine_reducer);
489 graph_reducer.AddReducer(&common_reducer); 526 AddReducer(data, &graph_reducer, &common_reducer);
490 graph_reducer.ReduceGraph(); 527 graph_reducer.ReduceGraph();
491 } 528 }
492 }; 529 };
493 530
494 531
495 struct ControlReductionPhase { 532 struct ControlReductionPhase {
496 void Run(PipelineData* data, Zone* temp_zone) { 533 void Run(PipelineData* data, Zone* temp_zone) {
497 SourcePositionTable::Scope pos(data->source_positions(), 534 SourcePositionTable::Scope pos(data->source_positions(),
498 SourcePosition::Unknown()); 535 SourcePosition::Unknown());
499 ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), data->common()); 536 ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), data->common());
(...skipping 30 matching lines...) Expand all
530 567
531 struct GenericLoweringPhase { 568 struct GenericLoweringPhase {
532 static const char* phase_name() { return "generic lowering"; } 569 static const char* phase_name() { return "generic lowering"; }
533 570
534 void Run(PipelineData* data, Zone* temp_zone) { 571 void Run(PipelineData* data, Zone* temp_zone) {
535 SourcePositionTable::Scope pos(data->source_positions(), 572 SourcePositionTable::Scope pos(data->source_positions(),
536 SourcePosition::Unknown()); 573 SourcePosition::Unknown());
537 JSGenericLowering generic(data->info(), data->jsgraph()); 574 JSGenericLowering generic(data->info(), data->jsgraph());
538 SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common()); 575 SelectLowering select(data->jsgraph()->graph(), data->jsgraph()->common());
539 GraphReducer graph_reducer(data->graph(), temp_zone); 576 GraphReducer graph_reducer(data->graph(), temp_zone);
540 graph_reducer.AddReducer(&generic); 577 AddReducer(data, &graph_reducer, &generic);
541 graph_reducer.AddReducer(&select); 578 AddReducer(data, &graph_reducer, &select);
542 graph_reducer.ReduceGraph(); 579 graph_reducer.ReduceGraph();
543 } 580 }
544 }; 581 };
545 582
546 583
547 struct ComputeSchedulePhase { 584 struct ComputeSchedulePhase {
548 static const char* phase_name() { return "scheduling"; } 585 static const char* phase_name() { return "scheduling"; }
549 586
550 void Run(PipelineData* data, Zone* temp_zone) { 587 void Run(PipelineData* data, Zone* temp_zone) {
551 Schedule* schedule = Scheduler::ComputeSchedule( 588 Schedule* schedule = Scheduler::ComputeSchedule(
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 } 1180 }
1144 1181
1145 1182
1146 void Pipeline::TearDown() { 1183 void Pipeline::TearDown() {
1147 InstructionOperand::TearDownCaches(); 1184 InstructionOperand::TearDownCaches();
1148 } 1185 }
1149 1186
1150 } // namespace compiler 1187 } // namespace compiler
1151 } // namespace internal 1188 } // namespace internal
1152 } // namespace v8 1189 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/graph.cc ('k') | src/compiler/simplified-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698