Skip to content

Commit bd6d414

Browse files
tunztunamagur0
authored andcommitted
deps: V8: cherry-pick c172ffc5bf54
Original commit message: Compact retained maps array more often When we add maps to the retained maps array, we compacted the array if it's full. But, since we are now adding maps in a batch, it's unlikely to meet the condition. Thus, update the condition to check whether new size exceeds the capacity. Bug: 398528460 Change-Id: I89caa47b69532c6397596edfe5caf7c7d24768cc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6330019 Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Choongwoo Han <choongwoo.han@microsoft.com> Cr-Commit-Position: refs/heads/main@{#99163} Refs: v8/v8@c172ffc PR-URL: #57437 Fixes: #57412 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Co-Authored-By: tunamagur0 <47546832+tunamagur0@users.noreply.github.com>
1 parent 77182e7 commit bd6d414

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.23',
41+
'v8_embedder_string': '-node.24',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/heap/heap.cc

+7-6
Original file line numberDiff line numberDiff line change
@@ -6252,12 +6252,13 @@ void Heap::AddRetainedMaps(Handle<NativeContext> context,
62526252
GlobalHandleVector<Map> maps) {
62536253
Handle<WeakArrayList> array(WeakArrayList::cast(context->retained_maps()),
62546254
isolate());
6255-
if (array->IsFull()) {
6255+
int new_maps_size = static_cast<int>(maps.size()) * kRetainMapEntrySize;
6256+
if (array->length() + new_maps_size > array->capacity()) {
62566257
CompactRetainedMaps(*array);
62576258
}
62586259
int cur_length = array->length();
6259-
array = WeakArrayList::EnsureSpace(
6260-
isolate(), array, cur_length + static_cast<int>(maps.size()) * 2);
6260+
array =
6261+
WeakArrayList::EnsureSpace(isolate(), array, cur_length + new_maps_size);
62616262
if (*array != context->retained_maps()) {
62626263
context->set_retained_maps(*array);
62636264
}
@@ -6275,7 +6276,7 @@ void Heap::AddRetainedMaps(Handle<NativeContext> context,
62756276
raw_array->Set(cur_length, MakeWeak(*map));
62766277
raw_array->Set(cur_length + 1,
62776278
Smi::FromInt(v8_flags.retain_maps_for_n_gc));
6278-
cur_length += 2;
6279+
cur_length += kRetainMapEntrySize;
62796280
raw_array->set_length(cur_length);
62806281

62816282
map->set_is_in_retained_map_list(true);
@@ -6287,7 +6288,7 @@ void Heap::CompactRetainedMaps(Tagged<WeakArrayList> retained_maps) {
62876288
int length = retained_maps->length();
62886289
int new_length = 0;
62896290
// This loop compacts the array by removing cleared weak cells.
6290-
for (int i = 0; i < length; i += 2) {
6291+
for (int i = 0; i < length; i += kRetainMapEntrySize) {
62916292
Tagged<MaybeObject> maybe_object = retained_maps->Get(i);
62926293
if (maybe_object.IsCleared()) {
62936294
continue;
@@ -6301,7 +6302,7 @@ void Heap::CompactRetainedMaps(Tagged<WeakArrayList> retained_maps) {
63016302
retained_maps->Set(new_length, maybe_object);
63026303
retained_maps->Set(new_length + 1, age);
63036304
}
6304-
new_length += 2;
6305+
new_length += kRetainMapEntrySize;
63056306
}
63066307
Tagged<HeapObject> undefined = ReadOnlyRoots(this).undefined_value();
63076308
for (int i = new_length; i < length; i++) {

deps/v8/src/heap/heap.h

+2
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,8 @@ class Heap final {
18071807
void AddToRingBuffer(const char* string);
18081808
void GetFromRingBuffer(char* buffer);
18091809

1810+
static constexpr int kRetainMapEntrySize = 2;
1811+
18101812
void CompactRetainedMaps(Tagged<WeakArrayList> retained_maps);
18111813

18121814
void CollectGarbageOnMemoryPressure();

0 commit comments

Comments
 (0)