mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
deps: V8: backport 8901c793e439
Original commit message:
[compiler] Stop collecting array and object prototypes
We can check in O(1) whether an object is either Object.prototype or
Array.prototype by directly comparing it with the objects, so there's
no need to collect them.
Change-Id: Iadedf8b05cae3d67191fb4836c186620dc009118
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6487694
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Auto-Submit: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#99894}
Refs: https://github.com/v8/v8/commit/8901c793e4392dfea261bcbf9c679e2978847d4d
Co-authored-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66089
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
83b3431c25
commit
9ce8ef405b
4 files changed
+9
-45
No files matched your search
+1
-1
@@ -42,7 +42,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.54',
|
||||
'v8_embedder_string': '-node.55',
|
||||
|
||||
##### V8 defaults for Node.js #####
|
||||
|
||||
|
||||
Vendored
-2
@@ -1039,8 +1039,6 @@ void JSHeapBroker::InitializeAndStartSerializing(
|
||||
refs_ =
|
||||
zone()->New<RefsMap>(kInitialRefsBucketCount, AddressMatcher(), zone());
|
||||
|
||||
CollectArrayAndObjectPrototypes();
|
||||
|
||||
SetTargetNativeContextRef(target_native_context);
|
||||
}
|
||||
|
||||
|
||||
+3
-31
@@ -47,7 +47,6 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone,
|
||||
refs_(zone()->New<RefsMap>(kMinimalRefsBucketCount, AddressMatcher(),
|
||||
zone())),
|
||||
root_index_map_(isolate),
|
||||
array_and_object_prototypes_(zone()),
|
||||
tracing_enabled_(tracing_enabled),
|
||||
code_kind_(code_kind),
|
||||
feedback_(zone()),
|
||||
@@ -118,28 +117,6 @@ void JSHeapBroker::SetTargetNativeContextRef(
|
||||
target_native_context_ = MakeRef(this, *native_context);
|
||||
}
|
||||
|
||||
void JSHeapBroker::CollectArrayAndObjectPrototypes() {
|
||||
DisallowGarbageCollection no_gc;
|
||||
CHECK_EQ(mode(), kSerializing);
|
||||
CHECK(array_and_object_prototypes_.empty());
|
||||
|
||||
Tagged<Object> maybe_context = isolate()->heap()->native_contexts_list();
|
||||
while (!IsUndefined(maybe_context, isolate())) {
|
||||
Tagged<Context> context = Cast<Context>(maybe_context);
|
||||
Tagged<Object> array_prot =
|
||||
context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX);
|
||||
Tagged<Object> object_prot =
|
||||
context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX);
|
||||
array_and_object_prototypes_.emplace(
|
||||
CanonicalPersistentHandle(Cast<JSObject>(array_prot)));
|
||||
array_and_object_prototypes_.emplace(
|
||||
CanonicalPersistentHandle(Cast<JSObject>(object_prot)));
|
||||
maybe_context = context->next_context_link();
|
||||
}
|
||||
|
||||
CHECK(!array_and_object_prototypes_.empty());
|
||||
}
|
||||
|
||||
StringRef JSHeapBroker::GetTypedArrayStringTag(ElementsKind kind) {
|
||||
DCHECK(IsTypedArrayOrRabGsabTypedArrayElementsKind(kind));
|
||||
switch (kind) {
|
||||
@@ -159,14 +136,9 @@ bool JSHeapBroker::IsArrayOrObjectPrototype(JSObjectRef object) const {
|
||||
}
|
||||
|
||||
bool JSHeapBroker::IsArrayOrObjectPrototype(Handle<JSObject> object) const {
|
||||
if (mode() == kDisabled) {
|
||||
return isolate()->IsInCreationContext(
|
||||
*object, Context::INITIAL_ARRAY_PROTOTYPE_INDEX) ||
|
||||
object->map(isolate_)->instance_type() == JS_OBJECT_PROTOTYPE_TYPE;
|
||||
}
|
||||
CHECK(!array_and_object_prototypes_.empty());
|
||||
return array_and_object_prototypes_.find(object) !=
|
||||
array_and_object_prototypes_.end();
|
||||
return isolate()->IsInCreationContext(
|
||||
*object, Context::INITIAL_ARRAY_PROTOTYPE_INDEX) ||
|
||||
object->map(isolate_)->instance_type() == JS_OBJECT_PROTOTYPE_TYPE;
|
||||
}
|
||||
|
||||
ObjectData* JSHeapBroker::TryGetOrCreateData(Tagged<Object> object,
|
||||
|
||||
+5
-11
@@ -285,12 +285,11 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
|
||||
if (Tagged<HeapObject> heap_object;
|
||||
TryCast<HeapObject>(object, &heap_object)) {
|
||||
RootIndex root_index;
|
||||
// CollectArrayAndObjectPrototypes calls this function often with T equal
|
||||
// to JSObject. The root index map only contains immortal, immutable
|
||||
// objects; it never contains any instances of type JSObject, since
|
||||
// JSObjects must exist within a NativeContext, and NativeContexts can be
|
||||
// created and destroyed. Thus, we can skip the lookup in the root index
|
||||
// map for those values and save a little time.
|
||||
// The root index map only contains immortal, immutable objects; it never
|
||||
// contains any instances of type JSObject, since JSObjects must exist
|
||||
// within a NativeContext, and NativeContexts can be created and
|
||||
// destroyed. Thus, we can skip the lookup in the root index map for those
|
||||
// values and save a little time.
|
||||
if constexpr (std::is_convertible_v<T, JSObject>) {
|
||||
DCHECK(!root_index_map_.Lookup(heap_object, &root_index));
|
||||
} else if (root_index_map_.Lookup(heap_object, &root_index)) {
|
||||
@@ -428,8 +427,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
|
||||
ProcessedFeedback const& ReadFeedbackForTemplateObject(
|
||||
FeedbackSource const& source);
|
||||
|
||||
void CollectArrayAndObjectPrototypes();
|
||||
|
||||
void set_persistent_handles(
|
||||
std::unique_ptr<PersistentHandles> persistent_handles) {
|
||||
DCHECK_NULL(ph_);
|
||||
@@ -457,9 +454,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
|
||||
OptionalNativeContextRef target_native_context_;
|
||||
RefsMap* refs_;
|
||||
RootIndexMap root_index_map_;
|
||||
ZoneUnorderedSet<IndirectHandle<JSObject>, IndirectHandle<JSObject>::hash,
|
||||
IndirectHandle<JSObject>::equal_to>
|
||||
array_and_object_prototypes_;
|
||||
BrokerMode mode_ = kDisabled;
|
||||
bool const tracing_enabled_;
|
||||
CodeKind const code_kind_;
|
||||
|
||||
Reference in new issue
Block a user