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

Unified Diff: src/builtins.cc

Issue 247613002: Micro-optimizations to pop() and shift() (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | no next file » | 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 d74741e0a4f233b0f37535c7e308196b8dffc8a4..c25430cc0ee0fd900f84b6d3821925335fc211cc 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -302,8 +302,8 @@ static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>();
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
// If there may be elements accessors in the prototype chain, the fast path
- // cannot be used.
- if (array->map()->DictionaryElementsInPrototypeChainOnly()) {
+ // cannot be used if there arguments to add to the array.
+ if (args != NULL && array->map()->DictionaryElementsInPrototypeChainOnly()) {
return MaybeHandle<FixedArrayBase>();
}
if (array->map()->is_observed()) return MaybeHandle<FixedArrayBase>();
@@ -520,15 +520,11 @@ BUILTIN(ArrayPop) {
ElementsAccessor* accessor = array->GetElementsAccessor();
int new_length = len - 1;
- MaybeHandle<Object> maybe_element;
- if (accessor->HasElement(array, array, new_length, elms_obj)) {
- maybe_element = accessor->Get(array, array, new_length, elms_obj);
- } else {
- Handle<Object> proto(array->GetPrototype(), isolate);
- maybe_element = Object::GetElement(isolate, proto, len - 1);
+ Handle<Object> element =
+ accessor->Get(array, array, new_length, elms_obj).ToHandleChecked();
+ if (element->IsTheHole()) {
+ return CallJsBuiltin(isolate, "ArrayPop", args);
}
- Handle<Object> element;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, element, maybe_element);
RETURN_IF_EMPTY_HANDLE(
isolate,
accessor->SetLength(array, handle(Smi::FromInt(new_length), isolate)));
@@ -556,11 +552,10 @@ BUILTIN(ArrayShift) {
// Get first element
ElementsAccessor* accessor = array->GetElementsAccessor();
- Handle<Object> first;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, first, accessor->Get(receiver, array, 0, elms_obj));
+ Handle<Object> first =
+ accessor->Get(array, array, 0, elms_obj).ToHandleChecked();
if (first->IsTheHole()) {
- first = isolate->factory()->undefined_value();
+ return CallJsBuiltin(isolate, "ArrayShift", args);
}
if (heap->CanMoveObjectStart(*elms_obj)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698