[CSA][cleanup] TNodify builtins collections gen (pt. 1)
TNodified several methods, such as the ones regarding CollectionType. Eliminated unneeded Context parameters Removed Sloppy-ness from TNodes. Bug: v8:6949, v8:9396 Change-Id: Ib4c7643957629b651aa39051f89a90bc70e215c9 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1803335 Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Cr-Commit-Position: refs/heads/master@{#63763}
This commit is contained in:
parent
b7cb606654
commit
f8e4b23adb
@ -79,8 +79,8 @@ class BaseCollectionsAssembler : public CodeStubAssembler {
|
||||
TNode<JSReceiver> new_target);
|
||||
|
||||
// Allocates the backing store for a collection.
|
||||
virtual TNode<Object> AllocateTable(Variant variant, TNode<Context> context,
|
||||
TNode<IntPtrT> at_least_space_for) = 0;
|
||||
virtual TNode<HeapObject> AllocateTable(
|
||||
Variant variant, TNode<IntPtrT> at_least_space_for) = 0;
|
||||
|
||||
// Main entry point for a collection constructor builtin.
|
||||
void GenerateConstructor(Variant variant,
|
||||
@ -122,7 +122,7 @@ class BaseCollectionsAssembler : public CodeStubAssembler {
|
||||
TNode<IntPtrT> EstimatedInitialSize(TNode<Object> initial_entries,
|
||||
TNode<BoolT> is_fast_jsarray);
|
||||
|
||||
void GotoIfNotJSReceiver(Node* const obj, Label* if_not_receiver);
|
||||
void GotoIfNotJSReceiver(TNode<Object> const obj, Label* if_not_receiver);
|
||||
|
||||
// Determines whether the collection's prototype has been modified.
|
||||
TNode<BoolT> HasInitialCollectionPrototype(Variant variant,
|
||||
@ -158,8 +158,8 @@ void BaseCollectionsAssembler::AddConstructorEntry(
|
||||
? LoadKeyValuePairNoSideEffects(context, key_value,
|
||||
if_may_have_side_effects)
|
||||
: LoadKeyValuePair(context, key_value);
|
||||
Node* key_n = pair.key;
|
||||
Node* value_n = pair.value;
|
||||
TNode<Object> key_n = pair.key;
|
||||
TNode<Object> value_n = pair.value;
|
||||
CallJS(CodeFactory::Call(isolate()), context, add_function, collection,
|
||||
key_n, value_n);
|
||||
} else {
|
||||
@ -181,7 +181,7 @@ void BaseCollectionsAssembler::AddConstructorEntries(
|
||||
Goto(&allocate_table);
|
||||
BIND(&allocate_table);
|
||||
{
|
||||
TNode<Object> table = AllocateTable(variant, context, at_least_space_for);
|
||||
TNode<HeapObject> table = AllocateTable(variant, at_least_space_for);
|
||||
StoreObjectField(collection, GetTableOffset(variant), table);
|
||||
GotoIf(IsNullOrUndefined(initial_entries), &exit);
|
||||
GotoIfInitialAddFunctionModified(variant, CAST(native_context),
|
||||
@ -521,10 +521,10 @@ TNode<IntPtrT> BaseCollectionsAssembler::EstimatedInitialSize(
|
||||
[=] { return IntPtrConstant(0); });
|
||||
}
|
||||
|
||||
void BaseCollectionsAssembler::GotoIfNotJSReceiver(Node* const obj,
|
||||
void BaseCollectionsAssembler::GotoIfNotJSReceiver(TNode<Object> const obj,
|
||||
Label* if_not_receiver) {
|
||||
GotoIf(TaggedIsSmi(obj), if_not_receiver);
|
||||
GotoIfNot(IsJSReceiver(obj), if_not_receiver);
|
||||
GotoIfNot(IsJSReceiver(CAST(obj)), if_not_receiver);
|
||||
}
|
||||
|
||||
TNode<Map> BaseCollectionsAssembler::GetInitialCollectionPrototype(
|
||||
@ -606,13 +606,14 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
|
||||
protected:
|
||||
template <typename IteratorType>
|
||||
Node* AllocateJSCollectionIterator(SloppyTNode<Context> context,
|
||||
int map_index, Node* collection);
|
||||
TNode<Object> AllocateTable(Variant variant, TNode<Context> context,
|
||||
TNode<IntPtrT> at_least_space_for) override;
|
||||
TNode<IntPtrT> GetHash(SloppyTNode<HeapObject> const key);
|
||||
TNode<IntPtrT> CallGetHashRaw(SloppyTNode<HeapObject> const key);
|
||||
TNode<Smi> CallGetOrCreateHashRaw(SloppyTNode<HeapObject> const key);
|
||||
TNode<HeapObject> AllocateJSCollectionIterator(
|
||||
const TNode<Context> context, int map_index,
|
||||
const TNode<HeapObject> collection);
|
||||
TNode<HeapObject> AllocateTable(Variant variant,
|
||||
TNode<IntPtrT> at_least_space_for) override;
|
||||
TNode<IntPtrT> GetHash(const TNode<HeapObject> key);
|
||||
TNode<IntPtrT> CallGetHashRaw(const TNode<HeapObject> key);
|
||||
TNode<Smi> CallGetOrCreateHashRaw(const TNode<HeapObject> key);
|
||||
|
||||
// Transitions the iterator to the non obsolete backing store.
|
||||
// This is a NOP if the [table] is not obsolete.
|
||||
@ -633,25 +634,23 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
// The {result} variable will contain the entry index if the key was found,
|
||||
// or the hash code otherwise.
|
||||
template <typename CollectionType>
|
||||
void FindOrderedHashTableEntryForSmiKey(Node* table,
|
||||
SloppyTNode<Smi> key_tagged,
|
||||
Variable* result, Label* entry_found,
|
||||
Label* not_found);
|
||||
void SameValueZeroSmi(SloppyTNode<Smi> key_smi,
|
||||
SloppyTNode<Object> candidate_key, Label* if_same,
|
||||
Label* if_not_same);
|
||||
void FindOrderedHashTableEntryForSmiKey(TNode<CollectionType> table,
|
||||
TNode<Smi> key_tagged,
|
||||
TVariable<IntPtrT>* result,
|
||||
Label* entry_found, Label* not_found);
|
||||
void SameValueZeroSmi(TNode<Smi> key_smi, TNode<Object> candidate_key,
|
||||
Label* if_same, Label* if_not_same);
|
||||
|
||||
// Specialization for heap numbers.
|
||||
// The {result} variable will contain the entry index if the key was found,
|
||||
// or the hash code otherwise.
|
||||
void SameValueZeroHeapNumber(SloppyTNode<Float64T> key_float,
|
||||
SloppyTNode<Object> candidate_key,
|
||||
Label* if_same, Label* if_not_same);
|
||||
void SameValueZeroHeapNumber(TNode<Float64T> key_float,
|
||||
TNode<Object> candidate_key, Label* if_same,
|
||||
Label* if_not_same);
|
||||
template <typename CollectionType>
|
||||
void FindOrderedHashTableEntryForHeapNumberKey(
|
||||
SloppyTNode<Context> context, Node* table,
|
||||
SloppyTNode<HeapNumber> key_heap_number, Variable* result,
|
||||
Label* entry_found, Label* not_found);
|
||||
TNode<CollectionType> table, TNode<HeapNumber> key_heap_number,
|
||||
TVariable<IntPtrT>* result, Label* entry_found, Label* not_found);
|
||||
|
||||
// Specialization for bigints.
|
||||
// The {result} variable will contain the entry index if the key was found,
|
||||
@ -659,9 +658,9 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
void SameValueZeroBigInt(Node* key, Node* candidate_key, Label* if_same,
|
||||
Label* if_not_same);
|
||||
template <typename CollectionType>
|
||||
void FindOrderedHashTableEntryForBigIntKey(SloppyTNode<Context> context,
|
||||
Node* table, Node* key,
|
||||
Variable* result,
|
||||
void FindOrderedHashTableEntryForBigIntKey(TNode<CollectionType> table,
|
||||
TNode<BigInt> key_big_int,
|
||||
TVariable<IntPtrT>* result,
|
||||
Label* entry_found,
|
||||
Label* not_found);
|
||||
|
||||
@ -669,14 +668,14 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
// The {result} variable will contain the entry index if the key was found,
|
||||
// or the hash code otherwise.
|
||||
template <typename CollectionType>
|
||||
void FindOrderedHashTableEntryForStringKey(
|
||||
SloppyTNode<Context> context, Node* table, SloppyTNode<String> key_tagged,
|
||||
Variable* result, Label* entry_found, Label* not_found);
|
||||
TNode<IntPtrT> ComputeStringHash(TNode<Context> context,
|
||||
TNode<String> string_key);
|
||||
void SameValueZeroString(SloppyTNode<Context> context,
|
||||
SloppyTNode<String> key_string,
|
||||
SloppyTNode<Object> candidate_key, Label* if_same,
|
||||
void FindOrderedHashTableEntryForStringKey(TNode<CollectionType> table,
|
||||
TNode<String> key_tagged,
|
||||
TVariable<IntPtrT>* result,
|
||||
Label* entry_found,
|
||||
Label* not_found);
|
||||
TNode<IntPtrT> ComputeStringHash(TNode<String> string_key);
|
||||
void SameValueZeroString(TNode<String> key_string,
|
||||
TNode<Object> candidate_key, Label* if_same,
|
||||
Label* if_not_same);
|
||||
|
||||
// Specialization for non-strings, non-numbers. For those we only need
|
||||
@ -685,17 +684,20 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
// or the hash code otherwise. If the hash-code has not been computed, it
|
||||
// should be Smi -1.
|
||||
template <typename CollectionType>
|
||||
void FindOrderedHashTableEntryForOtherKey(
|
||||
SloppyTNode<Context> context, Node* table, SloppyTNode<HeapObject> key,
|
||||
Variable* result, Label* entry_found, Label* not_found);
|
||||
void FindOrderedHashTableEntryForOtherKey(TNode<CollectionType> table,
|
||||
TNode<HeapObject> key_heap_object,
|
||||
TVariable<IntPtrT>* result,
|
||||
Label* entry_found,
|
||||
Label* not_found);
|
||||
|
||||
template <typename CollectionType>
|
||||
void TryLookupOrderedHashTableIndex(Node* const table, Node* const key,
|
||||
Node* const context, Variable* result,
|
||||
void TryLookupOrderedHashTableIndex(const TNode<CollectionType> table,
|
||||
const TNode<Object> key,
|
||||
TVariable<IntPtrT>* result,
|
||||
Label* if_entry_found,
|
||||
Label* if_not_found);
|
||||
|
||||
Node* NormalizeNumberKey(Node* key);
|
||||
const TNode<Object> NormalizeNumberKey(const TNode<Object> key);
|
||||
void StoreOrderedHashMapNewEntry(TNode<OrderedHashMap> const table,
|
||||
Node* const key, Node* const value,
|
||||
Node* const hash,
|
||||
@ -728,8 +730,9 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
};
|
||||
|
||||
template <typename IteratorType>
|
||||
Node* CollectionsBuiltinsAssembler::AllocateJSCollectionIterator(
|
||||
SloppyTNode<Context> context, int map_index, Node* collection) {
|
||||
TNode<HeapObject> CollectionsBuiltinsAssembler::AllocateJSCollectionIterator(
|
||||
TNode<Context> const context, int map_index,
|
||||
TNode<HeapObject> const collection) {
|
||||
TNode<Object> const table =
|
||||
LoadObjectField(collection, JSCollection::kTableOffset);
|
||||
TNode<NativeContext> const native_context = LoadNativeContext(context);
|
||||
@ -747,9 +750,8 @@ Node* CollectionsBuiltinsAssembler::AllocateJSCollectionIterator(
|
||||
return iterator;
|
||||
}
|
||||
|
||||
TNode<Object> CollectionsBuiltinsAssembler::AllocateTable(
|
||||
Variant variant, TNode<Context> context,
|
||||
TNode<IntPtrT> at_least_space_for) {
|
||||
TNode<HeapObject> CollectionsBuiltinsAssembler::AllocateTable(
|
||||
Variant variant, TNode<IntPtrT> at_least_space_for) {
|
||||
return CAST((variant == kMap || variant == kWeakMap)
|
||||
? AllocateOrderedHashTable<OrderedHashMap>()
|
||||
: AllocateOrderedHashTable<OrderedHashSet>());
|
||||
@ -776,7 +778,7 @@ TF_BUILTIN(SetConstructor, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TNode<Smi> CollectionsBuiltinsAssembler::CallGetOrCreateHashRaw(
|
||||
SloppyTNode<HeapObject> const key) {
|
||||
const TNode<HeapObject> key) {
|
||||
TNode<ExternalReference> const function_addr =
|
||||
ExternalConstant(ExternalReference::get_or_create_hash_raw());
|
||||
TNode<ExternalReference> const isolate_ptr =
|
||||
@ -793,7 +795,7 @@ TNode<Smi> CollectionsBuiltinsAssembler::CallGetOrCreateHashRaw(
|
||||
}
|
||||
|
||||
TNode<IntPtrT> CollectionsBuiltinsAssembler::CallGetHashRaw(
|
||||
SloppyTNode<HeapObject> const key) {
|
||||
const TNode<HeapObject> key) {
|
||||
TNode<ExternalReference> const function_addr =
|
||||
ExternalConstant(ExternalReference::orderedhashmap_gethash_raw());
|
||||
TNode<ExternalReference> const isolate_ptr =
|
||||
@ -810,7 +812,7 @@ TNode<IntPtrT> CollectionsBuiltinsAssembler::CallGetHashRaw(
|
||||
}
|
||||
|
||||
TNode<IntPtrT> CollectionsBuiltinsAssembler::GetHash(
|
||||
SloppyTNode<HeapObject> const key) {
|
||||
const TNode<HeapObject> key) {
|
||||
TVARIABLE(IntPtrT, var_hash);
|
||||
Label if_receiver(this), if_other(this), done(this);
|
||||
Branch(IsJSReceiver(key), &if_receiver, &if_other);
|
||||
@ -831,9 +833,10 @@ TNode<IntPtrT> CollectionsBuiltinsAssembler::GetHash(
|
||||
return var_hash.value();
|
||||
}
|
||||
|
||||
void CollectionsBuiltinsAssembler::SameValueZeroSmi(
|
||||
SloppyTNode<Smi> key_smi, SloppyTNode<Object> candidate_key, Label* if_same,
|
||||
Label* if_not_same) {
|
||||
void CollectionsBuiltinsAssembler::SameValueZeroSmi(TNode<Smi> key_smi,
|
||||
TNode<Object> candidate_key,
|
||||
Label* if_same,
|
||||
Label* if_not_same) {
|
||||
// If the key is the same, we are done.
|
||||
GotoIf(TaggedEqual(candidate_key, key_smi), if_same);
|
||||
|
||||
@ -1162,13 +1165,13 @@ TF_BUILTIN(SetOrSetIteratorToList, CollectionsBuiltinsAssembler) {
|
||||
|
||||
template <typename CollectionType>
|
||||
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey(
|
||||
Node* table, SloppyTNode<Smi> smi_key, Variable* result, Label* entry_found,
|
||||
Label* not_found) {
|
||||
TNode<CollectionType> table, TNode<Smi> smi_key, TVariable<IntPtrT>* result,
|
||||
Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const key_untagged = SmiUntag(smi_key);
|
||||
TNode<IntPtrT> const hash =
|
||||
ChangeInt32ToIntPtr(ComputeUnseededHash(key_untagged));
|
||||
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
|
||||
result->Bind(hash);
|
||||
*result = hash;
|
||||
FindOrderedHashTableEntry<CollectionType>(
|
||||
table, hash,
|
||||
[&](TNode<Object> other_key, Label* if_same, Label* if_not_same) {
|
||||
@ -1179,28 +1182,26 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey(
|
||||
|
||||
template <typename CollectionType>
|
||||
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForStringKey(
|
||||
SloppyTNode<Context> context, Node* table, SloppyTNode<String> key_tagged,
|
||||
Variable* result, Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = ComputeStringHash(context, key_tagged);
|
||||
TNode<CollectionType> table, TNode<String> key_tagged,
|
||||
TVariable<IntPtrT>* result, Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = ComputeStringHash(key_tagged);
|
||||
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
|
||||
result->Bind(hash);
|
||||
*result = hash;
|
||||
FindOrderedHashTableEntry<CollectionType>(
|
||||
table, hash,
|
||||
[&](TNode<Object> other_key, Label* if_same, Label* if_not_same) {
|
||||
SameValueZeroString(context, key_tagged, other_key, if_same,
|
||||
if_not_same);
|
||||
SameValueZeroString(key_tagged, other_key, if_same, if_not_same);
|
||||
},
|
||||
result, entry_found, not_found);
|
||||
}
|
||||
|
||||
template <typename CollectionType>
|
||||
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForHeapNumberKey(
|
||||
SloppyTNode<Context> context, Node* table,
|
||||
SloppyTNode<HeapNumber> key_heap_number, Variable* result,
|
||||
Label* entry_found, Label* not_found) {
|
||||
TNode<CollectionType> table, TNode<HeapNumber> key_heap_number,
|
||||
TVariable<IntPtrT>* result, Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = CallGetHashRaw(key_heap_number);
|
||||
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
|
||||
result->Bind(hash);
|
||||
*result = hash;
|
||||
TNode<Float64T> const key_float = LoadHeapNumberValue(key_heap_number);
|
||||
FindOrderedHashTableEntry<CollectionType>(
|
||||
table, hash,
|
||||
@ -1212,36 +1213,36 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForHeapNumberKey(
|
||||
|
||||
template <typename CollectionType>
|
||||
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForBigIntKey(
|
||||
SloppyTNode<Context> context, Node* table, Node* key, Variable* result,
|
||||
Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = CallGetHashRaw(key);
|
||||
TNode<CollectionType> table, TNode<BigInt> key_big_int,
|
||||
TVariable<IntPtrT>* result, Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = CallGetHashRaw(key_big_int);
|
||||
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
|
||||
result->Bind(hash);
|
||||
*result = hash;
|
||||
FindOrderedHashTableEntry<CollectionType>(
|
||||
table, hash,
|
||||
[&](TNode<Object> other_key, Label* if_same, Label* if_not_same) {
|
||||
SameValueZeroBigInt(key, other_key, if_same, if_not_same);
|
||||
SameValueZeroBigInt(key_big_int, other_key, if_same, if_not_same);
|
||||
},
|
||||
result, entry_found, not_found);
|
||||
}
|
||||
|
||||
template <typename CollectionType>
|
||||
void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForOtherKey(
|
||||
SloppyTNode<Context> context, Node* table, SloppyTNode<HeapObject> key,
|
||||
Variable* result, Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = GetHash(key);
|
||||
TNode<CollectionType> table, TNode<HeapObject> key_heap_object,
|
||||
TVariable<IntPtrT>* result, Label* entry_found, Label* not_found) {
|
||||
TNode<IntPtrT> const hash = GetHash(key_heap_object);
|
||||
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0)));
|
||||
result->Bind(hash);
|
||||
*result = hash;
|
||||
FindOrderedHashTableEntry<CollectionType>(
|
||||
table, hash,
|
||||
[&](TNode<Object> other_key, Label* if_same, Label* if_not_same) {
|
||||
Branch(TaggedEqual(key, other_key), if_same, if_not_same);
|
||||
Branch(TaggedEqual(key_heap_object, other_key), if_same, if_not_same);
|
||||
},
|
||||
result, entry_found, not_found);
|
||||
}
|
||||
|
||||
TNode<IntPtrT> CollectionsBuiltinsAssembler::ComputeStringHash(
|
||||
TNode<Context> context, TNode<String> string_key) {
|
||||
TNode<String> string_key) {
|
||||
TVARIABLE(IntPtrT, var_result);
|
||||
|
||||
Label hash_not_computed(this), done(this, &var_result);
|
||||
@ -1259,14 +1260,14 @@ TNode<IntPtrT> CollectionsBuiltinsAssembler::ComputeStringHash(
|
||||
}
|
||||
|
||||
void CollectionsBuiltinsAssembler::SameValueZeroString(
|
||||
SloppyTNode<Context> context, SloppyTNode<String> key_string,
|
||||
SloppyTNode<Object> candidate_key, Label* if_same, Label* if_not_same) {
|
||||
TNode<String> key_string, TNode<Object> candidate_key, Label* if_same,
|
||||
Label* if_not_same) {
|
||||
// If the candidate is not a string, the keys are not equal.
|
||||
GotoIf(TaggedIsSmi(candidate_key), if_not_same);
|
||||
GotoIfNot(IsString(CAST(candidate_key)), if_not_same);
|
||||
|
||||
Branch(TaggedEqual(CallBuiltin(Builtins::kStringEqual, context, key_string,
|
||||
candidate_key),
|
||||
Branch(TaggedEqual(CallBuiltin(Builtins::kStringEqual, NoContextConstant(),
|
||||
key_string, candidate_key),
|
||||
TrueConstant()),
|
||||
if_same, if_not_same);
|
||||
}
|
||||
@ -1286,8 +1287,8 @@ void CollectionsBuiltinsAssembler::SameValueZeroBigInt(Node* key,
|
||||
}
|
||||
|
||||
void CollectionsBuiltinsAssembler::SameValueZeroHeapNumber(
|
||||
SloppyTNode<Float64T> key_float, SloppyTNode<Object> candidate_key,
|
||||
Label* if_same, Label* if_not_same) {
|
||||
TNode<Float64T> key_float, TNode<Object> candidate_key, Label* if_same,
|
||||
Label* if_not_same) {
|
||||
Label if_smi(this), if_keyisnan(this);
|
||||
|
||||
GotoIf(TaggedIsSmi(candidate_key), &if_smi);
|
||||
@ -1458,13 +1459,14 @@ CollectionsBuiltinsAssembler::NextSkipHoles(TNode<TableType> table,
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeGet, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.get");
|
||||
|
||||
TNode<Object> const table = LoadObjectField(receiver, JSMap::kTableOffset);
|
||||
TNode<Object> const table =
|
||||
LoadObjectField<Object>(CAST(receiver), JSMap::kTableOffset);
|
||||
TNode<Smi> index = CAST(
|
||||
CallBuiltin(Builtins::kFindOrderedHashMapEntry, context, table, key));
|
||||
|
||||
@ -1483,13 +1485,14 @@ TF_BUILTIN(MapPrototypeGet, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeHas, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.has");
|
||||
|
||||
TNode<Object> const table = LoadObjectField(receiver, JSMap::kTableOffset);
|
||||
TNode<Object> const table =
|
||||
LoadObjectField(CAST(receiver), JSMap::kTableOffset);
|
||||
TNode<Smi> index = CAST(
|
||||
CallBuiltin(Builtins::kFindOrderedHashMapEntry, context, table, key));
|
||||
|
||||
@ -1504,17 +1507,18 @@ TF_BUILTIN(MapPrototypeHas, CollectionsBuiltinsAssembler) {
|
||||
Return(FalseConstant());
|
||||
}
|
||||
|
||||
Node* CollectionsBuiltinsAssembler::NormalizeNumberKey(Node* const key) {
|
||||
VARIABLE(result, MachineRepresentation::kTagged, key);
|
||||
const TNode<Object> CollectionsBuiltinsAssembler::NormalizeNumberKey(
|
||||
const TNode<Object> key) {
|
||||
TVARIABLE(Object, result, key);
|
||||
Label done(this);
|
||||
|
||||
GotoIf(TaggedIsSmi(key), &done);
|
||||
GotoIfNot(IsHeapNumber(key), &done);
|
||||
TNode<Float64T> const number = LoadHeapNumberValue(key);
|
||||
GotoIfNot(IsHeapNumber(CAST(key)), &done);
|
||||
TNode<Float64T> const number = LoadHeapNumberValue(CAST(key));
|
||||
GotoIfNot(Float64Equal(number, Float64Constant(0.0)), &done);
|
||||
// We know the value is zero, so we take the key to be Smi 0.
|
||||
// Another option would be to normalize to Smi here.
|
||||
result.Bind(SmiConstant(0));
|
||||
result = SmiConstant(0);
|
||||
Goto(&done);
|
||||
|
||||
BIND(&done);
|
||||
@ -1522,25 +1526,23 @@ Node* CollectionsBuiltinsAssembler::NormalizeNumberKey(Node* const key) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeSet, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* key = Parameter(Descriptor::kKey);
|
||||
Node* const value = Parameter(Descriptor::kValue);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Object> value = CAST(Parameter(Descriptor::kValue));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.set");
|
||||
|
||||
key = NormalizeNumberKey(key);
|
||||
|
||||
TNode<OrderedHashMap> const table =
|
||||
CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
LoadObjectField<OrderedHashMap>(CAST(receiver), JSMap::kTableOffset);
|
||||
|
||||
VARIABLE(entry_start_position_or_hash, MachineType::PointerRepresentation(),
|
||||
IntPtrConstant(0));
|
||||
TVARIABLE(IntPtrT, entry_start_position_or_hash, IntPtrConstant(0));
|
||||
Label entry_found(this), not_found(this);
|
||||
|
||||
TryLookupOrderedHashTableIndex<OrderedHashMap>(table, key, context,
|
||||
&entry_start_position_or_hash,
|
||||
&entry_found, ¬_found);
|
||||
TryLookupOrderedHashTableIndex<OrderedHashMap>(
|
||||
table, key, &entry_start_position_or_hash, &entry_found, ¬_found);
|
||||
|
||||
BIND(&entry_found);
|
||||
// If we found the entry, we just store the value there.
|
||||
@ -1559,7 +1561,7 @@ TF_BUILTIN(MapPrototypeSet, CollectionsBuiltinsAssembler) {
|
||||
&add_entry);
|
||||
|
||||
// Otherwise, go to runtime to compute the hash code.
|
||||
entry_start_position_or_hash.Bind(SmiUntag(CallGetOrCreateHashRaw(key)));
|
||||
entry_start_position_or_hash = SmiUntag(CallGetOrCreateHashRaw(CAST(key)));
|
||||
Goto(&add_entry);
|
||||
}
|
||||
|
||||
@ -1584,7 +1586,8 @@ TF_BUILTIN(MapPrototypeSet, CollectionsBuiltinsAssembler) {
|
||||
// We do not have enough space, grow the table and reload the relevant
|
||||
// fields.
|
||||
CallRuntime(Runtime::kMapGrow, context, receiver);
|
||||
table_var = CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
table_var =
|
||||
LoadObjectField<OrderedHashMap>(CAST(receiver), JSMap::kTableOffset);
|
||||
number_of_buckets.Bind(SmiUntag(CAST(UnsafeLoadFixedArrayElement(
|
||||
table_var.value(), OrderedHashMap::NumberOfBucketsIndex()))));
|
||||
TNode<IntPtrT> const new_number_of_elements = SmiUntag(CAST(LoadObjectField(
|
||||
@ -1640,23 +1643,21 @@ void CollectionsBuiltinsAssembler::StoreOrderedHashMapNewEntry(
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeDelete, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE,
|
||||
"Map.prototype.delete");
|
||||
|
||||
TNode<OrderedHashMap> const table =
|
||||
CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
LoadObjectField<OrderedHashMap>(CAST(receiver), JSMap::kTableOffset);
|
||||
|
||||
VARIABLE(entry_start_position_or_hash, MachineType::PointerRepresentation(),
|
||||
IntPtrConstant(0));
|
||||
TVARIABLE(IntPtrT, entry_start_position_or_hash, IntPtrConstant(0));
|
||||
Label entry_found(this), not_found(this);
|
||||
|
||||
TryLookupOrderedHashTableIndex<OrderedHashMap>(table, key, context,
|
||||
&entry_start_position_or_hash,
|
||||
&entry_found, ¬_found);
|
||||
TryLookupOrderedHashTableIndex<OrderedHashMap>(
|
||||
table, key, &entry_start_position_or_hash, &entry_found, ¬_found);
|
||||
|
||||
BIND(¬_found);
|
||||
Return(FalseConstant());
|
||||
@ -1701,24 +1702,22 @@ TF_BUILTIN(MapPrototypeDelete, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetPrototypeAdd, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.add");
|
||||
|
||||
key = NormalizeNumberKey(key);
|
||||
|
||||
TNode<OrderedHashSet> const table =
|
||||
CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
LoadObjectField<OrderedHashSet>(CAST(receiver), JSMap::kTableOffset);
|
||||
|
||||
VARIABLE(entry_start_position_or_hash, MachineType::PointerRepresentation(),
|
||||
IntPtrConstant(0));
|
||||
TVARIABLE(IntPtrT, entry_start_position_or_hash, IntPtrConstant(0));
|
||||
Label entry_found(this), not_found(this);
|
||||
|
||||
TryLookupOrderedHashTableIndex<OrderedHashSet>(table, key, context,
|
||||
&entry_start_position_or_hash,
|
||||
&entry_found, ¬_found);
|
||||
TryLookupOrderedHashTableIndex<OrderedHashSet>(
|
||||
table, key, &entry_start_position_or_hash, &entry_found, ¬_found);
|
||||
|
||||
BIND(&entry_found);
|
||||
// The entry was found, there is nothing to do.
|
||||
@ -1733,7 +1732,7 @@ TF_BUILTIN(SetPrototypeAdd, CollectionsBuiltinsAssembler) {
|
||||
&add_entry);
|
||||
|
||||
// Otherwise, go to runtime to compute the hash code.
|
||||
entry_start_position_or_hash.Bind(SmiUntag(CallGetOrCreateHashRaw(key)));
|
||||
entry_start_position_or_hash = SmiUntag(CallGetOrCreateHashRaw(CAST(key)));
|
||||
Goto(&add_entry);
|
||||
}
|
||||
|
||||
@ -1758,7 +1757,8 @@ TF_BUILTIN(SetPrototypeAdd, CollectionsBuiltinsAssembler) {
|
||||
// We do not have enough space, grow the table and reload the relevant
|
||||
// fields.
|
||||
CallRuntime(Runtime::kSetGrow, context, receiver);
|
||||
table_var = CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
table_var =
|
||||
LoadObjectField<OrderedHashSet>(CAST(receiver), JSMap::kTableOffset);
|
||||
number_of_buckets.Bind(SmiUntag(CAST(UnsafeLoadFixedArrayElement(
|
||||
table_var.value(), OrderedHashSet::NumberOfBucketsIndex()))));
|
||||
TNode<IntPtrT> const new_number_of_elements = SmiUntag(CAST(LoadObjectField(
|
||||
@ -1810,23 +1810,21 @@ void CollectionsBuiltinsAssembler::StoreOrderedHashSetNewEntry(
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetPrototypeDelete, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE,
|
||||
"Set.prototype.delete");
|
||||
|
||||
TNode<OrderedHashSet> const table =
|
||||
CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
LoadObjectField<OrderedHashSet>(CAST(receiver), JSMap::kTableOffset);
|
||||
|
||||
VARIABLE(entry_start_position_or_hash, MachineType::PointerRepresentation(),
|
||||
IntPtrConstant(0));
|
||||
TVARIABLE(IntPtrT, entry_start_position_or_hash, IntPtrConstant(0));
|
||||
Label entry_found(this), not_found(this);
|
||||
|
||||
TryLookupOrderedHashTableIndex<OrderedHashSet>(table, key, context,
|
||||
&entry_start_position_or_hash,
|
||||
&entry_found, ¬_found);
|
||||
TryLookupOrderedHashTableIndex<OrderedHashSet>(
|
||||
table, key, &entry_start_position_or_hash, &entry_found, ¬_found);
|
||||
|
||||
BIND(¬_found);
|
||||
Return(FalseConstant());
|
||||
@ -1867,21 +1865,21 @@ TF_BUILTIN(SetPrototypeDelete, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeEntries, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE,
|
||||
"Map.prototype.entries");
|
||||
Return(AllocateJSCollectionIterator<JSMapIterator>(
|
||||
context, Context::MAP_KEY_VALUE_ITERATOR_MAP_INDEX, receiver));
|
||||
context, Context::MAP_KEY_VALUE_ITERATOR_MAP_INDEX, CAST(receiver)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeGetSize, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE,
|
||||
"get Map.prototype.size");
|
||||
TNode<OrderedHashMap> const table =
|
||||
CAST(LoadObjectField(receiver, JSMap::kTableOffset));
|
||||
LoadObjectField<OrderedHashMap>(CAST(receiver), JSMap::kTableOffset);
|
||||
Return(LoadObjectField(table, OrderedHashMap::NumberOfElementsOffset()));
|
||||
}
|
||||
|
||||
@ -1889,7 +1887,7 @@ TF_BUILTIN(MapPrototypeForEach, CollectionsBuiltinsAssembler) {
|
||||
const char* const kMethodName = "Map.prototype.forEach";
|
||||
TNode<Int32T> argc =
|
||||
UncheckedCast<Int32T>(Parameter(Descriptor::kJSActualArgumentsCount));
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
CodeStubArguments args(this, argc);
|
||||
TNode<Object> const receiver = args.GetReceiver();
|
||||
TNode<Object> const callback = args.GetOptionalArgumentValue(0);
|
||||
@ -1950,31 +1948,32 @@ TF_BUILTIN(MapPrototypeForEach, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeKeys, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.keys");
|
||||
Return(AllocateJSCollectionIterator<JSMapIterator>(
|
||||
context, Context::MAP_KEY_ITERATOR_MAP_INDEX, receiver));
|
||||
context, Context::MAP_KEY_ITERATOR_MAP_INDEX, CAST(receiver)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapPrototypeValues, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE,
|
||||
"Map.prototype.values");
|
||||
Return(AllocateJSCollectionIterator<JSMapIterator>(
|
||||
context, Context::MAP_VALUE_ITERATOR_MAP_INDEX, receiver));
|
||||
context, Context::MAP_VALUE_ITERATOR_MAP_INDEX, CAST(receiver)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(MapIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
|
||||
const char* const kMethodName = "Map Iterator.prototype.next";
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
// Ensure that the {receiver} is actually a JSMapIterator.
|
||||
Label if_receiver_valid(this), if_receiver_invalid(this, Label::kDeferred);
|
||||
GotoIf(TaggedIsSmi(receiver), &if_receiver_invalid);
|
||||
TNode<Uint16T> const receiver_instance_type = LoadInstanceType(receiver);
|
||||
TNode<Uint16T> const receiver_instance_type =
|
||||
LoadInstanceType(CAST(receiver));
|
||||
GotoIf(
|
||||
InstanceTypeEqual(receiver_instance_type, JS_MAP_KEY_VALUE_ITERATOR_TYPE),
|
||||
&if_receiver_valid);
|
||||
@ -2042,23 +2041,22 @@ TF_BUILTIN(MapIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetPrototypeHas, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.has");
|
||||
|
||||
TNode<Object> const table = LoadObjectField(receiver, JSMap::kTableOffset);
|
||||
TNode<Object> const table =
|
||||
LoadObjectField(CAST(receiver), JSMap::kTableOffset);
|
||||
|
||||
VARIABLE(entry_start_position, MachineType::PointerRepresentation(),
|
||||
IntPtrConstant(0));
|
||||
VARIABLE(result, MachineRepresentation::kTaggedSigned, IntPtrConstant(0));
|
||||
TVARIABLE(IntPtrT, entry_start_position, IntPtrConstant(0));
|
||||
Label if_key_smi(this), if_key_string(this), if_key_heap_number(this),
|
||||
if_key_bigint(this), entry_found(this), not_found(this), done(this);
|
||||
|
||||
GotoIf(TaggedIsSmi(key), &if_key_smi);
|
||||
|
||||
TNode<Map> key_map = LoadMap(key);
|
||||
TNode<Map> key_map = LoadMap(CAST(key));
|
||||
TNode<Uint16T> key_instance_type = LoadMapInstanceType(key_map);
|
||||
|
||||
GotoIf(IsStringInstanceType(key_instance_type), &if_key_string);
|
||||
@ -2066,30 +2064,34 @@ TF_BUILTIN(SetPrototypeHas, CollectionsBuiltinsAssembler) {
|
||||
GotoIf(IsBigIntInstanceType(key_instance_type), &if_key_bigint);
|
||||
|
||||
FindOrderedHashTableEntryForOtherKey<OrderedHashSet>(
|
||||
context, table, key, &entry_start_position, &entry_found, ¬_found);
|
||||
CAST(table), CAST(key), &entry_start_position, &entry_found, ¬_found);
|
||||
|
||||
BIND(&if_key_smi);
|
||||
{
|
||||
FindOrderedHashTableEntryForSmiKey<OrderedHashSet>(
|
||||
table, key, &entry_start_position, &entry_found, ¬_found);
|
||||
CAST(table), CAST(key), &entry_start_position, &entry_found,
|
||||
¬_found);
|
||||
}
|
||||
|
||||
BIND(&if_key_string);
|
||||
{
|
||||
FindOrderedHashTableEntryForStringKey<OrderedHashSet>(
|
||||
context, table, key, &entry_start_position, &entry_found, ¬_found);
|
||||
CAST(table), CAST(key), &entry_start_position, &entry_found,
|
||||
¬_found);
|
||||
}
|
||||
|
||||
BIND(&if_key_heap_number);
|
||||
{
|
||||
FindOrderedHashTableEntryForHeapNumberKey<OrderedHashSet>(
|
||||
context, table, key, &entry_start_position, &entry_found, ¬_found);
|
||||
CAST(table), CAST(key), &entry_start_position, &entry_found,
|
||||
¬_found);
|
||||
}
|
||||
|
||||
BIND(&if_key_bigint);
|
||||
{
|
||||
FindOrderedHashTableEntryForBigIntKey<OrderedHashSet>(
|
||||
context, table, key, &entry_start_position, &entry_found, ¬_found);
|
||||
CAST(table), CAST(key), &entry_start_position, &entry_found,
|
||||
¬_found);
|
||||
}
|
||||
|
||||
BIND(&entry_found);
|
||||
@ -2100,21 +2102,21 @@ TF_BUILTIN(SetPrototypeHas, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetPrototypeEntries, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE,
|
||||
"Set.prototype.entries");
|
||||
Return(AllocateJSCollectionIterator<JSSetIterator>(
|
||||
context, Context::SET_KEY_VALUE_ITERATOR_MAP_INDEX, receiver));
|
||||
context, Context::SET_KEY_VALUE_ITERATOR_MAP_INDEX, CAST(receiver)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetPrototypeGetSize, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE,
|
||||
"get Set.prototype.size");
|
||||
TNode<OrderedHashSet> const table =
|
||||
CAST(LoadObjectField(receiver, JSSet::kTableOffset));
|
||||
LoadObjectField<OrderedHashSet>(CAST(receiver), JSSet::kTableOffset);
|
||||
Return(LoadObjectField(table, OrderedHashSet::NumberOfElementsOffset()));
|
||||
}
|
||||
|
||||
@ -2122,7 +2124,7 @@ TF_BUILTIN(SetPrototypeForEach, CollectionsBuiltinsAssembler) {
|
||||
const char* const kMethodName = "Set.prototype.forEach";
|
||||
TNode<Int32T> argc =
|
||||
UncheckedCast<Int32T>(Parameter(Descriptor::kJSActualArgumentsCount));
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
CodeStubArguments args(this, argc);
|
||||
TNode<Object> const receiver = args.GetReceiver();
|
||||
TNode<Object> const callback = args.GetOptionalArgumentValue(0);
|
||||
@ -2176,23 +2178,24 @@ TF_BUILTIN(SetPrototypeForEach, CollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetPrototypeValues, CollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE,
|
||||
"Set.prototype.values");
|
||||
Return(AllocateJSCollectionIterator<JSSetIterator>(
|
||||
context, Context::SET_VALUE_ITERATOR_MAP_INDEX, receiver));
|
||||
context, Context::SET_VALUE_ITERATOR_MAP_INDEX, CAST(receiver)));
|
||||
}
|
||||
|
||||
TF_BUILTIN(SetIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
|
||||
const char* const kMethodName = "Set Iterator.prototype.next";
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
// Ensure that the {receiver} is actually a JSSetIterator.
|
||||
Label if_receiver_valid(this), if_receiver_invalid(this, Label::kDeferred);
|
||||
GotoIf(TaggedIsSmi(receiver), &if_receiver_invalid);
|
||||
TNode<Uint16T> const receiver_instance_type = LoadInstanceType(receiver);
|
||||
TNode<Uint16T> const receiver_instance_type =
|
||||
LoadInstanceType(CAST(receiver));
|
||||
GotoIf(InstanceTypeEqual(receiver_instance_type, JS_SET_VALUE_ITERATOR_TYPE),
|
||||
&if_receiver_valid);
|
||||
Branch(
|
||||
@ -2253,14 +2256,14 @@ TF_BUILTIN(SetIteratorPrototypeNext, CollectionsBuiltinsAssembler) {
|
||||
|
||||
template <typename CollectionType>
|
||||
void CollectionsBuiltinsAssembler::TryLookupOrderedHashTableIndex(
|
||||
Node* const table, Node* const key, Node* const context, Variable* result,
|
||||
Label* if_entry_found, Label* if_not_found) {
|
||||
const TNode<CollectionType> table, const TNode<Object> key,
|
||||
TVariable<IntPtrT>* result, Label* if_entry_found, Label* if_not_found) {
|
||||
Label if_key_smi(this), if_key_string(this), if_key_heap_number(this),
|
||||
if_key_bigint(this);
|
||||
|
||||
GotoIf(TaggedIsSmi(key), &if_key_smi);
|
||||
|
||||
TNode<Map> key_map = LoadMap(key);
|
||||
TNode<Map> key_map = LoadMap(CAST(key));
|
||||
TNode<Uint16T> key_instance_type = LoadMapInstanceType(key_map);
|
||||
|
||||
GotoIf(IsStringInstanceType(key_instance_type), &if_key_string);
|
||||
@ -2268,44 +2271,42 @@ void CollectionsBuiltinsAssembler::TryLookupOrderedHashTableIndex(
|
||||
GotoIf(IsBigIntInstanceType(key_instance_type), &if_key_bigint);
|
||||
|
||||
FindOrderedHashTableEntryForOtherKey<CollectionType>(
|
||||
context, table, key, result, if_entry_found, if_not_found);
|
||||
table, CAST(key), result, if_entry_found, if_not_found);
|
||||
|
||||
BIND(&if_key_smi);
|
||||
{
|
||||
FindOrderedHashTableEntryForSmiKey<CollectionType>(
|
||||
table, key, result, if_entry_found, if_not_found);
|
||||
table, CAST(key), result, if_entry_found, if_not_found);
|
||||
}
|
||||
|
||||
BIND(&if_key_string);
|
||||
{
|
||||
FindOrderedHashTableEntryForStringKey<CollectionType>(
|
||||
context, table, key, result, if_entry_found, if_not_found);
|
||||
table, CAST(key), result, if_entry_found, if_not_found);
|
||||
}
|
||||
|
||||
BIND(&if_key_heap_number);
|
||||
{
|
||||
FindOrderedHashTableEntryForHeapNumberKey<CollectionType>(
|
||||
context, table, key, result, if_entry_found, if_not_found);
|
||||
table, CAST(key), result, if_entry_found, if_not_found);
|
||||
}
|
||||
|
||||
BIND(&if_key_bigint);
|
||||
{
|
||||
FindOrderedHashTableEntryForBigIntKey<CollectionType>(
|
||||
context, table, key, result, if_entry_found, if_not_found);
|
||||
table, CAST(key), result, if_entry_found, if_not_found);
|
||||
}
|
||||
}
|
||||
|
||||
TF_BUILTIN(FindOrderedHashMapEntry, CollectionsBuiltinsAssembler) {
|
||||
Node* const table = Parameter(Descriptor::kTable);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<OrderedHashMap> table = CAST(Parameter(Descriptor::kTable));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
|
||||
VARIABLE(entry_start_position, MachineType::PointerRepresentation(),
|
||||
IntPtrConstant(0));
|
||||
TVARIABLE(IntPtrT, entry_start_position, IntPtrConstant(0));
|
||||
Label entry_found(this), not_found(this);
|
||||
|
||||
TryLookupOrderedHashTableIndex<OrderedHashMap>(
|
||||
table, key, context, &entry_start_position, &entry_found, ¬_found);
|
||||
table, key, &entry_start_position, &entry_found, ¬_found);
|
||||
|
||||
BIND(&entry_found);
|
||||
Return(SmiTag(entry_start_position.value()));
|
||||
@ -2324,8 +2325,8 @@ class WeakCollectionsBuiltinsAssembler : public BaseCollectionsAssembler {
|
||||
TNode<Object> key, TNode<Object> value,
|
||||
TNode<IntPtrT> number_of_elements);
|
||||
|
||||
TNode<Object> AllocateTable(Variant variant, TNode<Context> context,
|
||||
TNode<IntPtrT> at_least_space_for) override;
|
||||
TNode<HeapObject> AllocateTable(Variant variant,
|
||||
TNode<IntPtrT> at_least_space_for) override;
|
||||
|
||||
// Generates and sets the identity for a JSRececiver.
|
||||
TNode<Smi> CreateIdentityHash(TNode<Object> receiver);
|
||||
@ -2390,9 +2391,8 @@ void WeakCollectionsBuiltinsAssembler::AddEntry(
|
||||
SmiFromIntPtr(number_of_elements), SKIP_WRITE_BARRIER);
|
||||
}
|
||||
|
||||
TNode<Object> WeakCollectionsBuiltinsAssembler::AllocateTable(
|
||||
Variant variant, TNode<Context> context,
|
||||
TNode<IntPtrT> at_least_space_for) {
|
||||
TNode<HeapObject> WeakCollectionsBuiltinsAssembler::AllocateTable(
|
||||
Variant variant, TNode<IntPtrT> at_least_space_for) {
|
||||
// See HashTable::New().
|
||||
CSA_ASSERT(this,
|
||||
IntPtrLessThanOrEqual(IntPtrConstant(0), at_least_space_for));
|
||||
@ -2631,9 +2631,9 @@ TF_BUILTIN(WeakMapLookupHashIndex, WeakCollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(WeakMapGet, WeakCollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
Label return_undefined(this);
|
||||
|
||||
@ -2653,9 +2653,9 @@ TF_BUILTIN(WeakMapGet, WeakCollectionsBuiltinsAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(WeakMapPrototypeHas, WeakCollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
Label return_false(this);
|
||||
|
||||
@ -2817,9 +2817,9 @@ TF_BUILTIN(WeakSetPrototypeDelete, CodeStubAssembler) {
|
||||
}
|
||||
|
||||
TF_BUILTIN(WeakSetPrototypeHas, WeakCollectionsBuiltinsAssembler) {
|
||||
Node* const receiver = Parameter(Descriptor::kReceiver);
|
||||
Node* const key = Parameter(Descriptor::kKey);
|
||||
Node* const context = Parameter(Descriptor::kContext);
|
||||
const TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
|
||||
const TNode<Object> key = CAST(Parameter(Descriptor::kKey));
|
||||
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
|
||||
|
||||
Label return_false(this);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user