Also mark as prototype when passing in while creating a function.

BUG=
R=ishell@chromium.org

Review URL: https://codereview.chromium.org/422233010

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22830 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2014-08-04 15:23:29 +00:00
parent 14f175d2a7
commit 10881d87de
2 changed files with 6 additions and 0 deletions

View File

@ -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;
}

View File

@ -7288,6 +7288,7 @@ Handle<Map> Map::CopyForObserved(Handle<Map> map) {
Handle<Map> Map::CopyAsPrototypeMap(Handle<Map> map) {
if (map->is_prototype_map()) return map;
Handle<Map> result = Copy(map);
result->mark_prototype_map();
return result;