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

Unified Diff: src/builtins.cc

Issue 223743003: Maybehandlification of EnsureJSArrayWithWritableFastElements(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes 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 | 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 ed5cf0353c2b2bcf31e3ae241db8b1f4704bc407..1c6c0429ba5c61cade91b52df92892b0e1dd074f 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -294,15 +294,15 @@ static bool ArrayPrototypeHasNoElements(Heap* heap,
// Returns empty handle if not applicable.
MUST_USE_RESULT
-static inline Handle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
+static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
Isolate* isolate,
Handle<Object> receiver,
Arguments* args,
int first_added_arg) {
- if (!receiver->IsJSArray()) return Handle<FixedArrayBase>::null();
+ if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>();
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
- if (array->map()->is_observed()) return Handle<FixedArrayBase>::null();
- if (!array->map()->is_extensible()) return Handle<FixedArrayBase>::null();
+ if (array->map()->is_observed()) return MaybeHandle<FixedArrayBase>();
+ if (!array->map()->is_extensible()) return MaybeHandle<FixedArrayBase>();
Handle<FixedArrayBase> elms(array->elements(), isolate);
Heap* heap = isolate->heap();
Map* map = elms->map();
@@ -314,7 +314,7 @@ static inline Handle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
} else if (map == heap->fixed_double_array_map()) {
if (args == NULL) return elms;
} else {
- return Handle<FixedArrayBase>::null();
+ return MaybeHandle<FixedArrayBase>();
}
// Need to ensure that the arguments passed in args can be contained in
@@ -391,9 +391,12 @@ MUST_USE_RESULT static MaybeObject* CallJsBuiltin(
BUILTIN(ArrayPush) {
HandleScope scope(isolate);
Handle<Object> receiver = args.receiver();
- Handle<FixedArrayBase> elms_obj =
+ MaybeHandle<FixedArrayBase> maybe_elms_obj =
EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1);
- if (elms_obj.is_null()) return CallJsBuiltin(isolate, "ArrayPush", args);
+ Handle<FixedArrayBase> elms_obj;
+ if (!maybe_elms_obj.ToHandle(&elms_obj)) {
+ return CallJsBuiltin(isolate, "ArrayPush", args);
+ }
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
ASSERT(!array->map()->is_observed());
@@ -496,9 +499,12 @@ BUILTIN(ArrayPush) {
BUILTIN(ArrayPop) {
HandleScope scope(isolate);
Handle<Object> receiver = args.receiver();
- Handle<FixedArrayBase> elms_obj =
+ MaybeHandle<FixedArrayBase> maybe_elms_obj =
EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0);
- if (elms_obj.is_null()) return CallJsBuiltin(isolate, "ArrayPop", args);
+ Handle<FixedArrayBase> elms_obj;
+ if (!maybe_elms_obj.ToHandle(&elms_obj)) {
+ return CallJsBuiltin(isolate, "ArrayPop", args);
+ }
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
ASSERT(!array->map()->is_observed());
@@ -528,9 +534,10 @@ BUILTIN(ArrayShift) {
HandleScope scope(isolate);
Heap* heap = isolate->heap();
Handle<Object> receiver = args.receiver();
- Handle<FixedArrayBase> elms_obj =
+ MaybeHandle<FixedArrayBase> maybe_elms_obj =
EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0);
- if (elms_obj.is_null() ||
+ Handle<FixedArrayBase> elms_obj;
+ if (!maybe_elms_obj.ToHandle(&elms_obj) ||
!IsJSArrayFastElementMovingAllowed(heap,
*Handle<JSArray>::cast(receiver))) {
return CallJsBuiltin(isolate, "ArrayShift", args);
@@ -576,9 +583,10 @@ BUILTIN(ArrayUnshift) {
HandleScope scope(isolate);
Heap* heap = isolate->heap();
Handle<Object> receiver = args.receiver();
- Handle<FixedArrayBase> elms_obj =
+ MaybeHandle<FixedArrayBase> maybe_elms_obj =
EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0);
- if (elms_obj.is_null() ||
+ Handle<FixedArrayBase> elms_obj;
+ if (!maybe_elms_obj.ToHandle(&elms_obj) ||
!IsJSArrayFastElementMovingAllowed(heap,
*Handle<JSArray>::cast(receiver))) {
return CallJsBuiltin(isolate, "ArrayUnshift", args);
@@ -778,9 +786,10 @@ BUILTIN(ArraySplice) {
HandleScope scope(isolate);
Heap* heap = isolate->heap();
Handle<Object> receiver = args.receiver();
- Handle<FixedArrayBase> elms_obj =
+ MaybeHandle<FixedArrayBase> maybe_elms_obj =
EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3);
- if (elms_obj.is_null() ||
+ Handle<FixedArrayBase> elms_obj;
+ if (!maybe_elms_obj.ToHandle(&elms_obj) ||
!IsJSArrayFastElementMovingAllowed(heap,
*Handle<JSArray>::cast(receiver))) {
return CallJsBuiltin(isolate, "ArraySplice", args);
« 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