| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 438 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 439 DCHECK(!array->map()->is_observed()); | 439 DCHECK(!array->map()->is_observed()); |
| 440 | 440 |
| 441 uint32_t len = static_cast<uint32_t>(Smi::cast(array->length())->value()); | 441 uint32_t len = static_cast<uint32_t>(Smi::cast(array->length())->value()); |
| 442 if (len == 0) return isolate->heap()->undefined_value(); | 442 if (len == 0) return isolate->heap()->undefined_value(); |
| 443 | 443 |
| 444 if (JSArray::HasReadOnlyLength(array)) { | 444 if (JSArray::HasReadOnlyLength(array)) { |
| 445 return CallJsBuiltin(isolate, "$arrayPop", args); | 445 return CallJsBuiltin(isolate, "$arrayPop", args); |
| 446 } | 446 } |
| 447 | 447 |
| 448 ElementsAccessor* accessor = array->GetElementsAccessor(); | |
| 449 uint32_t new_length = len - 1; | 448 uint32_t new_length = len - 1; |
| 450 Handle<Object> element; | 449 Handle<Object> element; |
| 451 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 450 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 452 isolate, element, Object::GetElement(isolate, array, new_length)); | 451 isolate, element, Object::GetElement(isolate, array, new_length)); |
| 453 | 452 |
| 454 RETURN_FAILURE_ON_EXCEPTION( | 453 JSArray::SetLength(array, new_length); |
| 455 isolate, | |
| 456 accessor->SetLength(array, handle(Smi::FromInt(new_length), isolate))); | |
| 457 return *element; | 454 return *element; |
| 458 } | 455 } |
| 459 | 456 |
| 460 | 457 |
| 461 BUILTIN(ArrayShift) { | 458 BUILTIN(ArrayShift) { |
| 462 HandleScope scope(isolate); | 459 HandleScope scope(isolate); |
| 463 Heap* heap = isolate->heap(); | 460 Heap* heap = isolate->heap(); |
| 464 Handle<Object> receiver = args.receiver(); | 461 Handle<Object> receiver = args.receiver(); |
| 465 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 462 MaybeHandle<FixedArrayBase> maybe_elms_obj = |
| 466 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); | 463 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); |
| (...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1651 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 1655 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1652 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1656 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 1653 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 1657 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1654 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1658 #undef DEFINE_BUILTIN_ACCESSOR_C | 1655 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 1659 #undef DEFINE_BUILTIN_ACCESSOR_A | 1656 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 1660 | 1657 |
| 1661 | 1658 |
| 1662 } // namespace internal | 1659 } // namespace internal |
| 1663 } // namespace v8 | 1660 } // namespace v8 |
| OLD | NEW |