Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index 4e30fb55f0f1d7ee5f9dd577069f041b7b8f78e5..d50d6d7157f9b34bd0d3b01efd036fbd038b60b9 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,21 @@ 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))) { |
Camillo Bruni
2015/08/31 07:45:50
Using this separate branch I gain roughly 50% spee
|
+ // Fast Elements Path |
+ result = array->GetElementsAccessor()->Pop(array, elms_obj); |
+ if (result->IsTheHole()) { |
Igor Sheludko
2015/08/31 14:08:03
I think hole handling should be in elements.cc and
Camillo Bruni
2015/08/31 14:41:35
Makes sense.
|
+ result = isolate->factory()->undefined_value(); |
Camillo Bruni
2015/08/28 14:08:11
I am not fully convinced about this branch myself.
|
+ } |
+ } 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; |
} |