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 JSGlobalObjectSpecialization global_object_specialization( | |
509 &graph_reducer, data->jsgraph(), | |
510 data->info()->is_deoptimization_enabled() | |
511 ? JSGlobalObjectSpecialization::kDeoptimizationEnabled | |
512 : JSGlobalObjectSpecialization::kNoFlags, | |
513 handle(data->info()->global_object(), data->isolate()), | |
514 data->info()->dependencies()); | |
515 JSNativeContextSpecialization native_context_specialization( | |
516 &graph_reducer, data->jsgraph(), | |
517 data->info()->is_deoptimization_enabled() | |
518 ? JSNativeContextSpecialization::kDeoptimizationEnabled | |
519 : JSNativeContextSpecialization::kNoFlags, | |
520 handle(data->info()->global_object()->native_context(), | |
521 data->isolate()), | |
522 data->info()->dependencies(), temp_zone); | |
523 AddReducer(data, &graph_reducer, &dead_code_elimination); | |
524 AddReducer(data, &graph_reducer, &common_reducer); | |
525 AddReducer(data, &graph_reducer, &global_object_specialization); | |
526 AddReducer(data, &graph_reducer, &native_context_specialization); | |
527 graph_reducer.ReduceGraph(); | |
528 } | |
529 }; | |
530 | |
531 | |
532 struct InliningPhase { | 499 struct InliningPhase { |
533 static const char* phase_name() { return "inlining"; } | 500 static const char* phase_name() { return "inlining"; } |
534 | 501 |
535 void Run(PipelineData* data, Zone* temp_zone) { | 502 void Run(PipelineData* data, Zone* temp_zone) { |
536 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 503 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
537 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 504 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
538 data->common()); | 505 data->common()); |
539 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 506 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
540 data->common(), data->machine()); | 507 data->common(), data->machine()); |
541 JSCallReducer call_reducer(data->jsgraph(), | 508 JSCallReducer call_reducer(data->jsgraph(), |
542 data->info()->is_deoptimization_enabled() | 509 data->info()->is_deoptimization_enabled() |
543 ? JSCallReducer::kDeoptimizationEnabled | 510 ? JSCallReducer::kDeoptimizationEnabled |
544 : JSCallReducer::kNoFlags); | 511 : JSCallReducer::kNoFlags); |
545 JSContextSpecialization context_specialization( | 512 JSContextSpecialization context_specialization( |
546 &graph_reducer, data->jsgraph(), | 513 &graph_reducer, data->jsgraph(), |
547 data->info()->is_function_context_specializing() | 514 data->info()->is_function_context_specializing() |
548 ? data->info()->context() | 515 ? data->info()->context() |
549 : MaybeHandle<Context>()); | 516 : MaybeHandle<Context>()); |
550 JSFrameSpecialization frame_specialization(data->info()->osr_frame(), | 517 JSFrameSpecialization frame_specialization(data->info()->osr_frame(), |
551 data->jsgraph()); | 518 data->jsgraph()); |
| 519 JSGlobalObjectSpecialization global_object_specialization( |
| 520 &graph_reducer, data->jsgraph(), |
| 521 data->info()->is_deoptimization_enabled() |
| 522 ? JSGlobalObjectSpecialization::kDeoptimizationEnabled |
| 523 : JSGlobalObjectSpecialization::kNoFlags, |
| 524 data->info()->is_native_context_specializing() |
| 525 ? handle(data->info()->native_context(), data->isolate()) |
| 526 : MaybeHandle<Context>(), |
| 527 data->info()->dependencies()); |
| 528 JSNativeContextSpecialization native_context_specialization( |
| 529 &graph_reducer, data->jsgraph(), |
| 530 data->info()->is_deoptimization_enabled() |
| 531 ? JSNativeContextSpecialization::kDeoptimizationEnabled |
| 532 : JSNativeContextSpecialization::kNoFlags, |
| 533 data->info()->is_native_context_specializing() |
| 534 ? handle(data->info()->native_context(), data->isolate()) |
| 535 : MaybeHandle<Context>(), |
| 536 data->info()->dependencies(), temp_zone); |
552 JSInliningHeuristic inlining(&graph_reducer, | 537 JSInliningHeuristic inlining(&graph_reducer, |
553 data->info()->is_inlining_enabled() | 538 data->info()->is_inlining_enabled() |
554 ? JSInliningHeuristic::kGeneralInlining | 539 ? JSInliningHeuristic::kGeneralInlining |
555 : JSInliningHeuristic::kRestrictedInlining, | 540 : JSInliningHeuristic::kRestrictedInlining, |
556 temp_zone, data->info(), data->jsgraph()); | 541 temp_zone, data->info(), data->jsgraph()); |
557 AddReducer(data, &graph_reducer, &dead_code_elimination); | 542 AddReducer(data, &graph_reducer, &dead_code_elimination); |
558 AddReducer(data, &graph_reducer, &common_reducer); | 543 AddReducer(data, &graph_reducer, &common_reducer); |
559 if (data->info()->is_frame_specializing()) { | 544 if (data->info()->is_frame_specializing()) { |
560 AddReducer(data, &graph_reducer, &frame_specialization); | 545 AddReducer(data, &graph_reducer, &frame_specialization); |
561 } | 546 } |
| 547 AddReducer(data, &graph_reducer, &global_object_specialization); |
| 548 AddReducer(data, &graph_reducer, &native_context_specialization); |
562 AddReducer(data, &graph_reducer, &context_specialization); | 549 AddReducer(data, &graph_reducer, &context_specialization); |
563 AddReducer(data, &graph_reducer, &call_reducer); | 550 AddReducer(data, &graph_reducer, &call_reducer); |
564 AddReducer(data, &graph_reducer, &inlining); | 551 AddReducer(data, &graph_reducer, &inlining); |
565 graph_reducer.ReduceGraph(); | 552 graph_reducer.ReduceGraph(); |
566 } | 553 } |
567 }; | 554 }; |
568 | 555 |
569 | 556 |
570 struct TyperPhase { | 557 struct TyperPhase { |
571 static const char* phase_name() { return "typer"; } | 558 static const char* phase_name() { return "typer"; } |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 Run<GraphBuilderPhase>(); | 1080 Run<GraphBuilderPhase>(); |
1094 if (data.compilation_failed()) return Handle<Code>::null(); | 1081 if (data.compilation_failed()) return Handle<Code>::null(); |
1095 RunPrintAndVerify("Initial untyped", true); | 1082 RunPrintAndVerify("Initial untyped", true); |
1096 | 1083 |
1097 // Perform OSR deconstruction. | 1084 // Perform OSR deconstruction. |
1098 if (info()->is_osr()) { | 1085 if (info()->is_osr()) { |
1099 Run<OsrDeconstructionPhase>(); | 1086 Run<OsrDeconstructionPhase>(); |
1100 RunPrintAndVerify("OSR deconstruction", true); | 1087 RunPrintAndVerify("OSR deconstruction", true); |
1101 } | 1088 } |
1102 | 1089 |
1103 // Perform native context specialization (if enabled). | |
1104 if (info()->is_native_context_specializing()) { | |
1105 Run<NativeContextSpecializationPhase>(); | |
1106 RunPrintAndVerify("Native context specialized", true); | |
1107 } | |
1108 | |
1109 // Perform function context specialization and inlining (if enabled). | 1090 // Perform function context specialization and inlining (if enabled). |
1110 Run<InliningPhase>(); | 1091 Run<InliningPhase>(); |
1111 RunPrintAndVerify("Inlined", true); | 1092 RunPrintAndVerify("Inlined", true); |
1112 | 1093 |
1113 // Remove dead->live edges from the graph. | 1094 // Remove dead->live edges from the graph. |
1114 Run<EarlyGraphTrimmingPhase>(); | 1095 Run<EarlyGraphTrimmingPhase>(); |
1115 RunPrintAndVerify("Early trimmed", true); | 1096 RunPrintAndVerify("Early trimmed", true); |
1116 | 1097 |
1117 if (FLAG_print_turbo_replay) { | 1098 if (FLAG_print_turbo_replay) { |
1118 // Print a replay of the initial graph. | 1099 // Print a replay of the initial graph. |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 tcf << AsC1VRegisterAllocationData("CodeGen", | 1425 tcf << AsC1VRegisterAllocationData("CodeGen", |
1445 data->register_allocation_data()); | 1426 data->register_allocation_data()); |
1446 } | 1427 } |
1447 | 1428 |
1448 data->DeleteRegisterAllocationZone(); | 1429 data->DeleteRegisterAllocationZone(); |
1449 } | 1430 } |
1450 | 1431 |
1451 } // namespace compiler | 1432 } // namespace compiler |
1452 } // namespace internal | 1433 } // namespace internal |
1453 } // namespace v8 | 1434 } // namespace v8 |
OLD | NEW |