diff --git a/src/builtins/builtins-collections-gen.cc b/src/builtins/builtins-collections-gen.cc index 3340d04fd2..78d47554b8 100644 --- a/src/builtins/builtins-collections-gen.cc +++ b/src/builtins/builtins-collections-gen.cc @@ -79,8 +79,8 @@ class BaseCollectionsAssembler : public CodeStubAssembler { TNode new_target); // Allocates the backing store for a collection. - virtual TNode AllocateTable(Variant variant, TNode context, - TNode at_least_space_for) = 0; + virtual TNode AllocateTable( + Variant variant, TNode 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 EstimatedInitialSize(TNode initial_entries, TNode is_fast_jsarray); - void GotoIfNotJSReceiver(Node* const obj, Label* if_not_receiver); + void GotoIfNotJSReceiver(TNode const obj, Label* if_not_receiver); // Determines whether the collection's prototype has been modified. TNode 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 key_n = pair.key; + TNode 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 table = AllocateTable(variant, context, at_least_space_for); + TNode 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 BaseCollectionsAssembler::EstimatedInitialSize( [=] { return IntPtrConstant(0); }); } -void BaseCollectionsAssembler::GotoIfNotJSReceiver(Node* const obj, +void BaseCollectionsAssembler::GotoIfNotJSReceiver(TNode 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 BaseCollectionsAssembler::GetInitialCollectionPrototype( @@ -606,13 +606,14 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler { protected: template - Node* AllocateJSCollectionIterator(SloppyTNode context, - int map_index, Node* collection); - TNode AllocateTable(Variant variant, TNode context, - TNode at_least_space_for) override; - TNode GetHash(SloppyTNode const key); - TNode CallGetHashRaw(SloppyTNode const key); - TNode CallGetOrCreateHashRaw(SloppyTNode const key); + TNode AllocateJSCollectionIterator( + const TNode context, int map_index, + const TNode collection); + TNode AllocateTable(Variant variant, + TNode at_least_space_for) override; + TNode GetHash(const TNode key); + TNode CallGetHashRaw(const TNode key); + TNode CallGetOrCreateHashRaw(const TNode 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 - void FindOrderedHashTableEntryForSmiKey(Node* table, - SloppyTNode key_tagged, - Variable* result, Label* entry_found, - Label* not_found); - void SameValueZeroSmi(SloppyTNode key_smi, - SloppyTNode candidate_key, Label* if_same, - Label* if_not_same); + void FindOrderedHashTableEntryForSmiKey(TNode table, + TNode key_tagged, + TVariable* result, + Label* entry_found, Label* not_found); + void SameValueZeroSmi(TNode key_smi, TNode 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 key_float, - SloppyTNode candidate_key, - Label* if_same, Label* if_not_same); + void SameValueZeroHeapNumber(TNode key_float, + TNode candidate_key, Label* if_same, + Label* if_not_same); template void FindOrderedHashTableEntryForHeapNumberKey( - SloppyTNode context, Node* table, - SloppyTNode key_heap_number, Variable* result, - Label* entry_found, Label* not_found); + TNode table, TNode key_heap_number, + TVariable* 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 - void FindOrderedHashTableEntryForBigIntKey(SloppyTNode context, - Node* table, Node* key, - Variable* result, + void FindOrderedHashTableEntryForBigIntKey(TNode table, + TNode key_big_int, + TVariable* 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 - void FindOrderedHashTableEntryForStringKey( - SloppyTNode context, Node* table, SloppyTNode key_tagged, - Variable* result, Label* entry_found, Label* not_found); - TNode ComputeStringHash(TNode context, - TNode string_key); - void SameValueZeroString(SloppyTNode context, - SloppyTNode key_string, - SloppyTNode candidate_key, Label* if_same, + void FindOrderedHashTableEntryForStringKey(TNode table, + TNode key_tagged, + TVariable* result, + Label* entry_found, + Label* not_found); + TNode ComputeStringHash(TNode string_key); + void SameValueZeroString(TNode key_string, + TNode 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 - void FindOrderedHashTableEntryForOtherKey( - SloppyTNode context, Node* table, SloppyTNode key, - Variable* result, Label* entry_found, Label* not_found); + void FindOrderedHashTableEntryForOtherKey(TNode table, + TNode key_heap_object, + TVariable* result, + Label* entry_found, + Label* not_found); template - void TryLookupOrderedHashTableIndex(Node* const table, Node* const key, - Node* const context, Variable* result, + void TryLookupOrderedHashTableIndex(const TNode table, + const TNode key, + TVariable* result, Label* if_entry_found, Label* if_not_found); - Node* NormalizeNumberKey(Node* key); + const TNode NormalizeNumberKey(const TNode key); void StoreOrderedHashMapNewEntry(TNode const table, Node* const key, Node* const value, Node* const hash, @@ -728,8 +730,9 @@ class CollectionsBuiltinsAssembler : public BaseCollectionsAssembler { }; template -Node* CollectionsBuiltinsAssembler::AllocateJSCollectionIterator( - SloppyTNode context, int map_index, Node* collection) { +TNode CollectionsBuiltinsAssembler::AllocateJSCollectionIterator( + TNode const context, int map_index, + TNode const collection) { TNode const table = LoadObjectField(collection, JSCollection::kTableOffset); TNode const native_context = LoadNativeContext(context); @@ -747,9 +750,8 @@ Node* CollectionsBuiltinsAssembler::AllocateJSCollectionIterator( return iterator; } -TNode CollectionsBuiltinsAssembler::AllocateTable( - Variant variant, TNode context, - TNode at_least_space_for) { +TNode CollectionsBuiltinsAssembler::AllocateTable( + Variant variant, TNode at_least_space_for) { return CAST((variant == kMap || variant == kWeakMap) ? AllocateOrderedHashTable() : AllocateOrderedHashTable()); @@ -776,7 +778,7 @@ TF_BUILTIN(SetConstructor, CollectionsBuiltinsAssembler) { } TNode CollectionsBuiltinsAssembler::CallGetOrCreateHashRaw( - SloppyTNode const key) { + const TNode key) { TNode const function_addr = ExternalConstant(ExternalReference::get_or_create_hash_raw()); TNode const isolate_ptr = @@ -793,7 +795,7 @@ TNode CollectionsBuiltinsAssembler::CallGetOrCreateHashRaw( } TNode CollectionsBuiltinsAssembler::CallGetHashRaw( - SloppyTNode const key) { + const TNode key) { TNode const function_addr = ExternalConstant(ExternalReference::orderedhashmap_gethash_raw()); TNode const isolate_ptr = @@ -810,7 +812,7 @@ TNode CollectionsBuiltinsAssembler::CallGetHashRaw( } TNode CollectionsBuiltinsAssembler::GetHash( - SloppyTNode const key) { + const TNode 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 CollectionsBuiltinsAssembler::GetHash( return var_hash.value(); } -void CollectionsBuiltinsAssembler::SameValueZeroSmi( - SloppyTNode key_smi, SloppyTNode candidate_key, Label* if_same, - Label* if_not_same) { +void CollectionsBuiltinsAssembler::SameValueZeroSmi(TNode key_smi, + TNode 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 void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey( - Node* table, SloppyTNode smi_key, Variable* result, Label* entry_found, - Label* not_found) { + TNode table, TNode smi_key, TVariable* result, + Label* entry_found, Label* not_found) { TNode const key_untagged = SmiUntag(smi_key); TNode const hash = ChangeInt32ToIntPtr(ComputeUnseededHash(key_untagged)); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); - result->Bind(hash); + *result = hash; FindOrderedHashTableEntry( table, hash, [&](TNode other_key, Label* if_same, Label* if_not_same) { @@ -1179,28 +1182,26 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForSmiKey( template void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForStringKey( - SloppyTNode context, Node* table, SloppyTNode key_tagged, - Variable* result, Label* entry_found, Label* not_found) { - TNode const hash = ComputeStringHash(context, key_tagged); + TNode table, TNode key_tagged, + TVariable* result, Label* entry_found, Label* not_found) { + TNode const hash = ComputeStringHash(key_tagged); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); - result->Bind(hash); + *result = hash; FindOrderedHashTableEntry( table, hash, [&](TNode 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 void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForHeapNumberKey( - SloppyTNode context, Node* table, - SloppyTNode key_heap_number, Variable* result, - Label* entry_found, Label* not_found) { + TNode table, TNode key_heap_number, + TVariable* result, Label* entry_found, Label* not_found) { TNode const hash = CallGetHashRaw(key_heap_number); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); - result->Bind(hash); + *result = hash; TNode const key_float = LoadHeapNumberValue(key_heap_number); FindOrderedHashTableEntry( table, hash, @@ -1212,36 +1213,36 @@ void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForHeapNumberKey( template void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForBigIntKey( - SloppyTNode context, Node* table, Node* key, Variable* result, - Label* entry_found, Label* not_found) { - TNode const hash = CallGetHashRaw(key); + TNode table, TNode key_big_int, + TVariable* result, Label* entry_found, Label* not_found) { + TNode const hash = CallGetHashRaw(key_big_int); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); - result->Bind(hash); + *result = hash; FindOrderedHashTableEntry( table, hash, [&](TNode 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 void CollectionsBuiltinsAssembler::FindOrderedHashTableEntryForOtherKey( - SloppyTNode context, Node* table, SloppyTNode key, - Variable* result, Label* entry_found, Label* not_found) { - TNode const hash = GetHash(key); + TNode table, TNode key_heap_object, + TVariable* result, Label* entry_found, Label* not_found) { + TNode const hash = GetHash(key_heap_object); CSA_ASSERT(this, IntPtrGreaterThanOrEqual(hash, IntPtrConstant(0))); - result->Bind(hash); + *result = hash; FindOrderedHashTableEntry( table, hash, [&](TNode 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 CollectionsBuiltinsAssembler::ComputeStringHash( - TNode context, TNode string_key) { + TNode string_key) { TVARIABLE(IntPtrT, var_result); Label hash_not_computed(this), done(this, &var_result); @@ -1259,14 +1260,14 @@ TNode CollectionsBuiltinsAssembler::ComputeStringHash( } void CollectionsBuiltinsAssembler::SameValueZeroString( - SloppyTNode context, SloppyTNode key_string, - SloppyTNode candidate_key, Label* if_same, Label* if_not_same) { + TNode key_string, TNode 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 key_float, SloppyTNode candidate_key, - Label* if_same, Label* if_not_same) { + TNode key_float, TNode 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 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.get"); - TNode const table = LoadObjectField(receiver, JSMap::kTableOffset); + TNode const table = + LoadObjectField(CAST(receiver), JSMap::kTableOffset); TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.has"); - TNode const table = LoadObjectField(receiver, JSMap::kTableOffset); + TNode const table = + LoadObjectField(CAST(receiver), JSMap::kTableOffset); TNode 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 CollectionsBuiltinsAssembler::NormalizeNumberKey( + const TNode key) { + TVARIABLE(Object, result, key); Label done(this); GotoIf(TaggedIsSmi(key), &done); - GotoIfNot(IsHeapNumber(key), &done); - TNode const number = LoadHeapNumberValue(key); + GotoIfNot(IsHeapNumber(CAST(key)), &done); + TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode value = CAST(Parameter(Descriptor::kValue)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.set"); key = NormalizeNumberKey(key); TNode const table = - CAST(LoadObjectField(receiver, JSMap::kTableOffset)); + LoadObjectField(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(table, key, context, - &entry_start_position_or_hash, - &entry_found, ¬_found); + TryLookupOrderedHashTableIndex( + 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(CAST(receiver), JSMap::kTableOffset); number_of_buckets.Bind(SmiUntag(CAST(UnsafeLoadFixedArrayElement( table_var.value(), OrderedHashMap::NumberOfBucketsIndex())))); TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.delete"); TNode const table = - CAST(LoadObjectField(receiver, JSMap::kTableOffset)); + LoadObjectField(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(table, key, context, - &entry_start_position_or_hash, - &entry_found, ¬_found); + TryLookupOrderedHashTableIndex( + 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.add"); key = NormalizeNumberKey(key); TNode const table = - CAST(LoadObjectField(receiver, JSMap::kTableOffset)); + LoadObjectField(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(table, key, context, - &entry_start_position_or_hash, - &entry_found, ¬_found); + TryLookupOrderedHashTableIndex( + 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(CAST(receiver), JSMap::kTableOffset); number_of_buckets.Bind(SmiUntag(CAST(UnsafeLoadFixedArrayElement( table_var.value(), OrderedHashSet::NumberOfBucketsIndex())))); TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.delete"); TNode const table = - CAST(LoadObjectField(receiver, JSMap::kTableOffset)); + LoadObjectField(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(table, key, context, - &entry_start_position_or_hash, - &entry_found, ¬_found); + TryLookupOrderedHashTableIndex( + 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.entries"); Return(AllocateJSCollectionIterator( - 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "get Map.prototype.size"); TNode const table = - CAST(LoadObjectField(receiver, JSMap::kTableOffset)); + LoadObjectField(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 argc = UncheckedCast(Parameter(Descriptor::kJSActualArgumentsCount)); - Node* const context = Parameter(Descriptor::kContext); + const TNode context = CAST(Parameter(Descriptor::kContext)); CodeStubArguments args(this, argc); TNode const receiver = args.GetReceiver(); TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.keys"); Return(AllocateJSCollectionIterator( - 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_MAP_TYPE, "Map.prototype.values"); Return(AllocateJSCollectionIterator( - 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode 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 const receiver_instance_type = LoadInstanceType(receiver); + TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.has"); - TNode const table = LoadObjectField(receiver, JSMap::kTableOffset); + TNode 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 key_map = LoadMap(key); + TNode key_map = LoadMap(CAST(key)); TNode 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( - context, table, key, &entry_start_position, &entry_found, ¬_found); + CAST(table), CAST(key), &entry_start_position, &entry_found, ¬_found); BIND(&if_key_smi); { FindOrderedHashTableEntryForSmiKey( - table, key, &entry_start_position, &entry_found, ¬_found); + CAST(table), CAST(key), &entry_start_position, &entry_found, + ¬_found); } BIND(&if_key_string); { FindOrderedHashTableEntryForStringKey( - 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( - context, table, key, &entry_start_position, &entry_found, ¬_found); + CAST(table), CAST(key), &entry_start_position, &entry_found, + ¬_found); } BIND(&if_key_bigint); { FindOrderedHashTableEntryForBigIntKey( - 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.entries"); Return(AllocateJSCollectionIterator( - 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "get Set.prototype.size"); TNode const table = - CAST(LoadObjectField(receiver, JSSet::kTableOffset)); + LoadObjectField(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 argc = UncheckedCast(Parameter(Descriptor::kJSActualArgumentsCount)); - Node* const context = Parameter(Descriptor::kContext); + const TNode context = CAST(Parameter(Descriptor::kContext)); CodeStubArguments args(this, argc); TNode const receiver = args.GetReceiver(); TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode context = CAST(Parameter(Descriptor::kContext)); ThrowIfNotInstanceType(context, receiver, JS_SET_TYPE, "Set.prototype.values"); Return(AllocateJSCollectionIterator( - 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode 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 const receiver_instance_type = LoadInstanceType(receiver); + TNode 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 void CollectionsBuiltinsAssembler::TryLookupOrderedHashTableIndex( - Node* const table, Node* const key, Node* const context, Variable* result, - Label* if_entry_found, Label* if_not_found) { + const TNode table, const TNode key, + TVariable* 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 key_map = LoadMap(key); + TNode key_map = LoadMap(CAST(key)); TNode 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( - 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( - table, key, result, if_entry_found, if_not_found); + table, CAST(key), result, if_entry_found, if_not_found); } BIND(&if_key_string); { FindOrderedHashTableEntryForStringKey( - 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( - 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( - 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 table = CAST(Parameter(Descriptor::kTable)); + const TNode 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( - 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 key, TNode value, TNode number_of_elements); - TNode AllocateTable(Variant variant, TNode context, - TNode at_least_space_for) override; + TNode AllocateTable(Variant variant, + TNode at_least_space_for) override; // Generates and sets the identity for a JSRececiver. TNode CreateIdentityHash(TNode receiver); @@ -2390,9 +2391,8 @@ void WeakCollectionsBuiltinsAssembler::AddEntry( SmiFromIntPtr(number_of_elements), SKIP_WRITE_BARRIER); } -TNode WeakCollectionsBuiltinsAssembler::AllocateTable( - Variant variant, TNode context, - TNode at_least_space_for) { +TNode WeakCollectionsBuiltinsAssembler::AllocateTable( + Variant variant, TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode 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 receiver = CAST(Parameter(Descriptor::kReceiver)); + const TNode key = CAST(Parameter(Descriptor::kKey)); + const TNode context = CAST(Parameter(Descriptor::kContext)); Label return_false(this);