[objects] Add instance types for hash tables

Adds a instance types for each HashTable subtype, rather than reusing
HASH_TABLE_TYPE. This allows us to check for these types by checking
the instance type directly, rather than by comparing against the map in
the root set.

Also, as a drive-by, do the same for SCRIPT_CONTEXT_TABLE_TYPE, and use
instance type checks rather than map checks for Context types.

This is a good general clean-up, but in particular is intended for
GetIsolate removal.

TBR=jarin@chromium.org

Bug: v8:7786
Change-Id: I420abdd12906dfa20c922e486ecdc657eb3c6ef0
Reviewed-on: https://chromium-review.googlesource.com/1114958
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54128}
This commit is contained in:
Leszek Swirski 2018-06-29 15:01:29 +01:00 committed by Commit Bot
parent 93b173ee94
commit 7a3d92c132
16 changed files with 286 additions and 177 deletions

View File

@ -1683,7 +1683,7 @@ TNode<IntPtrT> CodeStubAssembler::LoadJSReceiverIdentityHash(
GotoIf(InstanceTypeEqual(properties_instance_type, PROPERTY_ARRAY_TYPE),
&if_property_array);
Branch(InstanceTypeEqual(properties_instance_type, HASH_TABLE_TYPE),
Branch(InstanceTypeEqual(properties_instance_type, NAME_DICTIONARY_TYPE),
&if_property_dictionary, &if_fixed_array);
BIND(&if_fixed_array);
@ -1926,13 +1926,9 @@ TNode<Object> CodeStubAssembler::LoadFixedArrayElement(
ParameterMode parameter_mode, LoadSensitivity needs_poisoning) {
// This function is currently used for non-FixedArrays (e.g., PropertyArrays)
// and thus the reasonable assert IsFixedArraySubclass(object) is
// untrue. TODO(marja): Fix.
// not always true. TODO(marja): Fix.
CSA_SLOW_ASSERT(
this, Word32Or(IsHashTable(object),
Word32Or(IsFixedArray(object),
Word32Or(IsPropertyArray(object),
Word32Or(IsEphemeronHashTable(object),
IsContext(object))))));
this, Word32Or(IsFixedArraySubclass(object), IsPropertyArray(object)));
CSA_ASSERT(this, IsNotWeakFixedArraySubclass(object));
TNode<MaybeObject> element =
LoadArrayElement(object, FixedArray::kHeaderSize, index_node,
@ -2527,11 +2523,7 @@ Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node,
int additional_offset,
ParameterMode parameter_mode) {
CSA_SLOW_ASSERT(
this, Word32Or(IsHashTable(object),
Word32Or(IsFixedArray(object),
Word32Or(IsPropertyArray(object),
Word32Or(IsEphemeronHashTable(object),
IsContext(object))))));
this, Word32Or(IsFixedArraySubclass(object), IsPropertyArray(object)));
CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode));
DCHECK(barrier_mode == SKIP_WRITE_BARRIER ||
barrier_mode == UPDATE_WRITE_BARRIER);
@ -3471,7 +3463,7 @@ void CodeStubAssembler::InitializeJSObjectFromMap(
Heap::kEmptyFixedArrayRootIndex);
} else {
CSA_ASSERT(this, Word32Or(Word32Or(IsPropertyArray(properties),
IsDictionary(properties)),
IsNameDictionary(properties)),
IsEmptyFixedArray(properties)));
StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOrHashOffset,
properties);
@ -5448,7 +5440,12 @@ TNode<BoolT> CodeStubAssembler::IsFixedDoubleArray(
}
TNode<BoolT> CodeStubAssembler::IsHashTable(SloppyTNode<HeapObject> object) {
return HasInstanceType(object, HASH_TABLE_TYPE);
Node* instance_type = LoadInstanceType(object);
return UncheckedCast<BoolT>(
Word32And(Int32GreaterThanOrEqual(instance_type,
Int32Constant(FIRST_HASH_TABLE_TYPE)),
Int32LessThanOrEqual(instance_type,
Int32Constant(LAST_HASH_TABLE_TYPE))));
}
TNode<BoolT> CodeStubAssembler::IsEphemeronHashTable(
@ -5456,15 +5453,19 @@ TNode<BoolT> CodeStubAssembler::IsEphemeronHashTable(
return HasInstanceType(object, EPHEMERON_HASH_TABLE_TYPE);
}
TNode<BoolT> CodeStubAssembler::IsDictionary(SloppyTNode<HeapObject> object) {
return UncheckedCast<BoolT>(
Word32Or(IsHashTable(object), IsNumberDictionary(object)));
TNode<BoolT> CodeStubAssembler::IsNameDictionary(
SloppyTNode<HeapObject> object) {
return HasInstanceType(object, NAME_DICTIONARY_TYPE);
}
TNode<BoolT> CodeStubAssembler::IsGlobalDictionary(
SloppyTNode<HeapObject> object) {
return HasInstanceType(object, GLOBAL_DICTIONARY_TYPE);
}
TNode<BoolT> CodeStubAssembler::IsNumberDictionary(
SloppyTNode<HeapObject> object) {
return WordEqual(LoadMap(object),
LoadRoot(Heap::kNumberDictionaryMapRootIndex));
return HasInstanceType(object, NUMBER_DICTIONARY_TYPE);
}
TNode<BoolT> CodeStubAssembler::IsJSGeneratorObject(
@ -8089,7 +8090,7 @@ void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary,
Variable* var_details,
Variable* var_value) {
Comment("LoadPropertyFromNameDictionary");
CSA_ASSERT(this, IsDictionary(dictionary));
CSA_ASSERT(this, IsNameDictionary(dictionary));
var_details->Bind(
LoadDetailsByKeyIndex<NameDictionary>(dictionary, name_index));
@ -8104,7 +8105,7 @@ void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary,
Variable* var_value,
Label* if_deleted) {
Comment("[ LoadPropertyFromGlobalDictionary");
CSA_ASSERT(this, IsDictionary(dictionary));
CSA_ASSERT(this, IsGlobalDictionary(dictionary));
Node* property_cell = LoadFixedArrayElement(dictionary, name_index);
CSA_ASSERT(this, IsPropertyCell(property_cell));

View File

@ -1613,7 +1613,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<BoolT> IsConstructorMap(SloppyTNode<Map> map);
TNode<BoolT> IsConstructor(SloppyTNode<HeapObject> object);
TNode<BoolT> IsDeprecatedMap(SloppyTNode<Map> map);
TNode<BoolT> IsDictionary(SloppyTNode<HeapObject> object);
TNode<BoolT> IsNameDictionary(SloppyTNode<HeapObject> object);
TNode<BoolT> IsGlobalDictionary(SloppyTNode<HeapObject> object);
TNode<BoolT> IsExtensibleMap(SloppyTNode<Map> map);
TNode<BoolT> IsExternalStringInstanceType(SloppyTNode<Int32T> instance_type);
TNode<BoolT> IsFastJSArray(SloppyTNode<Object> object,

View File

@ -257,6 +257,13 @@ Type::bitset BitsetType::Lub(HeapObjectType const& type) {
case ACCESSOR_PAIR_TYPE:
case FIXED_ARRAY_TYPE:
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case WEAK_FIXED_ARRAY_TYPE:
case WEAK_ARRAY_LIST_TYPE:
@ -272,6 +279,7 @@ Type::bitset BitsetType::Lub(HeapObjectType const& type) {
case PROPERTY_ARRAY_TYPE:
case FOREIGN_TYPE:
case SCOPE_INFO_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
case DEBUG_EVALUATE_CONTEXT_TYPE:

View File

@ -3406,7 +3406,15 @@ void TranslatedState::InitializeCapturedObjectAt(
case WITH_CONTEXT_TYPE:
case BOILERPLATE_DESCRIPTION_TYPE:
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case PROPERTY_ARRAY_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
InitializeObjectWithTaggedFieldsAt(frame, &value_index, slot, map,
no_allocation);
break;
@ -3529,6 +3537,7 @@ void TranslatedState::EnsureCapturedObjectAllocatedAt(
return MaterializeMutableHeapNumber(frame, &value_index, slot);
case FIXED_ARRAY_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
case DEBUG_EVALUATE_CONTEXT_TYPE:
@ -3538,7 +3547,14 @@ void TranslatedState::EnsureCapturedObjectAllocatedAt(
case NATIVE_CONTEXT_TYPE:
case SCRIPT_CONTEXT_TYPE:
case WITH_CONTEXT_TYPE:
case HASH_TABLE_TYPE: {
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE: {
// Check we have the right size.
int array_length =
Smi::cast(frame->values_[value_index].GetRawValue())->value();

View File

@ -708,8 +708,6 @@ void ObjectStatsCollectorImpl::CollectGlobalStatistics() {
ObjectStats::SCRIPT_LIST_TYPE);
// HashTable.
RecordHashTableVirtualObjectStats(nullptr, heap_->string_table(),
ObjectStats::STRING_TABLE_TYPE);
RecordHashTableVirtualObjectStats(nullptr, heap_->code_stubs(),
ObjectStats::CODE_STUBS_TABLE_TYPE);
}

View File

@ -62,7 +62,6 @@
V(SERIALIZED_OBJECTS_TYPE) \
V(SINGLE_CHARACTER_STRING_CACHE_TYPE) \
V(STRING_SPLIT_CACHE_TYPE) \
V(STRING_TABLE_TYPE) \
V(SOURCE_POSITION_TABLE_TYPE) \
V(UNCOMPILED_JS_FUNCTION_TYPE) \
V(UNCOMPILED_SHARED_FUNCTION_INFO_TYPE) \

View File

@ -455,13 +455,14 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_VARSIZE_MAP(TRANSITION_ARRAY_TYPE, transition_array)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, hash_table)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, ordered_hash_map)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, ordered_hash_set)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, name_dictionary)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, global_dictionary)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, number_dictionary)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, simple_number_dictionary)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, string_table)
ALLOCATE_VARSIZE_MAP(ORDERED_HASH_MAP_TYPE, ordered_hash_map)
ALLOCATE_VARSIZE_MAP(ORDERED_HASH_SET_TYPE, ordered_hash_set)
ALLOCATE_VARSIZE_MAP(NAME_DICTIONARY_TYPE, name_dictionary)
ALLOCATE_VARSIZE_MAP(GLOBAL_DICTIONARY_TYPE, global_dictionary)
ALLOCATE_VARSIZE_MAP(NUMBER_DICTIONARY_TYPE, number_dictionary)
ALLOCATE_VARSIZE_MAP(SIMPLE_NUMBER_DICTIONARY_TYPE,
simple_number_dictionary)
ALLOCATE_VARSIZE_MAP(STRING_TABLE_TYPE, string_table)
ALLOCATE_VARSIZE_MAP(EPHEMERON_HASH_TABLE_TYPE, ephemeron_hash_table)
@ -475,7 +476,7 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_VARSIZE_MAP(MODULE_CONTEXT_TYPE, module_context)
ALLOCATE_VARSIZE_MAP(EVAL_CONTEXT_TYPE, eval_context)
ALLOCATE_VARSIZE_MAP(SCRIPT_CONTEXT_TYPE, script_context)
ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, script_context_table)
ALLOCATE_VARSIZE_MAP(SCRIPT_CONTEXT_TABLE_TYPE, script_context_table)
ALLOCATE_VARSIZE_MAP(BOILERPLATE_DESCRIPTION_TYPE, boilerplate_description)

View File

@ -638,8 +638,16 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
case FIXED_ARRAY_TYPE:
case BOILERPLATE_DESCRIPTION_TYPE:
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case SCOPE_INFO_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
case DEBUG_EVALUATE_CONTEXT_TYPE:

View File

@ -136,10 +136,18 @@ void HeapObject::HeapObjectVerify(Isolate* isolate) {
CallHandlerInfo::cast(this)->CallHandlerInfoVerify(isolate);
break;
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case BOILERPLATE_DESCRIPTION_TYPE:
case FIXED_ARRAY_TYPE:
case SCOPE_INFO_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
case DEBUG_EVALUATE_CONTEXT_TYPE:

View File

@ -70,6 +70,10 @@ int PropertyDetails::field_width_in_words() const {
return representation().IsDouble() ? kDoubleSize / kPointerSize : 1;
}
// TODO(v8:7786): For instance types that have a single map instance on the
// roots, and when that map is a embedded in the binary, compare against the map
// pointer rather than looking up the instance type.
TYPE_CHECKER(AllocationSite, ALLOCATION_SITE_TYPE)
TYPE_CHECKER(BigInt, BIGINT_TYPE)
TYPE_CHECKER(BoilerplateDescription, BOILERPLATE_DESCRIPTION_TYPE)
TYPE_CHECKER(BreakPoint, TUPLE2_TYPE)
@ -92,7 +96,7 @@ TYPE_CHECKER(FixedArrayOfWeakCells, FIXED_ARRAY_TYPE)
TYPE_CHECKER(FixedDoubleArray, FIXED_DOUBLE_ARRAY_TYPE)
TYPE_CHECKER(Foreign, FOREIGN_TYPE)
TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
TYPE_CHECKER(HashTable, HASH_TABLE_TYPE)
TYPE_CHECKER(GlobalDictionary, GLOBAL_DICTIONARY_TYPE)
TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
TYPE_CHECKER(JSArgumentsObject, JS_ARGUMENTS_TYPE)
TYPE_CHECKER(JSArray, JS_ARRAY_TYPE)
@ -121,16 +125,24 @@ TYPE_CHECKER(JSWeakMap, JS_WEAK_MAP_TYPE)
TYPE_CHECKER(JSWeakSet, JS_WEAK_SET_TYPE)
TYPE_CHECKER(Map, MAP_TYPE)
TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
TYPE_CHECKER(NameDictionary, NAME_DICTIONARY_TYPE)
TYPE_CHECKER(NativeContext, NATIVE_CONTEXT_TYPE)
TYPE_CHECKER(NumberDictionary, NUMBER_DICTIONARY_TYPE)
TYPE_CHECKER(Oddball, ODDBALL_TYPE)
TYPE_CHECKER(OrderedHashMap, ORDERED_HASH_MAP_TYPE)
TYPE_CHECKER(OrderedHashSet, ORDERED_HASH_SET_TYPE)
TYPE_CHECKER(PreParsedScopeData, TUPLE2_TYPE)
TYPE_CHECKER(PropertyArray, PROPERTY_ARRAY_TYPE)
TYPE_CHECKER(PropertyCell, PROPERTY_CELL_TYPE)
TYPE_CHECKER(PropertyDescriptorObject, FIXED_ARRAY_TYPE)
TYPE_CHECKER(ScopeInfo, SCOPE_INFO_TYPE)
TYPE_CHECKER(ScriptContextTable, SCRIPT_CONTEXT_TABLE_TYPE)
TYPE_CHECKER(SharedFunctionInfo, SHARED_FUNCTION_INFO_TYPE)
TYPE_CHECKER(SimpleNumberDictionary, SIMPLE_NUMBER_DICTIONARY_TYPE)
TYPE_CHECKER(SmallOrderedHashMap, SMALL_ORDERED_HASH_MAP_TYPE)
TYPE_CHECKER(SmallOrderedHashSet, SMALL_ORDERED_HASH_SET_TYPE)
TYPE_CHECKER(SourcePositionTableWithFrameCache, TUPLE2_TYPE)
TYPE_CHECKER(StringTable, STRING_TABLE_TYPE)
TYPE_CHECKER(Symbol, SYMBOL_TYPE)
TYPE_CHECKER(TemplateObjectDescription, TUPLE2_TYPE)
TYPE_CHECKER(TransitionArray, TRANSITION_ARRAY_TYPE)
@ -141,7 +153,6 @@ TYPE_CHECKER(WasmModuleObject, WASM_MODULE_TYPE)
TYPE_CHECKER(WasmTableObject, WASM_TABLE_TYPE)
TYPE_CHECKER(WeakArrayList, WEAK_ARRAY_LIST_TYPE)
TYPE_CHECKER(WeakCell, WEAK_CELL_TYPE)
TYPE_CHECKER(AllocationSite, ALLOCATION_SITE_TYPE)
#ifdef V8_INTL_SUPPORT
TYPE_CHECKER(JSLocale, JS_INTL_LOCALE_TYPE)
@ -429,22 +440,9 @@ bool HeapObject::IsDependentCode() const {
}
bool HeapObject::IsContext() const {
Map* map = this->map();
Heap* heap = GetHeap();
return (
map == heap->function_context_map() || map == heap->catch_context_map() ||
map == heap->with_context_map() || map == heap->native_context_map() ||
map == heap->block_context_map() || map == heap->module_context_map() ||
map == heap->eval_context_map() || map == heap->script_context_map() ||
map == heap->debug_evaluate_context_map());
}
bool HeapObject::IsNativeContext() const {
return map() == GetHeap()->native_context_map();
}
bool HeapObject::IsScriptContextTable() const {
return map() == GetHeap()->script_context_table_map();
int instance_type = map()->instance_type();
return instance_type >= FIRST_CONTEXT_TYPE &&
instance_type <= LAST_CONTEXT_TYPE;
}
template <>
@ -489,28 +487,16 @@ bool HeapObject::IsJSArrayBufferView() const {
return IsJSDataView() || IsJSTypedArray();
}
bool HeapObject::IsHashTable() const {
int instance_type = map()->instance_type();
return instance_type >= FIRST_HASH_TABLE_TYPE &&
instance_type <= LAST_HASH_TABLE_TYPE;
}
bool HeapObject::IsDictionary() const {
return IsHashTable() && this != GetHeap()->string_table();
}
bool HeapObject::IsGlobalDictionary() const {
return map() == GetHeap()->global_dictionary_map();
}
bool HeapObject::IsNameDictionary() const {
return map() == GetHeap()->name_dictionary_map();
}
bool HeapObject::IsNumberDictionary() const {
return map() == GetHeap()->number_dictionary_map();
}
bool HeapObject::IsSimpleNumberDictionary() const {
return map() == GetHeap()->simple_number_dictionary_map();
}
bool HeapObject::IsStringTable() const {
return map() == GetHeap()->string_table_map();
int instance_type = map()->instance_type();
return instance_type >= FIRST_DICTIONARY_TYPE &&
instance_type <= LAST_DICTIONARY_TYPE;
}
bool HeapObject::IsStringSet() const { return IsHashTable(); }
@ -527,14 +513,6 @@ bool HeapObject::IsMapCache() const { return IsHashTable(); }
bool HeapObject::IsObjectHashTable() const { return IsHashTable(); }
bool HeapObject::IsOrderedHashSet() const {
return map() == GetHeap()->ordered_hash_set_map();
}
bool HeapObject::IsOrderedHashMap() const {
return map() == GetHeap()->ordered_hash_map_map();
}
bool Object::IsSmallOrderedHashTable() const {
return IsSmallOrderedHashSet() || IsSmallOrderedHashMap();
}
@ -1828,13 +1806,16 @@ bool HeapObject::NeedsRehashing() const {
return DescriptorArray::cast(this)->number_of_descriptors() > 1;
case TRANSITION_ARRAY_TYPE:
return TransitionArray::cast(this)->number_of_entries() > 1;
case ORDERED_HASH_MAP_TYPE:
return OrderedHashMap::cast(this)->NumberOfElements() > 0;
case ORDERED_HASH_SET_TYPE:
return OrderedHashSet::cast(this)->NumberOfElements() > 0;
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case HASH_TABLE_TYPE:
if (IsOrderedHashMap()) {
return OrderedHashMap::cast(this)->NumberOfElements() > 0;
} else if (IsOrderedHashSet()) {
return OrderedHashSet::cast(this)->NumberOfElements() > 0;
}
return true;
case SMALL_ORDERED_HASH_MAP_TYPE:
case SMALL_ORDERED_HASH_SET_TYPE:
return true;

View File

@ -110,9 +110,17 @@ void HeapObject::HeapObjectPrint(Isolate* isolate,
case NATIVE_CONTEXT_TYPE:
case SCRIPT_CONTEXT_TYPE:
case WITH_CONTEXT_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
FixedArray::cast(this)->FixedArrayPrint(os);
break;
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
ObjectHashTable::cast(this)->ObjectHashTablePrint(os);
break;
case EPHEMERON_HASH_TABLE_TYPE:

View File

@ -2986,7 +2986,15 @@ VisitorId Map::GetVisitorId(Map* map) {
case FIXED_ARRAY_TYPE:
case BOILERPLATE_DESCRIPTION_TYPE:
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case SCOPE_INFO_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
case DEBUG_EVALUATE_CONTEXT_TYPE:
@ -3319,9 +3327,34 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
case WITH_CONTEXT_TYPE:
os << "<WithContext[" << FixedArray::cast(this)->length() << "]>";
break;
case SCRIPT_CONTEXT_TABLE_TYPE:
os << "<ScriptContextTable[" << FixedArray::cast(this)->length() << "]>";
break;
case HASH_TABLE_TYPE:
os << "<HashTable[" << FixedArray::cast(this)->length() << "]>";
break;
case ORDERED_HASH_MAP_TYPE:
os << "<OrderedHashMap[" << FixedArray::cast(this)->length() << "]>";
break;
case ORDERED_HASH_SET_TYPE:
os << "<OrderedHashSet[" << FixedArray::cast(this)->length() << "]>";
break;
case NAME_DICTIONARY_TYPE:
os << "<NameDictionary[" << FixedArray::cast(this)->length() << "]>";
break;
case GLOBAL_DICTIONARY_TYPE:
os << "<GlobalDictionary[" << FixedArray::cast(this)->length() << "]>";
break;
case NUMBER_DICTIONARY_TYPE:
os << "<NumberDictionary[" << FixedArray::cast(this)->length() << "]>";
break;
case SIMPLE_NUMBER_DICTIONARY_TYPE:
os << "<SimpleNumberDictionary[" << FixedArray::cast(this)->length()
<< "]>";
break;
case STRING_TABLE_TYPE:
os << "<StringTable[" << FixedArray::cast(this)->length() << "]>";
break;
case FIXED_ARRAY_TYPE:
os << "<FixedArray[" << FixedArray::cast(this)->length() << "]>";
break;
@ -3625,11 +3658,16 @@ String* JSReceiver::class_name() {
bool HeapObject::CanBeRehashed() const {
DCHECK(NeedsRehashing());
switch (map()->instance_type()) {
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
// TODO(yangguo): actually support rehashing OrderedHash{Map,Set}.
return IsNameDictionary() || IsGlobalDictionary() ||
IsNumberDictionary() || IsSimpleNumberDictionary() ||
IsStringTable();
return false;
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
return true;
case DESCRIPTOR_ARRAY_TYPE:
return true;
case TRANSITION_ARRAY_TYPE:
@ -3647,19 +3685,22 @@ bool HeapObject::CanBeRehashed() const {
void HeapObject::RehashBasedOnMap() {
switch (map()->instance_type()) {
case HASH_TABLE_TYPE:
if (IsNameDictionary()) {
NameDictionary::cast(this)->Rehash();
} else if (IsNumberDictionary()) {
NumberDictionary::cast(this)->Rehash();
} else if (IsSimpleNumberDictionary()) {
SimpleNumberDictionary::cast(this)->Rehash();
} else if (IsGlobalDictionary()) {
GlobalDictionary::cast(this)->Rehash();
} else if (IsStringTable()) {
StringTable::cast(this)->Rehash();
} else {
UNREACHABLE();
}
UNREACHABLE();
break;
case NAME_DICTIONARY_TYPE:
NameDictionary::cast(this)->Rehash();
break;
case GLOBAL_DICTIONARY_TYPE:
GlobalDictionary::cast(this)->Rehash();
break;
case NUMBER_DICTIONARY_TYPE:
NumberDictionary::cast(this)->Rehash();
break;
case SIMPLE_NUMBER_DICTIONARY_TYPE:
SimpleNumberDictionary::cast(this)->Rehash();
break;
case STRING_TABLE_TYPE:
StringTable::cast(this)->Rehash();
break;
case DESCRIPTOR_ARRAY_TYPE:
DCHECK_LE(1, DescriptorArray::cast(this)->number_of_descriptors());
@ -6488,7 +6529,7 @@ Handle<NumberDictionary> JSObject::NormalizeElements(Handle<JSObject> object) {
elements = SloppyArgumentsElements::cast(elements)->arguments();
}
if (elements->IsDictionary()) {
if (elements->IsNumberDictionary()) {
return handle(NumberDictionary::cast(elements), isolate);
}
}
@ -6552,7 +6593,7 @@ Object* SetHashAndUpdateProperties(HeapObject* properties, int hash) {
return properties;
}
DCHECK(properties->IsDictionary());
DCHECK(properties->IsNameDictionary());
NameDictionary::cast(properties)->SetHash(hash);
return properties;
}
@ -8013,7 +8054,8 @@ bool JSObject::ReferencesObject(Object* obj) {
}
// Check the arguments.
FixedArray* arguments = elements->arguments();
kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : HOLEY_ELEMENTS;
kind = arguments->IsNumberDictionary() ? DICTIONARY_ELEMENTS
: HOLEY_ELEMENTS;
if (ReferencesObjectFromElements(arguments, kind, obj)) return true;
break;
}
@ -12962,11 +13004,19 @@ bool CanSubclassHaveInobjectProperties(InstanceType instance_type) {
case CODE_TYPE:
case FILLER_TYPE:
case FIXED_ARRAY_TYPE:
case SCRIPT_CONTEXT_TABLE_TYPE:
case FIXED_DOUBLE_ARRAY_TYPE:
case FEEDBACK_METADATA_TYPE:
case FOREIGN_TYPE:
case FREE_SPACE_TYPE:
case HASH_TABLE_TYPE:
case ORDERED_HASH_MAP_TYPE:
case ORDERED_HASH_SET_TYPE:
case NAME_DICTIONARY_TYPE:
case GLOBAL_DICTIONARY_TYPE:
case NUMBER_DICTIONARY_TYPE:
case SIMPLE_NUMBER_DICTIONARY_TYPE:
case STRING_TABLE_TYPE:
case HEAP_NUMBER_TYPE:
case JS_BOUND_FUNCTION_TYPE:
case JS_GLOBAL_OBJECT_TYPE:

View File

@ -413,8 +413,16 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(FIXED_ARRAY_TYPE) \
V(BOILERPLATE_DESCRIPTION_TYPE) \
V(HASH_TABLE_TYPE) \
V(ORDERED_HASH_MAP_TYPE) \
V(ORDERED_HASH_SET_TYPE) \
V(NAME_DICTIONARY_TYPE) \
V(GLOBAL_DICTIONARY_TYPE) \
V(NUMBER_DICTIONARY_TYPE) \
V(SIMPLE_NUMBER_DICTIONARY_TYPE) \
V(STRING_TABLE_TYPE) \
V(EPHEMERON_HASH_TABLE_TYPE) \
V(SCOPE_INFO_TYPE) \
V(SCRIPT_CONTEXT_TABLE_TYPE) \
\
V(BLOCK_CONTEXT_TYPE) \
V(CATCH_CONTEXT_TYPE) \
@ -796,9 +804,17 @@ enum InstanceType : uint16_t {
// FixedArrays.
FIXED_ARRAY_TYPE, // FIRST_FIXED_ARRAY_TYPE
BOILERPLATE_DESCRIPTION_TYPE,
HASH_TABLE_TYPE,
HASH_TABLE_TYPE, // FIRST_HASH_TABLE_TYPE
ORDERED_HASH_MAP_TYPE, // FIRST_DICTIONARY_TYPE
ORDERED_HASH_SET_TYPE,
NAME_DICTIONARY_TYPE,
GLOBAL_DICTIONARY_TYPE,
NUMBER_DICTIONARY_TYPE,
SIMPLE_NUMBER_DICTIONARY_TYPE, // LAST_DICTIONARY_TYPE
STRING_TABLE_TYPE, // LAST_HASH_TABLE_TYPE
EPHEMERON_HASH_TABLE_TYPE,
SCOPE_INFO_TYPE,
SCRIPT_CONTEXT_TABLE_TYPE,
BLOCK_CONTEXT_TYPE, // FIRST_CONTEXT_TYPE
CATCH_CONTEXT_TYPE,
DEBUG_EVALUATE_CONTEXT_TYPE,
@ -902,6 +918,12 @@ enum InstanceType : uint16_t {
// Boundaries for testing if given HeapObject is a subclass of FixedArray.
FIRST_FIXED_ARRAY_TYPE = FIXED_ARRAY_TYPE,
LAST_FIXED_ARRAY_TYPE = WITH_CONTEXT_TYPE,
// Boundaries for testing if given HeapObject is a subclass of HashTable
FIRST_HASH_TABLE_TYPE = HASH_TABLE_TYPE,
LAST_HASH_TABLE_TYPE = STRING_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,

View File

@ -423,7 +423,7 @@ RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) {
CONVERT_ARG_CHECKED(JSArray, array, 0);
FixedArrayBase* elements = array->elements();
SealHandleScope shs(isolate);
if (elements->IsDictionary()) {
if (elements->IsNumberDictionary()) {
int result = NumberDictionary::cast(elements)->NumberOfElements();
return Smi::FromInt(result);
} else {

View File

@ -462,7 +462,7 @@ bool InitClassPrototype(Isolate* isolate,
Handle<Object> properties_template(
class_boilerplate->instance_properties_template(), isolate);
if (properties_template->IsDictionary()) {
if (properties_template->IsNameDictionary()) {
Handle<NameDictionary> properties_dictionary_template =
Handle<NameDictionary>::cast(properties_template);
@ -514,7 +514,7 @@ bool InitClassConstructor(Isolate* isolate,
Handle<Object> properties_template(
class_boilerplate->static_properties_template(), isolate);
if (properties_template->IsDictionary()) {
if (properties_template->IsNameDictionary()) {
Handle<NameDictionary> properties_dictionary_template =
Handle<NameDictionary>::cast(properties_template);

View File

@ -85,34 +85,42 @@ INSTANCE_TYPES = {
181: "FIXED_ARRAY_TYPE",
182: "BOILERPLATE_DESCRIPTION_TYPE",
183: "HASH_TABLE_TYPE",
184: "EPHEMERON_HASH_TABLE_TYPE",
185: "SCOPE_INFO_TYPE",
186: "BLOCK_CONTEXT_TYPE",
187: "CATCH_CONTEXT_TYPE",
188: "DEBUG_EVALUATE_CONTEXT_TYPE",
189: "EVAL_CONTEXT_TYPE",
190: "FUNCTION_CONTEXT_TYPE",
191: "MODULE_CONTEXT_TYPE",
192: "NATIVE_CONTEXT_TYPE",
193: "SCRIPT_CONTEXT_TYPE",
194: "WITH_CONTEXT_TYPE",
195: "WEAK_FIXED_ARRAY_TYPE",
196: "DESCRIPTOR_ARRAY_TYPE",
197: "TRANSITION_ARRAY_TYPE",
198: "CALL_HANDLER_INFO_TYPE",
199: "CELL_TYPE",
200: "CODE_DATA_CONTAINER_TYPE",
201: "FEEDBACK_CELL_TYPE",
202: "FEEDBACK_VECTOR_TYPE",
203: "LOAD_HANDLER_TYPE",
204: "PROPERTY_ARRAY_TYPE",
205: "PROPERTY_CELL_TYPE",
206: "SHARED_FUNCTION_INFO_TYPE",
207: "SMALL_ORDERED_HASH_MAP_TYPE",
208: "SMALL_ORDERED_HASH_SET_TYPE",
209: "STORE_HANDLER_TYPE",
210: "WEAK_CELL_TYPE",
211: "WEAK_ARRAY_LIST_TYPE",
184: "ORDERED_HASH_MAP_TYPE",
185: "ORDERED_HASH_SET_TYPE",
186: "NAME_DICTIONARY_TYPE",
187: "GLOBAL_DICTIONARY_TYPE",
188: "NUMBER_DICTIONARY_TYPE",
189: "SIMPLE_NUMBER_DICTIONARY_TYPE",
190: "STRING_TABLE_TYPE",
191: "EPHEMERON_HASH_TABLE_TYPE",
192: "SCOPE_INFO_TYPE",
193: "SCRIPT_CONTEXT_TABLE_TYPE",
194: "BLOCK_CONTEXT_TYPE",
195: "CATCH_CONTEXT_TYPE",
196: "DEBUG_EVALUATE_CONTEXT_TYPE",
197: "EVAL_CONTEXT_TYPE",
198: "FUNCTION_CONTEXT_TYPE",
199: "MODULE_CONTEXT_TYPE",
200: "NATIVE_CONTEXT_TYPE",
201: "SCRIPT_CONTEXT_TYPE",
202: "WITH_CONTEXT_TYPE",
203: "WEAK_FIXED_ARRAY_TYPE",
204: "DESCRIPTOR_ARRAY_TYPE",
205: "TRANSITION_ARRAY_TYPE",
206: "CALL_HANDLER_INFO_TYPE",
207: "CELL_TYPE",
208: "CODE_DATA_CONTAINER_TYPE",
209: "FEEDBACK_CELL_TYPE",
210: "FEEDBACK_VECTOR_TYPE",
211: "LOAD_HANDLER_TYPE",
212: "PROPERTY_ARRAY_TYPE",
213: "PROPERTY_CELL_TYPE",
214: "SHARED_FUNCTION_INFO_TYPE",
215: "SMALL_ORDERED_HASH_MAP_TYPE",
216: "SMALL_ORDERED_HASH_SET_TYPE",
217: "STORE_HANDLER_TYPE",
218: "WEAK_CELL_TYPE",
219: "WEAK_ARRAY_LIST_TYPE",
1024: "JS_PROXY_TYPE",
1025: "JS_GLOBAL_OBJECT_TYPE",
1026: "JS_GLOBAL_PROXY_TYPE",
@ -162,9 +170,9 @@ KNOWN_MAPS = {
("RO_SPACE", 0x02201): (138, "FreeSpaceMap"),
("RO_SPACE", 0x02259): (132, "MetaMap"),
("RO_SPACE", 0x022e1): (131, "NullMap"),
("RO_SPACE", 0x02359): (196, "DescriptorArrayMap"),
("RO_SPACE", 0x02359): (204, "DescriptorArrayMap"),
("RO_SPACE", 0x023c1): (181, "FixedArrayMap"),
("RO_SPACE", 0x02429): (210, "WeakCellMap"),
("RO_SPACE", 0x02429): (218, "WeakCellMap"),
("RO_SPACE", 0x024d1): (152, "OnePointerFillerMap"),
("RO_SPACE", 0x02539): (152, "TwoPointerFillerMap"),
("RO_SPACE", 0x025d1): (131, "UninitializedMap"),
@ -178,58 +186,58 @@ KNOWN_MAPS = {
("RO_SPACE", 0x02ad9): (183, "HashTableMap"),
("RO_SPACE", 0x02b41): (128, "SymbolMap"),
("RO_SPACE", 0x02ba9): (72, "OneByteStringMap"),
("RO_SPACE", 0x02c11): (185, "ScopeInfoMap"),
("RO_SPACE", 0x02c79): (206, "SharedFunctionInfoMap"),
("RO_SPACE", 0x02c11): (192, "ScopeInfoMap"),
("RO_SPACE", 0x02c79): (214, "SharedFunctionInfoMap"),
("RO_SPACE", 0x02ce1): (133, "CodeMap"),
("RO_SPACE", 0x02d49): (190, "FunctionContextMap"),
("RO_SPACE", 0x02db1): (199, "CellMap"),
("RO_SPACE", 0x02e19): (205, "GlobalPropertyCellMap"),
("RO_SPACE", 0x02d49): (198, "FunctionContextMap"),
("RO_SPACE", 0x02db1): (207, "CellMap"),
("RO_SPACE", 0x02e19): (213, "GlobalPropertyCellMap"),
("RO_SPACE", 0x02e81): (135, "ForeignMap"),
("RO_SPACE", 0x02ee9): (197, "TransitionArrayMap"),
("RO_SPACE", 0x02f51): (202, "FeedbackVectorMap"),
("RO_SPACE", 0x02ee9): (205, "TransitionArrayMap"),
("RO_SPACE", 0x02f51): (210, "FeedbackVectorMap"),
("RO_SPACE", 0x02ff9): (131, "ArgumentsMarkerMap"),
("RO_SPACE", 0x030b9): (131, "ExceptionMap"),
("RO_SPACE", 0x03179): (131, "TerminationExceptionMap"),
("RO_SPACE", 0x03241): (131, "OptimizedOutMap"),
("RO_SPACE", 0x03301): (131, "StaleRegisterMap"),
("RO_SPACE", 0x03391): (192, "NativeContextMap"),
("RO_SPACE", 0x033f9): (191, "ModuleContextMap"),
("RO_SPACE", 0x03461): (189, "EvalContextMap"),
("RO_SPACE", 0x034c9): (193, "ScriptContextMap"),
("RO_SPACE", 0x03531): (186, "BlockContextMap"),
("RO_SPACE", 0x03599): (187, "CatchContextMap"),
("RO_SPACE", 0x03601): (194, "WithContextMap"),
("RO_SPACE", 0x03669): (188, "DebugEvaluateContextMap"),
("RO_SPACE", 0x036d1): (181, "ScriptContextTableMap"),
("RO_SPACE", 0x03391): (200, "NativeContextMap"),
("RO_SPACE", 0x033f9): (199, "ModuleContextMap"),
("RO_SPACE", 0x03461): (197, "EvalContextMap"),
("RO_SPACE", 0x034c9): (201, "ScriptContextMap"),
("RO_SPACE", 0x03531): (194, "BlockContextMap"),
("RO_SPACE", 0x03599): (195, "CatchContextMap"),
("RO_SPACE", 0x03601): (202, "WithContextMap"),
("RO_SPACE", 0x03669): (196, "DebugEvaluateContextMap"),
("RO_SPACE", 0x036d1): (193, "ScriptContextTableMap"),
("RO_SPACE", 0x03739): (151, "FeedbackMetadataArrayMap"),
("RO_SPACE", 0x037a1): (181, "ArrayListMap"),
("RO_SPACE", 0x03809): (130, "BigIntMap"),
("RO_SPACE", 0x03871): (182, "BoilerplateDescriptionMap"),
("RO_SPACE", 0x038d9): (137, "BytecodeArrayMap"),
("RO_SPACE", 0x03941): (200, "CodeDataContainerMap"),
("RO_SPACE", 0x03941): (208, "CodeDataContainerMap"),
("RO_SPACE", 0x039a9): (150, "FixedDoubleArrayMap"),
("RO_SPACE", 0x03a11): (183, "GlobalDictionaryMap"),
("RO_SPACE", 0x03a79): (201, "ManyClosuresCellMap"),
("RO_SPACE", 0x03a11): (187, "GlobalDictionaryMap"),
("RO_SPACE", 0x03a79): (209, "ManyClosuresCellMap"),
("RO_SPACE", 0x03ae1): (181, "ModuleInfoMap"),
("RO_SPACE", 0x03b49): (134, "MutableHeapNumberMap"),
("RO_SPACE", 0x03bb1): (183, "NameDictionaryMap"),
("RO_SPACE", 0x03c19): (201, "NoClosuresCellMap"),
("RO_SPACE", 0x03c81): (183, "NumberDictionaryMap"),
("RO_SPACE", 0x03ce9): (201, "OneClosureCellMap"),
("RO_SPACE", 0x03d51): (183, "OrderedHashMapMap"),
("RO_SPACE", 0x03db9): (183, "OrderedHashSetMap"),
("RO_SPACE", 0x03e21): (204, "PropertyArrayMap"),
("RO_SPACE", 0x03e89): (198, "SideEffectCallHandlerInfoMap"),
("RO_SPACE", 0x03ef1): (198, "SideEffectFreeCallHandlerInfoMap"),
("RO_SPACE", 0x03f59): (198, "NextCallSideEffectFreeCallHandlerInfoMap"),
("RO_SPACE", 0x03fc1): (183, "SimpleNumberDictionaryMap"),
("RO_SPACE", 0x03bb1): (186, "NameDictionaryMap"),
("RO_SPACE", 0x03c19): (209, "NoClosuresCellMap"),
("RO_SPACE", 0x03c81): (188, "NumberDictionaryMap"),
("RO_SPACE", 0x03ce9): (209, "OneClosureCellMap"),
("RO_SPACE", 0x03d51): (184, "OrderedHashMapMap"),
("RO_SPACE", 0x03db9): (185, "OrderedHashSetMap"),
("RO_SPACE", 0x03e21): (212, "PropertyArrayMap"),
("RO_SPACE", 0x03e89): (206, "SideEffectCallHandlerInfoMap"),
("RO_SPACE", 0x03ef1): (206, "SideEffectFreeCallHandlerInfoMap"),
("RO_SPACE", 0x03f59): (206, "NextCallSideEffectFreeCallHandlerInfoMap"),
("RO_SPACE", 0x03fc1): (189, "SimpleNumberDictionaryMap"),
("RO_SPACE", 0x04029): (181, "SloppyArgumentsElementsMap"),
("RO_SPACE", 0x04091): (207, "SmallOrderedHashMapMap"),
("RO_SPACE", 0x040f9): (208, "SmallOrderedHashSetMap"),
("RO_SPACE", 0x04161): (183, "StringTableMap"),
("RO_SPACE", 0x041c9): (195, "WeakFixedArrayMap"),
("RO_SPACE", 0x04231): (211, "WeakArrayListMap"),
("RO_SPACE", 0x04299): (184, "EphemeronHashTableMap"),
("RO_SPACE", 0x04091): (215, "SmallOrderedHashMapMap"),
("RO_SPACE", 0x040f9): (216, "SmallOrderedHashSetMap"),
("RO_SPACE", 0x04161): (190, "StringTableMap"),
("RO_SPACE", 0x041c9): (203, "WeakFixedArrayMap"),
("RO_SPACE", 0x04231): (219, "WeakArrayListMap"),
("RO_SPACE", 0x04299): (191, "EphemeronHashTableMap"),
("RO_SPACE", 0x04301): (106, "NativeSourceStringMap"),
("RO_SPACE", 0x04369): (64, "StringMap"),
("RO_SPACE", 0x043d1): (73, "ConsOneByteStringMap"),