diff --git a/common.gypi b/common.gypi index 52636bb2fac590..1dca7c9a106e2e 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.20', + 'v8_embedder_string': '-node.21', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/objects/js-function.cc b/deps/v8/src/objects/js-function.cc index 1640cb0d31529c..94f7a672a704e1 100644 --- a/deps/v8/src/objects/js-function.cc +++ b/deps/v8/src/objects/js-function.cc @@ -676,6 +676,10 @@ void SetInstancePrototype(Isolate* isolate, Handle 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::cast(value)); + } } else { Handle new_map = Map::Copy(isolate, initial_map, "SetInstancePrototype"); @@ -801,8 +805,10 @@ void JSFunction::EnsureHasInitialMap(Handle function) { Handle 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());