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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 420 } |
421 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { | 421 if (FLAG_trace_turbo_graph || FLAG_trace_turbo_scheduler) { |
422 AllowHandleDereference allow_deref; | 422 AllowHandleDereference allow_deref; |
423 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); | 423 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
424 OFStream os(tracing_scope.file()); | 424 OFStream os(tracing_scope.file()); |
425 os << "-- Schedule --------------------------------------\n" << *schedule; | 425 os << "-- Schedule --------------------------------------\n" << *schedule; |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 | 429 |
430 class AstGraphBuilderWithPositions final : public AstGraphBuilder { | |
431 public: | |
432 AstGraphBuilderWithPositions(Zone* local_zone, CompilationInfo* info, | |
433 JSGraph* jsgraph, | |
434 LoopAssignmentAnalysis* loop_assignment, | |
435 TypeHintAnalysis* type_hint_analysis, | |
436 SourcePositionTable* source_positions) | |
437 : AstGraphBuilder(local_zone, info, jsgraph, 1.0f, loop_assignment, | |
438 type_hint_analysis), | |
439 source_positions_(source_positions), | |
440 start_position_(info->shared_info()->start_position()) {} | |
441 | |
442 bool CreateGraph() { | |
443 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); | |
444 return AstGraphBuilder::CreateGraph(); | |
445 } | |
446 | |
447 #define DEF_VISIT(type) \ | |
448 void Visit##type(type* node) override { \ | |
449 SourcePositionTable::Scope pos(source_positions_, \ | |
450 SourcePosition(node->position())); \ | |
451 AstGraphBuilder::Visit##type(node); \ | |
452 } | |
453 AST_NODE_LIST(DEF_VISIT) | |
454 #undef DEF_VISIT | |
455 | |
456 private: | |
457 SourcePositionTable* const source_positions_; | |
458 SourcePosition const start_position_; | |
459 }; | |
460 | |
461 | |
462 class SourcePositionWrapper final : public Reducer { | 430 class SourcePositionWrapper final : public Reducer { |
463 public: | 431 public: |
464 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) | 432 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) |
465 : reducer_(reducer), table_(table) {} | 433 : reducer_(reducer), table_(table) {} |
466 ~SourcePositionWrapper() final {} | 434 ~SourcePositionWrapper() final {} |
467 | 435 |
468 Reduction Reduce(Node* node) final { | 436 Reduction Reduce(Node* node) final { |
469 SourcePosition const pos = table_->GetSourcePosition(node); | 437 SourcePosition const pos = table_->GetSourcePosition(node); |
470 SourcePositionTable::Scope position(table_, pos); | 438 SourcePositionTable::Scope position(table_, pos); |
471 return reducer_->Reduce(node); | 439 return reducer_->Reduce(node); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 void Run(PipelineData* data, Zone* temp_zone) { | 714 void Run(PipelineData* data, Zone* temp_zone) { |
747 bool succeeded = false; | 715 bool succeeded = false; |
748 | 716 |
749 if (data->info()->is_optimizing_from_bytecode()) { | 717 if (data->info()->is_optimizing_from_bytecode()) { |
750 BytecodeGraphBuilder graph_builder(temp_zone, data->info(), | 718 BytecodeGraphBuilder graph_builder(temp_zone, data->info(), |
751 data->jsgraph(), 1.0f, | 719 data->jsgraph(), 1.0f, |
752 data->source_positions()); | 720 data->source_positions()); |
753 succeeded = graph_builder.CreateGraph(); | 721 succeeded = graph_builder.CreateGraph(); |
754 } else { | 722 } else { |
755 AstGraphBuilderWithPositions graph_builder( | 723 AstGraphBuilderWithPositions graph_builder( |
756 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), | 724 temp_zone, data->info(), data->jsgraph(), 1.0f, |
757 data->type_hint_analysis(), data->source_positions()); | 725 data->loop_assignment(), data->type_hint_analysis(), |
| 726 data->source_positions()); |
758 succeeded = graph_builder.CreateGraph(); | 727 succeeded = graph_builder.CreateGraph(); |
759 } | 728 } |
760 | 729 |
761 if (!succeeded) { | 730 if (!succeeded) { |
762 data->set_compilation_failed(); | 731 data->set_compilation_failed(); |
763 } | 732 } |
764 } | 733 } |
765 }; | 734 }; |
766 | 735 |
767 | 736 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 } | 769 } |
801 if (data->info()->is_bailout_on_uninitialized()) { | 770 if (data->info()->is_bailout_on_uninitialized()) { |
802 flags |= JSNativeContextSpecialization::kBailoutOnUninitialized; | 771 flags |= JSNativeContextSpecialization::kBailoutOnUninitialized; |
803 } | 772 } |
804 if (data->info()->is_deoptimization_enabled()) { | 773 if (data->info()->is_deoptimization_enabled()) { |
805 flags |= JSNativeContextSpecialization::kDeoptimizationEnabled; | 774 flags |= JSNativeContextSpecialization::kDeoptimizationEnabled; |
806 } | 775 } |
807 JSNativeContextSpecialization native_context_specialization( | 776 JSNativeContextSpecialization native_context_specialization( |
808 &graph_reducer, data->jsgraph(), flags, data->native_context(), | 777 &graph_reducer, data->jsgraph(), flags, data->native_context(), |
809 data->info()->dependencies(), temp_zone); | 778 data->info()->dependencies(), temp_zone); |
810 JSInliningHeuristic inlining(&graph_reducer, | 779 JSInliningHeuristic inlining( |
811 data->info()->is_inlining_enabled() | 780 &graph_reducer, data->info()->is_inlining_enabled() |
812 ? JSInliningHeuristic::kGeneralInlining | 781 ? JSInliningHeuristic::kGeneralInlining |
813 : JSInliningHeuristic::kRestrictedInlining, | 782 : JSInliningHeuristic::kRestrictedInlining, |
814 temp_zone, data->info(), data->jsgraph()); | 783 temp_zone, data->info(), data->jsgraph(), data->source_positions()); |
815 JSIntrinsicLowering intrinsic_lowering( | 784 JSIntrinsicLowering intrinsic_lowering( |
816 &graph_reducer, data->jsgraph(), | 785 &graph_reducer, data->jsgraph(), |
817 data->info()->is_deoptimization_enabled() | 786 data->info()->is_deoptimization_enabled() |
818 ? JSIntrinsicLowering::kDeoptimizationEnabled | 787 ? JSIntrinsicLowering::kDeoptimizationEnabled |
819 : JSIntrinsicLowering::kDeoptimizationDisabled); | 788 : JSIntrinsicLowering::kDeoptimizationDisabled); |
820 AddReducer(data, &graph_reducer, &dead_code_elimination); | 789 AddReducer(data, &graph_reducer, &dead_code_elimination); |
821 AddReducer(data, &graph_reducer, &common_reducer); | 790 AddReducer(data, &graph_reducer, &common_reducer); |
822 if (data->info()->is_frame_specializing()) { | 791 if (data->info()->is_frame_specializing()) { |
823 AddReducer(data, &graph_reducer, &frame_specialization); | 792 AddReducer(data, &graph_reducer, &frame_specialization); |
824 } | 793 } |
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1995 data->DeleteRegisterAllocationZone(); | 1964 data->DeleteRegisterAllocationZone(); |
1996 } | 1965 } |
1997 | 1966 |
1998 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1967 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1999 | 1968 |
2000 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1969 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
2001 | 1970 |
2002 } // namespace compiler | 1971 } // namespace compiler |
2003 } // namespace internal | 1972 } // namespace internal |
2004 } // namespace v8 | 1973 } // namespace v8 |
OLD | NEW |