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

Unified Diff: src/compiler/pipeline.cc

Issue 2841613002: [compiler][modules] Constant-fold the loads of module cells. (Closed)
Patch Set: Rebase. Created 3 years, 8 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
Index: src/compiler/pipeline.cc
diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc
index 585923fa69d36c63e016846be502018fea6b65be..f274d00afbf6a58de3eda9aef47a5bc9e8fee541 100644
--- a/src/compiler/pipeline.cc
+++ b/src/compiler/pipeline.cc
@@ -781,6 +781,31 @@ struct GraphBuilderPhase {
}
};
+namespace {
+
+Maybe<OuterContext> GetModuleContext(Handle<JSFunction> closure) {
+ Context* current = closure->context();
+ size_t distance = 0;
+ while (current != nullptr && !current->IsNativeContext() &&
+ !current->IsModuleContext()) {
+ current = current->previous();
+ distance++;
+ }
+ 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.
+ return Just(OuterContext(handle(current), 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 +822,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>());

Powered by Google App Engine
This is Rietveld 408576698