OLD | NEW |
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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, | 358 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, |
359 JSGraph* jsgraph, | 359 JSGraph* jsgraph, |
360 LoopAssignmentAnalysis* loop_assignment, | 360 LoopAssignmentAnalysis* loop_assignment, |
361 JSTypeFeedbackTable* js_type_feedback, | 361 JSTypeFeedbackTable* js_type_feedback, |
362 SourcePositionTable* source_positions) | 362 SourcePositionTable* source_positions) |
363 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, | 363 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, |
364 js_type_feedback), | 364 js_type_feedback), |
365 source_positions_(source_positions), | 365 source_positions_(source_positions), |
366 start_position_(info->shared_info()->start_position()) {} | 366 start_position_(info->shared_info()->start_position()) {} |
367 | 367 |
368 bool CreateGraph(bool constant_context, bool stack_check) { | 368 bool CreateGraph(bool stack_check) { |
369 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); | 369 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); |
370 return AstGraphBuilder::CreateGraph(constant_context, stack_check); | 370 return AstGraphBuilder::CreateGraph(stack_check); |
371 } | 371 } |
372 | 372 |
373 #define DEF_VISIT(type) \ | 373 #define DEF_VISIT(type) \ |
374 void Visit##type(type* node) override { \ | 374 void Visit##type(type* node) override { \ |
375 SourcePositionTable::Scope pos(source_positions_, \ | 375 SourcePositionTable::Scope pos(source_positions_, \ |
376 SourcePosition(node->position())); \ | 376 SourcePosition(node->position())); \ |
377 AstGraphBuilder::Visit##type(node); \ | 377 AstGraphBuilder::Visit##type(node); \ |
378 } | 378 } |
379 AST_NODE_LIST(DEF_VISIT) | 379 AST_NODE_LIST(DEF_VISIT) |
380 #undef DEF_VISIT | 380 #undef DEF_VISIT |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 AstLoopAssignmentAnalyzer analyzer(data->graph_zone(), data->info()); | 467 AstLoopAssignmentAnalyzer analyzer(data->graph_zone(), data->info()); |
468 LoopAssignmentAnalysis* loop_assignment = analyzer.Analyze(); | 468 LoopAssignmentAnalysis* loop_assignment = analyzer.Analyze(); |
469 data->set_loop_assignment(loop_assignment); | 469 data->set_loop_assignment(loop_assignment); |
470 } | 470 } |
471 }; | 471 }; |
472 | 472 |
473 | 473 |
474 struct GraphBuilderPhase { | 474 struct GraphBuilderPhase { |
475 static const char* phase_name() { return "graph builder"; } | 475 static const char* phase_name() { return "graph builder"; } |
476 | 476 |
477 void Run(PipelineData* data, Zone* temp_zone, bool constant_context) { | 477 void Run(PipelineData* data, Zone* temp_zone) { |
478 AstGraphBuilderWithPositions graph_builder( | 478 AstGraphBuilderWithPositions graph_builder( |
479 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), | 479 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), |
480 data->js_type_feedback(), data->source_positions()); | 480 data->js_type_feedback(), data->source_positions()); |
481 bool stack_check = !data->info()->IsStub(); | 481 bool stack_check = !data->info()->IsStub(); |
482 if (!graph_builder.CreateGraph(constant_context, stack_check)) { | 482 if (!graph_builder.CreateGraph(stack_check)) { |
483 data->set_compilation_failed(); | 483 data->set_compilation_failed(); |
484 } | 484 } |
485 } | 485 } |
486 }; | 486 }; |
487 | 487 |
488 | 488 |
489 struct InliningPhase { | 489 struct InliningPhase { |
490 static const char* phase_name() { return "inlining"; } | 490 static const char* phase_name() { return "inlining"; } |
491 | 491 |
492 void Run(PipelineData* data, Zone* temp_zone) { | 492 void Run(PipelineData* data, Zone* temp_zone) { |
493 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 493 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
494 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 494 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
495 data->common()); | 495 data->common()); |
496 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 496 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
497 data->common(), data->machine()); | 497 data->common(), data->machine()); |
498 JSContextSpecializer context_specializer(&graph_reducer, data->jsgraph()); | 498 JSContextSpecializer context_specializer( |
| 499 &graph_reducer, data->jsgraph(), |
| 500 data->info()->num_parameters_including_this(), data->info()->context()); |
499 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() | 501 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() |
500 ? JSInliner::kGeneralInlining | 502 ? JSInliner::kGeneralInlining |
501 : JSInliner::kRestrictedInlining, | 503 : JSInliner::kRestrictedInlining, |
502 temp_zone, data->info(), data->jsgraph()); | 504 temp_zone, data->info(), data->jsgraph()); |
503 AddReducer(data, &graph_reducer, &dead_code_elimination); | 505 AddReducer(data, &graph_reducer, &dead_code_elimination); |
504 AddReducer(data, &graph_reducer, &common_reducer); | 506 AddReducer(data, &graph_reducer, &common_reducer); |
505 if (data->info()->is_context_specializing()) { | 507 if (data->info()->is_context_specializing()) { |
506 AddReducer(data, &graph_reducer, &context_specializer); | 508 AddReducer(data, &graph_reducer, &context_specializer); |
507 } | 509 } |
508 AddReducer(data, &graph_reducer, &inliner); | 510 AddReducer(data, &graph_reducer, &inliner); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 TurboCfgFile tcf(isolate()); | 1027 TurboCfgFile tcf(isolate()); |
1026 tcf << AsC1VCompilation(info()); | 1028 tcf << AsC1VCompilation(info()); |
1027 } | 1029 } |
1028 | 1030 |
1029 data.source_positions()->AddDecorator(); | 1031 data.source_positions()->AddDecorator(); |
1030 | 1032 |
1031 if (FLAG_loop_assignment_analysis) { | 1033 if (FLAG_loop_assignment_analysis) { |
1032 Run<LoopAssignmentAnalysisPhase>(); | 1034 Run<LoopAssignmentAnalysisPhase>(); |
1033 } | 1035 } |
1034 | 1036 |
1035 Run<GraphBuilderPhase>(info()->is_context_specializing()); | 1037 Run<GraphBuilderPhase>(); |
1036 if (data.compilation_failed()) return Handle<Code>::null(); | 1038 if (data.compilation_failed()) return Handle<Code>::null(); |
1037 RunPrintAndVerify("Initial untyped", true); | 1039 RunPrintAndVerify("Initial untyped", true); |
1038 | 1040 |
1039 // Perform context specialization and inlining (if enabled). | 1041 // Perform context specialization and inlining (if enabled). |
1040 Run<InliningPhase>(); | 1042 Run<InliningPhase>(); |
1041 RunPrintAndVerify("Inlined", true); | 1043 RunPrintAndVerify("Inlined", true); |
1042 | 1044 |
1043 // Remove dead->live edges from the graph. | 1045 // Remove dead->live edges from the graph. |
1044 Run<EarlyGraphTrimmingPhase>(); | 1046 Run<EarlyGraphTrimmingPhase>(); |
1045 RunPrintAndVerify("Early trimmed", true); | 1047 RunPrintAndVerify("Early trimmed", true); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 tcf << AsC1VRegisterAllocationData("CodeGen", | 1358 tcf << AsC1VRegisterAllocationData("CodeGen", |
1357 data->register_allocation_data()); | 1359 data->register_allocation_data()); |
1358 } | 1360 } |
1359 | 1361 |
1360 data->DeleteRegisterAllocationZone(); | 1362 data->DeleteRegisterAllocationZone(); |
1361 } | 1363 } |
1362 | 1364 |
1363 } // namespace compiler | 1365 } // namespace compiler |
1364 } // namespace internal | 1366 } // namespace internal |
1365 } // namespace v8 | 1367 } // namespace v8 |
OLD | NEW |