Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index f906b50aa8b037b9ec6215487fbc290938417209..fe062007fc3f69b807821196ec2fdfc53c944270 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -483,19 +483,14 @@ BUILTIN(ArraySlice) { |
int relative_end = 0; |
bool is_sloppy_arguments = false; |
- // TODO(littledan): Look up @@species only once, not once here and |
- // again in the JS builtin. Pass the species out? |
- Handle<Object> species; |
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
- isolate, species, Object::ArraySpeciesConstructor(isolate, receiver)); |
- if (*species != isolate->context()->native_context()->array_function()) { |
- return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
- } |
if (receiver->IsJSArray()) { |
DisallowHeapAllocation no_gc; |
JSArray* array = JSArray::cast(*receiver); |
if (!array->HasFastElements() || |
- !IsJSArrayFastElementMovingAllowed(isolate, array)) { |
+ !IsJSArrayFastElementMovingAllowed(isolate, array) || |
+ !isolate->IsArraySpeciesLookupChainIntact() || |
+ // If this is a subclass of Array, then call out to JS |
+ !array->map()->new_target_is_base()) { |
AllowHeapAllocation allow_allocation; |
return CallJsIntrinsic(isolate, isolate->array_slice(), args); |
} |
@@ -573,15 +568,11 @@ BUILTIN(ArraySplice) { |
MaybeHandle<FixedArrayBase> maybe_elms_obj = |
EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3); |
Handle<FixedArrayBase> elms_obj; |
- if (!maybe_elms_obj.ToHandle(&elms_obj)) { |
- return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
- } |
- // TODO(littledan): Look up @@species only once, not once here and |
- // again in the JS builtin. Pass the species out? |
- Handle<Object> species; |
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
- isolate, species, Object::ArraySpeciesConstructor(isolate, receiver)); |
- if (*species != isolate->context()->native_context()->array_function()) { |
+ if (!maybe_elms_obj.ToHandle(&elms_obj) || |
+ // If this is a subclass of Array, then call out to JS |
+ !JSArray::cast(*receiver)->map()->new_target_is_base() || |
+ // If anything with @@species has been messed with, call out to JS |
+ !isolate->IsArraySpeciesLookupChainIntact()) { |
return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
} |
Handle<JSArray> array = Handle<JSArray>::cast(receiver); |