Chromium Code Reviews| Index: src/builtins.cc |
| diff --git a/src/builtins.cc b/src/builtins.cc |
| index b48de7f2cd52378eb5e706e1951fba1031192c4f..79b3f3bf38bfc813a42f992fc72c8b348887a7b1 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->mark_compact_collector()->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->mark_compact_collector()->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 elemetns to the left |
|
Michael Starzinger
2014/03/24 12:21:35
nit: s/elemetns/elements/
Hannes Payer (out of office)
2014/03/25 11:41:08
Done.
|
| + // 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()) { |