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

Unified Diff: src/builtins.cc

Issue 1159433003: Use GetProperty for getting elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/array.js ('k') | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 26c0b210feaa5fbcea9759f546a50fd027526217..ee34cdc360bbf08aebe661b61c1124bc9e97944f 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -438,7 +438,7 @@ BUILTIN(ArrayPop) {
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
DCHECK(!array->map()->is_observed());
- int len = Smi::cast(array->length())->value();
+ uint32_t len = static_cast<uint32_t>(Smi::cast(array->length())->value());
if (len == 0) return isolate->heap()->undefined_value();
if (JSArray::HasReadOnlyLength(array)) {
@@ -446,12 +446,11 @@ BUILTIN(ArrayPop) {
}
ElementsAccessor* accessor = array->GetElementsAccessor();
- int new_length = len - 1;
- Handle<Object> element =
- accessor->Get(array, array, new_length, elms_obj).ToHandleChecked();
- if (element->IsTheHole()) {
- return CallJsBuiltin(isolate, "$arrayPop", args);
- }
+ uint32_t new_length = len - 1;
+ Handle<Object> element;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, element, Object::GetElement(isolate, array, new_length));
+
RETURN_FAILURE_ON_EXCEPTION(
isolate,
accessor->SetLength(array, handle(Smi::FromInt(new_length), isolate)));
@@ -481,12 +480,9 @@ BUILTIN(ArrayShift) {
}
// Get first element
- ElementsAccessor* accessor = array->GetElementsAccessor();
- Handle<Object> first =
- accessor->Get(array, array, 0, elms_obj).ToHandleChecked();
- if (first->IsTheHole()) {
- return CallJsBuiltin(isolate, "$arrayShift", args);
- }
+ Handle<Object> first;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, first,
+ Object::GetElement(isolate, array, 0));
if (heap->CanMoveObjectStart(*elms_obj)) {
array->set_elements(heap->LeftTrimFixedArray(*elms_obj, 1));
« no previous file with comments | « src/array.js ('k') | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698