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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/node-properties.cc ('k') | src/compiler/types.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index fbe764d8253c54cf8fa84235e684dbe18b81fd18..84305b3bb72d0720826fd7f5bf470de33b6f9391 100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -781,6 +781,30 @@ struct GraphBuilderPhase {
}
};
+namespace {
+
+Maybe<OuterContext> GetModuleContext(Handle<JSFunction> closure) {
+ Context* current = closure->context();
+ size_t distance = 0;
+ while (!current->IsNativeContext()) {
+ if (current->IsModuleContext()) {
+ return Just(OuterContext(handle(current), distance));
+ }
+ current = current->previous();
+ distance++;
+ }
+ return Nothing<OuterContext>();
+}
+
+Maybe<OuterContext> ChooseSpecializationContext(CompilationInfo* info) {
+ if (info->is_function_context_specializing()) {
+ DCHECK(info->has_context());
+ return Just(OuterContext(handle(info->context()), 0));
+ }
+ return GetModuleContext(info->closure());
+}
+
+} // anonymous namespace
struct InliningPhase {
static const char* phase_name() { return "inlining"; }
@@ -797,9 +821,7 @@ struct InliningPhase {
data->info()->dependencies());
JSContextSpecialization context_specialization(
&graph_reducer, data->jsgraph(),
- data->info()->is_function_context_specializing()
- ? handle(data->info()->context())
- : MaybeHandle<Context>(),
+ ChooseSpecializationContext(data->info()),
data->info()->is_function_context_specializing()
? data->info()->closure()
: MaybeHandle<JSFunction>());
« 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