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

Unified Diff: src/factory.cc

Issue 441873005: Reland "Also mark as prototype when passing in while creating a function." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index a844bd1cdb8ba274888cb87419830fc2122ddec8..e3a19a1e4ba988a0b19b00219e8ed50d83cb3a23 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1268,6 +1268,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
? isolate()->sloppy_function_with_readonly_prototype_map()
: isolate()->sloppy_function_map();
Handle<JSFunction> result = NewFunction(map, name, code);
+ if (!prototype->IsTheHole()) {
+ Handle<JSObject> js_proto = Handle<JSObject>::cast(prototype);
+ Handle<Map> new_map = Map::CopyAsPrototypeMap(handle(js_proto->map()));
+ JSObject::MigrateToMap(js_proto, new_map);
+ }
result->set_prototype_or_initial_map(*prototype);
return result;
}
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698