Reviewers: ulan,
Message:
PTAL
Description:
Remove LeftTrimFixedArray
Left trimming has been disabled in the GC since a while and elements.cc
is one of the few places left relying on this. Since CanMoveObjectStart
returns false by default now I am stripping away all the code relying on
it.
BUG=
Please review this at https://codereview.chromium.org/1305353010/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+5, -75 lines):
M src/elements.cc
M src/heap/heap.h
M src/heap/heap.cc
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index
32e6605ca2fbd04d07a80a387a825c6bec346482..c6d47d9a8df87c5640425bf27a9b529b98de2e12
100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1337,12 +1337,8 @@ class FastElementsAccessor
Handle<Object> result =
FastElementsAccessorSubclass::GetImpl(backing_store, 0);
Heap* heap = isolate->heap();
- if (heap->CanMoveObjectStart(*backing_store)) {
- receiver->set_elements(heap->LeftTrimFixedArray(*backing_store, 1));
- } else {
- FastElementsAccessorSubclass::MoveElements(heap, backing_store, 0, 1,
- new_length, 0, 0);
- }
+ FastElementsAccessorSubclass::MoveElements(heap, backing_store, 0, 1,
+ new_length, 0, 0);
FastElementsAccessorSubclass::SetLengthImpl(receiver, new_length,
backing_store);
@@ -1509,22 +1505,9 @@ class FastElementsAccessor
uint32_t len, uint32_t new_length) {
const int move_left_count = len - delete_count - start;
const int move_left_dst_index = start + add_count;
- const bool left_trim_array = heap->CanMoveObjectStart(*backing_store)
&&
- (move_left_dst_index < move_left_count);
- if (left_trim_array) {
- const int delta = delete_count - add_count;
- // shift from before the insertion point to the right
- FastElementsAccessorSubclass::MoveElements(heap, backing_store,
delta, 0,
- start, 0, 0);
- backing_store = handle(heap->LeftTrimFixedArray(*backing_store,
delta));
- return true;
- } else {
- // No left-trim needed or possible (in this case we left-move and
store
- // the hole)
- FastElementsAccessorSubclass::MoveElements(
- heap, backing_store, move_left_dst_index, start + delete_count,
- move_left_count, new_length, len);
- }
+ FastElementsAccessorSubclass::MoveElements(
+ heap, backing_store, move_left_dst_index, start + delete_count,
+ move_left_count, new_length, len);
return false;
}
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
a0858ee7c54a2c8a419a20f5e5ee9d498e9cfcb6..675a8cbac6ba509165796a4ea4a2dba803ce619a
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3487,55 +3487,6 @@ void Heap::AdjustLiveBytes(HeapObject* object, int
by, InvocationMode mode) {
}
-FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
- int elements_to_trim) {
- DCHECK(!object->IsFixedTypedArrayBase());
- const int element_size = object->IsFixedArray() ? kPointerSize :
kDoubleSize;
- const int bytes_to_trim = elements_to_trim * element_size;
- Map* map = object->map();
-
- // For now this trick is only applied to objects in new and paged space.
- // In large object space the object's start must coincide with chunk
- // and thus the trick is just not applicable.
- DCHECK(!lo_space()->Contains(object));
- DCHECK(object->map() != fixed_cow_array_map());
-
- STATIC_ASSERT(FixedArrayBase::kMapOffset == 0);
- STATIC_ASSERT(FixedArrayBase::kLengthOffset == kPointerSize);
- STATIC_ASSERT(FixedArrayBase::kHeaderSize == 2 * kPointerSize);
-
- const int len = object->length();
- DCHECK(elements_to_trim <= len);
-
- // Calculate location of new array start.
- Address new_start = object->address() + bytes_to_trim;
-
- // Technically in new space this write might be omitted (except for
- // debug mode which iterates through the heap), but to play safer
- // we still do it.
- CreateFillerObjectAt(object->address(), bytes_to_trim);
-
- // Initialize header of the trimmed array. Since left trimming is only
- // performed on pages which are not concurrently swept creating a filler
- // object does not require synchronization.
- DCHECK(CanMoveObjectStart(object));
- Object** former_start = HeapObject::RawField(object, 0);
- int new_start_index = elements_to_trim * (element_size / kPointerSize);
- former_start[new_start_index] = map;
- former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim);
- FixedArrayBase* new_object =
- FixedArrayBase::cast(HeapObject::FromAddress(new_start));
-
- // Maintain consistency of live bytes during incremental marking
- Marking::TransferMark(this, object->address(), new_start);
- AdjustLiveBytes(new_object, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER);
-
- // Notify the heap profiler of change in object layout.
- OnMoveEvent(new_object, object, new_object->Size());
- return new_object;
-}
-
-
// Force instantiation of templatized method.
template void Heap::RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(
FixedArrayBase*, int);
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
8e1e4f6104dc21c3c0993a69f91e640fd858dcbf..44b0a7204a803664d0a9e003dfad0114de40993a
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -822,10 +822,6 @@ class Heap {
// Maintain consistency of live bytes during incremental marking.
void AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode);
- // Trim the given array from the left. Note that this relocates the
object
- // start and hence is only valid if there is only a single reference to
it.
- FixedArrayBase* LeftTrimFixedArray(FixedArrayBase* obj, int
elements_to_trim);
-
// Trim the given array from the right.
template<Heap::InvocationMode mode>
void RightTrimFixedArray(FixedArrayBase* obj, int elements_to_trim);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.