Skip to content

Commit ee01d6b

Browse files
committed
deps: V8: cherry-pick 2059ee813359
Original commit message: [heap] Make CompactTransitionArray deserializer friendly Add a pre-loop over transition arrays during compaction, that checks whether compaction is needed at all, and whether any of the entries are still uninitialized values as part of deserialization (and therefore no other targets can be dead). Bails out of compaction early if this is the case. Bug: v8:11305 Change-Id: I27af792a8a0bd3df17892f54ac95ed15e4bdfcc0 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2622910 Reviewed-by: Ulan Degenbaev <[email protected]> Commit-Queue: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/master@{#72038} Refs: v8/v8@2059ee8 PR-URL: #36139 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
1 parent 31a46f8 commit ee01d6b

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Diff for: common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.17',
39+
'v8_embedder_string': '-node.18',
4040

4141
##### V8 defaults for Node.js #####
4242

Diff for: deps/v8/src/heap/mark-compact.cc

+34
Original file line numberDiff line numberDiff line change
@@ -2288,11 +2288,45 @@ void MarkCompactCollector::ClearFullMapTransitions() {
22882288
}
22892289
}
22902290

2291+
// Returns false if no maps have died, or if the transition array is
2292+
// still being deserialized.
2293+
bool MarkCompactCollector::TransitionArrayNeedsCompaction(
2294+
TransitionArray transitions, int num_transitions) {
2295+
for (int i = 0; i < num_transitions; ++i) {
2296+
MaybeObject raw_target = transitions.GetRawTarget(i);
2297+
if (raw_target.IsSmi()) {
2298+
// This target is still being deserialized,
2299+
DCHECK(isolate()->has_active_deserializer());
2300+
DCHECK_EQ(raw_target.ToSmi(), Deserializer::uninitialized_field_value());
2301+
#ifdef DEBUG
2302+
// Targets can only be dead iff this array is fully deserialized.
2303+
for (int i = 0; i < num_transitions; ++i) {
2304+
DCHECK(!non_atomic_marking_state()->IsWhite(transitions.GetTarget(i)));
2305+
}
2306+
#endif
2307+
return false;
2308+
} else if (non_atomic_marking_state()->IsWhite(
2309+
TransitionsAccessor::GetTargetFromRaw(raw_target))) {
2310+
#ifdef DEBUG
2311+
// Targets can only be dead iff this array is fully deserialized.
2312+
for (int i = 0; i < num_transitions; ++i) {
2313+
DCHECK(!transitions.GetRawTarget(i).IsSmi());
2314+
}
2315+
#endif
2316+
return true;
2317+
}
2318+
}
2319+
return false;
2320+
}
2321+
22912322
bool MarkCompactCollector::CompactTransitionArray(Map map,
22922323
TransitionArray transitions,
22932324
DescriptorArray descriptors) {
22942325
DCHECK(!map.is_prototype_map());
22952326
int num_transitions = transitions.number_of_entries();
2327+
if (!TransitionArrayNeedsCompaction(transitions, num_transitions)) {
2328+
return false;
2329+
}
22962330
bool descriptors_owner_died = false;
22972331
int transition_index = 0;
22982332
// Compact all live transitions to the left.

Diff for: deps/v8/src/heap/mark-compact.h

+2
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,8 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
681681
void TrimEnumCache(Map map, DescriptorArray descriptors);
682682
bool CompactTransitionArray(Map map, TransitionArray transitions,
683683
DescriptorArray descriptors);
684+
bool TransitionArrayNeedsCompaction(TransitionArray transitions,
685+
int num_transitions);
684686

685687
// After all reachable objects have been marked those weak map entries
686688
// with an unreachable key are removed from all encountered weak maps.

0 commit comments

Comments
 (0)