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

Unified Diff: src/elements.cc

Issue 2162393002: [runtime] enable fast key accumulator by default (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove commented out code Created 4 years, 5 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/keys.cc » ('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 3cf8378162844a1fc00525e3ccacdb6f47406ac5..7f386125b75b1fe2a1217088dbf4d09ce3d3e788 100644
--- a/src/elements.cc
+++ b/src/elements.cc
@@ -982,19 +982,22 @@ class ElementsAccessorBase : public ElementsAccessor {
Isolate* isolate = object->GetIsolate();
uint32_t nof_property_keys = keys->length();
uint32_t initial_list_length =
- Subclass::GetCapacityImpl(*object, *backing_store);
+ Subclass::GetMaxNumberOfEntries(*object, *backing_store);
initial_list_length += nof_property_keys;
+ bool needs_sorting =
+ IsDictionaryElementsKind(kind()) || IsSloppyArgumentsElements(kind());
+
// Collect the element indices into a new list.
uint32_t nof_indices = 0;
Handle<FixedArray> combined_keys =
isolate->factory()->NewFixedArray(initial_list_length);
combined_keys = Subclass::DirectCollectElementIndicesImpl(
- isolate, object, backing_store, convert, filter, combined_keys,
- &nof_indices);
+ isolate, object, backing_store,
+ needs_sorting ? GetKeysConversion::kKeepNumbers : convert, filter,
+ combined_keys, &nof_indices);
- // Sort the indices list if necessary.
- if (IsDictionaryElementsKind(kind()) || IsSloppyArgumentsElements(kind())) {
+ if (needs_sorting) {
SortIndices(combined_keys, nof_indices, SKIP_WRITE_BARRIER);
uint32_t array_length = 0;
// Indices from dictionary elements should only be converted after
@@ -1021,7 +1024,9 @@ class ElementsAccessorBase : public ElementsAccessor {
CopyObjectToObjectElements(*keys, FAST_ELEMENTS, 0, *combined_keys,
FAST_ELEMENTS, nof_indices, nof_property_keys);
- if (IsHoleyElementsKind(kind())) {
+ // For holey elements and arguments we might have to shrink the collected
+ // keys since the estimates might be off.
+ if (IsHoleyElementsKind(kind()) || IsSloppyArgumentsElements(kind())) {
// Shrink combined_keys to the final size.
int final_size = nof_indices + nof_property_keys;
DCHECK_LE(final_size, combined_keys->length());
@@ -2305,6 +2310,14 @@ class SloppyArgumentsElementsAccessor
ArgumentsAccessor::GetCapacityImpl(holder, arguments);
}
+ static uint32_t GetMaxNumberOfEntries(JSObject* holder,
+ FixedArrayBase* backing_store) {
+ FixedArray* parameter_map = FixedArray::cast(backing_store);
+ FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1));
+ return parameter_map->length() - 2 +
+ ArgumentsAccessor::GetMaxNumberOfEntries(holder, arguments);
+ }
+
static void AddElementsToKeyAccumulatorImpl(Handle<JSObject> receiver,
KeyAccumulator* accumulator,
AddKeyConversion convert) {
« no previous file with comments | « no previous file | src/keys.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698