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

Unified Diff: src/elements.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 | « src/builtins.cc ('k') | test/mjsunit/array-slice.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/elements.cc
diff --git a/src/elements.cc b/src/elements.cc
index 3d176aef8033433615fa428fd6298533ac8bf34b..7afa08f8723142ba5936c48ef23220611e42b9eb 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -1453,7 +1453,8 @@ class FastElementsAccessor
}
if (entry == 0) {
FixedArray* empty = heap->empty_fixed_array();
- if (obj->HasFastArgumentsElements()) {
+ if (FastElementsAccessorSubclass::kind() ==
+ FAST_SLOPPY_ARGUMENTS_ELEMENTS) {
FixedArray::cast(obj->elements())->set(1, empty);
} else {
obj->set_elements(empty);
@@ -2568,16 +2569,45 @@ class FastSloppyArgumentsElementsAccessor
FastHoleyObjectElementsAccessor,
ElementsKindTraits<FAST_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {}
+ static Handle<FixedArray> GetArguments(Isolate* isolate,
+ FixedArrayBase* backing_store) {
+ FixedArray* parameter_map = FixedArray::cast(backing_store);
+ return Handle<FixedArray>(FixedArray::cast(parameter_map->get(1)), isolate);
+ }
+
+ static Handle<JSArray> SliceImpl(Handle<JSObject> receiver, uint32_t start,
+ uint32_t end) {
+ Isolate* isolate = receiver->GetIsolate();
+ uint32_t result_len = end < start ? 0u : end - start;
+ Handle<JSArray> result_array = isolate->factory()->NewJSArray(
+ FAST_HOLEY_ELEMENTS, result_len, result_len);
+ DisallowHeapAllocation no_gc;
+ FixedArray* elements = FixedArray::cast(result_array->elements());
+ FixedArray* parameters = FixedArray::cast(receiver->elements());
+ uint32_t insertion_index = 0;
+ for (uint32_t i = start; i < end; i++) {
+ uint32_t entry =
+ GetEntryForIndexImpl(*receiver, parameters, i, ALL_PROPERTIES);
+ if (entry != kMaxUInt32 && HasEntryImpl(parameters, entry)) {
+ elements->set(insertion_index, *GetImpl(parameters, entry));
+ } else {
+ elements->set_the_hole(insertion_index);
+ }
+ insertion_index++;
+ }
+ return result_array;
+ }
+
static Handle<SeededNumberDictionary> NormalizeImpl(
Handle<JSObject> object, Handle<FixedArrayBase> elements) {
- FixedArray* parameter_map = FixedArray::cast(*elements);
- Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
+ Handle<FixedArray> arguments =
+ GetArguments(elements->GetIsolate(), *elements);
return FastHoleyObjectElementsAccessor::NormalizeImpl(object, arguments);
}
static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) {
- FixedArray* parameter_map = FixedArray::cast(obj->elements());
- Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
+ Handle<FixedArray> arguments =
+ GetArguments(obj->GetIsolate(), obj->elements());
FastHoleyObjectElementsAccessor::DeleteCommon(obj, entry, arguments);
}
« no previous file with comments | « src/builtins.cc ('k') | test/mjsunit/array-slice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698