Commit 9d6911fd authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[heap] Skip write barrier Smi check for known HeapObjects

Add HeapObject overloads for MarkingBarrier, GenerationalBarrier and
WriteBarrierForCode, which the compiler automatically prefers if a
setter's type is a subclass of HeapObject. These overloads can skip
the IsHeapObject check, providing maybe a small performance boost and
I measure a ~4.5kB binary size reduction in libv8.so

Change-Id: Ia65ff8425ae4895da406587101c7813fe6bf5a2b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1958055
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65395}
parent ab8486ee
......@@ -132,9 +132,12 @@ inline void MarkingBarrierInternal(HeapObject object, Address slot,
inline void WriteBarrierForCode(Code host, RelocInfo* rinfo, Object value) {
DCHECK(!HasWeakHeapObjectTag(value));
if (!value.IsHeapObject()) return;
HeapObject object = HeapObject::cast(value);
GenerationalBarrierForCode(host, rinfo, object);
MarkingBarrierForCode(host, rinfo, object);
WriteBarrierForCode(host, rinfo, HeapObject::cast(value));
}
inline void WriteBarrierForCode(Code host, RelocInfo* rinfo, HeapObject value) {
GenerationalBarrierForCode(host, rinfo, value);
MarkingBarrierForCode(host, rinfo, value);
}
inline void WriteBarrierForCode(Code host) {
......@@ -144,9 +147,15 @@ inline void WriteBarrierForCode(Code host) {
inline void GenerationalBarrier(HeapObject object, ObjectSlot slot,
Object value) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
DCHECK(!HasWeakHeapObjectTag(*slot));
DCHECK(!HasWeakHeapObjectTag(value));
if (!value.IsHeapObject()) return;
GenerationalBarrier(object, slot, HeapObject::cast(value));
}
inline void GenerationalBarrier(HeapObject object, ObjectSlot slot,
HeapObject value) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
DCHECK(!HasWeakHeapObjectTag(*slot));
heap_internals::GenerationalBarrierInternal(object, slot.address(),
HeapObject::cast(value));
}
......@@ -181,9 +190,15 @@ inline void GenerationalBarrierForCode(Code host, RelocInfo* rinfo,
inline void MarkingBarrier(HeapObject object, ObjectSlot slot, Object value) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
DCHECK_IMPLIES(slot.address() != kNullAddress, !HasWeakHeapObjectTag(*slot));
DCHECK(!HasWeakHeapObjectTag(value));
if (!value.IsHeapObject()) return;
MarkingBarrier(object, slot, HeapObject::cast(value));
}
inline void MarkingBarrier(HeapObject object, ObjectSlot slot,
HeapObject value) {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return;
DCHECK_IMPLIES(slot.address() != kNullAddress, !HasWeakHeapObjectTag(*slot));
heap_internals::MarkingBarrierInternal(object, slot.address(),
HeapObject::cast(value));
}
......
......@@ -22,10 +22,12 @@ class EphemeronHashTable;
// Combined write barriers.
void WriteBarrierForCode(Code host, RelocInfo* rinfo, Object value);
void WriteBarrierForCode(Code host, RelocInfo* rinfo, HeapObject value);
void WriteBarrierForCode(Code host);
// Generational write barrier.
void GenerationalBarrier(HeapObject object, ObjectSlot slot, Object value);
void GenerationalBarrier(HeapObject object, ObjectSlot slot, HeapObject value);
void GenerationalBarrier(HeapObject object, MaybeObjectSlot slot,
MaybeObject value);
void GenerationalEphemeronKeyBarrier(EphemeronHashTable table, ObjectSlot slot,
......@@ -34,6 +36,7 @@ void GenerationalBarrierForCode(Code host, RelocInfo* rinfo, HeapObject object);
// Marking write barrier.
void MarkingBarrier(HeapObject object, ObjectSlot slot, Object value);
void MarkingBarrier(HeapObject object, ObjectSlot slot, HeapObject value);
void MarkingBarrier(HeapObject object, MaybeObjectSlot slot, MaybeObject value);
void MarkingBarrierForCode(Code host, RelocInfo* rinfo, HeapObject object);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment