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

Unified Diff: src/builtins.cc

Issue 1325483002: Adding ElementsAccessor::Pop (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-08-27_array_builtin_slice
Patch Set: Addressing comments Created 5 years, 4 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 | « no previous file | src/elements.h » ('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 4e30fb55f0f1d7ee5f9dd577069f041b7b8f78e5..e377b3374f778027dcb5e6d39c7a52c91092c842 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -209,7 +209,7 @@ inline bool GetSloppyArgumentsLength(Isolate* isolate, Handle<JSObject> object,
}
-bool PrototypeHasNoElements(PrototypeIterator* iter) {
+inline bool PrototypeHasNoElements(PrototypeIterator* iter) {
DisallowHeapAllocation no_gc;
for (; !iter->IsAtEnd(); iter->Advance()) {
if (iter->GetCurrent()->IsJSProxy()) return false;
@@ -386,13 +386,18 @@ BUILTIN(ArrayPop) {
return CallJsIntrinsic(isolate, isolate->array_pop(), args);
}
- uint32_t new_length = len - 1;
- Handle<Object> element;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, element, Object::GetElement(isolate, array, new_length));
-
- JSArray::SetLength(array, new_length);
- return *element;
+ Handle<Object> result;
+ if (IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) {
+ // Fast Elements Path
+ result = array->GetElementsAccessor()->Pop(array, elms_obj);
+ } else {
+ // Use Slow Lookup otherwise
+ uint32_t new_length = len - 1;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result, Object::GetElement(isolate, array, new_length));
+ JSArray::SetLength(array, new_length);
+ }
+ return *result;
}
« no previous file with comments | « no previous file | src/elements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698