Revision: 13343
Author: [email protected]
Date: Wed Jan 9 06:01:39 2013
Log: Filter old space and large object space to new space references
when moving parts of a FixedArray.
BUG=v8:2452
Review URL: https://codereview.chromium.org/11737006
http://code.google.com/p/v8/source/detail?r=13343
Modified:
/branches/bleeding_edge/src/builtins.cc
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
=======================================
--- /branches/bleeding_edge/src/builtins.cc Fri Jan 4 07:37:59 2013
+++ /branches/bleeding_edge/src/builtins.cc Wed Jan 9 06:01:39 2013
@@ -335,26 +335,6 @@
src->data_start() + src_index,
len * kDoubleSize);
}
-
-
-static void MoveElements(Heap* heap,
- AssertNoAllocation* no_gc,
- FixedArray* dst,
- int dst_index,
- FixedArray* src,
- int src_index,
- int len) {
- if (len == 0) return;
- ASSERT(dst->map() != HEAP->fixed_cow_array_map());
- memmove(dst->data_start() + dst_index,
- src->data_start() + src_index,
- len * kPointerSize);
- WriteBarrierMode mode = dst->GetWriteBarrierMode(*no_gc);
- if (mode == UPDATE_WRITE_BARRIER) {
- heap->RecordWrites(dst->address(), dst->OffsetOfElementAt(dst_index),
len);
- }
- heap->incremental_marking()->RecordWrites(dst);
-}
static void FillWithHoles(Heap* heap, FixedArray* dst, int from, int to) {
@@ -724,7 +704,7 @@
if (elms_obj->IsFixedArray()) {
FixedArray* elms = FixedArray::cast(elms_obj);
AssertNoAllocation no_gc;
- MoveElements(heap, &no_gc, elms, 0, elms, 1, len - 1);
+ heap->MoveElements(elms, 0, 1, len - 1);
elms->set(len - 1, heap->the_hole_value());
} else {
FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj);
@@ -794,7 +774,7 @@
array->set_elements(elms);
} else {
AssertNoAllocation no_gc;
- MoveElements(heap, &no_gc, elms, to_add, elms, 0, len);
+ heap->MoveElements(elms, to_add, 0, len);
}
// Add the provided values.
@@ -1060,7 +1040,7 @@
} else {
FixedArray* elms = FixedArray::cast(elms_obj);
AssertNoAllocation no_gc;
- MoveElements(heap, &no_gc, elms, delta, elms, 0, actual_start);
+ heap->MoveElements(elms, delta, 0, actual_start);
}
elms_obj = LeftTrimFixedArray(heap, elms_obj, delta);
@@ -1076,10 +1056,9 @@
} else {
FixedArray* elms = FixedArray::cast(elms_obj);
AssertNoAllocation no_gc;
- MoveElements(heap, &no_gc,
- elms, actual_start + item_count,
- elms, actual_start + actual_delete_count,
- (len - actual_delete_count - actual_start));
+ heap->MoveElements(elms, actual_start + item_count,
+ actual_start + actual_delete_count,
+ (len - actual_delete_count - actual_start));
FillWithHoles(heap, elms, new_length, len);
}
}
@@ -1119,10 +1098,9 @@
elms_changed = true;
} else {
AssertNoAllocation no_gc;
- MoveElements(heap, &no_gc,
- elms, actual_start + item_count,
- elms, actual_start + actual_delete_count,
- (len - actual_delete_count - actual_start));
+ heap->MoveElements(elms, actual_start + item_count,
+ actual_start + actual_delete_count,
+ (len - actual_delete_count - actual_start));
}
}
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Jan 9 04:29:06 2013
+++ /branches/bleeding_edge/src/heap.cc Wed Jan 9 06:01:39 2013
@@ -675,6 +675,29 @@
PerformGarbageCollection(MARK_COMPACTOR, &tracer);
}
}
+
+
+void Heap::MoveElements(FixedArray* array,
+ int dst_index,
+ int src_index,
+ int len) {
+ if (len == 0) return;
+
+ ASSERT(array->map() != HEAP->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++) {
+ // TODO(hpayer): check store buffer for entries
+ if (InNewSpace(dst_objects[i])) {
+ RecordWrite(array->address(), array->OffsetOfElementAt(dst_index +
i));
+ }
+ }
+ }
+ incremental_marking()->RecordWrites(array);
+}
#ifdef VERIFY_HEAP
=======================================
--- /branches/bleeding_edge/src/heap.h Wed Jan 9 02:30:54 2013
+++ /branches/bleeding_edge/src/heap.h Wed Jan 9 06:01:39 2013
@@ -813,6 +813,10 @@
// Please note this does not perform a garbage collection.
MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length);
+ // Move len elements within a given array from src_index index to
dst_index
+ // index.
+ void MoveElements(FixedArray* array, int dst_index, int src_index, int
len);
+
// Make a copy of src and return it. Returns
// Failure::RetryAfterGC(requested_bytes, space) if the allocation
failed.
MUST_USE_RESULT inline MaybeObject* CopyFixedArray(FixedArray* src);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev