Commit 3b93e695 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

Add InstanceType for EphemeronHashTable

This will allow the GC to differentiate between regular HashTables and EphemeronHashTables.

Bug: chromium:844008
Change-Id: I2f9009ac25eb117de03786b110dd362b829c5e9e
Reviewed-on: https://chromium-review.googlesource.com/1089066Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@google.com>
Cr-Commit-Position: refs/heads/master@{#53577}
parent 2725f395
......@@ -254,6 +254,7 @@ Type::bitset BitsetType::Lub(HeapReferenceType const& type) {
case ACCESSOR_PAIR_TYPE:
case FIXED_ARRAY_TYPE:
case HASH_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case WEAK_FIXED_ARRAY_TYPE:
case WEAK_ARRAY_LIST_TYPE:
case FIXED_DOUBLE_ARRAY_TYPE:
......
......@@ -140,6 +140,7 @@ using v8::MemoryPressureLevel;
V(Map, string_table_map, StringTableMap) \
V(Map, weak_fixed_array_map, WeakFixedArrayMap) \
V(Map, weak_array_list_map, WeakArrayListMap) \
V(Map, ephemeron_hash_table_map, EphemeronHashTableMap) \
/* String maps */ \
V(Map, native_source_string_map, NativeSourceStringMap) \
V(Map, string_map, StringMap) \
......@@ -326,6 +327,7 @@ using v8::MemoryPressureLevel;
V(CodeMap) \
V(DebugEvaluateContextMap) \
V(DescriptorArrayMap) \
V(EphemeronHashTableMap) \
V(EmptyByteArray) \
V(EmptyDescriptorArray) \
V(EmptyFixedArray) \
......
......@@ -103,7 +103,7 @@ int MarkingVisitor<fixed_array_mode, retaining_path_mode, MarkingState>::
this);
// Partially initialized weak collection is enqueued, but table is ignored.
if (!weak_collection->table()->IsHashTable()) return size;
if (!weak_collection->table()->IsEphemeronHashTable()) return size;
// Mark the backing hash table without pushing it on the marking stack.
Object** slot =
......
......@@ -1878,6 +1878,8 @@ void MarkCompactCollector::ProcessWeakCollections() {
visitor.VisitPointer(table, value_slot);
}
}
} else {
DCHECK(weak_collection->table()->IsUndefined(isolate()));
}
weak_collection_obj = weak_collection->next();
}
......@@ -1899,6 +1901,8 @@ void MarkCompactCollector::ClearWeakCollections() {
table->RemoveEntry(i);
}
}
} else {
DCHECK(weak_collection->table()->IsUndefined(isolate()));
}
weak_collection_obj = weak_collection->next();
weak_collection->set_next(heap()->undefined_value());
......
......@@ -458,6 +458,8 @@ bool Heap::CreateInitialMaps() {
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, simple_number_dictionary)
ALLOCATE_VARSIZE_MAP(HASH_TABLE_TYPE, string_table)
ALLOCATE_VARSIZE_MAP(EPHEMERON_HASH_TABLE_TYPE, ephemeron_hash_table)
ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, array_list)
ALLOCATE_VARSIZE_MAP(FUNCTION_CONTEXT_TYPE, function_context)
......
......@@ -602,6 +602,7 @@ 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 EPHEMERON_HASH_TABLE_TYPE:
case SCOPE_INFO_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
......
......@@ -132,6 +132,7 @@ void HeapObject::HeapObjectVerify() {
CallHandlerInfo::cast(this)->CallHandlerInfoVerify();
break;
case HASH_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case BOILERPLATE_DESCRIPTION_TYPE:
case FIXED_ARRAY_TYPE:
case SCOPE_INFO_TYPE:
......@@ -1186,7 +1187,7 @@ void JSWeakMap::JSWeakMapVerify() {
CHECK(IsJSWeakMap());
JSObjectVerify();
VerifyHeapPointer(table());
CHECK(table()->IsHashTable() || table()->IsUndefined(GetIsolate()));
CHECK(table()->IsEphemeronHashTable() || table()->IsUndefined(GetIsolate()));
}
void JSArrayIterator::JSArrayIteratorVerify() {
......@@ -1227,7 +1228,7 @@ void JSWeakSet::JSWeakSetVerify() {
CHECK(IsJSWeakSet());
JSObjectVerify();
VerifyHeapPointer(table());
CHECK(table()->IsHashTable() || table()->IsUndefined(GetIsolate()));
CHECK(table()->IsEphemeronHashTable() || table()->IsUndefined(GetIsolate()));
}
void Microtask::MicrotaskVerify() { CHECK(IsMicrotask()); }
......
......@@ -83,6 +83,7 @@ TYPE_CHECKER(CodeDataContainer, CODE_DATA_CONTAINER_TYPE)
TYPE_CHECKER(ConstantElementsPair, TUPLE2_TYPE)
TYPE_CHECKER(CoverageInfo, FIXED_ARRAY_TYPE)
TYPE_CHECKER(DescriptorArray, DESCRIPTOR_ARRAY_TYPE)
TYPE_CHECKER(EphemeronHashTable, EPHEMERON_HASH_TABLE_TYPE)
TYPE_CHECKER(FeedbackCell, FEEDBACK_CELL_TYPE)
TYPE_CHECKER(FeedbackMetadata, FEEDBACK_METADATA_TYPE)
TYPE_CHECKER(FeedbackVector, FEEDBACK_VECTOR_TYPE)
......@@ -505,8 +506,6 @@ bool HeapObject::IsMapCache() const { return IsHashTable(); }
bool HeapObject::IsObjectHashTable() const { return IsHashTable(); }
bool HeapObject::IsEphemeronHashTable() const { return IsHashTable(); }
bool HeapObject::IsOrderedHashSet() const {
return map() == GetHeap()->ordered_hash_set_map();
}
......
......@@ -98,6 +98,7 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT
FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(os);
break;
case HASH_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case FIXED_ARRAY_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
......@@ -863,8 +864,15 @@ void PrintWeakArrayListWithHeader(std::ostream& os, WeakArrayList* array) {
} // namespace
void FixedArray::FixedArrayPrint(std::ostream& os) { // NOLINT
PrintFixedArrayWithHeader(os, this,
IsHashTable() ? "HashTable" : "FixedArray");
const char* name = "FixedArray";
if (IsHashTable()) {
name = "HashTable";
} else if (IsEphemeronHashTable()) {
name = "EphemeronHashTable";
}
PrintFixedArrayWithHeader(os, this, name);
}
void BoilerplateDescription::BoilerplateDescriptionPrint(std::ostream& os) {
......
......@@ -2979,6 +2979,7 @@ VisitorId Map::GetVisitorId(Map* map) {
case FIXED_ARRAY_TYPE:
case BOILERPLATE_DESCRIPTION_TYPE:
case HASH_TABLE_TYPE:
case EPHEMERON_HASH_TABLE_TYPE:
case SCOPE_INFO_TYPE:
case BLOCK_CONTEXT_TYPE:
case CATCH_CONTEXT_TYPE:
......
......@@ -416,6 +416,7 @@ const int kStubMinorKeyBits = kSmiValueSize - kStubMajorKeyBits - 1;
V(FIXED_ARRAY_TYPE) \
V(BOILERPLATE_DESCRIPTION_TYPE) \
V(HASH_TABLE_TYPE) \
V(EPHEMERON_HASH_TABLE_TYPE) \
V(SCOPE_INFO_TYPE) \
\
V(BLOCK_CONTEXT_TYPE) \
......@@ -799,6 +800,7 @@ enum InstanceType : uint16_t {
FIXED_ARRAY_TYPE, // FIRST_FIXED_ARRAY_TYPE
BOILERPLATE_DESCRIPTION_TYPE,
HASH_TABLE_TYPE,
EPHEMERON_HASH_TABLE_TYPE,
SCOPE_INFO_TYPE,
BLOCK_CONTEXT_TYPE, // FIRST_CONTEXT_TYPE
CATCH_CONTEXT_TYPE,
......
......@@ -58,6 +58,10 @@ int BaseShape<Key>::GetMapRootIndex() {
return Heap::kHashTableMapRootIndex;
}
int EphemeronHashTableShape::GetMapRootIndex() {
return Heap::kEphemeronHashTableMapRootIndex;
}
template <typename Derived, typename Shape>
int HashTable<Derived, Shape>::FindEntry(Key key) {
return FindEntry(GetIsolate(), key);
......
......@@ -312,7 +312,10 @@ class ObjectHashTable
DECL_CAST(ObjectHashTable)
};
typedef ObjectHashTableShape EphemeronHashTableShape;
class EphemeronHashTableShape : public ObjectHashTableShape {
public:
static inline int GetMapRootIndex();
};
// EphemeronHashTable is similar to ObjectHashTable but gets special treatment
// by the GC. The GC treats its entries as ephemerons: both key and value are
......
......@@ -1037,7 +1037,7 @@ void V8HeapExplorer::ExtractJSCollectionReferences(int entry,
void V8HeapExplorer::ExtractJSWeakCollectionReferences(int entry,
JSWeakCollection* obj) {
if (obj->table()->IsHashTable()) {
if (obj->table()->IsEphemeronHashTable()) {
EphemeronHashTable* table = EphemeronHashTable::cast(obj->table());
TagFixedArraySubType(table, JS_WEAK_COLLECTION_SUB_TYPE);
}
......
This diff is collapsed.
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