[cleanup] Remove the Map::IsDictionaryMap() method.

There's a `Map::IsDictionaryMap()` method in addition to the
`Map::is_dictionary_map()`, which apparently do very different things:
The former checks whether the instance type of the Map is in a certain
range (FIRST_DICTIONARY_TYPE to LAST_DICTIONARY_TYPE), while the latter
checks the `is_dictionary_map` bit (which means that the backing store
for the properties of a JSObject is in slow mode). To make matters worse
there's also `CodeStubAssembler::IsDictionaryMap()`, which does the bit
check similar to `Map::is_dictionary_map()`. And to make matters even
worse the FIRST_DICTIONARY_TYPE to LAST_DICTIONARY_TYPE range also
contains instance types for classes that aren't subclass of `Dictionary`
(despite a comment stating the opposite).

So in conclusion it's best to remove the confusing
`Map::IsDictionaryMap()` method, which is anyways wrong, and just test
explicitly for `NameDictionary`, `NumberDictionary` or
`GlobalDictionary` in the appropriate places.

Bug: v8:9183
Change-Id: If35f73261e3cc96938ebf499bf32be3ec725288b
Cq-Include-Trybots: luci.chromium.try:linux-rel,win7-rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627330
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61770}
This commit is contained in:
Benedikt Meurer 2019-05-23 10:11:01 +02:00 committed by Commit Bot
parent a0c3797461
commit 5b46f5736f
5 changed files with 16 additions and 21 deletions

View File

@ -4209,7 +4209,7 @@ class FastSloppyArgumentsElementsAccessor
uint32_t from_start, FixedArrayBase to,
ElementsKind from_kind, uint32_t to_start,
int packed_size, int copy_size) {
DCHECK(!to.IsDictionary());
DCHECK(!to.IsNumberDictionary());
if (from_kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS) {
CopyDictionaryToObjectElements(isolate, from, from_start, to,
HOLEY_ELEMENTS, to_start, copy_size);
@ -4393,7 +4393,7 @@ class StringWrapperElementsAccessor
uint32_t from_start, FixedArrayBase to,
ElementsKind from_kind, uint32_t to_start,
int packed_size, int copy_size) {
DCHECK(!to.IsDictionary());
DCHECK(!to.IsNumberDictionary());
if (from_kind == SLOW_STRING_WRAPPER_ELEMENTS) {
CopyDictionaryToObjectElements(isolate, from, from_start, to,
HOLEY_ELEMENTS, to_start, copy_size);

View File

@ -193,14 +193,14 @@ enum InstanceType : uint16_t {
FIXED_ARRAY_TYPE, // FIRST_FIXED_ARRAY_TYPE
OBJECT_BOILERPLATE_DESCRIPTION_TYPE,
CLOSURE_FEEDBACK_CELL_ARRAY_TYPE,
HASH_TABLE_TYPE, // FIRST_HASH_TABLE_TYPE
ORDERED_HASH_MAP_TYPE, // FIRST_DICTIONARY_TYPE
HASH_TABLE_TYPE, // FIRST_HASH_TABLE_TYPE
ORDERED_HASH_MAP_TYPE,
ORDERED_HASH_SET_TYPE,
ORDERED_NAME_DICTIONARY_TYPE,
NAME_DICTIONARY_TYPE,
GLOBAL_DICTIONARY_TYPE,
NUMBER_DICTIONARY_TYPE,
SIMPLE_NUMBER_DICTIONARY_TYPE, // LAST_DICTIONARY_TYPE
SIMPLE_NUMBER_DICTIONARY_TYPE,
STRING_TABLE_TYPE,
EPHEMERON_HASH_TABLE_TYPE, // LAST_HASH_TABLE_TYPE
SCOPE_INFO_TYPE,
@ -333,9 +333,6 @@ enum InstanceType : uint16_t {
// Boundaries for testing if given HeapObject is a subclass of HashTable
FIRST_HASH_TABLE_TYPE = HASH_TABLE_TYPE,
LAST_HASH_TABLE_TYPE = EPHEMERON_HASH_TABLE_TYPE,
// Boundaries for testing if given HeapObject is a subclass of Dictionary
FIRST_DICTIONARY_TYPE = ORDERED_HASH_MAP_TYPE,
LAST_DICTIONARY_TYPE = SIMPLE_NUMBER_DICTIONARY_TYPE,
// Boundaries for testing if given HeapObject is a subclass of WeakFixedArray.
FIRST_WEAK_FIXED_ARRAY_TYPE = WEAK_FIXED_ARRAY_TYPE,
LAST_WEAK_FIXED_ARRAY_TYPE = TRANSITION_ARRAY_TYPE,
@ -516,7 +513,6 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
#define INSTANCE_TYPE_CHECKERS_RANGE(V) \
V(Context, FIRST_CONTEXT_TYPE, LAST_CONTEXT_TYPE) \
V(Dictionary, FIRST_DICTIONARY_TYPE, LAST_DICTIONARY_TYPE) \
V(FixedArray, FIRST_FIXED_ARRAY_TYPE, LAST_FIXED_ARRAY_TYPE) \
V(FixedTypedArrayBase, FIRST_FIXED_TYPED_ARRAY_TYPE, \
LAST_FIXED_TYPED_ARRAY_TYPE) \

View File

@ -775,7 +775,7 @@ ElementsKind JSObject::GetElementsKind() const {
fixed_array == GetReadOnlyRoots().empty_fixed_array());
} else if (kind == DICTIONARY_ELEMENTS) {
DCHECK(fixed_array.IsFixedArray());
DCHECK(fixed_array.IsDictionary());
DCHECK(fixed_array.IsNumberDictionary());
} else {
DCHECK(kind > DICTIONARY_ELEMENTS || IsFrozenOrSealedElementsKind(kind));
}
@ -898,9 +898,10 @@ void JSReceiver::initialize_properties() {
}
bool JSReceiver::HasFastProperties() const {
DCHECK(
raw_properties_or_hash().IsSmi() ||
(raw_properties_or_hash().IsDictionary() == map().is_dictionary_map()));
DCHECK(raw_properties_or_hash().IsSmi() ||
((raw_properties_or_hash().IsGlobalDictionary() ||
raw_properties_or_hash().IsNameDictionary()) ==
map().is_dictionary_map()));
return !map().is_dictionary_map();
}

View File

@ -258,9 +258,7 @@ class ZoneForwardList;
#define HEAP_OBJECT_ORDINARY_TYPE_LIST(V) HEAP_OBJECT_ORDINARY_TYPE_LIST_BASE(V)
#endif // V8_INTL_SUPPORT
#define HEAP_OBJECT_TEMPLATE_TYPE_LIST(V) \
V(Dictionary) \
V(HashTable)
#define HEAP_OBJECT_TEMPLATE_TYPE_LIST(V) V(HashTable)
#define HEAP_OBJECT_TYPE_LIST(V) \
HEAP_OBJECT_ORDINARY_TYPE_LIST(V) \

View File

@ -37,7 +37,7 @@ void CheckFastObject(Handle<JSObject> obj, int hash) {
void CheckDictionaryObject(Handle<JSObject> obj, int hash) {
CHECK(!obj->HasFastProperties());
CHECK(obj->raw_properties_or_hash().IsDictionary());
CHECK(obj->raw_properties_or_hash().IsNameDictionary());
CHECK_EQ(Smi::FromInt(hash), obj->GetHash());
CHECK_EQ(hash, obj->property_dictionary().Hash());
}
@ -98,7 +98,7 @@ TEST(AddHashCodeToSlowObject) {
CHECK(obj->HasFastProperties());
JSObject::NormalizeProperties(obj, CLEAR_INOBJECT_PROPERTIES, 0,
"cctest/test-hashcode");
CHECK(obj->raw_properties_or_hash().IsDictionary());
CHECK(obj->raw_properties_or_hash().IsNameDictionary());
int hash = AddToSetAndGetHash(isolate, obj, false);
CheckDictionaryObject(obj, hash);
@ -181,7 +181,7 @@ TEST(TransitionSlowToSlow) {
Handle<JSObject> obj = GetGlobal<JSObject>("x");
JSObject::NormalizeProperties(obj, CLEAR_INOBJECT_PROPERTIES, 0,
"cctest/test-hashcode");
CHECK(obj->raw_properties_or_hash().IsDictionary());
CHECK(obj->raw_properties_or_hash().IsNameDictionary());
int hash = AddToSetAndGetHash(isolate, obj, false);
CHECK_EQ(hash, obj->property_dictionary().Hash());
@ -201,7 +201,7 @@ TEST(TransitionSlowToFastWithoutProperties) {
isolate->factory()->NewJSObject(isolate->object_function());
JSObject::NormalizeProperties(obj, CLEAR_INOBJECT_PROPERTIES, 0,
"cctest/test-hashcode");
CHECK(obj->raw_properties_or_hash().IsDictionary());
CHECK(obj->raw_properties_or_hash().IsNameDictionary());
int hash = AddToSetAndGetHash(isolate, obj, false);
CHECK_EQ(hash, obj->property_dictionary().Hash());
@ -221,7 +221,7 @@ TEST(TransitionSlowToFastWithPropertyArray) {
CompileRun(source);
Handle<JSObject> obj = GetGlobal<JSObject>("x");
CHECK(obj->raw_properties_or_hash().IsDictionary());
CHECK(obj->raw_properties_or_hash().IsNameDictionary());
int hash = AddToSetAndGetHash(isolate, obj, false);
CHECK_EQ(hash, obj->property_dictionary().Hash());