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

Unified Diff: src/objects.cc

Issue 2407183002: [modules] Don't unnecessarily keep function alive after evaluation. (Closed)
Patch Set: Remove stale offset. Created 4 years, 2 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/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 11bba2372b36a1e21c3574907fc56c0d01721ff8..ad2f679f4d86e2ea5275f821e90a81a21c05bc3c 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -19944,8 +19944,7 @@ MaybeHandle<Cell> Module::ResolveExportUsingStarExports(
bool Module::Instantiate(Handle<Module> module, v8::Local<v8::Context> context,
v8::Module::ResolveCallback callback) {
- // Already instantiated.
- if (module->code()->IsJSFunction()) return true;
+ if (module->instantiated()) return true;
Isolate* isolate = module->GetIsolate();
Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(module->code()),
@@ -19955,6 +19954,7 @@ bool Module::Instantiate(Handle<Module> module, v8::Local<v8::Context> context,
shared,
handle(Utils::OpenHandle(*context)->native_context(), isolate));
module->set_code(*function);
+ DCHECK(module->instantiated());
Handle<ModuleInfo> module_info(shared->scope_info()->ModuleDescriptorInfo(),
isolate);
@@ -20036,16 +20036,15 @@ bool Module::Instantiate(Handle<Module> module, v8::Local<v8::Context> context,
}
MaybeHandle<Object> Module::Evaluate(Handle<Module> module) {
- DCHECK(module->code()->IsJSFunction()); // Instantiated.
-
- Isolate* isolate = module->GetIsolate();
+ DCHECK(module->instantiated());
// Each module can only be evaluated once.
+ Isolate* isolate = module->GetIsolate();
if (module->evaluated()) return isolate->factory()->undefined_value();
- module->set_evaluated(true);
+ Handle<JSFunction> function(JSFunction::cast(module->code()), isolate);
+ module->set_evaluated();
// Initialization.
- Handle<JSFunction> function(JSFunction::cast(module->code()), isolate);
DCHECK_EQ(MODULE_SCOPE, function->shared()->scope_info()->scope_type());
Handle<Object> receiver = isolate->factory()->undefined_value();
Handle<Object> argv[] = {module};
@@ -20072,7 +20071,7 @@ namespace {
void FetchStarExports(Handle<Module> module, Zone* zone,
UnorderedModuleSet* visited) {
- DCHECK(module->code()->IsJSFunction()); // Instantiated.
+ DCHECK(module->instantiated());
bool cycle = !visited->insert(module).second;
if (cycle) return;
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698