Skip to content

Commit 9ce8ef4

Browse files
verwaestinoway46
authored andcommitted
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 <[email protected]> Reviewed-by: Igor Sheludko <[email protected]> Commit-Queue: Igor Sheludko <[email protected]> Auto-Submit: Toon Verwaest <[email protected]> Cr-Commit-Position: refs/heads/main@{#99894} Refs: v8/v8@8901c79 Co-authored-by: inoway46 <[email protected]> PR-URL: #66089 Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 83b3431 commit 9ce8ef4

4 files changed

Lines changed: 9 additions & 45 deletions

File tree

‎common.gypi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# Reset this number to 0 on major V8 upgrades.
4444
# Increment by one for each non-official patch applied to deps/v8.
45-
'v8_embedder_string': '-node.54',
45+
'v8_embedder_string': '-node.55',
4646

4747
##### V8 defaults for Node.js #####
4848

‎deps/v8/src/compiler/heap-refs.cc‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,8 +1039,6 @@ void JSHeapBroker::InitializeAndStartSerializing(
10391039
refs_ =
10401040
zone()->New<RefsMap>(kInitialRefsBucketCount, AddressMatcher(), zone());
10411041

1042-
CollectArrayAndObjectPrototypes();
1043-
10441042
SetTargetNativeContextRef(target_native_context);
10451043
}
10461044

‎deps/v8/src/compiler/js-heap-broker.cc‎

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ JSHeapBroker::JSHeapBroker(Isolate* isolate, Zone* broker_zone,
4747
refs_(zone()->New<RefsMap>(kMinimalRefsBucketCount, AddressMatcher(),
4848
zone())),
4949
root_index_map_(isolate),
50-
array_and_object_prototypes_(zone()),
5150
tracing_enabled_(tracing_enabled),
5251
code_kind_(code_kind),
5352
feedback_(zone()),
@@ -118,28 +117,6 @@ void JSHeapBroker::SetTargetNativeContextRef(
118117
target_native_context_ = MakeRef(this, *native_context);
119118
}
120119

121-
void JSHeapBroker::CollectArrayAndObjectPrototypes() {
122-
DisallowGarbageCollection no_gc;
123-
CHECK_EQ(mode(), kSerializing);
124-
CHECK(array_and_object_prototypes_.empty());
125-
126-
Tagged<Object> maybe_context = isolate()->heap()->native_contexts_list();
127-
while (!IsUndefined(maybe_context, isolate())) {
128-
Tagged<Context> context = Cast<Context>(maybe_context);
129-
Tagged<Object> array_prot =
130-
context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX);
131-
Tagged<Object> object_prot =
132-
context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX);
133-
array_and_object_prototypes_.emplace(
134-
CanonicalPersistentHandle(Cast<JSObject>(array_prot)));
135-
array_and_object_prototypes_.emplace(
136-
CanonicalPersistentHandle(Cast<JSObject>(object_prot)));
137-
maybe_context = context->next_context_link();
138-
}
139-
140-
CHECK(!array_and_object_prototypes_.empty());
141-
}
142-
143120
StringRef JSHeapBroker::GetTypedArrayStringTag(ElementsKind kind) {
144121
DCHECK(IsTypedArrayOrRabGsabTypedArrayElementsKind(kind));
145122
switch (kind) {
@@ -159,14 +136,9 @@ bool JSHeapBroker::IsArrayOrObjectPrototype(JSObjectRef object) const {
159136
}
160137

161138
bool JSHeapBroker::IsArrayOrObjectPrototype(Handle<JSObject> object) const {
162-
if (mode() == kDisabled) {
163-
return isolate()->IsInCreationContext(
164-
*object, Context::INITIAL_ARRAY_PROTOTYPE_INDEX) ||
165-
object->map(isolate_)->instance_type() == JS_OBJECT_PROTOTYPE_TYPE;
166-
}
167-
CHECK(!array_and_object_prototypes_.empty());
168-
return array_and_object_prototypes_.find(object) !=
169-
array_and_object_prototypes_.end();
139+
return isolate()->IsInCreationContext(
140+
*object, Context::INITIAL_ARRAY_PROTOTYPE_INDEX) ||
141+
object->map(isolate_)->instance_type() == JS_OBJECT_PROTOTYPE_TYPE;
170142
}
171143

172144
ObjectData* JSHeapBroker::TryGetOrCreateData(Tagged<Object> object,

‎deps/v8/src/compiler/js-heap-broker.h‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,11 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
285285
if (Tagged<HeapObject> heap_object;
286286
TryCast<HeapObject>(object, &heap_object)) {
287287
RootIndex root_index;
288-
// CollectArrayAndObjectPrototypes calls this function often with T equal
289-
// to JSObject. The root index map only contains immortal, immutable
290-
// objects; it never contains any instances of type JSObject, since
291-
// JSObjects must exist within a NativeContext, and NativeContexts can be
292-
// created and destroyed. Thus, we can skip the lookup in the root index
293-
// map for those values and save a little time.
288+
// The root index map only contains immortal, immutable objects; it never
289+
// contains any instances of type JSObject, since JSObjects must exist
290+
// within a NativeContext, and NativeContexts can be created and
291+
// destroyed. Thus, we can skip the lookup in the root index map for those
292+
// values and save a little time.
294293
if constexpr (std::is_convertible_v<T, JSObject>) {
295294
DCHECK(!root_index_map_.Lookup(heap_object, &root_index));
296295
} else if (root_index_map_.Lookup(heap_object, &root_index)) {
@@ -428,8 +427,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
428427
ProcessedFeedback const& ReadFeedbackForTemplateObject(
429428
FeedbackSource const& source);
430429

431-
void CollectArrayAndObjectPrototypes();
432-
433430
void set_persistent_handles(
434431
std::unique_ptr<PersistentHandles> persistent_handles) {
435432
DCHECK_NULL(ph_);
@@ -457,9 +454,6 @@ class V8_EXPORT_PRIVATE JSHeapBroker {
457454
OptionalNativeContextRef target_native_context_;
458455
RefsMap* refs_;
459456
RootIndexMap root_index_map_;
460-
ZoneUnorderedSet<IndirectHandle<JSObject>, IndirectHandle<JSObject>::hash,
461-
IndirectHandle<JSObject>::equal_to>
462-
array_and_object_prototypes_;
463457
BrokerMode mode_ = kDisabled;
464458
bool const tracing_enabled_;
465459
CodeKind const code_kind_;

0 commit comments

Comments
 (0)