[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}
This commit is contained in:
parent
85e9c2095a
commit
7b2861e35c
@ -999,13 +999,10 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
&array_length) &&
|
||||
array_length <= Smi::kMaxValue)) {
|
||||
// Since we use std::sort above, the GC will no longer know where the
|
||||
// HeapNumbers are, hence we have to write them again.
|
||||
// For Arrays with valid Smi length, we are sure to have no HeapNumber
|
||||
// indices and thus we can skip this step.
|
||||
for (uint32_t i = 0; i < nof_indices; i++) {
|
||||
Object* index = combined_keys->get(i);
|
||||
combined_keys->set(i, index);
|
||||
}
|
||||
// HeapNumbers are. For Arrays with valid Smi length, we are sure to
|
||||
// have no HeapNumber indices and thus we can skip this step.
|
||||
FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(isolate->heap(), *combined_keys, 0,
|
||||
nof_indices);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,9 +405,20 @@ void Heap::RecordWrite(Object* object, int offset, Object* o) {
|
||||
if (!InNewSpace(o) || !object->IsHeapObject() || InNewSpace(object)) {
|
||||
return;
|
||||
}
|
||||
Page* page = Page::FromAddress(reinterpret_cast<Address>(object));
|
||||
Address slot = HeapObject::cast(object)->address() + offset;
|
||||
RememberedSet<OLD_TO_NEW>::Insert(page, slot);
|
||||
RememberedSet<OLD_TO_NEW>::Insert(
|
||||
Page::FromAddress(reinterpret_cast<Address>(object)),
|
||||
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,
|
||||
DCHECK(array->map() != fixed_cow_array_map());
|
||||
Object** dst_objects = array->data_start() + dst_index;
|
||||
MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize);
|
||||
if (!InNewSpace(array)) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
RecordWrite(array, array->OffsetOfElementAt(dst_index + i),
|
||||
dst_objects[i]);
|
||||
}
|
||||
}
|
||||
incremental_marking()->IterateBlackObject(array);
|
||||
FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(this, array, dst_index, len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1080,6 +1080,8 @@ class Heap {
|
||||
|
||||
// Write barrier support for object[offset] = 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(); }
|
||||
|
||||
|
@ -1145,6 +1145,12 @@ MaybeHandle<Object> JSReceiver::GetProperty(Isolate* isolate,
|
||||
object, HeapObject::RawField(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) \
|
||||
if (mode != SKIP_WRITE_BARRIER) { \
|
||||
if (mode == UPDATE_WRITE_BARRIER) { \
|
||||
|
Loading…
Reference in New Issue
Block a user