Commit 92d239b8 authored by Irina Yatsenko's avatar Irina Yatsenko Committed by Commit Bot

Make EnumCache derive directly from Struct and add a new instance type for it.

Bug: v8:9136
Change-Id: I9c0b4b662c2d061a13ee22df728fbee5df01b89e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1568106Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Irina Yatsenko <irinayat@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#60908}
parent d1068b4f
......@@ -153,6 +153,12 @@ extern class ByteArray extends FixedArrayBase {}
type BytecodeArray extends FixedArrayBase;
@generatePrint
extern class EnumCache extends Struct {
keys: FixedArray;
indices: FixedArray;
}
// These intrinsics should never be called from Torque code. They're used
// internally by the 'new' operator and only declared here because it's simpler
// than building the definition from C++.
......
......@@ -354,6 +354,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
case INTERPRETER_DATA_TYPE:
case TUPLE2_TYPE:
case TUPLE3_TYPE:
case ENUM_CACHE_TYPE:
case WASM_DEBUG_INFO_TYPE:
case WASM_EXCEPTION_TAG_TYPE:
case WASM_EXPORTED_FUNCTION_DATA_TYPE:
......
......@@ -231,8 +231,11 @@ Handle<PrototypeInfo> Factory::NewPrototypeInfo() {
Handle<EnumCache> Factory::NewEnumCache(Handle<FixedArray> keys,
Handle<FixedArray> indices) {
return Handle<EnumCache>::cast(
NewTuple2(keys, indices, AllocationType::kOld));
Handle<EnumCache> result = Handle<EnumCache>::cast(
NewStruct(ENUM_CACHE_TYPE, AllocationType::kOld));
result->set_keys(*keys);
result->set_indices(*indices);
return result;
}
Handle<Tuple2> Factory::NewTuple2(Handle<Object> value1, Handle<Object> value2,
......
......@@ -860,7 +860,7 @@ void ObjectStatsCollectorImpl::RecordVirtualMapDetails(Map map) {
EnumCache enum_cache = array->enum_cache();
RecordSimpleVirtualObjectStats(array, enum_cache->keys(),
ObjectStats::ENUM_CACHE_TYPE);
ObjectStats::ENUM_KEYS_CACHE_TYPE);
RecordSimpleVirtualObjectStats(array, enum_cache->indices(),
ObjectStats::ENUM_INDICES_CACHE_TYPE);
}
......
......@@ -29,7 +29,7 @@
V(DEPENDENT_CODE_TYPE) \
V(DEPRECATED_DESCRIPTOR_ARRAY_TYPE) \
V(EMBEDDED_OBJECT_TYPE) \
V(ENUM_CACHE_TYPE) \
V(ENUM_KEYS_CACHE_TYPE) \
V(ENUM_INDICES_CACHE_TYPE) \
V(FEEDBACK_VECTOR_ENTRY_TYPE) \
V(FEEDBACK_VECTOR_HEADER_TYPE) \
......
......@@ -314,7 +314,7 @@ bool Heap::CreateInitialMaps() {
// Allocate the empty enum cache.
{
AllocationResult allocation =
Allocate(roots.tuple2_map(), AllocationType::kReadOnly);
Allocate(roots.enum_cache_map(), AllocationType::kReadOnly);
if (!allocation.To(&obj)) return false;
}
set_empty_enum_cache(EnumCache::cast(obj));
......
......@@ -1842,15 +1842,21 @@ void PrototypeUsers::Verify(WeakArrayList array) {
void Tuple2::Tuple2Verify(Isolate* isolate) {
CHECK(IsTuple2());
VerifyObjectField(isolate, kValue1Offset);
VerifyObjectField(isolate, kValue2Offset);
}
void EnumCache::EnumCacheVerify(Isolate* isolate) {
CHECK(IsEnumCache());
Heap* heap = isolate->heap();
if (*this == ReadOnlyRoots(heap).empty_enum_cache()) {
CHECK_EQ(ReadOnlyRoots(heap).empty_fixed_array(),
EnumCache::cast(*this)->keys());
CHECK_EQ(ReadOnlyRoots(heap).empty_fixed_array(),
EnumCache::cast(*this)->indices());
CHECK_EQ(ReadOnlyRoots(heap).empty_fixed_array(), keys());
CHECK_EQ(ReadOnlyRoots(heap).empty_fixed_array(), indices());
} else {
VerifyObjectField(isolate, kValue1Offset);
VerifyObjectField(isolate, kValue2Offset);
VerifyObjectField(isolate, kKeysOffset);
VerifyObjectField(isolate, kIndicesOffset);
CHECK(keys()->IsFixedArray());
CHECK(indices()->IsFixedArray());
}
}
......
......@@ -97,6 +97,7 @@ namespace internal {
V(ASYNC_GENERATOR_REQUEST_TYPE) \
V(CLASS_POSITIONS_TYPE) \
V(DEBUG_INFO_TYPE) \
V(ENUM_CACHE_TYPE) \
V(FUNCTION_TEMPLATE_INFO_TYPE) \
V(FUNCTION_TEMPLATE_RARE_DATA_TYPE) \
V(INTERCEPTOR_INFO_TYPE) \
......@@ -310,6 +311,7 @@ namespace internal {
async_generator_request) \
V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \
V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \
V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \
V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \
function_template_info) \
V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \
......
......@@ -222,8 +222,6 @@ bool HeapObject::IsPromiseReactionJobTask() const {
return IsPromiseFulfillReactionJobTask() || IsPromiseRejectReactionJobTask();
}
bool HeapObject::IsEnumCache() const { return IsTuple2(); }
bool HeapObject::IsFrameArray() const { return IsFixedArrayExact(); }
bool HeapObject::IsArrayList() const {
......
......@@ -354,7 +354,6 @@ class ZoneForwardList;
V(DescriptorArray) \
V(EmbedderDataArray) \
V(EphemeronHashTable) \
V(EnumCache) \
V(ExternalOneByteString) \
V(ExternalString) \
V(ExternalTwoByteString) \
......
......@@ -25,7 +25,7 @@ namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(DescriptorArray, HeapObject)
OBJECT_CONSTRUCTORS_IMPL(EnumCache, Tuple2)
OBJECT_CONSTRUCTORS_IMPL(EnumCache, Struct)
CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(EnumCache)
......
......@@ -22,18 +22,21 @@ class Handle;
class Isolate;
// An EnumCache is a pair used to hold keys and indices caches.
class EnumCache : public Tuple2 {
class EnumCache : public Struct {
public:
DECL_ACCESSORS(keys, FixedArray)
DECL_ACCESSORS(indices, FixedArray)
DECL_CAST(EnumCache)
DECL_PRINTER(EnumCache)
DECL_VERIFIER(EnumCache)
// Layout description.
static const int kKeysOffset = kValue1Offset;
static const int kIndicesOffset = kValue2Offset;
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_ENUM_CACHE_FIELDS)
OBJECT_CONSTRUCTORS(EnumCache, Tuple2);
OBJECT_CONSTRUCTORS(EnumCache, Struct);
};
// A DescriptorArray is a custom array that holds instance descriptors.
......
......@@ -164,6 +164,7 @@ enum InstanceType : uint16_t {
ASYNC_GENERATOR_REQUEST_TYPE,
CLASS_POSITIONS_TYPE,
DEBUG_INFO_TYPE,
ENUM_CACHE_TYPE,
FUNCTION_TEMPLATE_INFO_TYPE,
FUNCTION_TEMPLATE_RARE_DATA_TYPE,
INTERCEPTOR_INFO_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