Commit 66e2f60b authored by adamk's avatar adamk Committed by Commit bot

Optimize add/set/delete operations for string keys in Maps and Sets

Review URL: https://codereview.chromium.org/773993002

Cr-Commit-Position: refs/heads/master@{#25668}
parent 44149ae7
......@@ -56,7 +56,7 @@ function SetAddJS(key) {
if (key === 0) {
key = 0;
}
return %SetAdd(this, key);
return %_SetAdd(this, key);
}
......@@ -74,7 +74,7 @@ function SetDeleteJS(key) {
throw MakeTypeError('incompatible_method_receiver',
['Set.prototype.delete', this]);
}
return %SetDelete(this, key);
return %_SetDelete(this, key);
}
......@@ -209,7 +209,7 @@ function MapSetJS(key, value) {
if (key === 0) {
key = 0;
}
return %MapSet(this, key, value);
return %_MapSet(this, key, value);
}
......@@ -227,7 +227,7 @@ function MapDeleteJS(key) {
throw MakeTypeError('incompatible_method_receiver',
['Map.prototype.delete', this]);
}
return %MapDelete(this, key);
return %_MapDelete(this, key);
}
......
......@@ -6356,6 +6356,13 @@ class HObjectAccess FINAL {
Representation::Smi());
}
template <typename CollectionType>
static HObjectAccess ForOrderedHashTableNumberOfDeletedElements() {
return HObjectAccess(kInobject,
CollectionType::kNumberOfDeletedElementsOffset,
Representation::Smi());
}
inline bool Equals(HObjectAccess that) const {
return value_ == that.value_; // portion and offset must match
}
......
This diff is collapsed.
......@@ -2417,14 +2417,26 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
ElementsKind fixed_elements_kind,
HValue* byte_length, HValue* length);
// TODO(adamk): Move all OrderedHashTable functions to their own class.
HValue* BuildOrderedHashTableHashToBucket(HValue* hash, HValue* num_buckets);
template <typename CollectionType>
HValue* BuildOrderedHashTableHashToEntry(HValue* table, HValue* hash,
HValue* num_buckets);
template <typename CollectionType>
HValue* BuildOrderedHashTableEntryToIndex(HValue* entry, HValue* num_buckets);
template <typename CollectionType>
HValue* BuildOrderedHashTableFindEntry(HValue* table, HValue* key,
HValue* hash);
template <typename CollectionType>
HValue* BuildOrderedHashTableAddEntry(HValue* table, HValue* key,
HValue* hash,
HIfContinuation* join_continuation);
template <typename CollectionType>
void BuildJSCollectionDelete(CallRuntime* call,
const Runtime::Function* c_function);
template <typename CollectionType>
void BuildJSCollectionHas(CallRuntime* call,
const Runtime::Function* c_function);
HValue* BuildStringHashLoadIfIsStringAndHashComputed(
HValue* object, HIfContinuation* continuation);
......
......@@ -3915,10 +3915,14 @@ class OrderedHashTable: public FixedArray {
kHeaderSize + kNumberOfBucketsIndex * kPointerSize;
static const int kNumberOfElementsOffset =
kHeaderSize + kNumberOfElementsIndex * kPointerSize;
static const int kNumberOfDeletedElementsOffset =
kHeaderSize + kNumberOfDeletedElementsIndex * kPointerSize;
static const int kEntrySize = entrysize + 1;
static const int kChainOffset = entrysize;
static const int kLoadFactor = 2;
private:
static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity);
......@@ -3963,7 +3967,6 @@ class OrderedHashTable: public FixedArray {
static const int kNextTableIndex = kNumberOfElementsIndex;
static const int kRemovedHolesIndex = kHashTableStartIndex;
static const int kLoadFactor = 2;
static const int kMaxCapacity =
(FixedArray::kMaxLength - kHashTableStartIndex)
/ (1 + (kEntrySize * kLoadFactor));
......
......@@ -303,8 +303,6 @@ namespace internal {
\
/* Harmony sets */ \
F(SetInitialize, 1, 1) \
F(SetAdd, 2, 1) \
F(SetDelete, 2, 1) \
F(SetClear, 1, 1) \
\
F(SetIteratorInitialize, 3, 1) \
......@@ -314,9 +312,7 @@ namespace internal {
\
/* Harmony maps */ \
F(MapInitialize, 1, 1) \
F(MapDelete, 2, 1) \
F(MapClear, 1, 1) \
F(MapSet, 3, 1) \
\
F(MapIteratorInitialize, 3, 1) \
F(MapIteratorClone, 1, 1) \
......@@ -728,9 +724,13 @@ namespace internal {
F(MathSqrtRT, 1, 1) \
F(MathLogRT, 1, 1) \
/* ES6 Collections */ \
F(MapDelete, 2, 1) \
F(MapGet, 2, 1) \
F(MapGetSize, 1, 1) \
F(MapHas, 2, 1) \
F(MapSet, 3, 1) \
F(SetAdd, 2, 1) \
F(SetDelete, 2, 1) \
F(SetGetSize, 1, 1) \
F(SetHas, 2, 1) \
/* Arrays */ \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment