Skip to content

Commit c7c4477

Browse files
verwaestV8 LUCI CQ
authored andcommitted
[runtime] Set instance prototypes directly on maps
Bug: chromium:1452137 Change-Id: If1de44950711c99da4ace2e988f188421e849330 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4618153 Commit-Queue: Toon Verwaest <[email protected]> Reviewed-by: Igor Sheludko <[email protected]> Auto-Submit: Toon Verwaest <[email protected]> Commit-Queue: Igor Sheludko <[email protected]> Cr-Commit-Position: refs/heads/main@{#88326}
1 parent 4f74c2d commit c7c4477

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/objects/js-function.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,10 @@ void SetInstancePrototype(Isolate* isolate, Handle<JSFunction> function,
678678
// At that point, a new initial map is created and the prototype is put
679679
// into the initial map where it belongs.
680680
function->set_prototype_or_initial_map(*value, kReleaseStore);
681+
if (value->IsJSObjectThatCanBeTrackedAsPrototype()) {
682+
// Optimize as prototype to detach it from its transition tree.
683+
JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value));
684+
}
681685
} else {
682686
Handle<Map> new_map =
683687
Map::Copy(isolate, initial_map, "SetInstancePrototype");
@@ -809,8 +813,10 @@ void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) {
809813
Handle<HeapObject> prototype;
810814
if (function->has_instance_prototype()) {
811815
prototype = handle(function->instance_prototype(), isolate);
816+
map->set_prototype(*prototype);
812817
} else {
813818
prototype = isolate->factory()->NewFunctionPrototype(function);
819+
Map::SetPrototype(isolate, map, prototype);
814820
}
815821
DCHECK(map->has_fast_object_elements());
816822

0 commit comments

Comments
 (0)