OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 9571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9582 // Move contents of argument 0 (an array) to argument 1 (an array) | 9582 // Move contents of argument 0 (an array) to argument 1 (an array) |
9583 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 9583 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { |
9584 ASSERT(args.length() == 2); | 9584 ASSERT(args.length() == 2); |
9585 CONVERT_CHECKED(JSArray, from, args[0]); | 9585 CONVERT_CHECKED(JSArray, from, args[0]); |
9586 CONVERT_CHECKED(JSArray, to, args[1]); | 9586 CONVERT_CHECKED(JSArray, to, args[1]); |
9587 HeapObject* new_elements = from->elements(); | 9587 HeapObject* new_elements = from->elements(); |
9588 MaybeObject* maybe_new_map; | 9588 MaybeObject* maybe_new_map; |
9589 if (new_elements->map() == isolate->heap()->fixed_array_map() || | 9589 if (new_elements->map() == isolate->heap()->fixed_array_map() || |
9590 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { | 9590 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { |
9591 maybe_new_map = to->map()->GetFastElementsMap(); | 9591 maybe_new_map = to->map()->GetFastElementsMap(); |
| 9592 } else if (new_elements->map() == |
| 9593 isolate->heap()->fixed_double_array_map()) { |
| 9594 maybe_new_map = to->map()->GetFastDoubleElementsMap(); |
9592 } else { | 9595 } else { |
9593 maybe_new_map = to->map()->GetSlowElementsMap(); | 9596 maybe_new_map = to->map()->GetSlowElementsMap(); |
9594 } | 9597 } |
9595 Object* new_map; | 9598 Object* new_map; |
9596 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 9599 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
9597 to->set_map(Map::cast(new_map)); | 9600 to->set_map(Map::cast(new_map)); |
9598 to->set_elements(new_elements); | 9601 to->set_elements(new_elements); |
9599 to->set_length(from->length()); | 9602 to->set_length(from->length()); |
9600 Object* obj; | 9603 Object* obj; |
9601 { MaybeObject* maybe_obj = from->ResetElements(); | 9604 { MaybeObject* maybe_obj = from->ResetElements(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9669 for (int i = 0; i < keys_length; i++) { | 9672 for (int i = 0; i < keys_length; i++) { |
9670 Object* key = keys->get(i); | 9673 Object* key = keys->get(i); |
9671 uint32_t index = 0; | 9674 uint32_t index = 0; |
9672 if (!key->ToArrayIndex(&index) || index >= length) { | 9675 if (!key->ToArrayIndex(&index) || index >= length) { |
9673 // Zap invalid keys. | 9676 // Zap invalid keys. |
9674 keys->set_undefined(i); | 9677 keys->set_undefined(i); |
9675 } | 9678 } |
9676 } | 9679 } |
9677 return *isolate->factory()->NewJSArrayWithElements(keys); | 9680 return *isolate->factory()->NewJSArrayWithElements(keys); |
9678 } else { | 9681 } else { |
9679 ASSERT(array->HasFastElements()); | 9682 ASSERT(array->HasFastElements() || array->HasFastDoubleElements()); |
9680 Handle<FixedArray> single_interval = isolate->factory()->NewFixedArray(2); | 9683 Handle<FixedArray> single_interval = isolate->factory()->NewFixedArray(2); |
9681 // -1 means start of array. | 9684 // -1 means start of array. |
9682 single_interval->set(0, Smi::FromInt(-1)); | 9685 single_interval->set(0, Smi::FromInt(-1)); |
| 9686 FixedArrayBase* elements = FixedArrayBase::cast(array->elements()); |
9683 uint32_t actual_length = | 9687 uint32_t actual_length = |
9684 static_cast<uint32_t>(FixedArray::cast(array->elements())->length()); | 9688 static_cast<uint32_t>(elements->length()); |
9685 uint32_t min_length = actual_length < length ? actual_length : length; | 9689 uint32_t min_length = actual_length < length ? actual_length : length; |
9686 Handle<Object> length_object = | 9690 Handle<Object> length_object = |
9687 isolate->factory()->NewNumber(static_cast<double>(min_length)); | 9691 isolate->factory()->NewNumber(static_cast<double>(min_length)); |
9688 single_interval->set(1, *length_object); | 9692 single_interval->set(1, *length_object); |
9689 return *isolate->factory()->NewJSArrayWithElements(single_interval); | 9693 return *isolate->factory()->NewJSArrayWithElements(single_interval); |
9690 } | 9694 } |
9691 } | 9695 } |
9692 | 9696 |
9693 | 9697 |
9694 // DefineAccessor takes an optional final argument which is the | 9698 // DefineAccessor takes an optional final argument which is the |
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12762 } else { | 12766 } else { |
12763 // Handle last resort GC and make sure to allow future allocations | 12767 // Handle last resort GC and make sure to allow future allocations |
12764 // to grow the heap without causing GCs (if possible). | 12768 // to grow the heap without causing GCs (if possible). |
12765 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12769 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12766 isolate->heap()->CollectAllGarbage(false); | 12770 isolate->heap()->CollectAllGarbage(false); |
12767 } | 12771 } |
12768 } | 12772 } |
12769 | 12773 |
12770 | 12774 |
12771 } } // namespace v8::internal | 12775 } } // namespace v8::internal |
OLD | NEW |