| 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 508 |
| 509 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 509 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 510 ASSERT(!array->map()->is_observed()); | 510 ASSERT(!array->map()->is_observed()); |
| 511 | 511 |
| 512 int len = Smi::cast(array->length())->value(); | 512 int len = Smi::cast(array->length())->value(); |
| 513 if (len == 0) return isolate->heap()->undefined_value(); | 513 if (len == 0) return isolate->heap()->undefined_value(); |
| 514 | 514 |
| 515 ElementsAccessor* accessor = array->GetElementsAccessor(); | 515 ElementsAccessor* accessor = array->GetElementsAccessor(); |
| 516 int new_length = len - 1; | 516 int new_length = len - 1; |
| 517 Handle<Object> element; | 517 Handle<Object> element; |
| 518 if (accessor->HasElement(*array, *array, new_length, *elms_obj)) { | 518 if (accessor->HasElement(array, array, new_length, elms_obj)) { |
| 519 element = accessor->Get( | 519 element = accessor->Get( |
| 520 array, array, new_length, elms_obj); | 520 array, array, new_length, elms_obj); |
| 521 } else { | 521 } else { |
| 522 Handle<Object> proto(array->GetPrototype(), isolate); | 522 Handle<Object> proto(array->GetPrototype(), isolate); |
| 523 element = Object::GetElement(isolate, proto, len - 1); | 523 element = Object::GetElement(isolate, proto, len - 1); |
| 524 } | 524 } |
| 525 RETURN_IF_EMPTY_HANDLE(isolate, element); | 525 RETURN_IF_EMPTY_HANDLE(isolate, element); |
| 526 RETURN_IF_EMPTY_HANDLE(isolate, | 526 RETURN_IF_EMPTY_HANDLE(isolate, |
| 527 accessor->SetLength( | 527 accessor->SetLength( |
| 528 array, handle(Smi::FromInt(new_length), isolate))); | 528 array, handle(Smi::FromInt(new_length), isolate))); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 | 749 |
| 750 Handle<JSObject> object = Handle<JSObject>::cast(receiver); | 750 Handle<JSObject> object = Handle<JSObject>::cast(receiver); |
| 751 Handle<FixedArrayBase> elms(object->elements(), isolate); | 751 Handle<FixedArrayBase> elms(object->elements(), isolate); |
| 752 | 752 |
| 753 ElementsKind kind = object->GetElementsKind(); | 753 ElementsKind kind = object->GetElementsKind(); |
| 754 if (IsHoleyElementsKind(kind)) { | 754 if (IsHoleyElementsKind(kind)) { |
| 755 DisallowHeapAllocation no_gc; | 755 DisallowHeapAllocation no_gc; |
| 756 bool packed = true; | 756 bool packed = true; |
| 757 ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); | 757 ElementsAccessor* accessor = ElementsAccessor::ForKind(kind); |
| 758 for (int i = k; i < final; i++) { | 758 for (int i = k; i < final; i++) { |
| 759 if (!accessor->HasElement(*object, *object, i, *elms)) { | 759 if (!accessor->HasElement(object, object, i, elms)) { |
| 760 packed = false; | 760 packed = false; |
| 761 break; | 761 break; |
| 762 } | 762 } |
| 763 } | 763 } |
| 764 if (packed) { | 764 if (packed) { |
| 765 kind = GetPackedElementsKind(kind); | 765 kind = GetPackedElementsKind(kind); |
| 766 } else if (!receiver->IsJSArray()) { | 766 } else if (!receiver->IsJSArray()) { |
| 767 AllowHeapAllocation allow_allocation; | 767 AllowHeapAllocation allow_allocation; |
| 768 return CallJsBuiltin(isolate, "ArraySlice", args); | 768 return CallJsBuiltin(isolate, "ArraySlice", args); |
| 769 } | 769 } |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 } | 1744 } |
| 1745 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1745 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 1746 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1746 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1747 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1747 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 1748 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1748 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1749 #undef DEFINE_BUILTIN_ACCESSOR_C | 1749 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 1750 #undef DEFINE_BUILTIN_ACCESSOR_A | 1750 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 1751 | 1751 |
| 1752 | 1752 |
| 1753 } } // namespace v8::internal | 1753 } } // namespace v8::internal |
| OLD | NEW |