Commit 243764b0 authored by adamk's avatar adamk Committed by Commit bot

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

This was previously landed in commit 8599f5f0, but failed the
collections mjsunit test on ia32 with --deopt-every-n=1. The fixed
patch adds a ClearFlag(HValue::kCanOverflow) call after every
arithmetic operation, which should remove all the deopt points in these
intrinsics.

Ideally, it seems like there should be a way to verify that there are
no deopt points for these inline optimized functions, since there's
nothing to deopt to. But I don't currently know of such a thing.

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

Cr-Commit-Position: refs/heads/master@{#25715}
parent b4f32507
......@@ -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);
}
......
......@@ -6360,6 +6360,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);
......
......@@ -3920,10 +3920,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);
......@@ -3968,7 +3972,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));
......
......@@ -301,8 +301,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) \
......@@ -312,9 +310,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) \
......@@ -726,9 +722,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