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

Unified Diff: src/builtins.cc

Issue 200363002: Handlify callers of Object::GetElement. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 9 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/factory.cc » ('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 4e5fbd3f18a596bd6b2b6901458c104f162fd834..27efaeaa1c0e761f10d7cf7b503426cbdbaa0894 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -507,6 +507,17 @@ BUILTIN(ArrayPush) {
}
+static Handle<Object> ElementsAccessorSetLengthWrapper(
+ Isolate* isolate,
+ ElementsAccessor* accessor,
+ Handle<JSArray> array,
+ int new_length) {
+ CALL_HEAP_FUNCTION(isolate,
+ accessor->SetLength(*array, Smi::FromInt(new_length)),
+ Object);
+}
+
+
BUILTIN(ArrayPop) {
Heap* heap = isolate->heap();
Object* receiver = *args.receiver();
@@ -524,17 +535,26 @@ BUILTIN(ArrayPop) {
ElementsAccessor* accessor = array->GetElementsAccessor();
int new_length = len - 1;
- MaybeObject* maybe_result;
if (accessor->HasElement(array, array, new_length, elms_obj)) {
- maybe_result = accessor->Get(array, array, new_length, elms_obj);
+ MaybeObject* maybe_result =
+ accessor->Get(array, array, new_length, elms_obj);
+ if (maybe_result->IsFailure()) return maybe_result;
+ MaybeObject* maybe_failure =
+ accessor->SetLength(array, Smi::FromInt(new_length));
+ if (maybe_failure->IsFailure()) return maybe_failure;
+ return maybe_result;
} else {
- maybe_result = array->GetPrototype()->GetElement(isolate, len - 1);
+ // TODO(yangguo): handlify all once ElementsAccessors are handlified.
+ HandleScope scope(isolate);
+ Handle<Object> proto(array->GetPrototype(), isolate);
+ Handle<Object> element = Object::GetElement(isolate, proto, len - 1);
+ RETURN_IF_EMPTY_HANDLE(isolate, element);
+ Handle<JSArray> array_handle(array, isolate);
+ RETURN_IF_EMPTY_HANDLE(isolate,
+ ElementsAccessorSetLengthWrapper(
+ isolate, accessor, array_handle, new_length));
+ return *element;
}
- if (maybe_result->IsFailure()) return maybe_result;
- MaybeObject* maybe_failure =
- accessor->SetLength(array, Smi::FromInt(new_length));
- if (maybe_failure->IsFailure()) return maybe_failure;
- return maybe_result;
}
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698