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

Unified Diff: src/objects.cc

Issue 2407183002: [modules] Don't unnecessarily keep function alive after evaluation. (Closed)
Patch Set: Remove shared(). 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
« src/objects.h ('K') | « 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 61f738e0ac2dc3d001f0cb6ff7f4f2f438d89bb1..0022bbf04462ee8e427c1b2e4e77911b9c7f7bf3 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -19935,8 +19935,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()),
@@ -19946,6 +19945,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);
@@ -20027,16 +20027,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};
@@ -20063,7 +20062,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;
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698