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

Unified Diff: src/builtins.cc

Issue 1689733002: Optimize @@species based on a global 'protector' cell (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove blank lines Created 4 years, 10 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 | « include/v8.h ('k') | src/heap/heap.h » ('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 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);
« no previous file with comments | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698