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 1325483002: Adding ElementsAccessor::Pop (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-08-27_array_builtin_slice
Patch Set: fixing holey pop 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') | src/elements.cc » ('J')
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..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;
}
« no previous file with comments | « no previous file | src/elements.h » ('j') | src/elements.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698