Skip to content

Commit 18b8fbb

Browse files
ulanCommit Bot
authored andcommitted
[heap] Correctly handle strings in concurrent marking.
String with pointers should use snapshotting protocol because they can be externalized concurrently. Sequential strings can be turned into thin strings, so we need to cache the length and synchronized of markbits. No-Try: true Bug: v8:6915, chromium:694255 Change-Id: Ibd1f0ead31544f56aa9de9a177bee7e60fbc2e6a Reviewed-on: https://chromium-review.googlesource.com/708761 Commit-Queue: Ulan Degenbaev <[email protected]> Reviewed-by: Michael Lippautz <[email protected]> Cr-Commit-Position: refs/heads/master@{#48432}
1 parent bdde74c commit 18b8fbb

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

src/heap/concurrent-marking.cc

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,52 @@ class ConcurrentMarkingVisitor final
133133
return 0;
134134
}
135135

136+
// ===========================================================================
137+
// Strings with pointers =====================================================
138+
// ===========================================================================
139+
140+
int VisitConsString(Map* map, ConsString* object) {
141+
int size = ConsString::BodyDescriptor::SizeOf(map, object);
142+
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, size);
143+
if (!ShouldVisit(object)) return 0;
144+
VisitPointersInSnapshot(object, snapshot);
145+
return size;
146+
}
147+
148+
int VisitSlicedString(Map* map, SlicedString* object) {
149+
int size = SlicedString::BodyDescriptor::SizeOf(map, object);
150+
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, size);
151+
if (!ShouldVisit(object)) return 0;
152+
VisitPointersInSnapshot(object, snapshot);
153+
return size;
154+
}
155+
156+
int VisitThinString(Map* map, ThinString* object) {
157+
int size = ThinString::BodyDescriptor::SizeOf(map, object);
158+
const SlotSnapshot& snapshot = MakeSlotSnapshot(map, object, size);
159+
if (!ShouldVisit(object)) return 0;
160+
VisitPointersInSnapshot(object, snapshot);
161+
return size;
162+
}
163+
164+
// ===========================================================================
165+
// Strings without pointers ==================================================
166+
// ===========================================================================
167+
168+
int VisitSeqOneByteString(Map* map, SeqOneByteString* object) {
169+
int size = SeqOneByteString::SizeFor(object->synchronized_length());
170+
if (!ShouldVisit(object)) return 0;
171+
VisitMapPointer(object, object->map_slot());
172+
return size;
173+
}
174+
175+
int VisitSeqTwoByteString(Map* map, SeqTwoByteString* object) {
176+
int size = SeqTwoByteString::SizeFor(object->synchronized_length());
177+
if (!ShouldVisit(object)) return 0;
178+
VisitMapPointer(object, object->map_slot());
179+
return size;
180+
}
181+
136182
// ===========================================================================
137183
// Fixed array object ========================================================
138184
// ===========================================================================
@@ -284,13 +330,14 @@ class ConcurrentMarkingVisitor final
284330
SlotSnapshot* slot_snapshot_;
285331
};
286332

287-
const SlotSnapshot& MakeSlotSnapshot(Map* map, HeapObject* object, int size) {
333+
template <typename T>
334+
const SlotSnapshot& MakeSlotSnapshot(Map* map, T* object, int size) {
288335
// TODO(ulan): Iterate only the existing fields and skip slack at the end
289336
// of the object.
290337
SlotSnapshottingVisitor visitor(&slot_snapshot_);
291338
visitor.VisitPointer(object,
292339
reinterpret_cast<Object**>(object->map_slot()));
293-
JSObject::BodyDescriptor::IterateBody(object, size, &visitor);
340+
T::BodyDescriptor::IterateBody(object, size, &visitor);
294341
return slot_snapshot_;
295342
}
296343
ConcurrentMarking::MarkingWorklist::View shared_;

0 commit comments

Comments
 (0)