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

Unified Diff: src/builtins.cc

Issue 1834613003: [elements] add fast-path for slice with FastSloppyArguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: typo Created 4 years, 8 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/elements.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 347b428d5c250d00d8d3f3f096fdb84d42926536..2cb65a1588e138dbf387d85891973cc3899735b4 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -207,9 +207,14 @@ inline bool ClampedToInteger(Object* object, int* out) {
inline bool GetSloppyArgumentsLength(Isolate* isolate, Handle<JSObject> object,
int* out) {
- Map* arguments_map = isolate->native_context()->sloppy_arguments_map();
- if (object->map() != arguments_map) return false;
- DCHECK(object->HasFastElements());
+ Context* context = *isolate->native_context();
+ Map* map = object->map();
+ if (map != context->sloppy_arguments_map() &&
+ map != context->strict_arguments_map() &&
+ map != context->fast_aliased_arguments_map()) {
+ return false;
+ }
+ DCHECK(object->HasFastElements() || object->HasFastArgumentsElements());
Object* len_obj = object->InObjectPropertyAt(JSArgumentsObject::kLengthIndex);
if (!len_obj->IsSmi()) return false;
*out = Max(0, Smi::cast(len_obj)->value());
@@ -670,10 +675,11 @@ BUILTIN(ArraySlice) {
} else if (receiver->IsJSObject() &&
GetSloppyArgumentsLength(isolate, Handle<JSObject>::cast(receiver),
&len)) {
- DCHECK_EQ(FAST_ELEMENTS, JSObject::cast(*receiver)->GetElementsKind());
- // Array.prototype.slice(arguments, ...) is quite a common idiom
+ // Array.prototype.slice.call(arguments, ...) is quite a common idiom
// (notably more than 50% of invocations in Web apps).
// Treat it in C++ as well.
+ DCHECK(JSObject::cast(*receiver)->HasFastElements() ||
+ JSObject::cast(*receiver)->HasFastArgumentsElements());
} else {
AllowHeapAllocation allow_allocation;
return CallJsIntrinsic(isolate, isolate->array_slice(), args);
« no previous file with comments | « no previous file | src/elements.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698