Commit 24c23947 authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[cleanup] Don't inherit from Tuple2 and Tuple3

This change updates CachedTemplateObjectMap, BreakPointInfo, and
BreakPoint to inherit directly from Struct rather than Tuple2 or Tuple3.
It also removes Tuple3 because nothing else used Tuple3. By avoiding
tuple types, we get various benefits that Torque can provide:
- stricter debug verifier functions
- accessors, cast functions, and printers are generated
- BreakPoint and BreakPointInfo have different instance types, so you
  can tell them apart at runtime or in a debugger

Change-Id: I9367bc08c6dea55d659fd610f9f6105fd61c907a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1988793Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#65668}
parent 65cf3663
......@@ -152,7 +152,10 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \
V(TrueValue, true_value, True) \
V(Tuple2Map, tuple2_map, Tuple2Map) \
V(Tuple3Map, tuple3_map, Tuple3Map) \
V(BreakPointMap, break_point_map, BreakPointMap) \
V(BreakPointInfoMap, break_point_info_map, BreakPointInfoMap) \
V(CachedTemplateObjectMap, cached_template_object_map, \
CachedTemplateObjectMap) \
V(UncompiledDataWithoutPreparseDataMap, \
uncompiled_data_without_preparse_data_map, \
UncompiledDataWithoutPreparseDataMap) \
......
......@@ -347,7 +347,9 @@ Type::bitset BitsetType::Lub(const MapRefLike& map) {
case INTERPRETER_DATA_TYPE:
case TEMPLATE_OBJECT_DESCRIPTION_TYPE:
case TUPLE2_TYPE:
case TUPLE3_TYPE:
case BREAK_POINT_TYPE:
case BREAK_POINT_INFO_TYPE:
case CACHED_TEMPLATE_OBJECT_TYPE:
case ENUM_CACHE_TYPE:
case WASM_CAPI_FUNCTION_DATA_TYPE:
case WASM_INDIRECT_FUNCTION_TABLE_TYPE:
......
......@@ -3730,15 +3730,15 @@ Handle<CoverageInfo> Factory::NewCoverageInfo(
Handle<BreakPointInfo> Factory::NewBreakPointInfo(int source_position) {
Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
NewStruct(TUPLE2_TYPE, AllocationType::kOld));
NewStruct(BREAK_POINT_INFO_TYPE, AllocationType::kOld));
new_break_point_info->set_source_position(source_position);
new_break_point_info->set_break_points(*undefined_value());
return new_break_point_info;
}
Handle<BreakPoint> Factory::NewBreakPoint(int id, Handle<String> condition) {
Handle<BreakPoint> new_break_point =
Handle<BreakPoint>::cast(NewStruct(TUPLE2_TYPE, AllocationType::kOld));
Handle<BreakPoint> new_break_point = Handle<BreakPoint>::cast(
NewStruct(BREAK_POINT_TYPE, AllocationType::kOld));
new_break_point->set_id(id);
new_break_point->set_condition(*condition);
return new_break_point;
......
......@@ -18,16 +18,14 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(BreakPoint, Tuple2)
OBJECT_CONSTRUCTORS_IMPL(BreakPointInfo, Tuple2)
TQ_OBJECT_CONSTRUCTORS_IMPL(BreakPoint)
TQ_OBJECT_CONSTRUCTORS_IMPL(BreakPointInfo)
OBJECT_CONSTRUCTORS_IMPL(CoverageInfo, FixedArray)
TQ_OBJECT_CONSTRUCTORS_IMPL(DebugInfo)
NEVER_READ_ONLY_SPACE_IMPL(DebugInfo)
CAST_ACCESSOR(BreakPointInfo)
CAST_ACCESSOR(CoverageInfo)
CAST_ACCESSOR(BreakPoint)
TQ_SMI_ACCESSORS(DebugInfo, flags)
TQ_SMI_ACCESSORS(DebugInfo, debugger_hints)
......@@ -41,11 +39,9 @@ BIT_FIELD_ACCESSORS(DebugInfo, debugger_hints, computed_debug_is_blackboxed,
BIT_FIELD_ACCESSORS(DebugInfo, debugger_hints, debugging_id,
DebugInfo::DebuggingIdBits)
SMI_ACCESSORS(BreakPointInfo, source_position, kSourcePositionOffset)
ACCESSORS(BreakPointInfo, break_points, Object, kBreakPointsOffset)
TQ_SMI_ACCESSORS(BreakPointInfo, source_position)
SMI_ACCESSORS(BreakPoint, id, kIdOffset)
ACCESSORS(BreakPoint, condition, String, kConditionOffset)
TQ_SMI_ACCESSORS(BreakPoint, id)
bool DebugInfo::HasInstrumentedBytecodeArray() {
DCHECK_EQ(debug_bytecode_array().IsBytecodeArray(),
......
......@@ -162,12 +162,11 @@ class DebugInfo : public TorqueGeneratedDebugInfo<DebugInfo, Struct> {
// The BreakPointInfo class holds information for break points set in a
// function. The DebugInfo object holds a BreakPointInfo object for each code
// position with one or more break points.
class BreakPointInfo : public Tuple2 {
class BreakPointInfo
: public TorqueGeneratedBreakPointInfo<BreakPointInfo, Struct> {
public:
// The position in the source for the break position.
DECL_INT_ACCESSORS(source_position)
// List of related JavaScript break points.
DECL_ACCESSORS(break_points, Object)
// Removes a break point.
static void ClearBreakPoint(Isolate* isolate, Handle<BreakPointInfo> info,
......@@ -187,12 +186,7 @@ class BreakPointInfo : public Tuple2 {
int GetStatementPosition(Handle<DebugInfo> debug_info);
DECL_CAST(BreakPointInfo)
static const int kSourcePositionOffset = kValue1Offset;
static const int kBreakPointsOffset = kValue2Offset;
OBJECT_CONSTRUCTORS(BreakPointInfo, Tuple2);
TQ_OBJECT_CONSTRUCTORS(BreakPointInfo)
};
// Holds information related to block code coverage.
......@@ -240,17 +234,11 @@ class CoverageInfo : public FixedArray {
};
// Holds breakpoint related information. This object is used by inspector.
class BreakPoint : public Tuple2 {
class BreakPoint : public TorqueGeneratedBreakPoint<BreakPoint, Struct> {
public:
DECL_INT_ACCESSORS(id)
DECL_ACCESSORS(condition, String)
DECL_CAST(BreakPoint)
static const int kIdOffset = kValue1Offset;
static const int kConditionOffset = kValue2Offset;
OBJECT_CONSTRUCTORS(BreakPoint, Tuple2);
TQ_OBJECT_CONSTRUCTORS(BreakPoint)
};
} // namespace internal
......
......@@ -2,12 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@hasSameInstanceTypeAsParent
extern class BreakPoint extends Tuple2 {
@generateCppClass
@generatePrint
extern class BreakPoint extends Struct {
id: Smi;
condition: String;
}
@hasSameInstanceTypeAsParent
extern class BreakPointInfo extends Tuple2 {
@generateCppClass
@generatePrint
extern class BreakPointInfo extends Struct {
// The position in the source for the break position.
source_position: Smi;
// List of related JavaScript break points.
break_points: FixedArray|BreakPoint|Undefined;
}
type CoverageInfo extends FixedArray;
@generateCppClass
......
......@@ -214,9 +214,6 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
TORQUE_INSTANCE_CHECKERS_SINGLE_FULLY_DEFINED(V) \
TORQUE_INSTANCE_CHECKERS_SINGLE_ONLY_DECLARED(V) \
V(BigInt, BIGINT_TYPE) \
V(BreakPoint, TUPLE2_TYPE) \
V(BreakPointInfo, TUPLE2_TYPE) \
V(CachedTemplateObject, TUPLE3_TYPE) \
V(CoverageInfo, FIXED_ARRAY_TYPE) \
V(FixedArrayExact, FIXED_ARRAY_TYPE) \
V(PropertyDescriptorObject, FIXED_ARRAY_TYPE)
......
......@@ -85,11 +85,8 @@ class ZoneForwardList;
V(ObjectBoilerplateDescription) \
V(Boolean) \
V(BooleanWrapper) \
V(BreakPoint) \
V(BreakPointInfo) \
V(ByteArray) \
V(BytecodeArray) \
V(CachedTemplateObject) \
V(CallHandlerInfo) \
V(Callable) \
V(Cell) \
......
......@@ -102,56 +102,59 @@ namespace internal {
// code for the class including allocation and garbage collection routines,
// casts and predicates. All you need to define is the class, methods and
// object verification routines. Easy, no?
#define STRUCT_LIST_GENERATOR_BASE(V, _) \
V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \
promise_fulfill_reaction_job_task) \
V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \
promise_reject_reaction_job_task) \
V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \
V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \
V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \
promise_resolve_thenable_job_task) \
V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \
function_template_info) \
V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \
V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \
V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \
V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \
V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \
aliased_arguments_entry) \
V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \
V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \
array_boilerplate_description) \
V(_, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \
V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \
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_RARE_DATA_TYPE, FunctionTemplateRareData, \
function_template_rare_data) \
V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \
V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \
V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \
V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \
V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \
V(_, SCRIPT_TYPE, Script, script) \
V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \
module_info_entry) \
V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \
V(_, STACK_TRACE_FRAME_TYPE, StackTraceFrame, stack_trace_frame) \
V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \
template_object_description) \
V(_, TUPLE2_TYPE, Tuple2, tuple2) \
V(_, TUPLE3_TYPE, Tuple3, tuple3) \
V(_, WASM_CAPI_FUNCTION_DATA_TYPE, WasmCapiFunctionData, \
wasm_capi_function_data) \
V(_, WASM_DEBUG_INFO_TYPE, WasmDebugInfo, wasm_debug_info) \
V(_, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \
V(_, WASM_EXPORTED_FUNCTION_DATA_TYPE, WasmExportedFunctionData, \
wasm_exported_function_data) \
V(_, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \
wasm_indirect_function_table) \
#define STRUCT_LIST_GENERATOR_BASE(V, _) \
V(_, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE, PromiseFulfillReactionJobTask, \
promise_fulfill_reaction_job_task) \
V(_, PROMISE_REJECT_REACTION_JOB_TASK_TYPE, PromiseRejectReactionJobTask, \
promise_reject_reaction_job_task) \
V(_, CALLABLE_TASK_TYPE, CallableTask, callable_task) \
V(_, CALLBACK_TASK_TYPE, CallbackTask, callback_task) \
V(_, PROMISE_RESOLVE_THENABLE_JOB_TASK_TYPE, PromiseResolveThenableJobTask, \
promise_resolve_thenable_job_task) \
V(_, FUNCTION_TEMPLATE_INFO_TYPE, FunctionTemplateInfo, \
function_template_info) \
V(_, OBJECT_TEMPLATE_INFO_TYPE, ObjectTemplateInfo, object_template_info) \
V(_, ACCESS_CHECK_INFO_TYPE, AccessCheckInfo, access_check_info) \
V(_, ACCESSOR_INFO_TYPE, AccessorInfo, accessor_info) \
V(_, ACCESSOR_PAIR_TYPE, AccessorPair, accessor_pair) \
V(_, ALIASED_ARGUMENTS_ENTRY_TYPE, AliasedArgumentsEntry, \
aliased_arguments_entry) \
V(_, ALLOCATION_MEMENTO_TYPE, AllocationMemento, allocation_memento) \
V(_, ARRAY_BOILERPLATE_DESCRIPTION_TYPE, ArrayBoilerplateDescription, \
array_boilerplate_description) \
V(_, ASM_WASM_DATA_TYPE, AsmWasmData, asm_wasm_data) \
V(_, ASYNC_GENERATOR_REQUEST_TYPE, AsyncGeneratorRequest, \
async_generator_request) \
V(_, BREAK_POINT_TYPE, BreakPoint, break_point) \
V(_, BREAK_POINT_INFO_TYPE, BreakPointInfo, break_point_info) \
V(_, CACHED_TEMPLATE_OBJECT_TYPE, CachedTemplateObject, \
cached_template_object) \
V(_, CLASS_POSITIONS_TYPE, ClassPositions, class_positions) \
V(_, DEBUG_INFO_TYPE, DebugInfo, debug_info) \
V(_, ENUM_CACHE_TYPE, EnumCache, enum_cache) \
V(_, FUNCTION_TEMPLATE_RARE_DATA_TYPE, FunctionTemplateRareData, \
function_template_rare_data) \
V(_, INTERCEPTOR_INFO_TYPE, InterceptorInfo, interceptor_info) \
V(_, INTERPRETER_DATA_TYPE, InterpreterData, interpreter_data) \
V(_, PROMISE_CAPABILITY_TYPE, PromiseCapability, promise_capability) \
V(_, PROMISE_REACTION_TYPE, PromiseReaction, promise_reaction) \
V(_, PROTOTYPE_INFO_TYPE, PrototypeInfo, prototype_info) \
V(_, SCRIPT_TYPE, Script, script) \
V(_, SOURCE_TEXT_MODULE_INFO_ENTRY_TYPE, SourceTextModuleInfoEntry, \
module_info_entry) \
V(_, STACK_FRAME_INFO_TYPE, StackFrameInfo, stack_frame_info) \
V(_, STACK_TRACE_FRAME_TYPE, StackTraceFrame, stack_trace_frame) \
V(_, TEMPLATE_OBJECT_DESCRIPTION_TYPE, TemplateObjectDescription, \
template_object_description) \
V(_, TUPLE2_TYPE, Tuple2, tuple2) \
V(_, WASM_CAPI_FUNCTION_DATA_TYPE, WasmCapiFunctionData, \
wasm_capi_function_data) \
V(_, WASM_DEBUG_INFO_TYPE, WasmDebugInfo, wasm_debug_info) \
V(_, WASM_EXCEPTION_TAG_TYPE, WasmExceptionTag, wasm_exception_tag) \
V(_, WASM_EXPORTED_FUNCTION_DATA_TYPE, WasmExportedFunctionData, \
wasm_exported_function_data) \
V(_, WASM_INDIRECT_FUNCTION_TABLE_TYPE, WasmIndirectFunctionTable, \
wasm_indirect_function_table) \
V(_, WASM_JS_FUNCTION_DATA_TYPE, WasmJSFunctionData, wasm_js_function_data)
#define STRUCT_LIST_GENERATOR(V, _) \
......
......@@ -2142,11 +2142,6 @@ void Tuple2::BriefPrintDetails(std::ostream& os) {
os << " " << Brief(value1()) << ", " << Brief(value2());
}
void Tuple3::BriefPrintDetails(std::ostream& os) {
os << " " << Brief(value1()) << ", " << Brief(value2()) << ", "
<< Brief(value3());
}
void ClassPositions::BriefPrintDetails(std::ostream& os) {
os << " " << start() << ", " << end();
}
......
......@@ -163,6 +163,7 @@
// - DebugInfo
// - BreakPoint
// - BreakPointInfo
// - CachedTemplateObject
// - StackFrameInfo
// - StackTraceFrame
// - CodeCache
......
......@@ -21,7 +21,6 @@ namespace internal {
TQ_OBJECT_CONSTRUCTORS_IMPL(Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple2)
TQ_OBJECT_CONSTRUCTORS_IMPL(Tuple3)
TQ_OBJECT_CONSTRUCTORS_IMPL(AccessorPair)
NEVER_READ_ONLY_SPACE_IMPL(AccessorPair)
......
......@@ -34,13 +34,6 @@ class Tuple2 : public TorqueGeneratedTuple2<Tuple2, Struct> {
TQ_OBJECT_CONSTRUCTORS(Tuple2)
};
class Tuple3 : public TorqueGeneratedTuple3<Tuple3, Struct> {
public:
void BriefPrintDetails(std::ostream& os);
TQ_OBJECT_CONSTRUCTORS(Tuple3)
};
// Support for JavaScript accessors: A pair of a getter and a setter. Each
// accessor can either be
// * a JavaScript function or proxy: a real accessor
......
......@@ -15,14 +15,6 @@ extern class Tuple2 extends Struct {
value2: Object;
}
@generatePrint
@generateCppClass
extern class Tuple3 extends Struct {
value1: Object;
value2: Object;
value3: Object;
}
@generateCppClass
extern class ClassPositions extends Struct {
start: Smi;
......
......@@ -16,13 +16,9 @@ namespace v8 {
namespace internal {
TQ_OBJECT_CONSTRUCTORS_IMPL(TemplateObjectDescription)
OBJECT_CONSTRUCTORS_IMPL(CachedTemplateObject, Tuple3)
TQ_OBJECT_CONSTRUCTORS_IMPL(CachedTemplateObject)
CAST_ACCESSOR(CachedTemplateObject)
SMI_ACCESSORS(CachedTemplateObject, slot_id, kSlotIdOffset)
ACCESSORS(CachedTemplateObject, template_object, JSArray, kTemplateObjectOffset)
ACCESSORS(CachedTemplateObject, next, HeapObject, kNextOffset)
TQ_SMI_ACCESSORS(CachedTemplateObject, slot_id)
} // namespace internal
} // namespace v8
......
......@@ -85,7 +85,7 @@ Handle<CachedTemplateObject> CachedTemplateObject::New(
DCHECK(next->IsCachedTemplateObject() || next->IsTheHole());
Factory* factory = isolate->factory();
Handle<CachedTemplateObject> result = Handle<CachedTemplateObject>::cast(
factory->NewStruct(TUPLE3_TYPE, AllocationType::kOld));
factory->NewStruct(CACHED_TEMPLATE_OBJECT_TYPE, AllocationType::kOld));
result->set_slot_id(slot_id);
result->set_template_object(*template_object);
result->set_next(*next);
......
......@@ -17,23 +17,16 @@ namespace internal {
// CachedTemplateObject is a tuple used to cache a TemplateObject that has been
// created. All the CachedTemplateObject's for a given SharedFunctionInfo form a
// linked list via the next fields.
class CachedTemplateObject final : public Tuple3 {
class CachedTemplateObject final
: public TorqueGeneratedCachedTemplateObject<CachedTemplateObject, Struct> {
public:
DECL_INT_ACCESSORS(slot_id)
DECL_ACCESSORS(template_object, JSArray)
DECL_ACCESSORS(next, HeapObject)
static Handle<CachedTemplateObject> New(Isolate* isolate, int slot_id,
Handle<JSArray> template_object,
Handle<HeapObject> next);
DECL_CAST(CachedTemplateObject)
static constexpr int kSlotIdOffset = kValue1Offset;
static constexpr int kTemplateObjectOffset = kValue2Offset;
static constexpr int kNextOffset = kValue3Offset;
OBJECT_CONSTRUCTORS(CachedTemplateObject, Tuple3);
TQ_OBJECT_CONSTRUCTORS(CachedTemplateObject)
};
// TemplateObjectDescription is a tuple of raw strings and cooked strings for
......
......@@ -2,6 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@generatePrint
@generateCppClass
extern class CachedTemplateObject extends Struct {
slot_id: Smi;
template_object: JSArray;
next: CachedTemplateObject|TheHole;
}
@generatePrint
@generateCppClass
extern class TemplateObjectDescription extends Struct {
......
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