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; |
} |