Commit 93bcce68 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa] Typify dictionary related code.

Bug: v8:7754
Change-Id: I44d20d55f5da0a0f95b89a565dbe21304c6d174c
Reviewed-on: https://chromium-review.googlesource.com/1052111
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53122}
parent 8251c146
...@@ -459,8 +459,8 @@ Node* ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral( ...@@ -459,8 +459,8 @@ Node* ConstructorBuiltinsAssembler::EmitCreateShallowObjectLiteral(
BIND(&if_dictionary); BIND(&if_dictionary);
{ {
Comment("Copy dictionary properties"); Comment("Copy dictionary properties");
var_properties.Bind( var_properties.Bind(CopyNameDictionary(
CopyNameDictionary(LoadSlowProperties(boilerplate), call_runtime)); CAST(LoadSlowProperties(boilerplate)), call_runtime));
// Slow objects have no in-object properties. // Slow objects have no in-object properties.
Goto(&done); Goto(&done);
} }
......
...@@ -484,22 +484,23 @@ class DeletePropertyBaseAssembler : public AccessorAssembler { ...@@ -484,22 +484,23 @@ class DeletePropertyBaseAssembler : public AccessorAssembler {
explicit DeletePropertyBaseAssembler(compiler::CodeAssemblerState* state) explicit DeletePropertyBaseAssembler(compiler::CodeAssemblerState* state)
: AccessorAssembler(state) {} : AccessorAssembler(state) {}
void DeleteDictionaryProperty(Node* receiver, Node* properties, Node* name, void DeleteDictionaryProperty(TNode<Object> receiver,
Node* context, Label* dont_delete, TNode<NameDictionary> properties,
Label* notfound) { TNode<Name> name, TNode<Context> context,
VARIABLE(var_name_index, MachineType::PointerRepresentation()); Label* dont_delete, Label* notfound) {
TVARIABLE(IntPtrT, var_name_index);
Label dictionary_found(this, &var_name_index); Label dictionary_found(this, &var_name_index);
NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found, NameDictionaryLookup<NameDictionary>(properties, name, &dictionary_found,
&var_name_index, notfound); &var_name_index, notfound);
BIND(&dictionary_found); BIND(&dictionary_found);
Node* key_index = var_name_index.value(); TNode<IntPtrT> key_index = var_name_index.value();
Node* details = TNode<Uint32T> details =
LoadDetailsByKeyIndex<NameDictionary>(properties, key_index); LoadDetailsByKeyIndex<NameDictionary>(properties, key_index);
GotoIf(IsSetWord32(details, PropertyDetails::kAttributesDontDeleteMask), GotoIf(IsSetWord32(details, PropertyDetails::kAttributesDontDeleteMask),
dont_delete); dont_delete);
// Overwrite the entry itself (see NameDictionary::SetEntry). // Overwrite the entry itself (see NameDictionary::SetEntry).
Node* filler = TheHoleConstant(); TNode<HeapObject> filler = TheHoleConstant();
DCHECK(Heap::RootIsImmortalImmovable(Heap::kTheHoleValueRootIndex)); DCHECK(Heap::RootIsImmortalImmovable(Heap::kTheHoleValueRootIndex));
StoreFixedArrayElement(properties, key_index, filler, SKIP_WRITE_BARRIER); StoreFixedArrayElement(properties, key_index, filler, SKIP_WRITE_BARRIER);
StoreValueByKeyIndex<NameDictionary>(properties, key_index, filler, StoreValueByKeyIndex<NameDictionary>(properties, key_index, filler,
...@@ -508,16 +509,17 @@ class DeletePropertyBaseAssembler : public AccessorAssembler { ...@@ -508,16 +509,17 @@ class DeletePropertyBaseAssembler : public AccessorAssembler {
SmiConstant(0)); SmiConstant(0));
// Update bookkeeping information (see NameDictionary::ElementRemoved). // Update bookkeeping information (see NameDictionary::ElementRemoved).
Node* nof = GetNumberOfElements<NameDictionary>(properties); TNode<Smi> nof = GetNumberOfElements<NameDictionary>(properties);
Node* new_nof = SmiSub(nof, SmiConstant(1)); TNode<Smi> new_nof = SmiSub(nof, SmiConstant(1));
SetNumberOfElements<NameDictionary>(properties, new_nof); SetNumberOfElements<NameDictionary>(properties, new_nof);
Node* num_deleted = GetNumberOfDeletedElements<NameDictionary>(properties); TNode<Smi> num_deleted =
Node* new_deleted = SmiAdd(num_deleted, SmiConstant(1)); GetNumberOfDeletedElements<NameDictionary>(properties);
TNode<Smi> new_deleted = SmiAdd(num_deleted, SmiConstant(1));
SetNumberOfDeletedElements<NameDictionary>(properties, new_deleted); SetNumberOfDeletedElements<NameDictionary>(properties, new_deleted);
// Shrink the dictionary if necessary (see NameDictionary::Shrink). // Shrink the dictionary if necessary (see NameDictionary::Shrink).
Label shrinking_done(this); Label shrinking_done(this);
Node* capacity = GetCapacity<NameDictionary>(properties); TNode<Smi> capacity = GetCapacity<NameDictionary>(properties);
GotoIf(SmiGreaterThan(new_nof, SmiShr(capacity, 2)), &shrinking_done); GotoIf(SmiGreaterThan(new_nof, SmiShr(capacity, 2)), &shrinking_done);
GotoIf(SmiLessThan(new_nof, SmiConstant(16)), &shrinking_done); GotoIf(SmiLessThan(new_nof, SmiConstant(16)), &shrinking_done);
CallRuntime(Runtime::kShrinkPropertyDictionary, context, receiver); CallRuntime(Runtime::kShrinkPropertyDictionary, context, receiver);
...@@ -529,10 +531,10 @@ class DeletePropertyBaseAssembler : public AccessorAssembler { ...@@ -529,10 +531,10 @@ class DeletePropertyBaseAssembler : public AccessorAssembler {
}; };
TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) { TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) {
Node* receiver = Parameter(Descriptor::kObject); TNode<Object> receiver = CAST(Parameter(Descriptor::kObject));
Node* key = Parameter(Descriptor::kKey); TNode<Object> key = CAST(Parameter(Descriptor::kKey));
Node* language_mode = Parameter(Descriptor::kLanguageMode); TNode<Smi> language_mode = CAST(Parameter(Descriptor::kLanguageMode));
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
VARIABLE(var_index, MachineType::PointerRepresentation()); VARIABLE(var_index, MachineType::PointerRepresentation());
VARIABLE(var_unique, MachineRepresentation::kTagged, key); VARIABLE(var_unique, MachineRepresentation::kTagged, key);
...@@ -540,7 +542,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) { ...@@ -540,7 +542,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) {
if_notfound(this), slow(this); if_notfound(this), slow(this);
GotoIf(TaggedIsSmi(receiver), &slow); GotoIf(TaggedIsSmi(receiver), &slow);
Node* receiver_map = LoadMap(receiver); TNode<Map> receiver_map = LoadMap(CAST(receiver));
TNode<Int32T> instance_type = LoadMapInstanceType(receiver_map); TNode<Int32T> instance_type = LoadMapInstanceType(receiver_map);
GotoIf(IsCustomElementsReceiverInstanceType(instance_type), &slow); GotoIf(IsCustomElementsReceiverInstanceType(instance_type), &slow);
TryToName(key, &if_index, &var_index, &if_unique_name, &var_unique, &slow, TryToName(key, &if_index, &var_index, &if_unique_name, &var_unique, &slow,
...@@ -555,7 +557,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) { ...@@ -555,7 +557,7 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) {
BIND(&if_unique_name); BIND(&if_unique_name);
{ {
Comment("key is unique name"); Comment("key is unique name");
Node* unique = var_unique.value(); TNode<Name> unique = CAST(var_unique.value());
CheckForAssociatedProtector(unique, &slow); CheckForAssociatedProtector(unique, &slow);
Label dictionary(this), dont_delete(this); Label dictionary(this), dont_delete(this);
...@@ -569,7 +571,8 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) { ...@@ -569,7 +571,8 @@ TF_BUILTIN(DeleteProperty, DeletePropertyBaseAssembler) {
{ {
InvalidateValidityCellIfPrototype(receiver_map); InvalidateValidityCellIfPrototype(receiver_map);
Node* properties = LoadSlowProperties(receiver); TNode<NameDictionary> properties =
CAST(LoadSlowProperties(CAST(receiver)));
DeleteDictionaryProperty(receiver, properties, unique, context, DeleteDictionaryProperty(receiver, properties, unique, context,
&dont_delete, &if_notfound); &dont_delete, &if_notfound);
} }
......
...@@ -28,8 +28,10 @@ class ObjectBuiltinsAssembler : public CodeStubAssembler { ...@@ -28,8 +28,10 @@ class ObjectBuiltinsAssembler : public CodeStubAssembler {
protected: protected:
void ReturnToStringFormat(Node* context, Node* string); void ReturnToStringFormat(Node* context, Node* string);
void AddToDictionaryIf(Node* condition, Node* name_dictionary, void AddToDictionaryIf(TNode<BoolT> condition,
Handle<Name> name, Node* value, Label* bailout); TNode<NameDictionary> name_dictionary,
Handle<Name> name, TNode<Object> value,
Label* bailout);
Node* FromPropertyDescriptor(Node* context, Node* desc); Node* FromPropertyDescriptor(Node* context, Node* desc);
Node* FromPropertyDetails(Node* context, Node* raw_value, Node* details, Node* FromPropertyDetails(Node* context, Node* raw_value, Node* details,
Label* if_bailout); Label* if_bailout);
...@@ -1492,10 +1494,9 @@ TF_BUILTIN(ObjectGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) { ...@@ -1492,10 +1494,9 @@ TF_BUILTIN(ObjectGetOwnPropertyDescriptor, ObjectBuiltinsAssembler) {
args.PopAndReturn(UndefinedConstant()); args.PopAndReturn(UndefinedConstant());
} }
void ObjectBuiltinsAssembler::AddToDictionaryIf(Node* condition, void ObjectBuiltinsAssembler::AddToDictionaryIf(
Node* name_dictionary, TNode<BoolT> condition, TNode<NameDictionary> name_dictionary,
Handle<Name> name, Node* value, Handle<Name> name, TNode<Object> value, Label* bailout) {
Label* bailout) {
Label done(this); Label done(this);
GotoIfNot(condition, &done); GotoIfNot(condition, &done);
...@@ -1555,13 +1556,14 @@ Node* ObjectBuiltinsAssembler::FromPropertyDescriptor(Node* context, ...@@ -1555,13 +1556,14 @@ Node* ObjectBuiltinsAssembler::FromPropertyDescriptor(Node* context,
native_context, Context::SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP); native_context, Context::SLOW_OBJECT_WITH_OBJECT_PROTOTYPE_MAP);
// We want to preallocate the slots for value, writable, get, set, // We want to preallocate the slots for value, writable, get, set,
// enumerable and configurable - a total of 6 // enumerable and configurable - a total of 6
Node* properties = AllocateNameDictionary(6); TNode<NameDictionary> properties = AllocateNameDictionary(6);
Node* js_desc = AllocateJSObjectFromMap(map, properties); Node* js_desc = AllocateJSObjectFromMap(map, properties);
Label bailout(this, Label::kDeferred); Label bailout(this, Label::kDeferred);
Factory* factory = isolate()->factory(); Factory* factory = isolate()->factory();
Node* value = LoadObjectField(desc, PropertyDescriptorObject::kValueOffset); TNode<Object> value =
LoadObjectField(desc, PropertyDescriptorObject::kValueOffset);
AddToDictionaryIf(IsNotTheHole(value), properties, factory->value_string(), AddToDictionaryIf(IsNotTheHole(value), properties, factory->value_string(),
value, &bailout); value, &bailout);
AddToDictionaryIf( AddToDictionaryIf(
...@@ -1571,10 +1573,12 @@ Node* ObjectBuiltinsAssembler::FromPropertyDescriptor(Node* context, ...@@ -1571,10 +1573,12 @@ Node* ObjectBuiltinsAssembler::FromPropertyDescriptor(Node* context,
IsSetWord32<PropertyDescriptorObject::IsWritableBit>(flags)), IsSetWord32<PropertyDescriptorObject::IsWritableBit>(flags)),
&bailout); &bailout);
Node* get = LoadObjectField(desc, PropertyDescriptorObject::kGetOffset); TNode<Object> get =
LoadObjectField(desc, PropertyDescriptorObject::kGetOffset);
AddToDictionaryIf(IsNotTheHole(get), properties, factory->get_string(), get, AddToDictionaryIf(IsNotTheHole(get), properties, factory->get_string(), get,
&bailout); &bailout);
Node* set = LoadObjectField(desc, PropertyDescriptorObject::kSetOffset); TNode<Object> set =
LoadObjectField(desc, PropertyDescriptorObject::kSetOffset);
AddToDictionaryIf(IsNotTheHole(set), properties, factory->set_string(), set, AddToDictionaryIf(IsNotTheHole(set), properties, factory->set_string(), set,
&bailout); &bailout);
......
This diff is collapsed.
...@@ -236,7 +236,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -236,7 +236,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
ParameterMode mode); ParameterMode mode);
// Round the 32bits payload of the provided word up to the next power of two. // Round the 32bits payload of the provided word up to the next power of two.
Node* IntPtrRoundUpToPowerOfTwo32(Node* value); TNode<IntPtrT> IntPtrRoundUpToPowerOfTwo32(TNode<IntPtrT> value);
// Select the maximum of the two provided IntPtr values. // Select the maximum of the two provided IntPtr values.
TNode<IntPtrT> IntPtrMax(SloppyTNode<IntPtrT> left, TNode<IntPtrT> IntPtrMax(SloppyTNode<IntPtrT> left,
SloppyTNode<IntPtrT> right); SloppyTNode<IntPtrT> right);
...@@ -288,11 +288,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -288,11 +288,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Smi> TrySmiAdd(TNode<Smi> a, TNode<Smi> b, Label* if_overflow); TNode<Smi> TrySmiAdd(TNode<Smi> a, TNode<Smi> b, Label* if_overflow);
TNode<Smi> TrySmiSub(TNode<Smi> a, TNode<Smi> b, Label* if_overflow); TNode<Smi> TrySmiSub(TNode<Smi> a, TNode<Smi> b, Label* if_overflow);
Node* SmiShl(Node* a, int shift) { TNode<Smi> SmiShl(SloppyTNode<Smi> a, int shift) {
return BitcastWordToTaggedSigned(WordShl(BitcastTaggedToWord(a), shift)); return BitcastWordToTaggedSigned(WordShl(BitcastTaggedToWord(a), shift));
} }
Node* SmiShr(Node* a, int shift) { TNode<Smi> SmiShr(SloppyTNode<Smi> a, int shift) {
return BitcastWordToTaggedSigned( return BitcastWordToTaggedSigned(
WordAnd(WordShr(BitcastTaggedToWord(a), shift), WordAnd(WordShr(BitcastTaggedToWord(a), shift),
BitcastTaggedToWord(SmiConstant(-1)))); BitcastTaggedToWord(SmiConstant(-1))));
...@@ -991,10 +991,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -991,10 +991,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<String> left, TNode<String> right, TNode<String> left, TNode<String> right,
AllocationFlags flags = kNone); AllocationFlags flags = kNone);
Node* AllocateNameDictionary(int at_least_space_for); TNode<NameDictionary> AllocateNameDictionary(int at_least_space_for);
Node* AllocateNameDictionary(Node* at_least_space_for); TNode<NameDictionary> AllocateNameDictionary(
Node* AllocateNameDictionaryWithCapacity(Node* capacity); TNode<IntPtrT> at_least_space_for);
Node* CopyNameDictionary(Node* dictionary, Label* large_object_fallback); TNode<NameDictionary> AllocateNameDictionaryWithCapacity(
TNode<IntPtrT> capacity);
TNode<NameDictionary> CopyNameDictionary(TNode<NameDictionary> dictionary,
Label* large_object_fallback);
template <typename CollectionType> template <typename CollectionType>
Node* AllocateOrderedHashTable(); Node* AllocateOrderedHashTable();
...@@ -1749,9 +1752,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1749,9 +1752,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// Calculates array index for given dictionary entry and entry field. // Calculates array index for given dictionary entry and entry field.
// See Dictionary::EntryToIndex(). // See Dictionary::EntryToIndex().
template <typename Dictionary> template <typename Dictionary>
Node* EntryToIndex(Node* entry, int field_index); TNode<IntPtrT> EntryToIndex(TNode<IntPtrT> entry, int field_index);
template <typename Dictionary> template <typename Dictionary>
Node* EntryToIndex(Node* entry) { TNode<IntPtrT> EntryToIndex(TNode<IntPtrT> entry) {
return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex); return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex);
} }
...@@ -1801,44 +1804,52 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1801,44 +1804,52 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
} }
// Calculate a valid size for the a hash table. // Calculate a valid size for the a hash table.
TNode<IntPtrT> HashTableComputeCapacity( TNode<IntPtrT> HashTableComputeCapacity(TNode<IntPtrT> at_least_space_for);
SloppyTNode<IntPtrT> at_least_space_for);
template <class Dictionary> template <class Dictionary>
Node* GetNumberOfElements(Node* dictionary) { TNode<Smi> GetNumberOfElements(TNode<Dictionary> dictionary) {
return LoadFixedArrayElement(dictionary, return CAST(
Dictionary::kNumberOfElementsIndex); LoadFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex));
} }
template <class Dictionary> template <class Dictionary>
void SetNumberOfElements(Node* dictionary, Node* num_elements_smi) { void SetNumberOfElements(TNode<Dictionary> dictionary,
TNode<Smi> num_elements_smi) {
StoreFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex, StoreFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex,
num_elements_smi, SKIP_WRITE_BARRIER); num_elements_smi, SKIP_WRITE_BARRIER);
} }
template <class Dictionary> template <class Dictionary>
Node* GetNumberOfDeletedElements(Node* dictionary) { TNode<Smi> GetNumberOfDeletedElements(TNode<Dictionary> dictionary) {
return LoadFixedArrayElement(dictionary, return CAST(LoadFixedArrayElement(
Dictionary::kNumberOfDeletedElementsIndex); dictionary, Dictionary::kNumberOfDeletedElementsIndex));
} }
template <class Dictionary> template <class Dictionary>
void SetNumberOfDeletedElements(Node* dictionary, Node* num_deleted_smi) { void SetNumberOfDeletedElements(TNode<Dictionary> dictionary,
TNode<Smi> num_deleted_smi) {
StoreFixedArrayElement(dictionary, StoreFixedArrayElement(dictionary,
Dictionary::kNumberOfDeletedElementsIndex, Dictionary::kNumberOfDeletedElementsIndex,
num_deleted_smi, SKIP_WRITE_BARRIER); num_deleted_smi, SKIP_WRITE_BARRIER);
} }
template <class Dictionary> template <class Dictionary>
Node* GetCapacity(Node* dictionary) { TNode<Smi> GetCapacity(TNode<Dictionary> dictionary) {
return LoadFixedArrayElement(dictionary, Dictionary::kCapacityIndex); return CAST(LoadFixedArrayElement(dictionary, Dictionary::kCapacityIndex));
} }
template <class Dictionary> template <class Dictionary>
Node* GetNextEnumerationIndex(Node* dictionary); TNode<Smi> GetNextEnumerationIndex(TNode<Dictionary> dictionary) {
return CAST(LoadFixedArrayElement(dictionary,
Dictionary::kNextEnumerationIndexIndex));
}
template <class Dictionary> template <class Dictionary>
void SetNextEnumerationIndex(Node* dictionary, Node* next_enum_index_smi); void SetNextEnumerationIndex(TNode<Dictionary> dictionary,
TNode<Smi> next_enum_index_smi) {
StoreFixedArrayElement(dictionary, Dictionary::kNextEnumerationIndexIndex,
next_enum_index_smi, SKIP_WRITE_BARRIER);
}
// Looks up an entry in a NameDictionaryBase successor. If the entry is found // Looks up an entry in a NameDictionaryBase successor. If the entry is found
// control goes to {if_found} and {var_name_index} contains an index of the // control goes to {if_found} and {var_name_index} contains an index of the
...@@ -1848,11 +1859,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1848,11 +1859,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
enum LookupMode { kFindExisting, kFindInsertionIndex }; enum LookupMode { kFindExisting, kFindInsertionIndex };
template <typename Dictionary> template <typename Dictionary>
Node* LoadName(Node* key); TNode<HeapObject> LoadName(TNode<HeapObject> key);
template <typename Dictionary> template <typename Dictionary>
void NameDictionaryLookup(Node* dictionary, Node* unique_name, void NameDictionaryLookup(TNode<Dictionary> dictionary,
Label* if_found, Variable* var_name_index, TNode<Name> unique_name, Label* if_found,
TVariable<IntPtrT>* var_name_index,
Label* if_not_found, Label* if_not_found,
int inlined_probes = kInlinedDictionaryProbes, int inlined_probes = kInlinedDictionaryProbes,
LookupMode mode = kFindExisting); LookupMode mode = kFindExisting);
...@@ -1860,19 +1872,23 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1860,19 +1872,23 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* ComputeIntegerHash(Node* key); Node* ComputeIntegerHash(Node* key);
Node* ComputeIntegerHash(Node* key, Node* seed); Node* ComputeIntegerHash(Node* key, Node* seed);
void NumberDictionaryLookup(Node* dictionary, Node* intptr_index, void NumberDictionaryLookup(TNode<NumberDictionary> dictionary,
Label* if_found, Variable* var_entry, TNode<IntPtrT> intptr_index, Label* if_found,
TVariable<IntPtrT>* var_entry,
Label* if_not_found); Label* if_not_found);
template <class Dictionary> template <class Dictionary>
void FindInsertionEntry(Node* dictionary, Node* key, Variable* var_key_index); void FindInsertionEntry(TNode<Dictionary> dictionary, TNode<Name> key,
TVariable<IntPtrT>* var_key_index);
template <class Dictionary> template <class Dictionary>
void InsertEntry(Node* dictionary, Node* key, Node* value, Node* index, void InsertEntry(TNode<Dictionary> dictionary, TNode<Name> key,
Node* enum_index); TNode<Object> value, TNode<IntPtrT> index,
TNode<Smi> enum_index);
template <class Dictionary> template <class Dictionary>
void Add(Node* dictionary, Node* key, Node* value, Label* bailout); void Add(TNode<Dictionary> dictionary, TNode<Name> key, TNode<Object> value,
Label* bailout);
// Tries to check if {object} has own {unique_name} property. // Tries to check if {object} has own {unique_name} property.
void TryHasOwnProperty(Node* object, Node* map, Node* instance_type, void TryHasOwnProperty(Node* object, Node* map, Node* instance_type,
...@@ -1980,8 +1996,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1980,8 +1996,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// if_absent if it's known to not exist. To if_not_found if the prototype // if_absent if it's known to not exist. To if_not_found if the prototype
// chain needs to be checked. And if_bailout if the lookup is unsupported. // chain needs to be checked. And if_bailout if the lookup is unsupported.
void TryLookupElement(Node* object, Node* map, void TryLookupElement(Node* object, Node* map,
SloppyTNode<Int32T> instance_type, Node* intptr_index, SloppyTNode<Int32T> instance_type,
Label* if_found, Label* if_absent, Label* if_not_found, SloppyTNode<IntPtrT> intptr_index, Label* if_found,
Label* if_absent, Label* if_not_found,
Label* if_bailout); Label* if_bailout);
// This is a type of a lookup in holder generator function. In case of a // This is a type of a lookup in holder generator function. In case of a
......
...@@ -380,7 +380,7 @@ class TNode { ...@@ -380,7 +380,7 @@ class TNode {
TNode() : node_(nullptr) {} TNode() : node_(nullptr) {}
TNode operator=(TNode other) { TNode operator=(TNode other) {
DCHECK_NULL(node_); DCHECK_NOT_NULL(other.node_);
node_ = other.node_; node_ = other.node_;
return *this; return *this;
} }
......
...@@ -426,10 +426,10 @@ void AccessorAssembler::HandleLoadICSmiHandlerCase( ...@@ -426,10 +426,10 @@ void AccessorAssembler::HandleLoadICSmiHandlerCase(
BIND(&normal); BIND(&normal);
{ {
Comment("load_normal"); Comment("load_normal");
Node* properties = LoadSlowProperties(holder); TNode<NameDictionary> properties = CAST(LoadSlowProperties(holder));
VARIABLE(var_name_index, MachineType::PointerRepresentation()); TVARIABLE(IntPtrT, var_name_index);
Label found(this, &var_name_index); Label found(this, &var_name_index);
NameDictionaryLookup<NameDictionary>(properties, p->name, &found, NameDictionaryLookup<NameDictionary>(properties, CAST(p->name), &found,
&var_name_index, miss); &var_name_index, miss);
BIND(&found); BIND(&found);
{ {
...@@ -677,10 +677,11 @@ Node* AccessorAssembler::HandleProtoHandler( ...@@ -677,10 +677,11 @@ Node* AccessorAssembler::HandleProtoHandler(
CSA_ASSERT(this, Word32BinaryNot(HasInstanceType( CSA_ASSERT(this, Word32BinaryNot(HasInstanceType(
p->receiver, JS_GLOBAL_OBJECT_TYPE))); p->receiver, JS_GLOBAL_OBJECT_TYPE)));
Node* properties = LoadSlowProperties(p->receiver); TNode<NameDictionary> properties =
VARIABLE(var_name_index, MachineType::PointerRepresentation()); CAST(LoadSlowProperties(p->receiver));
TVARIABLE(IntPtrT, var_name_index);
Label found(this, &var_name_index); Label found(this, &var_name_index);
NameDictionaryLookup<NameDictionary>(properties, p->name, &found, NameDictionaryLookup<NameDictionary>(properties, CAST(p->name), &found,
&var_name_index, &done); &var_name_index, &done);
BIND(&found); BIND(&found);
{ {
...@@ -816,12 +817,12 @@ void AccessorAssembler::HandleStoreICHandlerCase( ...@@ -816,12 +817,12 @@ void AccessorAssembler::HandleStoreICHandlerCase(
&if_proxy); &if_proxy);
CSA_ASSERT(this, CSA_ASSERT(this,
WordEqual(handler_kind, IntPtrConstant(StoreHandler::kNormal))); WordEqual(handler_kind, IntPtrConstant(StoreHandler::kNormal)));
Node* properties = LoadSlowProperties(holder); TNode<NameDictionary> properties = CAST(LoadSlowProperties(holder));
VARIABLE(var_name_index, MachineType::PointerRepresentation()); TVARIABLE(IntPtrT, var_name_index);
Label dictionary_found(this, &var_name_index); Label dictionary_found(this, &var_name_index);
NameDictionaryLookup<NameDictionary>(properties, p->name, &dictionary_found, NameDictionaryLookup<NameDictionary>(
&var_name_index, miss); properties, CAST(p->name), &dictionary_found, &var_name_index, miss);
BIND(&dictionary_found); BIND(&dictionary_found);
{ {
Node* details = LoadDetailsByKeyIndex<NameDictionary>( Node* details = LoadDetailsByKeyIndex<NameDictionary>(
...@@ -1283,11 +1284,11 @@ void AccessorAssembler::HandleStoreICProtoHandler( ...@@ -1283,11 +1284,11 @@ void AccessorAssembler::HandleStoreICProtoHandler(
// case is covered above by LookupOnReceiver bit handling of the smi // case is covered above by LookupOnReceiver bit handling of the smi
// handler. // handler.
Label slow(this); Label slow(this);
Node* receiver_map = LoadMap(p->receiver); TNode<Map> receiver_map = LoadMap(p->receiver);
InvalidateValidityCellIfPrototype(receiver_map); InvalidateValidityCellIfPrototype(receiver_map);
Node* properties = LoadSlowProperties(p->receiver); TNode<NameDictionary> properties = CAST(LoadSlowProperties(p->receiver));
Add<NameDictionary>(properties, p->name, p->value, &slow); Add<NameDictionary>(properties, CAST(p->name), p->value, &slow);
Return(p->value); Return(p->value);
BIND(&slow); BIND(&slow);
...@@ -1695,10 +1696,11 @@ void AccessorAssembler::EmitFastElementsBoundsCheck(Node* object, ...@@ -1695,10 +1696,11 @@ void AccessorAssembler::EmitFastElementsBoundsCheck(Node* object,
} }
void AccessorAssembler::EmitElementLoad( void AccessorAssembler::EmitElementLoad(
Node* object, Node* elements, Node* elements_kind, Node* intptr_index, Node* object, Node* elements, Node* elements_kind,
Node* is_jsarray_condition, Label* if_hole, Label* rebox_double, SloppyTNode<IntPtrT> intptr_index, Node* is_jsarray_condition,
Variable* var_double_value, Label* unimplemented_elements_kind, Label* if_hole, Label* rebox_double, Variable* var_double_value,
Label* out_of_bounds, Label* miss, ExitPoint* exit_point) { Label* unimplemented_elements_kind, Label* out_of_bounds, Label* miss,
ExitPoint* exit_point) {
Label if_typed_array(this), if_fast_packed(this), if_fast_holey(this), Label if_typed_array(this), if_fast_packed(this), if_fast_holey(this),
if_fast_double(this), if_fast_holey_double(this), if_nonfast(this), if_fast_double(this), if_fast_holey_double(this), if_nonfast(this),
if_dictionary(this); if_dictionary(this);
...@@ -1775,13 +1777,13 @@ void AccessorAssembler::EmitElementLoad( ...@@ -1775,13 +1777,13 @@ void AccessorAssembler::EmitElementLoad(
{ {
Comment("dictionary elements"); Comment("dictionary elements");
GotoIf(IntPtrLessThan(intptr_index, IntPtrConstant(0)), out_of_bounds); GotoIf(IntPtrLessThan(intptr_index, IntPtrConstant(0)), out_of_bounds);
VARIABLE(var_entry, MachineType::PointerRepresentation()); TVARIABLE(IntPtrT, var_entry);
Label if_found(this); Label if_found(this);
NumberDictionaryLookup(elements, intptr_index, &if_found, &var_entry, NumberDictionaryLookup(CAST(elements), intptr_index, &if_found, &var_entry,
if_hole); if_hole);
BIND(&if_found); BIND(&if_found);
// Check that the value is a data property. // Check that the value is a data property.
Node* index = EntryToIndex<NumberDictionary>(var_entry.value()); TNode<IntPtrT> index = EntryToIndex<NumberDictionary>(var_entry.value());
Node* details = LoadDetailsByKeyIndex<NumberDictionary>(elements, index); Node* details = LoadDetailsByKeyIndex<NumberDictionary>(elements, index);
Node* kind = DecodeWord32<PropertyDetails::KindField>(details); Node* kind = DecodeWord32<PropertyDetails::KindField>(details);
// TODO(jkummerow): Support accessors without missing? // TODO(jkummerow): Support accessors without missing?
...@@ -1896,12 +1898,13 @@ void AccessorAssembler::EmitElementLoad( ...@@ -1896,12 +1898,13 @@ void AccessorAssembler::EmitElementLoad(
} }
} }
void AccessorAssembler::NameDictionaryNegativeLookup(Node* object, Node* name, void AccessorAssembler::NameDictionaryNegativeLookup(Node* object,
SloppyTNode<Name> name,
Label* miss) { Label* miss) {
CSA_ASSERT(this, IsDictionaryMap(LoadMap(object))); CSA_ASSERT(this, IsDictionaryMap(LoadMap(object)));
Node* properties = LoadSlowProperties(object); TNode<NameDictionary> properties = CAST(LoadSlowProperties(object));
// Ensure the property does not exist in a dictionary-mode object. // Ensure the property does not exist in a dictionary-mode object.
VARIABLE(var_name_index, MachineType::PointerRepresentation()); TVARIABLE(IntPtrT, var_name_index);
Label done(this); Label done(this);
NameDictionaryLookup<NameDictionary>(properties, name, miss, &var_name_index, NameDictionaryLookup<NameDictionary>(properties, name, miss, &var_name_index,
&done); &done);
...@@ -2103,11 +2106,11 @@ void AccessorAssembler::GenericPropertyLoad(Node* receiver, Node* receiver_map, ...@@ -2103,11 +2106,11 @@ void AccessorAssembler::GenericPropertyLoad(Node* receiver, Node* receiver_map,
// We checked for LAST_CUSTOM_ELEMENTS_RECEIVER before, which rules out // We checked for LAST_CUSTOM_ELEMENTS_RECEIVER before, which rules out
// seeing global objects here (which would need special handling). // seeing global objects here (which would need special handling).
VARIABLE(var_name_index, MachineType::PointerRepresentation()); TVARIABLE(IntPtrT, var_name_index);
Label dictionary_found(this, &var_name_index); Label dictionary_found(this, &var_name_index);
Node* properties = LoadSlowProperties(receiver); TNode<NameDictionary> properties = CAST(LoadSlowProperties(receiver));
NameDictionaryLookup<NameDictionary>(properties, p->name, &dictionary_found, NameDictionaryLookup<NameDictionary>(properties, CAST(p->name),
&var_name_index, &dictionary_found, &var_name_index,
&lookup_prototype_chain); &lookup_prototype_chain);
BIND(&dictionary_found); BIND(&dictionary_found);
{ {
...@@ -2910,7 +2913,7 @@ void AccessorAssembler::StoreGlobalIC(const StoreICParameters* pp) { ...@@ -2910,7 +2913,7 @@ void AccessorAssembler::StoreGlobalIC(const StoreICParameters* pp) {
Signed(DecodeWord<FeedbackNexus::SlotIndexBits>(lexical_handler)); Signed(DecodeWord<FeedbackNexus::SlotIndexBits>(lexical_handler));
TNode<Context> script_context = TNode<Context> script_context =
LoadScriptContext(CAST(pp->context), context_index); LoadScriptContext(CAST(pp->context), context_index);
StoreContextElement(script_context, slot_index, CAST(pp->value)); StoreContextElement(script_context, slot_index, pp->value);
Return(pp->value); Return(pp->value);
} }
} }
......
...@@ -93,11 +93,11 @@ class AccessorAssembler : public CodeStubAssembler { ...@@ -93,11 +93,11 @@ class AccessorAssembler : public CodeStubAssembler {
protected: protected:
struct StoreICParameters : public LoadICParameters { struct StoreICParameters : public LoadICParameters {
StoreICParameters(Node* context, Node* receiver, Node* name, Node* value, StoreICParameters(Node* context, Node* receiver, Node* name,
Node* slot, Node* vector) SloppyTNode<Object> value, Node* slot, Node* vector)
: LoadICParameters(context, receiver, name, slot, vector), : LoadICParameters(context, receiver, name, slot, vector),
value(value) {} value(value) {}
Node* value; SloppyTNode<Object> value;
}; };
enum class ICMode { kNonGlobalIC, kGlobalIC }; enum class ICMode { kNonGlobalIC, kGlobalIC };
...@@ -265,11 +265,13 @@ class AccessorAssembler : public CodeStubAssembler { ...@@ -265,11 +265,13 @@ class AccessorAssembler : public CodeStubAssembler {
Node* intptr_index, Node* intptr_index,
Node* is_jsarray_condition, Label* miss); Node* is_jsarray_condition, Label* miss);
void EmitElementLoad(Node* object, Node* elements, Node* elements_kind, void EmitElementLoad(Node* object, Node* elements, Node* elements_kind,
Node* key, Node* is_jsarray_condition, Label* if_hole, SloppyTNode<IntPtrT> key, Node* is_jsarray_condition,
Label* rebox_double, Variable* var_double_value, Label* if_hole, Label* rebox_double,
Variable* var_double_value,
Label* unimplemented_elements_kind, Label* out_of_bounds, Label* unimplemented_elements_kind, Label* out_of_bounds,
Label* miss, ExitPoint* exit_point); Label* miss, ExitPoint* exit_point);
void NameDictionaryNegativeLookup(Node* object, Node* name, Label* miss); void NameDictionaryNegativeLookup(Node* object, SloppyTNode<Name> name,
Label* miss);
// Stub cache access helpers. // Stub cache access helpers.
......
...@@ -759,15 +759,16 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore( ...@@ -759,15 +759,16 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
// We checked for LAST_CUSTOM_ELEMENTS_RECEIVER before, which rules out // We checked for LAST_CUSTOM_ELEMENTS_RECEIVER before, which rules out
// seeing global objects here (which would need special handling). // seeing global objects here (which would need special handling).
VARIABLE(var_name_index, MachineType::PointerRepresentation()); TVARIABLE(IntPtrT, var_name_index);
Label dictionary_found(this, &var_name_index), not_found(this); Label dictionary_found(this, &var_name_index), not_found(this);
TNode<NameDictionary> properties = CAST(LoadSlowProperties(CAST(receiver))); TNode<NameDictionary> properties = CAST(LoadSlowProperties(CAST(receiver)));
NameDictionaryLookup<NameDictionary>(properties, p->name, &dictionary_found, NameDictionaryLookup<NameDictionary>(properties, CAST(p->name),
&var_name_index, &not_found); &dictionary_found, &var_name_index,
&not_found);
BIND(&dictionary_found); BIND(&dictionary_found);
{ {
Label overwrite(this); Label overwrite(this);
Node* details = LoadDetailsByKeyIndex<NameDictionary>( TNode<Uint32T> details = LoadDetailsByKeyIndex<NameDictionary>(
properties, var_name_index.value()); properties, var_name_index.value());
JumpIfDataProperty(details, &overwrite, &readonly); JumpIfDataProperty(details, &overwrite, &readonly);
...@@ -800,7 +801,7 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore( ...@@ -800,7 +801,7 @@ void KeyedStoreGenericAssembler::EmitGenericPropertyStore(
&readonly, slow); &readonly, slow);
Label add_dictionary_property_slow(this); Label add_dictionary_property_slow(this);
InvalidateValidityCellIfPrototype(receiver_map, bitfield2); InvalidateValidityCellIfPrototype(receiver_map, bitfield2);
Add<NameDictionary>(properties, p->name, p->value, Add<NameDictionary>(properties, CAST(p->name), p->value,
&add_dictionary_property_slow); &add_dictionary_property_slow);
exit_point->Return(p->value); exit_point->Return(p->value);
......
...@@ -25,8 +25,10 @@ namespace compiler { ...@@ -25,8 +25,10 @@ namespace compiler {
namespace { namespace {
typedef CodeAssemblerLabel Label; using Label = CodeAssemblerLabel;
typedef CodeAssemblerVariable Variable; using Variable = CodeAssemblerVariable;
template <class T>
using TVariable = TypedCodeAssemblerVariable<T>;
Handle<String> MakeString(const char* str) { Handle<String> MakeString(const char* str) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
...@@ -545,8 +547,8 @@ void TestEntryToIndex() { ...@@ -545,8 +547,8 @@ void TestEntryToIndex() {
CodeAssemblerTester asm_tester(isolate, kNumParams); CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeStubAssembler m(asm_tester.state()); CodeStubAssembler m(asm_tester.state());
{ {
Node* entry = m.SmiUntag(m.Parameter(0)); TNode<IntPtrT> entry = m.SmiUntag(m.Parameter(0));
Node* result = m.EntryToIndex<Dictionary>(entry); TNode<IntPtrT> result = m.EntryToIndex<Dictionary>(entry);
m.Return(m.SmiTag(result)); m.Return(m.SmiTag(result));
} }
...@@ -578,14 +580,14 @@ void TestNameDictionaryLookup() { ...@@ -578,14 +580,14 @@ void TestNameDictionaryLookup() {
enum Result { kFound, kNotFound }; enum Result { kFound, kNotFound };
{ {
Node* dictionary = m.Parameter(0); TNode<Dictionary> dictionary = m.CAST(m.Parameter(0));
Node* unique_name = m.Parameter(1); TNode<Name> unique_name = m.CAST(m.Parameter(1));
Node* expected_result = m.Parameter(2); TNode<Smi> expected_result = m.CAST(m.Parameter(2));
Node* expected_arg = m.Parameter(3); TNode<Object> expected_arg = m.CAST(m.Parameter(3));
Label passed(&m), failed(&m); Label passed(&m), failed(&m);
Label if_found(&m), if_not_found(&m); Label if_found(&m), if_not_found(&m);
Variable var_name_index(&m, MachineType::PointerRepresentation()); TVariable<IntPtrT> var_name_index(&m);
m.NameDictionaryLookup<Dictionary>(dictionary, unique_name, &if_found, m.NameDictionaryLookup<Dictionary>(dictionary, unique_name, &if_found,
&var_name_index, &if_not_found); &var_name_index, &if_not_found);
...@@ -593,8 +595,9 @@ void TestNameDictionaryLookup() { ...@@ -593,8 +595,9 @@ void TestNameDictionaryLookup() {
m.GotoIfNot( m.GotoIfNot(
m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))),
&failed); &failed);
m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_name_index.value()), m.Branch(
&passed, &failed); m.WordEqual(m.SmiUntag(m.CAST(expected_arg)), var_name_index.value()),
&passed, &failed);
m.BIND(&if_not_found); m.BIND(&if_not_found);
m.Branch( m.Branch(
...@@ -679,14 +682,14 @@ TEST(NumberDictionaryLookup) { ...@@ -679,14 +682,14 @@ TEST(NumberDictionaryLookup) {
enum Result { kFound, kNotFound }; enum Result { kFound, kNotFound };
{ {
Node* dictionary = m.Parameter(0); TNode<NumberDictionary> dictionary = m.CAST(m.Parameter(0));
Node* key = m.SmiUntag(m.Parameter(1)); TNode<IntPtrT> key = m.SmiUntag(m.Parameter(1));
Node* expected_result = m.Parameter(2); TNode<Smi> expected_result = m.CAST(m.Parameter(2));
Node* expected_arg = m.Parameter(3); TNode<Object> expected_arg = m.CAST(m.Parameter(3));
Label passed(&m), failed(&m); Label passed(&m), failed(&m);
Label if_found(&m), if_not_found(&m); Label if_found(&m), if_not_found(&m);
Variable var_entry(&m, MachineType::PointerRepresentation()); TVariable<IntPtrT> var_entry(&m);
m.NumberDictionaryLookup(dictionary, key, &if_found, &var_entry, m.NumberDictionaryLookup(dictionary, key, &if_found, &var_entry,
&if_not_found); &if_not_found);
...@@ -694,8 +697,8 @@ TEST(NumberDictionaryLookup) { ...@@ -694,8 +697,8 @@ TEST(NumberDictionaryLookup) {
m.GotoIfNot( m.GotoIfNot(
m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))), m.WordEqual(expected_result, m.SmiConstant(Smi::FromInt(kFound))),
&failed); &failed);
m.Branch(m.WordEqual(m.SmiUntag(expected_arg), var_entry.value()), &passed, m.Branch(m.WordEqual(m.SmiUntag(m.CAST(expected_arg)), var_entry.value()),
&failed); &passed, &failed);
m.BIND(&if_not_found); m.BIND(&if_not_found);
m.Branch( m.Branch(
......
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