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

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

Issue 2841613002: [compiler][modules] Constant-fold the loads of module cells. (Closed)
Patch Set: Address feedback. 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
« no previous file with comments | « src/compiler/node-properties.cc ('k') | src/compiler/types.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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->IsNativeContext()) {
790 if (current->IsModuleContext()) {
791 return Just(OuterContext(handle(current), distance));
792 }
793 current = current->previous();
794 distance++;
795 }
796 return Nothing<OuterContext>();
797 }
798
799 Maybe<OuterContext> ChooseSpecializationContext(CompilationInfo* info) {
800 if (info->is_function_context_specializing()) {
801 DCHECK(info->has_context());
802 return Just(OuterContext(handle(info->context()), 0));
803 }
804 return GetModuleContext(info->closure());
805 }
806
807 } // anonymous namespace
784 808
785 struct InliningPhase { 809 struct InliningPhase {
786 static const char* phase_name() { return "inlining"; } 810 static const char* phase_name() { return "inlining"; }
787 811
788 void Run(PipelineData* data, Zone* temp_zone) { 812 void Run(PipelineData* data, Zone* temp_zone) {
789 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); 813 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
790 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), 814 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
791 data->common()); 815 data->common());
792 CheckpointElimination checkpoint_elimination(&graph_reducer); 816 CheckpointElimination checkpoint_elimination(&graph_reducer);
793 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), 817 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
794 data->common(), data->machine()); 818 data->common(), data->machine());
795 JSCallReducer call_reducer(&graph_reducer, data->jsgraph(), 819 JSCallReducer call_reducer(&graph_reducer, data->jsgraph(),
796 data->native_context(), 820 data->native_context(),
797 data->info()->dependencies()); 821 data->info()->dependencies());
798 JSContextSpecialization context_specialization( 822 JSContextSpecialization context_specialization(
799 &graph_reducer, data->jsgraph(), 823 &graph_reducer, data->jsgraph(),
800 data->info()->is_function_context_specializing() 824 ChooseSpecializationContext(data->info()),
801 ? handle(data->info()->context())
802 : MaybeHandle<Context>(),
803 data->info()->is_function_context_specializing() 825 data->info()->is_function_context_specializing()
804 ? data->info()->closure() 826 ? data->info()->closure()
805 : MaybeHandle<JSFunction>()); 827 : MaybeHandle<JSFunction>());
806 JSFrameSpecialization frame_specialization( 828 JSFrameSpecialization frame_specialization(
807 &graph_reducer, data->info()->osr_frame(), data->jsgraph()); 829 &graph_reducer, data->info()->osr_frame(), data->jsgraph());
808 JSNativeContextSpecialization::Flags flags = 830 JSNativeContextSpecialization::Flags flags =
809 JSNativeContextSpecialization::kNoFlags; 831 JSNativeContextSpecialization::kNoFlags;
810 if (data->info()->is_accessor_inlining_enabled()) { 832 if (data->info()->is_accessor_inlining_enabled()) {
811 flags |= JSNativeContextSpecialization::kAccessorInliningEnabled; 833 flags |= JSNativeContextSpecialization::kAccessorInliningEnabled;
812 } 834 }
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 data->DeleteRegisterAllocationZone(); 2049 data->DeleteRegisterAllocationZone();
2028 } 2050 }
2029 2051
2030 CompilationInfo* PipelineImpl::info() const { return data_->info(); } 2052 CompilationInfo* PipelineImpl::info() const { return data_->info(); }
2031 2053
2032 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } 2054 Isolate* PipelineImpl::isolate() const { return info()->isolate(); }
2033 2055
2034 } // namespace compiler 2056 } // namespace compiler
2035 } // namespace internal 2057 } // namespace internal
2036 } // namespace v8 2058 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.cc ('k') | src/compiler/types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698