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

Unified Diff: src/objects.cc

Issue 942493002: Clear Map::constructor to object_function from the same context for prototype maps. This avoids kee… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | no next file » | 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 716694bdfe96b3c016887c54209d34265b2b519f..47c79b5e73e093eded54e085dccad0a3327c6704 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9976,6 +9976,19 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object,
Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype");
JSObject::MigrateToMap(object, new_map);
}
+ if (object->map()->constructor()->IsJSFunction()) {
+ JSFunction* constructor = JSFunction::cast(object->map()->constructor());
+ // Replace the pointer to the exact constructor with the Object function
+ // from the same context if undetectable from JS. This is to avoid keeping
+ // memory alive unnecessarily.
+ if (!constructor->shared()->IsApiFunction() &&
+ object->class_name() ==
+ object->GetIsolate()->heap()->Object_string()) {
+ Context* context = constructor->context()->native_context();
+ JSFunction* object_function = context->object_function();
+ object->map()->set_constructor(object_function);
+ }
+ }
object->map()->set_is_prototype_map(true);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698