Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: src/compiler/pipeline.cc

Issue 2841613002: [compiler][modules] Constant-fold the loads of module cells. (Closed)
Patch Set: Rebase. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 data->loop_assignment(), data->source_positions()); 774 data->loop_assignment(), data->source_positions());
775 succeeded = graph_builder.CreateGraph(); 775 succeeded = graph_builder.CreateGraph();
776 } 776 }
777 777
778 if (!succeeded) { 778 if (!succeeded) {
779 data->set_compilation_failed(); 779 data->set_compilation_failed();
780 } 780 }
781 } 781 }
782 }; 782 };
783 783
784 namespace {
785
786 Maybe<OuterContext> GetModuleContext(Handle<JSFunction> closure) {
787 Context* current = closure->context();
788 size_t distance = 0;
789 while (current != nullptr && !current->IsNativeContext() &&
790 !current->IsModuleContext()) {
791 current = current->previous();
792 distance++;
793 }
794 if (current != nullptr && current->IsModuleContext()) {
Michael Starzinger 2017/05/03 17:28:16 question: Can we ever hit the {nullptr} case here?
neis 2017/05/04 10:36:21 As discussed, I removed this condition.
795 return Just(OuterContext(handle(current), distance));
796 }
797 return Nothing<OuterContext>();
798 }
799
800 Maybe<OuterContext> ChooseSpecializationContext(CompilationInfo* info) {
801 if (info->is_function_context_specializing()) {
802 DCHECK(info->has_context());
803 return Just(OuterContext(handle(info->context()), 0));
804 }
805 return GetModuleContext(info->closure());
806 }
807
808 } // anonymous namespace
784 809
785 struct InliningPhase { 810 struct InliningPhase {
786 static const char* phase_name() { return "inlining"; } 811 static const char* phase_name() { return "inlining"; }
787 812
788 void Run(PipelineData* data, Zone* temp_zone) { 813 void Run(PipelineData* data, Zone* temp_zone) {
789 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); 814 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
790 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), 815 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
791 data->common()); 816 data->common());
792 CheckpointElimination checkpoint_elimination(&graph_reducer); 817 CheckpointElimination checkpoint_elimination(&graph_reducer);
793 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), 818 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
794 data->common(), data->machine()); 819 data->common(), data->machine());
795 JSCallReducer call_reducer(&graph_reducer, data->jsgraph(), 820 JSCallReducer call_reducer(&graph_reducer, data->jsgraph(),
796 data->native_context(), 821 data->native_context(),
797 data->info()->dependencies()); 822 data->info()->dependencies());
798 JSContextSpecialization context_specialization( 823 JSContextSpecialization context_specialization(
799 &graph_reducer, data->jsgraph(), 824 &graph_reducer, data->jsgraph(),
800 data->info()->is_function_context_specializing() 825 ChooseSpecializationContext(data->info()),
801 ? handle(data->info()->context())
802 : MaybeHandle<Context>(),
803 data->info()->is_function_context_specializing() 826 data->info()->is_function_context_specializing()
804 ? data->info()->closure() 827 ? data->info()->closure()
805 : MaybeHandle<JSFunction>()); 828 : MaybeHandle<JSFunction>());
806 JSFrameSpecialization frame_specialization( 829 JSFrameSpecialization frame_specialization(
807 &graph_reducer, data->info()->osr_frame(), data->jsgraph()); 830 &graph_reducer, data->info()->osr_frame(), data->jsgraph());
808 JSNativeContextSpecialization::Flags flags = 831 JSNativeContextSpecialization::Flags flags =
809 JSNativeContextSpecialization::kNoFlags; 832 JSNativeContextSpecialization::kNoFlags;
810 if (data->info()->is_accessor_inlining_enabled()) { 833 if (data->info()->is_accessor_inlining_enabled()) {
811 flags |= JSNativeContextSpecialization::kAccessorInliningEnabled; 834 flags |= JSNativeContextSpecialization::kAccessorInliningEnabled;
812 } 835 }
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 data->DeleteRegisterAllocationZone(); 2050 data->DeleteRegisterAllocationZone();
2028 } 2051 }
2029 2052
2030 CompilationInfo* PipelineImpl::info() const { return data_->info(); } 2053 CompilationInfo* PipelineImpl::info() const { return data_->info(); }
2031 2054
2032 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } 2055 Isolate* PipelineImpl::isolate() const { return info()->isolate(); }
2033 2056
2034 } // namespace compiler 2057 } // namespace compiler
2035 } // namespace internal 2058 } // namespace internal
2036 } // namespace v8 2059 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698