Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index b48de7f2cd52378eb5e706e1951fba1031192c4f..3e97f7648a5f4c328011d4b564e9c35bad96ff34 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -610,7 +610,7 @@ BUILTIN(ArrayShift) { |
first = heap->undefined_value(); |
} |
- if (!heap->lo_space()->Contains(elms_obj)) { |
+ if (!heap->CanMoveObjectStart(elms_obj)) { |
array->set_elements(LeftTrimFixedArray(heap, elms_obj, 1)); |
} else { |
// Shift the elements. |
@@ -950,8 +950,23 @@ BUILTIN(ArraySplice) { |
heap->MoveElements(elms, delta, 0, actual_start); |
} |
- elms_obj = LeftTrimFixedArray(heap, elms_obj, delta); |
- |
+ if (heap->CanMoveObjectStart(elms_obj)) { |
+ // On the fast path we move the start of the object in memory. |
+ elms_obj = LeftTrimFixedArray(heap, elms_obj, delta); |
+ } else { |
+ // This is the slow path. We are going to move the elements to the left |
+ // by copying them. For trimmed values we store the hole. |
+ if (elms_obj->IsFixedDoubleArray()) { |
+ FixedDoubleArray* elms = FixedDoubleArray::cast(elms_obj); |
+ MoveDoubleElements(elms, 0, elms, delta, len - delta); |
+ FillWithHoles(elms, len - delta, len); |
+ } else { |
+ FixedArray* elms = FixedArray::cast(elms_obj); |
+ DisallowHeapAllocation no_gc; |
+ heap->MoveElements(elms, 0, delta, len - delta); |
+ FillWithHoles(heap, elms, len - delta, len); |
+ } |
+ } |
elms_changed = true; |
} else { |
if (elms_obj->IsFixedDoubleArray()) { |