Commit 872b733f authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Create untangled entry for elements write barrier

Implement independent write barrier for contents of objects.

Change-Id: I739745f524245fa61b2b1cd01263cc8fe3a3d373
Reviewed-on: https://chromium-review.googlesource.com/1152909
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54979}
parent c0d6659d
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "src/conversions.h" #include "src/conversions.h"
#include "src/frames.h" #include "src/frames.h"
#include "src/heap/factory.h" #include "src/heap/factory.h"
#include "src/heap/heap-write-barrier-inl.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
......
...@@ -435,15 +435,6 @@ void Heap::RecordWriteIntoCode(Code* host, RelocInfo* rinfo, Object* value) { ...@@ -435,15 +435,6 @@ void Heap::RecordWriteIntoCode(Code* host, RelocInfo* rinfo, Object* value) {
} }
} }
void Heap::RecordFixedArrayElements(FixedArray* array, int offset, int length) {
if (InNewSpace(array)) return;
for (int i = 0; i < length; i++) {
if (!InNewSpace(array->get(offset + i))) continue;
store_buffer()->InsertEntry(
reinterpret_cast<Address>(array->RawFieldOfElementAt(offset + i)));
}
}
Address* Heap::store_buffer_top_address() { Address* Heap::store_buffer_top_address() {
return store_buffer()->top_address(); return store_buffer()->top_address();
} }
......
...@@ -89,6 +89,15 @@ inline void GenerationalBarrier(HeapObject* object, MaybeObject** slot, ...@@ -89,6 +89,15 @@ inline void GenerationalBarrier(HeapObject* object, MaybeObject** slot,
object, reinterpret_cast<Address>(slot), value_heap_object); object, reinterpret_cast<Address>(slot), value_heap_object);
} }
inline void GenerationalBarrierForElements(Heap* heap, FixedArray* array,
int offset, int length) {
heap_internals::MemoryChunk* array_chunk =
heap_internals::MemoryChunk::FromHeapObject(array);
if (array_chunk->InNewSpace()) return;
Heap::GenerationalBarrierForElementsSlow(heap, array, offset, length);
}
inline void MarkingBarrier(HeapObject* object, Object** slot, Object* value) { inline void MarkingBarrier(HeapObject* object, Object** slot, Object* value) {
DCHECK_IMPLIES(slot != nullptr, !HasWeakHeapObjectTag(*slot)); DCHECK_IMPLIES(slot != nullptr, !HasWeakHeapObjectTag(*slot));
DCHECK(!HasWeakHeapObjectTag(value)); DCHECK(!HasWeakHeapObjectTag(value));
...@@ -105,6 +114,14 @@ inline void MarkingBarrier(HeapObject* object, MaybeObject** slot, ...@@ -105,6 +114,14 @@ inline void MarkingBarrier(HeapObject* object, MaybeObject** slot,
object, reinterpret_cast<Address>(slot), value_heap_object); object, reinterpret_cast<Address>(slot), value_heap_object);
} }
inline void MarkingBarrierForElements(Heap* heap, HeapObject* object) {
heap_internals::MemoryChunk* object_chunk =
heap_internals::MemoryChunk::FromHeapObject(object);
if (!object_chunk->IsMarking()) return;
Heap::MarkingBarrierForElementsSlow(heap, object);
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class FixedArray;
class Heap;
class HeapObject; class HeapObject;
class MaybeObject; class MaybeObject;
class Object; class Object;
...@@ -15,14 +17,24 @@ class Object; ...@@ -15,14 +17,24 @@ class Object;
// Note: In general it is preferred to use the macros defined in // Note: In general it is preferred to use the macros defined in
// object-macros.h. // object-macros.h.
// Write barrier for FixedArray elements.
#define FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(heap, array, start, length) \
do { \
GenerationalBarrierForElements(heap, array, start, length); \
MarkingBarrierForElements(heap, array); \
} while (false)
// Generational write barrier. // Generational write barrier.
void GenerationalBarrier(HeapObject* object, Object** slot, Object* value); void GenerationalBarrier(HeapObject* object, Object** slot, Object* value);
void GenerationalBarrier(HeapObject* object, MaybeObject** slot, void GenerationalBarrier(HeapObject* object, MaybeObject** slot,
MaybeObject* value); MaybeObject* value);
void GenerationalBarrierForElements(Heap* heap, FixedArray* array, int offset,
int length);
// Marking write barrier. // Marking write barrier.
void MarkingBarrier(HeapObject* object, Object** slot, Object* value); void MarkingBarrier(HeapObject* object, Object** slot, Object* value);
void MarkingBarrier(HeapObject* object, MaybeObject** slot, MaybeObject* value); void MarkingBarrier(HeapObject* object, MaybeObject** slot, MaybeObject* value);
void MarkingBarrierForElements(Heap* heap, HeapObject* object);
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -5833,6 +5833,15 @@ void Heap::GenerationalBarrierSlow(HeapObject* object, Address slot, ...@@ -5833,6 +5833,15 @@ void Heap::GenerationalBarrierSlow(HeapObject* object, Address slot,
heap->store_buffer()->InsertEntry(slot); heap->store_buffer()->InsertEntry(slot);
} }
void Heap::GenerationalBarrierForElementsSlow(Heap* heap, FixedArray* array,
int offset, int length) {
for (int i = 0; i < length; i++) {
if (!InNewSpace(array->get(offset + i))) continue;
heap->store_buffer()->InsertEntry(
reinterpret_cast<Address>(array->RawFieldOfElementAt(offset + i)));
}
}
void Heap::MarkingBarrierSlow(HeapObject* object, Address slot, void Heap::MarkingBarrierSlow(HeapObject* object, Address slot,
HeapObject* value) { HeapObject* value) {
Heap* heap = Heap::FromWritableHeapObject(object); Heap* heap = Heap::FromWritableHeapObject(object);
...@@ -5840,6 +5849,13 @@ void Heap::MarkingBarrierSlow(HeapObject* object, Address slot, ...@@ -5840,6 +5849,13 @@ void Heap::MarkingBarrierSlow(HeapObject* object, Address slot,
object, reinterpret_cast<HeapObjectReference**>(slot), value); object, reinterpret_cast<HeapObjectReference**>(slot), value);
} }
void Heap::MarkingBarrierForElementsSlow(Heap* heap, HeapObject* object) {
if (FLAG_concurrent_marking ||
heap->incremental_marking()->marking_state()->IsBlack(object)) {
heap->incremental_marking()->RevisitObject(object);
}
}
bool Heap::PageFlagsAreConsistent(HeapObject* object) { bool Heap::PageFlagsAreConsistent(HeapObject* object) {
Heap* heap = Heap::FromWritableHeapObject(object); Heap* heap = Heap::FromWritableHeapObject(object);
MemoryChunk* chunk = MemoryChunk::FromHeapObject(object); MemoryChunk* chunk = MemoryChunk::FromHeapObject(object);
......
...@@ -166,12 +166,6 @@ using v8::MemoryPressureLevel; ...@@ -166,12 +166,6 @@ using v8::MemoryPressureLevel;
V(empty_string) \ V(empty_string) \
PRIVATE_SYMBOL_LIST(V) PRIVATE_SYMBOL_LIST(V)
#define FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(heap, array, start, length) \
do { \
heap->RecordFixedArrayElements(array, start, length); \
heap->incremental_marking()->RecordWrites(array); \
} while (false)
class AllocationObserver; class AllocationObserver;
class ArrayBufferCollector; class ArrayBufferCollector;
class ArrayBufferTracker; class ArrayBufferTracker;
...@@ -495,9 +489,13 @@ class Heap { ...@@ -495,9 +489,13 @@ class Heap {
V8_EXPORT_PRIVATE static void GenerationalBarrierSlow(HeapObject* object, V8_EXPORT_PRIVATE static void GenerationalBarrierSlow(HeapObject* object,
Address slot, Address slot,
HeapObject* value); HeapObject* value);
V8_EXPORT_PRIVATE static void GenerationalBarrierForElementsSlow(
Heap* heap, FixedArray* array, int offset, int length);
V8_EXPORT_PRIVATE static void MarkingBarrierSlow(HeapObject* object, V8_EXPORT_PRIVATE static void MarkingBarrierSlow(HeapObject* object,
Address slot, Address slot,
HeapObject* value); HeapObject* value);
V8_EXPORT_PRIVATE static void MarkingBarrierForElementsSlow(
Heap* heap, HeapObject* object);
V8_EXPORT_PRIVATE static bool PageFlagsAreConsistent(HeapObject* object); V8_EXPORT_PRIVATE static bool PageFlagsAreConsistent(HeapObject* object);
// Notifies the heap that is ok to start marking or other activities that // Notifies the heap that is ok to start marking or other activities that
...@@ -991,8 +989,6 @@ class Heap { ...@@ -991,8 +989,6 @@ class Heap {
inline void RecordWriteIntoCode(Code* host, RelocInfo* rinfo, Object* target); inline void RecordWriteIntoCode(Code* host, RelocInfo* rinfo, Object* target);
void RecordWriteIntoCodeSlow(Code* host, RelocInfo* rinfo, Object* target); void RecordWriteIntoCodeSlow(Code* host, RelocInfo* rinfo, Object* target);
void RecordWritesIntoCode(Code* code); void RecordWritesIntoCode(Code* code);
inline void RecordFixedArrayElements(FixedArray* array, int offset,
int length);
// Used for query incremental marking status in generated code. // Used for query incremental marking status in generated code.
Address* IsMarkingFlagAddress() { Address* IsMarkingFlagAddress() {
......
...@@ -36,14 +36,6 @@ void IncrementalMarking::RecordMaybeWeakWrite(HeapObject* obj, ...@@ -36,14 +36,6 @@ void IncrementalMarking::RecordMaybeWeakWrite(HeapObject* obj,
} }
} }
void IncrementalMarking::RecordWrites(HeapObject* obj) {
if (IsMarking()) {
if (FLAG_concurrent_marking || marking_state()->IsBlack(obj)) {
RevisitObject(obj);
}
}
}
void IncrementalMarking::RecordWriteIntoCode(Code* host, RelocInfo* rinfo, void IncrementalMarking::RecordWriteIntoCode(Code* host, RelocInfo* rinfo,
Object* value) { Object* value) {
if (IsMarking() && value->IsHeapObject()) { if (IsMarking() && value->IsHeapObject()) {
......
...@@ -211,7 +211,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking { ...@@ -211,7 +211,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
MaybeObject* value); MaybeObject* value);
V8_INLINE void RecordWriteIntoCode(Code* host, RelocInfo* rinfo, V8_INLINE void RecordWriteIntoCode(Code* host, RelocInfo* rinfo,
Object* value); Object* value);
V8_INLINE void RecordWrites(HeapObject* obj); void RevisitObject(HeapObject* obj);
void RecordWriteSlow(HeapObject* obj, HeapObjectReference** slot, void RecordWriteSlow(HeapObject* obj, HeapObjectReference** slot,
Object* value); Object* value);
...@@ -301,8 +301,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking { ...@@ -301,8 +301,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
// Visits the object and returns its size. // Visits the object and returns its size.
V8_INLINE int VisitObject(Map* map, HeapObject* obj); V8_INLINE int VisitObject(Map* map, HeapObject* obj);
void RevisitObject(HeapObject* obj);
void IncrementIdleMarkingDelayCounter(); void IncrementIdleMarkingDelayCounter();
void AdvanceIncrementalMarkingOnAllocation(); void AdvanceIncrementalMarkingOnAllocation();
......
...@@ -4619,7 +4619,7 @@ void Map::ReplaceDescriptors(Isolate* isolate, DescriptorArray* new_descriptors, ...@@ -4619,7 +4619,7 @@ void Map::ReplaceDescriptors(Isolate* isolate, DescriptorArray* new_descriptors,
// Replace descriptors by new_descriptors in all maps that share it. The old // Replace descriptors by new_descriptors in all maps that share it. The old
// descriptors will not be trimmed in the mark-compactor, we need to mark // descriptors will not be trimmed in the mark-compactor, we need to mark
// all its elements. // all its elements.
isolate->heap()->incremental_marking()->RecordWrites(to_replace); MarkingBarrierForElements(isolate->heap(), to_replace);
Map* current = this; Map* current = this;
while (current->instance_descriptors() == to_replace) { while (current->instance_descriptors() == to_replace) {
Object* next = current->GetBackPointer(); Object* next = current->GetBackPointer();
...@@ -5400,7 +5400,7 @@ void Map::EnsureDescriptorSlack(Isolate* isolate, Handle<Map> map, int slack) { ...@@ -5400,7 +5400,7 @@ void Map::EnsureDescriptorSlack(Isolate* isolate, Handle<Map> map, int slack) {
// Replace descriptors by new_descriptors in all maps that share it. The old // Replace descriptors by new_descriptors in all maps that share it. The old
// descriptors will not be trimmed in the mark-compactor, we need to mark // descriptors will not be trimmed in the mark-compactor, we need to mark
// all its elements. // all its elements.
isolate->heap()->incremental_marking()->RecordWrites(*descriptors); MarkingBarrierForElements(isolate->heap(), *descriptors);
Map* current = *map; Map* current = *map;
while (current->instance_descriptors() == *descriptors) { while (current->instance_descriptors() == *descriptors) {
......
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