Commit 7b2861e3 authored by cbruni's avatar cbruni Committed by Commit bot

[heap] Add optimized RecordWrites

BUG=

Committed: https://crrev.com/5210f167e802a3758aac1f2900a6560c8de07831
Cr-Commit-Position: refs/heads/master@{#35231}

Review URL: https://codereview.chromium.org/1834373003

Cr-Commit-Position: refs/heads/master@{#35516}
parent 85e9c209
...@@ -999,13 +999,10 @@ class ElementsAccessorBase : public ElementsAccessor { ...@@ -999,13 +999,10 @@ class ElementsAccessorBase : public ElementsAccessor {
&array_length) && &array_length) &&
array_length <= Smi::kMaxValue)) { array_length <= Smi::kMaxValue)) {
// Since we use std::sort above, the GC will no longer know where the // Since we use std::sort above, the GC will no longer know where the
// HeapNumbers are, hence we have to write them again. // HeapNumbers are. For Arrays with valid Smi length, we are sure to
// For Arrays with valid Smi length, we are sure to have no HeapNumber // have no HeapNumber indices and thus we can skip this step.
// indices and thus we can skip this step. FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(isolate->heap(), *combined_keys, 0,
for (uint32_t i = 0; i < nof_indices; i++) { nof_indices);
Object* index = combined_keys->get(i);
combined_keys->set(i, index);
}
} }
} }
......
...@@ -405,9 +405,20 @@ void Heap::RecordWrite(Object* object, int offset, Object* o) { ...@@ -405,9 +405,20 @@ void Heap::RecordWrite(Object* object, int offset, Object* o) {
if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) { if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) {
return; return;
} }
Page* page = Page::FromAddress(reinterpret_cast<Address>(object)); RememberedSet<OLD_TO_NEW>::Insert(
Address slot = HeapObject::cast(object)->address() + offset; Page::FromAddress(reinterpret_cast<Address>(object)),
RememberedSet<OLD_TO_NEW>::Insert(page, slot); HeapObject::cast(object)->address() + offset);
}
void Heap::RecordFixedArrayElements(FixedArray* array, int offset, int length) {
if (InNewSpace(array)) return;
Page* page = Page::FromAddress(reinterpret_cast<Address>(array));
for (int i = 0; i < length; i++) {
if (!InNewSpace(array->get(offset + i))) continue;
RememberedSet<OLD_TO_NEW>::Insert(
page,
reinterpret_cast<Address>(array->RawFieldOfElementAt(offset + i)));
}
} }
......
...@@ -1102,13 +1102,7 @@ void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, ...@@ -1102,13 +1102,7 @@ void Heap::MoveElements(FixedArray* array, int dst_index, int src_index,
DCHECK(array->map() != fixed_cow_array_map()); DCHECK(array->map() != fixed_cow_array_map());
Object** dst_objects = array->data_start() + dst_index; Object** dst_objects = array->data_start() + dst_index;
MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize); MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize);
if (!InNewSpace(array)) { FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(this, array, dst_index, len);
for (int i = 0; i < len; i++) {
RecordWrite(array, array->OffsetOfElementAt(dst_index + i),
dst_objects[i]);
}
}
incremental_marking()->IterateBlackObject(array);
} }
......
...@@ -1080,6 +1080,8 @@ class Heap { ...@@ -1080,6 +1080,8 @@ class Heap {
// Write barrier support for object[offset] = o; // Write barrier support for object[offset] = o;
inline void RecordWrite(Object* object, int offset, Object* o); inline void RecordWrite(Object* object, int offset, Object* o);
inline void RecordFixedArrayElements(FixedArray* array, int offset,
int length);
Address* store_buffer_top_address() { return store_buffer()->top_address(); } Address* store_buffer_top_address() { return store_buffer()->top_address(); }
......
...@@ -1145,6 +1145,12 @@ MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate, ...@@ -1145,6 +1145,12 @@ MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
object, HeapObject::RawField(object, offset), value); \ object, HeapObject::RawField(object, offset), value); \
heap->RecordWrite(object, offset, value); heap->RecordWrite(object, offset, value);
#define FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(heap, array, start, length) \
do { \
heap->RecordFixedArrayElements(array, start, length); \
heap->incremental_marking()->IterateBlackObject(array); \
} while (false)
#define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \ #define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \
if (mode != SKIP_WRITE_BARRIER) { \ if (mode != SKIP_WRITE_BARRIER) { \
if (mode == UPDATE_WRITE_BARRIER) { \ if (mode == UPDATE_WRITE_BARRIER) { \
......
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