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

Unified Diff: src/builtins.cc

Issue 1560763002: Add Array support for @@species and subclassing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Last couple comments Created 4 years, 11 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/js/array.js » ('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 f89a5bc2b15d136d004bc32ac6d7024d2b4e3067..59d04f886107e42b6b31f768def44f673581ab34 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -458,6 +458,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);
@@ -543,6 +551,14 @@ BUILTIN(ArraySplice) {
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()) {
+ return CallJsIntrinsic(isolate, isolate->array_splice(), args);
+ }
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
DCHECK(!array->map()->is_observed());
« no previous file with comments | « no previous file | src/js/array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698