Commit ca525298 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[cleanup] Cleanup BodyDescriptorApply() and friends

In particular
* use variadic templates in BodyDescriptorApply(),
* ensure all the relevant classes have BodyDescriptor definition,
* ensure "objects-body-descriptors[-inl].h" headers are included only
  where necessary.

Bug: v8:12425
Change-Id: I7a95ed94bf62952e3d22d419d4a65ad2fe959d57
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3312273Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78242}
parent 18cb0cb4
......@@ -9,9 +9,7 @@
#include "src/heap/invalidated-slots.h"
#include "src/heap/spaces.h"
#include "src/objects/objects-body-descriptors-inl.h"
#include "src/objects/objects-body-descriptors.h"
#include "src/objects/objects.h"
#include "src/objects/objects-inl.h"
#include "src/utils/allocation.h"
namespace v8 {
......
......@@ -57,7 +57,6 @@
#include "src/objects/microtask-inl.h"
#include "src/objects/module-inl.h"
#include "src/objects/name-inl.h"
#include "src/objects/objects-body-descriptors-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/oddball-inl.h"
#include "src/objects/ordered-hash-table-inl.h"
......@@ -87,6 +86,7 @@
#include "src/objects/templates-inl.h"
#include "src/objects/torque-defined-classes-inl.h"
#include "src/objects/transitions-inl.h"
#include "src/objects/turbofan-types-inl.h"
#ifdef V8_INTL_SUPPORT
#include "src/objects/js-break-iterator-inl.h"
......
......@@ -181,6 +181,8 @@ class AllocationMemento
DECL_PRINTER(AllocationMemento)
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(AllocationMemento)
};
......
......@@ -14,6 +14,8 @@
namespace v8 {
namespace internal {
class StructBodyDescriptor;
#include "torque-generated/src/objects/api-callbacks-tq.inc"
// An accessor must have a getter, but can have no setter.
......@@ -66,6 +68,8 @@ class AccessorInfo : public TorqueGeneratedAccessorInfo<AccessorInfo, Struct> {
DECL_PRINTER(AccessorInfo)
using BodyDescriptor = StructBodyDescriptor;
private:
inline bool HasExpectedReceiverType();
......@@ -80,6 +84,8 @@ class AccessCheckInfo
public:
static AccessCheckInfo Get(Isolate* isolate, Handle<JSObject> receiver);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(AccessCheckInfo)
};
......@@ -94,6 +100,8 @@ class InterceptorInfo
DEFINE_TORQUE_GENERATED_INTERCEPTOR_INFO_FLAGS()
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(InterceptorInfo)
};
......@@ -113,6 +121,8 @@ class CallHandlerInfo
Address redirected_callback() const;
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(CallHandlerInfo)
};
......
......@@ -15,6 +15,8 @@
namespace v8 {
namespace internal {
class StructBodyDescriptor;
#include "torque-generated/src/objects/arguments-tq.inc"
// Superclass for all objects with instance type {JS_ARGUMENTS_OBJECT_TYPE}
......@@ -66,6 +68,8 @@ class AliasedArgumentsEntry
: public TorqueGeneratedAliasedArgumentsEntry<AliasedArgumentsEntry,
Struct> {
public:
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(AliasedArgumentsEntry)
};
......
......@@ -21,6 +21,7 @@ namespace internal {
class BreakPoint;
class BytecodeArray;
class StructBodyDescriptor;
#include "torque-generated/src/objects/debug-objects-tq.inc"
......@@ -132,6 +133,8 @@ class DebugInfo : public TorqueGeneratedDebugInfo<DebugInfo, Struct> {
static const int kEstimatedNofBreakPointsInFunction = 4;
using BodyDescriptor = StructBodyDescriptor;
private:
// Get the break point info object for a source position.
Object GetBreakPointInfo(Isolate* isolate, int source_position);
......@@ -163,6 +166,8 @@ class BreakPointInfo
int GetStatementPosition(Handle<DebugInfo> debug_info);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(BreakPointInfo)
};
......@@ -193,6 +198,8 @@ class CoverageInfo
// Holds breakpoint related information. This object is used by inspector.
class BreakPoint : public TorqueGeneratedBreakPoint<BreakPoint, Struct> {
public:
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(BreakPoint)
};
......
......@@ -24,6 +24,7 @@ template <typename T>
class Handle;
class Isolate;
class StructBodyDescriptor;
#include "torque-generated/src/objects/descriptor-array-tq.inc"
......@@ -32,6 +33,8 @@ class EnumCache : public TorqueGeneratedEnumCache<EnumCache, Struct> {
public:
DECL_VERIFIER(EnumCache)
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(EnumCache)
};
......
......@@ -37,6 +37,8 @@ class FreeSpace : public TorqueGeneratedFreeSpace<FreeSpace, HeapObject> {
// Dispatched behavior.
DECL_PRINTER(FreeSpace)
class BodyDescriptor;
private:
inline bool IsValid();
......
......@@ -59,6 +59,8 @@ class HeapNumber
DECL_PRINTER(HeapNumber)
V8_EXPORT_PRIVATE void HeapNumberShortPrint(std::ostream& os);
class BodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(HeapNumber)
};
......
......@@ -16,6 +16,7 @@ namespace internal {
// Forward declarations.
class JSPromise;
class StructBodyDescriptor;
#include "torque-generated/src/objects/js-generator-tq.inc"
......@@ -71,6 +72,8 @@ class AsyncGeneratorRequest
DECL_PRINTER(AsyncGeneratorRequest)
DECL_VERIFIER(AsyncGeneratorRequest)
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(AsyncGeneratorRequest)
};
......
......@@ -16,6 +16,7 @@ namespace v8 {
namespace internal {
class ClassLiteral;
class StructBodyDescriptor;
#include "torque-generated/src/objects/literal-objects-tq.inc"
......@@ -71,6 +72,8 @@ class ArrayBoilerplateDescription
DECL_PRINTER(ArrayBoilerplateDescription)
void BriefPrintDetails(std::ostream& os);
using BodyDescriptor = StructBodyDescriptor;
private:
TQ_OBJECT_CONSTRUCTORS(ArrayBoilerplateDescription)
};
......@@ -82,6 +85,8 @@ class RegExpBoilerplateDescription
// Dispatched behavior.
void BriefPrintDetails(std::ostream& os);
using BodyDescriptor = StructBodyDescriptor;
private:
TQ_OBJECT_CONSTRUCTORS(RegExpBoilerplateDescription)
};
......
......@@ -14,6 +14,8 @@
namespace v8 {
namespace internal {
class StructBodyDescriptor;
#include "torque-generated/src/objects/microtask-tq.inc"
// Abstract base class for all microtasks that can be scheduled on the
......@@ -30,6 +32,8 @@ class Microtask : public TorqueGeneratedMicrotask<Microtask, Struct> {
class CallbackTask
: public TorqueGeneratedCallbackTask<CallbackTask, Microtask> {
public:
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(CallbackTask)
};
......@@ -43,6 +47,8 @@ class CallableTask
DECL_VERIFIER(CallableTask)
void BriefPrintDetails(std::ostream& os);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(CallableTask)
};
......
......@@ -181,6 +181,9 @@ class ScriptOrModule
: public TorqueGeneratedScriptOrModule<ScriptOrModule, Struct> {
public:
DECL_PRINTER(ScriptOrModule)
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(ScriptOrModule)
};
......
This diff is collapsed.
......@@ -152,7 +152,11 @@ class FlexibleBodyDescriptor : public SuffixRangeBodyDescriptor<start_offset> {
static inline int SizeOf(Map map, HeapObject object);
};
using StructBodyDescriptor = FlexibleBodyDescriptor<HeapObject::kHeaderSize>;
// A forward-declacable descriptor body alias for most of the Struct successors.
class StructBodyDescriptor
: public FlexibleBodyDescriptor<HeapObject::kHeaderSize> {
public:
};
// This class describes a body of an object in which all pointer fields are
// located in the [start_offset, object_size) interval.
......
......@@ -2172,15 +2172,15 @@ void HeapObject::IterateBody(Map map, int object_size, ObjectVisitor* v) {
struct CallIsValidSlot {
template <typename BodyDescriptor>
static bool apply(Map map, HeapObject obj, int offset, int) {
static bool apply(Map map, HeapObject obj, int offset) {
return BodyDescriptor::IsValidSlot(map, obj, offset);
}
};
bool HeapObject::IsValidSlot(Map map, int offset) {
DCHECK_NE(0, offset);
return BodyDescriptorApply<CallIsValidSlot, bool>(map.instance_type(), map,
*this, offset, 0);
return BodyDescriptorApply<CallIsValidSlot>(map.instance_type(), map, *this,
offset);
}
int HeapObject::SizeFromMap(Map map) const {
......
......@@ -14,6 +14,7 @@ namespace v8 {
namespace internal {
class JSPromise;
class StructBodyDescriptor;
#include "torque-generated/src/objects/promise-tq.inc"
......@@ -31,6 +32,9 @@ class PromiseReactionJobTask
Microtask> {
public:
static const int kSizeOfAllPromiseReactionJobTasks = kHeaderSize;
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PromiseReactionJobTask)
};
......@@ -41,6 +45,8 @@ class PromiseFulfillReactionJobTask
public:
STATIC_ASSERT(kSize == kSizeOfAllPromiseReactionJobTasks);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PromiseFulfillReactionJobTask)
};
......@@ -51,6 +57,8 @@ class PromiseRejectReactionJobTask
public:
STATIC_ASSERT(kSize == kSizeOfAllPromiseReactionJobTasks);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PromiseRejectReactionJobTask)
};
......@@ -59,6 +67,8 @@ class PromiseResolveThenableJobTask
: public TorqueGeneratedPromiseResolveThenableJobTask<
PromiseResolveThenableJobTask, Microtask> {
public:
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PromiseResolveThenableJobTask)
};
......@@ -66,6 +76,8 @@ class PromiseResolveThenableJobTask
class PromiseCapability
: public TorqueGeneratedPromiseCapability<PromiseCapability, Struct> {
public:
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PromiseCapability)
};
......@@ -91,6 +103,8 @@ class PromiseReaction
public:
enum Type { kFulfill, kReject };
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PromiseReaction)
};
......
......@@ -35,6 +35,8 @@ class PropertyDescriptorObject
HasWritableBit::kMask | HasValueBit::kMask |
HasGetBit::kMask | HasSetBit::kMask;
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(PropertyDescriptorObject)
};
......
......@@ -22,6 +22,7 @@ namespace v8 {
namespace internal {
class FunctionLiteral;
class StructBodyDescriptor;
namespace wasm {
class NativeModule;
......@@ -230,6 +231,8 @@ class Script : public TorqueGeneratedScript<Script, Struct> {
DECL_PRINTER(Script)
DECL_VERIFIER(Script)
using BodyDescriptor = StructBodyDescriptor;
private:
// Bit positions in the flags field.
DEFINE_TORQUE_GENERATED_SCRIPT_FLAGS()
......
......@@ -148,6 +148,8 @@ class UncompiledDataWithPreparseData
class InterpreterData
: public TorqueGeneratedInterpreterData<InterpreterData, Struct> {
public:
using BodyDescriptor = StructBodyDescriptor;
private:
TQ_OBJECT_CONSTRUCTORS(InterpreterData)
};
......
......@@ -17,6 +17,7 @@ namespace v8 {
namespace internal {
class UnorderedModuleSet;
class StructBodyDescriptor;
#include "torque-generated/src/objects/source-text-module-tq.inc"
......@@ -276,6 +277,8 @@ class ModuleRequest
// a single assertion.
static const size_t kAssertionEntrySize = 3;
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(ModuleRequest)
};
......@@ -292,6 +295,8 @@ class SourceTextModuleInfoEntry
Handle<PrimitiveHeapObject> import_name, int module_request,
int cell_index, int beg_pos, int end_pos);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(SourceTextModuleInfoEntry)
};
......
......@@ -16,6 +16,7 @@ namespace internal {
class MessageLocation;
class WasmInstanceObject;
class StructBodyDescriptor;
#include "torque-generated/src/objects/stack-frame-info-tq.inc"
......@@ -86,6 +87,8 @@ class StackFrameInfo
static bool ComputeLocation(Handle<StackFrameInfo> info,
MessageLocation* location);
using BodyDescriptor = StructBodyDescriptor;
private:
// Bit position in the flag, from least significant bit position.
DEFINE_TORQUE_GENERATED_STACK_FRAME_INFO_FLAGS()
......
......@@ -14,6 +14,8 @@
namespace v8 {
namespace internal {
class StructBodyDescriptor;
#include "torque-generated/src/objects/struct-tq.inc"
// An abstract superclass, a marker class really, for simple structure classes.
......@@ -31,6 +33,8 @@ class Tuple2 : public TorqueGeneratedTuple2<Tuple2, Struct> {
public:
void BriefPrintDetails(std::ostream& os);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(Tuple2)
};
......@@ -69,6 +73,8 @@ class AccessorPair : public TorqueGeneratedAccessorPair<AccessorPair, Struct> {
inline bool Equals(Object getter_value, Object setter_value);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(AccessorPair)
};
......@@ -78,6 +84,8 @@ class ClassPositions
// Dispatched behavior.
void BriefPrintDetails(std::ostream& os);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(ClassPositions)
};
......
......@@ -15,6 +15,8 @@
namespace v8 {
namespace internal {
class StructBodyDescriptor;
#include "torque-generated/src/objects/template-objects-tq.inc"
// CachedTemplateObject is a tuple used to cache a TemplateObject that has been
......@@ -27,6 +29,8 @@ class CachedTemplateObject final
Handle<JSArray> template_object,
Handle<HeapObject> next);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(CachedTemplateObject)
};
......@@ -42,6 +46,8 @@ class TemplateObjectDescription final
Handle<TemplateObjectDescription> description,
Handle<SharedFunctionInfo> shared_info, int slot_id);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(TemplateObjectDescription)
};
......
......@@ -14,6 +14,7 @@
namespace v8 {
class CFunctionInfo;
class StructBodyDescriptor;
namespace internal {
......@@ -40,6 +41,8 @@ class TemplateInfo : public TorqueGeneratedTemplateInfo<TemplateInfo, Struct> {
inline bool should_cache() const;
inline bool is_cached() const;
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(TemplateInfo)
};
......@@ -49,6 +52,9 @@ class FunctionTemplateRareData
Struct> {
public:
DECL_VERIFIER(FunctionTemplateRareData)
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(FunctionTemplateRareData)
};
......@@ -176,6 +182,8 @@ class FunctionTemplateInfo
// Bit position in the flag, from least significant bit position.
DEFINE_TORQUE_GENERATED_FUNCTION_TEMPLATE_INFO_FLAGS()
using BodyDescriptor = StructBodyDescriptor;
private:
static constexpr int kNoJSApiObjectType = 0;
static inline FunctionTemplateRareData EnsureFunctionTemplateRareData(
......@@ -202,6 +210,8 @@ class ObjectTemplateInfo
// chain till a function template that has an instance template is found.
inline ObjectTemplateInfo GetParent(Isolate* isolate);
using BodyDescriptor = StructBodyDescriptor;
private:
DEFINE_TORQUE_GENERATED_OBJECT_TEMPLATE_INFO_FLAGS()
......
......@@ -29,7 +29,6 @@
#include "src/objects/js-regexp-inl.h"
#include "src/objects/js-weak-refs-inl.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/objects-body-descriptors.h"
#include "src/objects/objects-inl.h"
#include "src/objects/prototype.h"
#include "src/objects/slots-inl.h"
......
......@@ -42,6 +42,7 @@ class WireBytesRef;
class BreakPoint;
class JSArrayBuffer;
class SeqOneByteString;
class StructBodyDescriptor;
class WasmCapiFunction;
class WasmExceptionTag;
class WasmExportedFunction;
......@@ -858,6 +859,8 @@ class WasmExceptionTag
V8_EXPORT_PRIVATE static Handle<WasmExceptionTag> New(Isolate* isolate,
int index);
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(WasmExceptionTag)
};
......@@ -871,6 +874,8 @@ class AsmWasmData : public TorqueGeneratedAsmWasmData<AsmWasmData, Struct> {
DECL_PRINTER(AsmWasmData)
using BodyDescriptor = StructBodyDescriptor;
TQ_OBJECT_CONSTRUCTORS(AsmWasmData)
};
......@@ -994,12 +999,15 @@ class WasmContinuationObject
WasmContinuationObject parent);
DECL_PRINTER(WasmContinuationObject)
TQ_OBJECT_CONSTRUCTORS(WasmContinuationObject)
using BodyDescriptor = StructBodyDescriptor;
private:
static Handle<WasmContinuationObject> New(
Isolate* isolate, std::unique_ptr<wasm::StackMemory> stack,
HeapObject parent);
TQ_OBJECT_CONSTRUCTORS(WasmContinuationObject)
};
// The suspender object provides an API to suspend and resume wasm code using
......
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