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

Unified Diff: src/elements.cc

Issue 1778023004: [runtime] fix getting element keys from SLOW_SLOPPY_ARGUMENTS_ELEMENTS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix another issue with FastSloppyArgumentsElements Created 4 years, 9 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 | test/mjsunit/regress/regress-4825.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 742942b844c718e04f0956799c61acf5df7fa50d..2ec224c23efd64dc20742affd427db546a8e3092 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -866,10 +866,10 @@ class ElementsAccessorBase : public ElementsAccessor {
static Handle<FixedArray> DirectCollectElementIndicesImpl(
Isolate* isolate, Handle<JSObject> object,
Handle<FixedArrayBase> backing_store, GetKeysConversion convert,
- PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices) {
+ PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices,
+ uint32_t insertion_index = 0) {
uint32_t length =
ElementsAccessorSubclass::GetIterationLength(*object, *backing_store);
- uint32_t insertion_index = 0;
for (uint32_t i = 0; i < length; i++) {
if (ElementsAccessorSubclass::HasElementImpl(object, i, backing_store,
filter)) {
@@ -914,7 +914,7 @@ class ElementsAccessorBase : public ElementsAccessor {
&nof_indices);
// Sort the indices list if necessary.
- if (IsDictionaryElementsKind(kind())) {
+ if (IsDictionaryElementsKind(kind()) || IsSloppyArgumentsElements(kind())) {
struct {
bool operator()(Object* a, Object* b) {
if (!a->IsUndefined()) {
@@ -1227,11 +1227,11 @@ class DictionaryElementsAccessor
static Handle<FixedArray> DirectCollectElementIndicesImpl(
Isolate* isolate, Handle<JSObject> object,
Handle<FixedArrayBase> backing_store, GetKeysConversion convert,
- PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices) {
+ PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices,
+ uint32_t insertion_index = 0) {
Handle<SeededNumberDictionary> dictionary =
Handle<SeededNumberDictionary>::cast(backing_store);
uint32_t capacity = dictionary->Capacity();
- uint32_t insertion_index = 0;
for (uint32_t i = 0; i < capacity; i++) {
uint32_t key = GetKeyForEntryImpl(dictionary, i, filter);
if (key == kMaxUInt32) continue;
@@ -2223,6 +2223,55 @@ class SloppyArgumentsElementsAccessor
obj, entry - length);
}
}
+
+ static void CollectElementIndicesImpl(Handle<JSObject> object,
+ Handle<FixedArrayBase> backing_store,
+ KeyAccumulator* keys, uint32_t range,
+ PropertyFilter filter,
+ uint32_t offset) {
+ FixedArray* parameter_map = FixedArray::cast(*backing_store);
+ uint32_t length = parameter_map->length() - 2;
+ if (range < length) length = range;
+
+ for (uint32_t i = offset; i < length; ++i) {
+ if (!parameter_map->get(i + 2)->IsTheHole()) {
+ keys->AddKey(i);
+ }
+ }
+
+ Handle<FixedArrayBase> store(FixedArrayBase::cast(parameter_map->get(1)));
+ ArgumentsAccessor::CollectElementIndicesImpl(object, store, keys, range,
+ filter, offset);
+ if (SloppyArgumentsElementsAccessorSubclass::kind() ==
+ FAST_SLOPPY_ARGUMENTS_ELEMENTS) {
+ keys->SortCurrentElementsList();
+ }
+ }
+
+ static Handle<FixedArray> DirectCollectElementIndicesImpl(
+ Isolate* isolate, Handle<JSObject> object,
+ Handle<FixedArrayBase> backing_store, GetKeysConversion convert,
+ PropertyFilter filter, Handle<FixedArray> list, uint32_t* nof_indices,
+ uint32_t insertion_index = 0) {
+ FixedArray* parameter_map = FixedArray::cast(*backing_store);
+ uint32_t length = parameter_map->length() - 2;
+
+ for (uint32_t i = 0; i < length; ++i) {
+ if (parameter_map->get(i + 2)->IsTheHole()) continue;
+ if (convert == CONVERT_TO_STRING) {
+ Handle<String> index_string = isolate->factory()->Uint32ToString(i);
+ list->set(insertion_index, *index_string);
+ } else {
+ list->set(insertion_index, Smi::FromInt(i), SKIP_WRITE_BARRIER);
+ }
+ insertion_index++;
+ }
+
+ Handle<FixedArrayBase> store(FixedArrayBase::cast(parameter_map->get(1)));
+ return ArgumentsAccessor::DirectCollectElementIndicesImpl(
+ isolate, object, store, convert, filter, list, nof_indices,
+ insertion_index);
+ }
};
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-4825.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698