Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ccf1178

Browse filesBrowse files
committed
deps: V8: cherry-pick d3a1a5b6c491
Original commit message: [objects] Fix memory leak in PrototypeUsers::Add PrototypeUsers::Add now iterates the WeakArrayList to find empty slots before growing the array. Not reusing empty slots caused a memory leak. It might also be desirable to shrink the WeakArrayList in the future. Right now it is only compacted when invoking CreateBlob. Also removed unused PrototypeUsers::IsEmptySlot declaration. Bug: v8:10031 Change-Id: I570ec78fca37e8f0c794f1f40846a4daab47c225 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1967317 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org> Cr-Commit-Position: refs/heads/master@{#65456} Refs: v8/v8@d3a1a5b Fixes: #30753 PR-URL: #31005 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 9d2e8c5 commit ccf1178
Copy full SHA for ccf1178

File tree

Expand file treeCollapse file tree

3 files changed

+18
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-2
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
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.24',
41+
'v8_embedder_string': '-node.25',
4242

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

Collapse file

‎deps/v8/src/objects/objects.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/objects/objects.cc
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4025,6 +4025,13 @@ Handle<WeakArrayList> PrototypeUsers::Add(Isolate* isolate,
40254025

40264026
// If there are empty slots, use one of them.
40274027
int empty_slot = Smi::ToInt(empty_slot_index(*array));
4028+
4029+
if (empty_slot == kNoEmptySlotsMarker) {
4030+
// GCs might have cleared some references, rescan the array for empty slots.
4031+
PrototypeUsers::ScanForEmptySlots(*array);
4032+
empty_slot = Smi::ToInt(empty_slot_index(*array));
4033+
}
4034+
40284035
if (empty_slot != kNoEmptySlotsMarker) {
40294036
DCHECK_GE(empty_slot, kFirstIndex);
40304037
CHECK_LT(empty_slot, array->length());
@@ -4047,6 +4054,15 @@ Handle<WeakArrayList> PrototypeUsers::Add(Isolate* isolate,
40474054
return array;
40484055
}
40494056

4057+
// static
4058+
void PrototypeUsers::ScanForEmptySlots(WeakArrayList array) {
4059+
for (int i = kFirstIndex; i < array.length(); i++) {
4060+
if (array.Get(i)->IsCleared()) {
4061+
PrototypeUsers::MarkSlotEmpty(array, i);
4062+
}
4063+
}
4064+
}
4065+
40504066
WeakArrayList PrototypeUsers::Compact(Handle<WeakArrayList> array, Heap* heap,
40514067
CompactionCallback callback,
40524068
AllocationType allocation) {
Collapse file

‎deps/v8/src/objects/prototype-info.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/objects/prototype-info.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class V8_EXPORT_PRIVATE PrototypeUsers : public WeakArrayList {
9999
static inline Smi empty_slot_index(WeakArrayList array);
100100
static inline void set_empty_slot_index(WeakArrayList array, int index);
101101

102-
static void IsSlotEmpty(WeakArrayList array, int index);
102+
static void ScanForEmptySlots(WeakArrayList array);
103103

104104
DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeUsers);
105105
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.