Commit 4beadfde authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] fully port Oddball and add @customMap annotation

Bug: v8:7793
TBR=hpayer@chromium.org

Change-Id: I88644c9476b74f57d3cf7a3056a9b70f1467b96d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2489689
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71079}
parent ef2363db
......@@ -329,49 +329,7 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
// Remaining instance types are unsupported for now. If any of them do
// require bit set types, they should get kOtherInternal.
case FREE_SPACE_TYPE:
case FILLER_TYPE:
case ACCESS_CHECK_INFO_TYPE:
case ASM_WASM_DATA_TYPE:
case CALL_HANDLER_INFO_TYPE:
case INTERCEPTOR_INFO_TYPE:
case OBJECT_TEMPLATE_INFO_TYPE:
case ALLOCATION_MEMENTO_TYPE:
case ALIASED_ARGUMENTS_ENTRY_TYPE:
case PROMISE_CAPABILITY_TYPE:
case PROMISE_REACTION_TYPE:
case CLASS_POSITIONS_TYPE:
case DEBUG_INFO_TYPE:
case STACK_FRAME_INFO_TYPE:
case STACK_TRACE_FRAME_TYPE:
case SMALL_ORDERED_HASH_MAP_TYPE:
case SMALL_ORDERED_HASH_SET_TYPE:
case SMALL_ORDERED_NAME_DICTIONARY_TYPE:
case PROTOTYPE_INFO_TYPE:
case INTERPRETER_DATA_TYPE:
case TEMPLATE_OBJECT_DESCRIPTION_TYPE:
case TUPLE2_TYPE:
case BREAK_POINT_TYPE:
case BREAK_POINT_INFO_TYPE:
case WASM_VALUE_TYPE:
case CACHED_TEMPLATE_OBJECT_TYPE:
case ENUM_CACHE_TYPE:
case WASM_INDIRECT_FUNCTION_TABLE_TYPE:
case WASM_EXCEPTION_TAG_TYPE:
case WASM_EXPORTED_FUNCTION_DATA_TYPE:
case WASM_JS_FUNCTION_DATA_TYPE:
case LOAD_HANDLER_TYPE:
case STORE_HANDLER_TYPE:
case ASYNC_GENERATOR_REQUEST_TYPE:
case CODE_DATA_CONTAINER_TYPE:
case CALLBACK_TASK_TYPE:
case CALLABLE_TASK_TYPE:
case PROMISE_FULFILL_REACTION_JOB_TASK_TYPE:
case PROMISE_REJECT_REACTION_JOB_TASK_TYPE:
case PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE:
#define MAKE_TORQUE_CLASS_TYPE(INSTANCE_TYPE, Name, name) case INSTANCE_TYPE:
TORQUE_DEFINED_INSTANCE_TYPE_LIST(MAKE_TORQUE_CLASS_TYPE)
#undef MAKE_TORQUE_CLASS_TYPE
default:
UNREACHABLE();
}
UNREACHABLE();
......
......@@ -40,7 +40,6 @@ namespace internal {
V(JSWeakRef) \
V(Map) \
V(NativeContext) \
V(Oddball) \
V(PreparseData) \
V(PropertyArray) \
V(PropertyCell) \
......
......@@ -187,9 +187,6 @@ VisitorId Map::GetVisitorId(Map map) {
case FEEDBACK_METADATA_TYPE:
return kVisitFeedbackMetadata;
case ODDBALL_TYPE:
return kVisitOddball;
case MAP_TYPE:
return kVisitMap;
......
......@@ -55,7 +55,6 @@ enum InstanceType : uint16_t;
V(JSWeakCollection) \
V(Map) \
V(NativeContext) \
V(Oddball) \
V(PreparseData) \
V(PropertyArray) \
V(PropertyCell) \
......
......@@ -180,7 +180,6 @@ class ZoneForwardList;
V(NumberWrapper) \
V(ObjectHashSet) \
V(ObjectHashTable) \
V(Oddball) \
V(OrderedHashMap) \
V(OrderedHashSet) \
V(OrderedNameDictionary) \
......
......@@ -1028,8 +1028,6 @@ ReturnType BodyDescriptorApply(InstanceType type, T1 p1, T2 p2, T3 p3, T4 p4) {
return Op::template apply<WeakCell::BodyDescriptor>(p1, p2, p3, p4);
case JS_WEAK_REF_TYPE:
return Op::template apply<JSWeakRef::BodyDescriptor>(p1, p2, p3, p4);
case ODDBALL_TYPE:
return Op::template apply<Oddball::BodyDescriptor>(p1, p2, p3, p4);
case JS_PROXY_TYPE:
return Op::template apply<JSProxy::BodyDescriptor>(p1, p2, p3, p4);
case FOREIGN_TYPE:
......
......@@ -51,10 +51,7 @@ class Oddball : public TorqueGeneratedOddball<Oddball, PrimitiveHeapObject> {
static const byte kSelfReferenceMarker = 10;
static const byte kBasicBlockCountersMarker = 11;
static_assert(kStartOfWeakFieldsOffset == kEndOfWeakFieldsOffset,
"Ensure BodyDescriptor does not need to handle weak fields.");
using BodyDescriptor = FixedBodyDescriptor<kStartOfStrongFieldsOffset,
kEndOfStrongFieldsOffset, kSize>;
class BodyDescriptor;
STATIC_ASSERT(kKindOffset == Internals::kOddballKindOffset);
STATIC_ASSERT(kNull == Internals::kNullOddballKind);
......
......@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generateCppClass
@export
@customCppClass
@customMap // Oddballs have one of multiple maps, depending on the kind.
@apiExposedInstanceTypeValue(0x43)
@highestInstanceTypeWithinParentClassRange
extern class Oddball extends PrimitiveHeapObject {
class Oddball extends PrimitiveHeapObject {
to_number_raw: float64;
to_string: String;
to_number: Number;
......
......@@ -85,6 +85,7 @@ static const char* const ANNOTATION_ABSTRACT = "@abstract";
static const char* const ANNOTATION_HAS_SAME_INSTANCE_TYPE_AS_PARENT =
"@hasSameInstanceTypeAsParent";
static const char* const ANNOTATION_GENERATE_CPP_CLASS = "@generateCppClass";
static const char* const ANNOTATION_CUSTOM_MAP = "@customMap";
static const char* const ANNOTATION_CUSTOM_CPP_CLASS = "@customCppClass";
static const char* const ANNOTATION_HIGHEST_INSTANCE_TYPE_WITHIN_PARENT =
"@highestInstanceTypeWithinParentClassRange";
......@@ -142,7 +143,8 @@ enum class ClassFlag {
kUndefinedLayout = 1 << 11,
kGenerateBodyDescriptor = 1 << 12,
kExport = 1 << 13,
kDoNotGenerateCast = 1 << 14
kDoNotGenerateCast = 1 << 14,
kCustomMap = 1 << 15,
};
using ClassFlags = base::Flags<ClassFlag>;
......
......@@ -4220,7 +4220,8 @@ void ImplementationVisitor::GenerateClassDefinitions(
structs_used_in_classes.insert(*field_as_struct);
}
}
if (type->ShouldExport() && !type->IsAbstract()) {
if (type->ShouldExport() && !type->IsAbstract() &&
!type->HasCustomMap()) {
factory_header << type->HandlifiedCppTypeName() << " New"
<< type->name() << "(";
factory_impl << type->HandlifiedCppTypeName() << " Factory::New"
......
......@@ -451,7 +451,7 @@ void ImplementationVisitor::GenerateInstanceTypes(
if (type->IsExtern()) continue;
torque_defined_class_list << " V(" << upper_case_name << ") \\\n";
if (type->IsAbstract()) continue;
if (type->IsAbstract() || type->HasCustomMap()) continue;
torque_defined_map_csa_list << " V(_, " << upper_case_name << "Map, "
<< lower_case_name << "_map, "
<< upper_case_name << ") \\\n";
......
......@@ -890,8 +890,8 @@ base::Optional<ParseResult> MakeClassDeclaration(
{ANNOTATION_GENERATE_PRINT, ANNOTATION_NO_VERIFIER, ANNOTATION_ABSTRACT,
ANNOTATION_HAS_SAME_INSTANCE_TYPE_AS_PARENT,
ANNOTATION_GENERATE_CPP_CLASS, ANNOTATION_CUSTOM_CPP_CLASS,
ANNOTATION_GENERATE_BODY_DESCRIPTOR, ANNOTATION_EXPORT,
ANNOTATION_DO_NOT_GENERATE_CAST,
ANNOTATION_CUSTOM_MAP, ANNOTATION_GENERATE_BODY_DESCRIPTOR,
ANNOTATION_EXPORT, ANNOTATION_DO_NOT_GENERATE_CAST,
ANNOTATION_HIGHEST_INSTANCE_TYPE_WITHIN_PARENT,
ANNOTATION_LOWEST_INSTANCE_TYPE_WITHIN_PARENT},
{ANNOTATION_RESERVE_BITS_IN_INSTANCE_TYPE,
......@@ -913,6 +913,9 @@ base::Optional<ParseResult> MakeClassDeclaration(
if (annotations.Contains(ANNOTATION_CUSTOM_CPP_CLASS)) {
flags |= ClassFlag::kCustomCppClass;
}
if (annotations.Contains(ANNOTATION_CUSTOM_MAP)) {
flags |= ClassFlag::kCustomMap;
}
if (annotations.Contains(ANNOTATION_DO_NOT_GENERATE_CAST)) {
flags |= ClassFlag::kDoNotGenerateCast;
}
......
......@@ -686,6 +686,8 @@ class ClassType final : public AggregateType {
bool ShouldGenerateFullClassDefinition() const {
return !IsExtern() && !(flags_ & ClassFlag::kCustomCppClass);
}
// Class with multiple or non-standard maps, do not auto-generate map.
bool HasCustomMap() const { return flags_ & ClassFlag::kCustomMap; }
bool ShouldExport() const { return flags_ & ClassFlag::kExport; }
bool IsShape() const { return flags_ & ClassFlag::kIsShape; }
bool HasStaticSize() const;
......
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