Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/builtins.cc

Issue 1191313003: More cleanup related to setting array.length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ast.cc ('k') | src/elements.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/elements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698