Commit 10881d87 authored by verwaest@chromium.org's avatar verwaest@chromium.org

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
parent 14f175d2
...@@ -1268,6 +1268,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, ...@@ -1268,6 +1268,11 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
? isolate()->sloppy_function_with_readonly_prototype_map() ? isolate()->sloppy_function_with_readonly_prototype_map()
: isolate()->sloppy_function_map(); : isolate()->sloppy_function_map();
Handle<JSFunction> result = NewFunction(map, name, code); 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); result->set_prototype_or_initial_map(*prototype);
return result; return result;
} }
......
...@@ -7288,6 +7288,7 @@ Handle<Map> Map::CopyForObserved(Handle<Map> map) { ...@@ -7288,6 +7288,7 @@ Handle<Map> Map::CopyForObserved(Handle<Map> map) {
Handle<Map> Map::CopyAsPrototypeMap(Handle<Map> map) { Handle<Map> Map::CopyAsPrototypeMap(Handle<Map> map) {
if (map->is_prototype_map()) return map;
Handle<Map> result = Copy(map); Handle<Map> result = Copy(map);
result->mark_prototype_map(); result->mark_prototype_map();
return result; return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment