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 <memory> | 8 #include <memory> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 430 } |
431 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { | 431 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { |
432 AllowHandleDereference allow_deref; | 432 AllowHandleDereference allow_deref; |
433 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); | 433 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
434 OFStream os(tracing_scope.file()); | 434 OFStream os(tracing_scope.file()); |
435 os << "-- Schedule --------------------------------------\n" << *schedule; | 435 os << "-- Schedule --------------------------------------\n" << *schedule; |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 | 439 |
440 class AstGraphBuilderWithPositions final : public AstGraphBuilder { | |
441 public: | |
442 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, | |
443 JSGraph* jsgraph, | |
444 LoopAssignmentAnalysis* loop_assignment, | |
445 TypeHintAnalysis* type_hint_analysis, | |
446 SourcePositionTable* source_positions) | |
447 : AstGraphBuilder(local_zone, info, jsgraph, 1.0f, loop_assignment, | |
448 type_hint_analysis), | |
449 source_positions_(source_positions), | |
450 start_position_(info->shared_info()->start_position()) {} | |
451 | |
452 bool CreateGraph() { | |
453 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); | |
454 return AstGraphBuilder::CreateGraph(); | |
455 } | |
456 | |
457 #define DEF_VISIT(type) \ | |
458 void Visit##type(type* node) override { \ | |
459 SourcePositionTable::Scope pos(source_positions_, \ | |
460 SourcePosition(node->position())); \ | |
461 AstGraphBuilder::Visit##type(node); \ | |
462 } | |
463 AST_NODE_LIST(DEF_VISIT) | |
464 #undef DEF_VISIT | |
465 | |
466 private: | |
467 SourcePositionTable* const source_positions_; | |
468 SourcePosition const start_position_; | |
469 }; | |
470 | |
471 | |
472 class SourcePositionWrapper final : public Reducer { | 440 class SourcePositionWrapper final : public Reducer { |
473 public: | 441 public: |
474 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) | 442 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) |
475 : reducer_(reducer), table_(table) {} | 443 : reducer_(reducer), table_(table) {} |
476 ~SourcePositionWrapper() final {} | 444 ~SourcePositionWrapper() final {} |
477 | 445 |
478 Reduction Reduce(Node* node) final { | 446 Reduction Reduce(Node* node) final { |
479 SourcePosition const pos = table_->GetSourcePosition(node); | 447 SourcePosition const pos = table_->GetSourcePosition(node); |
480 SourcePositionTable::Scope position(table_, pos); | 448 SourcePositionTable::Scope position(table_, pos); |
481 return reducer_->Reduce(node); | 449 return reducer_->Reduce(node); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 void Run(PipelineData* data, Zone* temp_zone) { | 724 void Run(PipelineData* data, Zone* temp_zone) { |
757 bool succeeded = false; | 725 bool succeeded = false; |
758 | 726 |
759 if (data->info()->is_optimizing_from_bytecode()) { | 727 if (data->info()->is_optimizing_from_bytecode()) { |
760 BytecodeGraphBuilder graph_builder(temp_zone, data->info(), | 728 BytecodeGraphBuilder graph_builder(temp_zone, data->info(), |
761 data->jsgraph(), 1.0f, | 729 data->jsgraph(), 1.0f, |
762 data->source_positions()); | 730 data->source_positions()); |
763 succeeded = graph_builder.CreateGraph(); | 731 succeeded = graph_builder.CreateGraph(); |
764 } else { | 732 } else { |
765 AstGraphBuilderWithPositions graph_builder( | 733 AstGraphBuilderWithPositions graph_builder( |
766 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), | 734 temp_zone, data->info(), data->jsgraph(), 1.0f, |
767 data->type_hint_analysis(), data->source_positions()); | 735 data->loop_assignment(), data->type_hint_analysis(), |
| 736 data->source_positions()); |
768 succeeded = graph_builder.CreateGraph(); | 737 succeeded = graph_builder.CreateGraph(); |
769 } | 738 } |
770 | 739 |
771 if (!succeeded) { | 740 if (!succeeded) { |
772 data->set_compilation_failed(); | 741 data->set_compilation_failed(); |
773 } | 742 } |
774 } | 743 } |
775 }; | 744 }; |
776 | 745 |
777 | 746 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 } | 779 } |
811 if (data->info()->is_bailout_on_uninitialized()) { | 780 if (data->info()->is_bailout_on_uninitialized()) { |
812 flags |= JSNativeContextSpecialization::kBailoutOnUninitialized; | 781 flags |= JSNativeContextSpecialization::kBailoutOnUninitialized; |
813 } | 782 } |
814 if (data->info()->is_deoptimization_enabled()) { | 783 if (data->info()->is_deoptimization_enabled()) { |
815 flags |= JSNativeContextSpecialization::kDeoptimizationEnabled; | 784 flags |= JSNativeContextSpecialization::kDeoptimizationEnabled; |
816 } | 785 } |
817 JSNativeContextSpecialization native_context_specialization( | 786 JSNativeContextSpecialization native_context_specialization( |
818 &graph_reducer, data->jsgraph(), flags, data->native_context(), | 787 &graph_reducer, data->jsgraph(), flags, data->native_context(), |
819 data->info()->dependencies(), temp_zone); | 788 data->info()->dependencies(), temp_zone); |
820 JSInliningHeuristic inlining(&graph_reducer, | 789 JSInliningHeuristic inlining( |
821 data->info()->is_inlining_enabled() | 790 &graph_reducer, data->info()->is_inlining_enabled() |
822 ? JSInliningHeuristic::kGeneralInlining | 791 ? JSInliningHeuristic::kGeneralInlining |
823 : JSInliningHeuristic::kRestrictedInlining, | 792 : JSInliningHeuristic::kRestrictedInlining, |
824 temp_zone, data->info(), data->jsgraph()); | 793 temp_zone, data->info(), data->jsgraph(), data->source_positions()); |
825 JSIntrinsicLowering intrinsic_lowering( | 794 JSIntrinsicLowering intrinsic_lowering( |
826 &graph_reducer, data->jsgraph(), | 795 &graph_reducer, data->jsgraph(), |
827 data->info()->is_deoptimization_enabled() | 796 data->info()->is_deoptimization_enabled() |
828 ? JSIntrinsicLowering::kDeoptimizationEnabled | 797 ? JSIntrinsicLowering::kDeoptimizationEnabled |
829 : JSIntrinsicLowering::kDeoptimizationDisabled); | 798 : JSIntrinsicLowering::kDeoptimizationDisabled); |
830 AddReducer(data, &graph_reducer, &dead_code_elimination); | 799 AddReducer(data, &graph_reducer, &dead_code_elimination); |
831 AddReducer(data, &graph_reducer, &common_reducer); | 800 AddReducer(data, &graph_reducer, &common_reducer); |
832 if (data->info()->is_frame_specializing()) { | 801 if (data->info()->is_frame_specializing()) { |
833 AddReducer(data, &graph_reducer, &frame_specialization); | 802 AddReducer(data, &graph_reducer, &frame_specialization); |
834 } | 803 } |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 data->DeleteRegisterAllocationZone(); | 1962 data->DeleteRegisterAllocationZone(); |
1994 } | 1963 } |
1995 | 1964 |
1996 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1965 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1997 | 1966 |
1998 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1967 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1999 | 1968 |
2000 } // namespace compiler | 1969 } // namespace compiler |
2001 } // namespace internal | 1970 } // namespace internal |
2002 } // namespace v8 | 1971 } // namespace v8 |
OLD | NEW |