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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 succeeded = graph_builder.CreateGraph(stack_check); | 489 succeeded = graph_builder.CreateGraph(stack_check); |
490 } | 490 } |
491 | 491 |
492 if (!succeeded) { | 492 if (!succeeded) { |
493 data->set_compilation_failed(); | 493 data->set_compilation_failed(); |
494 } | 494 } |
495 } | 495 } |
496 }; | 496 }; |
497 | 497 |
498 | 498 |
| 499 struct NativeContextSpecializationPhase { |
| 500 static const char* phase_name() { return "native context specialization"; } |
| 501 |
| 502 void Run(PipelineData* data, Zone* temp_zone) { |
| 503 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 504 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 505 data->common()); |
| 506 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
| 507 data->common(), data->machine()); |
| 508 JSGlobalSpecialization::Flags flags = JSGlobalSpecialization::kNoFlags; |
| 509 if (data->info()->is_deoptimization_enabled()) { |
| 510 flags |= JSGlobalSpecialization::kDeoptimizationEnabled; |
| 511 } |
| 512 if (data->info()->is_typing_enabled()) { |
| 513 flags |= JSGlobalSpecialization::kTypingEnabled; |
| 514 } |
| 515 JSGlobalSpecialization global_specialization( |
| 516 &graph_reducer, data->jsgraph(), flags, |
| 517 handle(data->info()->global_object(), data->isolate()), |
| 518 data->info()->dependencies()); |
| 519 AddReducer(data, &graph_reducer, &dead_code_elimination); |
| 520 AddReducer(data, &graph_reducer, &common_reducer); |
| 521 AddReducer(data, &graph_reducer, &global_specialization); |
| 522 graph_reducer.ReduceGraph(); |
| 523 } |
| 524 }; |
| 525 |
| 526 |
499 struct InliningPhase { | 527 struct InliningPhase { |
500 static const char* phase_name() { return "inlining"; } | 528 static const char* phase_name() { return "inlining"; } |
501 | 529 |
502 void Run(PipelineData* data, Zone* temp_zone) { | 530 void Run(PipelineData* data, Zone* temp_zone) { |
503 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 531 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
504 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 532 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
505 data->common()); | 533 data->common()); |
506 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 534 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
507 data->common(), data->machine()); | 535 data->common(), data->machine()); |
508 JSContextSpecialization context_specialization( | 536 JSContextSpecialization context_specialization( |
509 &graph_reducer, data->jsgraph(), | 537 &graph_reducer, data->jsgraph(), |
510 data->info()->is_function_context_specializing() | 538 data->info()->is_function_context_specializing() |
511 ? data->info()->context() | 539 ? data->info()->context() |
512 : MaybeHandle<Context>()); | 540 : MaybeHandle<Context>()); |
513 JSFrameSpecialization frame_specialization(data->info()->osr_frame(), | 541 JSFrameSpecialization frame_specialization(data->info()->osr_frame(), |
514 data->jsgraph()); | 542 data->jsgraph()); |
515 JSGlobalSpecialization::Flags global_flags = | |
516 JSGlobalSpecialization::kNoFlags; | |
517 if (data->info()->is_deoptimization_enabled()) { | |
518 global_flags |= JSGlobalSpecialization::kDeoptimizationEnabled; | |
519 } | |
520 if (data->info()->is_typing_enabled()) { | |
521 global_flags |= JSGlobalSpecialization::kTypingEnabled; | |
522 } | |
523 JSGlobalSpecialization global_specialization( | |
524 &graph_reducer, data->jsgraph(), global_flags, | |
525 data->info()->has_global_object() | |
526 ? handle(data->info()->global_object()) | |
527 : Handle<GlobalObject>(), | |
528 data->info()->dependencies()); | |
529 JSInliningHeuristic inlining(&graph_reducer, | 543 JSInliningHeuristic inlining(&graph_reducer, |
530 data->info()->is_inlining_enabled() | 544 data->info()->is_inlining_enabled() |
531 ? JSInliningHeuristic::kGeneralInlining | 545 ? JSInliningHeuristic::kGeneralInlining |
532 : JSInliningHeuristic::kRestrictedInlining, | 546 : JSInliningHeuristic::kRestrictedInlining, |
533 temp_zone, data->info(), data->jsgraph()); | 547 temp_zone, data->info(), data->jsgraph()); |
534 AddReducer(data, &graph_reducer, &dead_code_elimination); | 548 AddReducer(data, &graph_reducer, &dead_code_elimination); |
535 AddReducer(data, &graph_reducer, &common_reducer); | 549 AddReducer(data, &graph_reducer, &common_reducer); |
536 if (data->info()->is_frame_specializing()) { | 550 if (data->info()->is_frame_specializing()) { |
537 AddReducer(data, &graph_reducer, &frame_specialization); | 551 AddReducer(data, &graph_reducer, &frame_specialization); |
538 } | 552 } |
539 if (data->info()->is_native_context_specializing()) { | |
540 AddReducer(data, &graph_reducer, &global_specialization); | |
541 } | |
542 AddReducer(data, &graph_reducer, &context_specialization); | 553 AddReducer(data, &graph_reducer, &context_specialization); |
543 AddReducer(data, &graph_reducer, &inlining); | 554 AddReducer(data, &graph_reducer, &inlining); |
544 graph_reducer.ReduceGraph(); | 555 graph_reducer.ReduceGraph(); |
545 } | 556 } |
546 }; | 557 }; |
547 | 558 |
548 | 559 |
549 struct TyperPhase { | 560 struct TyperPhase { |
550 static const char* phase_name() { return "typer"; } | 561 static const char* phase_name() { return "typer"; } |
551 | 562 |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 Run<GraphBuilderPhase>(); | 1099 Run<GraphBuilderPhase>(); |
1089 if (data.compilation_failed()) return Handle<Code>::null(); | 1100 if (data.compilation_failed()) return Handle<Code>::null(); |
1090 RunPrintAndVerify("Initial untyped", true); | 1101 RunPrintAndVerify("Initial untyped", true); |
1091 | 1102 |
1092 // Perform OSR deconstruction. | 1103 // Perform OSR deconstruction. |
1093 if (info()->is_osr()) { | 1104 if (info()->is_osr()) { |
1094 Run<OsrDeconstructionPhase>(); | 1105 Run<OsrDeconstructionPhase>(); |
1095 RunPrintAndVerify("OSR deconstruction", true); | 1106 RunPrintAndVerify("OSR deconstruction", true); |
1096 } | 1107 } |
1097 | 1108 |
1098 // Perform context specialization and inlining (if enabled). | 1109 // Perform native context specialization (if enabled). |
| 1110 if (info()->is_native_context_specializing()) { |
| 1111 Run<NativeContextSpecializationPhase>(); |
| 1112 RunPrintAndVerify("Native context specialized", true); |
| 1113 } |
| 1114 |
| 1115 // Perform function context specialization and inlining (if enabled). |
1099 Run<InliningPhase>(); | 1116 Run<InliningPhase>(); |
1100 RunPrintAndVerify("Inlined", true); | 1117 RunPrintAndVerify("Inlined", true); |
1101 | 1118 |
1102 // Remove dead->live edges from the graph. | 1119 // Remove dead->live edges from the graph. |
1103 Run<EarlyGraphTrimmingPhase>(); | 1120 Run<EarlyGraphTrimmingPhase>(); |
1104 RunPrintAndVerify("Early trimmed", true); | 1121 RunPrintAndVerify("Early trimmed", true); |
1105 | 1122 |
1106 if (FLAG_print_turbo_replay) { | 1123 if (FLAG_print_turbo_replay) { |
1107 // Print a replay of the initial graph. | 1124 // Print a replay of the initial graph. |
1108 GraphReplayPrinter::PrintReplay(data.graph()); | 1125 GraphReplayPrinter::PrintReplay(data.graph()); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 tcf << AsC1VRegisterAllocationData("CodeGen", | 1447 tcf << AsC1VRegisterAllocationData("CodeGen", |
1431 data->register_allocation_data()); | 1448 data->register_allocation_data()); |
1432 } | 1449 } |
1433 | 1450 |
1434 data->DeleteRegisterAllocationZone(); | 1451 data->DeleteRegisterAllocationZone(); |
1435 } | 1452 } |
1436 | 1453 |
1437 } // namespace compiler | 1454 } // namespace compiler |
1438 } // namespace internal | 1455 } // namespace internal |
1439 } // namespace v8 | 1456 } // namespace v8 |
OLD | NEW |