Skip to content

Commit

Permalink
Merged: [runtime] Set instance prototypes directly on maps
Browse files Browse the repository at this point in the history
Bug: chromium:1452137
(cherry picked from commit c7c4477)

Change-Id: I022863daf8da14feb68862b45bf3d3504a25540c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4637890
Reviewed-by: Toon Verwaest <[email protected]>
Auto-Submit: Igor Sheludko <[email protected]>
Commit-Queue: Toon Verwaest <[email protected]>
Commit-Queue: Igor Sheludko <[email protected]>
Cr-Commit-Position: refs/branch-heads/11.5@{v8#20}
Cr-Branched-From: 0c4044b-refs/heads/11.5.150@{#1}
Cr-Branched-From: b71d303-refs/heads/main@{#87781}
  • Loading branch information
verwaest authored and V8 LUCI CQ committed Jun 23, 2023
1 parent 88d0419 commit f732ccd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/objects/js-function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ void SetInstancePrototype(Isolate* isolate, Handle<JSFunction> function,
// At that point, a new initial map is created and the prototype is put
// into the initial map where it belongs.
function->set_prototype_or_initial_map(*value, kReleaseStore);
if (value->IsJSObjectThatCanBeTrackedAsPrototype()) {
// Optimize as prototype to detach it from its transition tree.
JSObject::OptimizeAsPrototype(Handle<JSObject>::cast(value));
}
} else {
Handle<Map> new_map =
Map::Copy(isolate, initial_map, "SetInstancePrototype");
Expand Down Expand Up @@ -808,8 +812,10 @@ void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) {
Handle<HeapObject> prototype;
if (function->has_instance_prototype()) {
prototype = handle(function->instance_prototype(), isolate);
map->set_prototype(*prototype);
} else {
prototype = isolate->factory()->NewFunctionPrototype(function);
Map::SetPrototype(isolate, map, prototype);
}
DCHECK(map->has_fast_object_elements());

Expand Down

0 comments on commit f732ccd

Please sign in to comment.