| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 200                                FixedDoubleArray* src, | 200                                FixedDoubleArray* src, | 
| 201                                int src_index, | 201                                int src_index, | 
| 202                                int len) { | 202                                int len) { | 
| 203   if (len == 0) return; | 203   if (len == 0) return; | 
| 204   OS::MemMove(dst->data_start() + dst_index, | 204   OS::MemMove(dst->data_start() + dst_index, | 
| 205               src->data_start() + src_index, | 205               src->data_start() + src_index, | 
| 206               len * kDoubleSize); | 206               len * kDoubleSize); | 
| 207 } | 207 } | 
| 208 | 208 | 
| 209 | 209 | 
| 210 static void FillWithHoles(Heap* heap, FixedArray* dst, int from, int to) { |  | 
| 211   ASSERT(dst->map() != heap->fixed_cow_array_map()); |  | 
| 212   MemsetPointer(dst->data_start() + from, heap->the_hole_value(), to - from); |  | 
| 213 } |  | 
| 214 |  | 
| 215 |  | 
| 216 static void FillWithHoles(FixedDoubleArray* dst, int from, int to) { |  | 
| 217   for (int i = from; i < to; i++) { |  | 
| 218     dst->set_the_hole(i); |  | 
| 219   } |  | 
| 220 } |  | 
| 221 |  | 
| 222 |  | 
| 223 static FixedArrayBase* LeftTrimFixedArray(Heap* heap, | 210 static FixedArrayBase* LeftTrimFixedArray(Heap* heap, | 
| 224                                           FixedArrayBase* elms, | 211                                           FixedArrayBase* elms, | 
| 225                                           int to_trim) { | 212                                           int to_trim) { | 
| 226   Map* map = elms->map(); | 213   Map* map = elms->map(); | 
| 227   int entry_size; | 214   int entry_size; | 
| 228   if (elms->IsFixedArray()) { | 215   if (elms->IsFixedArray()) { | 
| 229     entry_size = kPointerSize; | 216     entry_size = kPointerSize; | 
| 230   } else { | 217   } else { | 
| 231     entry_size = kDoubleSize; | 218     entry_size = kDoubleSize; | 
| 232   } | 219   } | 
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 894       if (heap->CanMoveObjectStart(*elms_obj)) { | 881       if (heap->CanMoveObjectStart(*elms_obj)) { | 
| 895         // On the fast path we move the start of the object in memory. | 882         // On the fast path we move the start of the object in memory. | 
| 896         elms_obj = handle(LeftTrimFixedArray(heap, *elms_obj, delta)); | 883         elms_obj = handle(LeftTrimFixedArray(heap, *elms_obj, delta)); | 
| 897       } else { | 884       } else { | 
| 898         // This is the slow path. We are going to move the elements to the left | 885         // This is the slow path. We are going to move the elements to the left | 
| 899         // by copying them. For trimmed values we store the hole. | 886         // by copying them. For trimmed values we store the hole. | 
| 900         if (elms_obj->IsFixedDoubleArray()) { | 887         if (elms_obj->IsFixedDoubleArray()) { | 
| 901           Handle<FixedDoubleArray> elms = | 888           Handle<FixedDoubleArray> elms = | 
| 902               Handle<FixedDoubleArray>::cast(elms_obj); | 889               Handle<FixedDoubleArray>::cast(elms_obj); | 
| 903           MoveDoubleElements(*elms, 0, *elms, delta, len - delta); | 890           MoveDoubleElements(*elms, 0, *elms, delta, len - delta); | 
| 904           FillWithHoles(*elms, len - delta, len); | 891           elms->FillWithHoles(len - delta, len); | 
| 905         } else { | 892         } else { | 
| 906           Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); | 893           Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); | 
| 907           DisallowHeapAllocation no_gc; | 894           DisallowHeapAllocation no_gc; | 
| 908           heap->MoveElements(*elms, 0, delta, len - delta); | 895           heap->MoveElements(*elms, 0, delta, len - delta); | 
| 909           FillWithHoles(heap, *elms, len - delta, len); | 896           elms->FillWithHoles(len - delta, len); | 
| 910         } | 897         } | 
| 911       } | 898       } | 
| 912       elms_changed = true; | 899       elms_changed = true; | 
| 913     } else { | 900     } else { | 
| 914       if (elms_obj->IsFixedDoubleArray()) { | 901       if (elms_obj->IsFixedDoubleArray()) { | 
| 915         Handle<FixedDoubleArray> elms = | 902         Handle<FixedDoubleArray> elms = | 
| 916             Handle<FixedDoubleArray>::cast(elms_obj); | 903             Handle<FixedDoubleArray>::cast(elms_obj); | 
| 917         MoveDoubleElements(*elms, actual_start + item_count, | 904         MoveDoubleElements(*elms, actual_start + item_count, | 
| 918                            *elms, actual_start + actual_delete_count, | 905                            *elms, actual_start + actual_delete_count, | 
| 919                            (len - actual_delete_count - actual_start)); | 906                            (len - actual_delete_count - actual_start)); | 
| 920         FillWithHoles(*elms, new_length, len); | 907         elms->FillWithHoles(new_length, len); | 
| 921       } else { | 908       } else { | 
| 922         Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); | 909         Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); | 
| 923         DisallowHeapAllocation no_gc; | 910         DisallowHeapAllocation no_gc; | 
| 924         heap->MoveElements(*elms, actual_start + item_count, | 911         heap->MoveElements(*elms, actual_start + item_count, | 
| 925                            actual_start + actual_delete_count, | 912                            actual_start + actual_delete_count, | 
| 926                            (len - actual_delete_count - actual_start)); | 913                            (len - actual_delete_count - actual_start)); | 
| 927         FillWithHoles(heap, *elms, new_length, len); | 914         elms->FillWithHoles(new_length, len); | 
| 928       } | 915       } | 
| 929     } | 916     } | 
| 930   } else if (item_count > actual_delete_count) { | 917   } else if (item_count > actual_delete_count) { | 
| 931     Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); | 918     Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj); | 
| 932     // Currently fixed arrays cannot grow too big, so | 919     // Currently fixed arrays cannot grow too big, so | 
| 933     // we should never hit this case. | 920     // we should never hit this case. | 
| 934     ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len)); | 921     ASSERT((item_count - actual_delete_count) <= (Smi::kMaxValue - len)); | 
| 935 | 922 | 
| 936     // Check if array need to grow. | 923     // Check if array need to grow. | 
| 937     if (new_length > elms->length()) { | 924     if (new_length > elms->length()) { | 
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1735 } | 1722 } | 
| 1736 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1723 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 
| 1737 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1724 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 1738 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1725 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 
| 1739 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1726 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 1740 #undef DEFINE_BUILTIN_ACCESSOR_C | 1727 #undef DEFINE_BUILTIN_ACCESSOR_C | 
| 1741 #undef DEFINE_BUILTIN_ACCESSOR_A | 1728 #undef DEFINE_BUILTIN_ACCESSOR_A | 
| 1742 | 1729 | 
| 1743 | 1730 | 
| 1744 } }  // namespace v8::internal | 1731 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|