Commit cc4b7a9b authored by Seth Brenith's avatar Seth Brenith Committed by V8 LUCI CQ

[cleanup] Use @generateCppClass on wasm classes

Most Torque-defined extern classes already use @generateCppClass. As
Nico pointed out in [1], it would be nice to convert the remaining
classes and remove this option. This change converts about a third of
those remaining classes. I know that the future of Torque-defined
classes is a subject of some debate right now, but I think that it's
worth doing a few mechanical changes to reduce the existing variety of
options.

[1] https://docs.google.com/document/d/1q_gZLnXd4bGnCx3IUfbln46K3bSs9UHBGasy9McQtHI/edit#

Bug: v8:8952
Change-Id: Ic96f9b16397149099f87380f68e01b1f2a6d5b90
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3018056Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#75685}
parent fb28cfe6
......@@ -1633,7 +1633,6 @@ void ObjectBoilerplateDescription::ObjectBoilerplateDescriptionVerify(
}
#if V8_ENABLE_WEBASSEMBLY
USE_TORQUE_VERIFIER(AsmWasmData)
void WasmInstanceObject::WasmInstanceObjectVerify(Isolate* isolate) {
JSObjectVerify(isolate);
......@@ -1653,8 +1652,6 @@ void WasmValueObject::WasmValueObjectVerify(Isolate* isolate) {
CHECK(IsWasmValueObject());
}
USE_TORQUE_VERIFIER(WasmObject)
void WasmExportedFunctionData::WasmExportedFunctionDataVerify(
Isolate* isolate) {
TorqueGeneratedClassVerifiers::WasmExportedFunctionDataVerify(*this, isolate);
......@@ -1664,20 +1661,6 @@ void WasmExportedFunctionData::WasmExportedFunctionDataVerify(
wrapper_code().builtin_id() == Builtin::kGenericJSToWasmWrapper));
}
USE_TORQUE_VERIFIER(WasmModuleObject)
USE_TORQUE_VERIFIER(WasmTableObject)
USE_TORQUE_VERIFIER(WasmMemoryObject)
USE_TORQUE_VERIFIER(WasmGlobalObject)
USE_TORQUE_VERIFIER(WasmExceptionObject)
USE_TORQUE_VERIFIER(WasmCapiFunctionData)
USE_TORQUE_VERIFIER(WasmJSFunctionData)
USE_TORQUE_VERIFIER(WasmIndirectFunctionTable)
#endif // V8_ENABLE_WEBASSEMBLY
void DataHandler::DataHandlerVerify(Isolate* isolate) {
......
......@@ -35,36 +35,23 @@ namespace internal {
#include "torque-generated/src/wasm/wasm-objects-tq-inl.inc"
OBJECT_CONSTRUCTORS_IMPL(WasmExceptionObject, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExceptionObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExceptionTag)
OBJECT_CONSTRUCTORS_IMPL(WasmCapiFunctionData, WasmFunctionData)
OBJECT_CONSTRUCTORS_IMPL(WasmExportedFunctionData, WasmFunctionData)
OBJECT_CONSTRUCTORS_IMPL(WasmGlobalObject, JSObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmCapiFunctionData)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmExportedFunctionData)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmGlobalObject)
OBJECT_CONSTRUCTORS_IMPL(WasmInstanceObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(WasmObject, JSReceiver)
OBJECT_CONSTRUCTORS_IMPL(WasmMemoryObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(WasmModuleObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(WasmTableObject, JSObject)
OBJECT_CONSTRUCTORS_IMPL(AsmWasmData, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmMemoryObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmModuleObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmTableObject)
TQ_OBJECT_CONSTRUCTORS_IMPL(AsmWasmData)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmFunctionData)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmTypeInfo)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmStruct)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmArray)
CAST_ACCESSOR(WasmCapiFunctionData)
CAST_ACCESSOR(WasmExceptionObject)
CAST_ACCESSOR(WasmExportedFunctionData)
CAST_ACCESSOR(WasmGlobalObject)
CAST_ACCESSOR(WasmInstanceObject)
CAST_ACCESSOR(WasmObject)
CAST_ACCESSOR(WasmMemoryObject)
CAST_ACCESSOR(WasmModuleObject)
CAST_ACCESSOR(WasmTableObject)
CAST_ACCESSOR(AsmWasmData)
CAST_ACCESSOR(WasmFunctionData)
CAST_ACCESSOR(WasmTypeInfo)
CAST_ACCESSOR(WasmStruct)
CAST_ACCESSOR(WasmArray)
#define OPTIONAL_ACCESSORS(holder, name, type, offset) \
DEF_GETTER(holder, has_##name, bool) { \
......@@ -101,10 +88,6 @@ CAST_ACCESSOR(WasmArray)
}
// WasmModuleObject
ACCESSORS(WasmModuleObject, managed_native_module, Managed<wasm::NativeModule>,
kNativeModuleOffset)
ACCESSORS(WasmModuleObject, export_wrappers, FixedArray, kExportWrappersOffset)
ACCESSORS(WasmModuleObject, script, Script, kScriptOffset)
wasm::NativeModule* WasmModuleObject::native_module() const {
return managed_native_module().raw();
}
......@@ -122,28 +105,13 @@ bool WasmModuleObject::is_asm_js() {
return asm_js;
}
// WasmTableObject
ACCESSORS(WasmTableObject, instance, HeapObject, kInstanceOffset)
ACCESSORS(WasmTableObject, entries, FixedArray, kEntriesOffset)
SMI_ACCESSORS(WasmTableObject, current_length, kCurrentLengthOffset)
ACCESSORS(WasmTableObject, maximum_length, Object, kMaximumLengthOffset)
ACCESSORS(WasmTableObject, dispatch_tables, FixedArray, kDispatchTablesOffset)
SMI_ACCESSORS(WasmTableObject, raw_type, kRawTypeOffset)
// WasmMemoryObject
ACCESSORS(WasmMemoryObject, array_buffer, JSArrayBuffer, kArrayBufferOffset)
SMI_ACCESSORS(WasmMemoryObject, maximum_pages, kMaximumPagesOffset)
OPTIONAL_ACCESSORS(WasmMemoryObject, instances, WeakArrayList, kInstancesOffset)
// WasmGlobalObject
ACCESSORS(WasmGlobalObject, instance, HeapObject, kInstanceOffset)
ACCESSORS(WasmGlobalObject, untagged_buffer, JSArrayBuffer,
kUntaggedBufferOffset)
ACCESSORS(WasmGlobalObject, tagged_buffer, FixedArray, kTaggedBufferOffset)
SMI_ACCESSORS(WasmGlobalObject, offset, kOffsetOffset)
// TODO(7748): Try to come up with some encoding that includes is_mutable?
SMI_ACCESSORS(WasmGlobalObject, raw_type, kRawTypeOffset)
SMI_ACCESSORS(WasmGlobalObject, is_mutable, kIsMutableOffset)
wasm::ValueType WasmGlobalObject::type() const {
return wasm::ValueType::FromRawBitField(static_cast<uint32_t>(raw_type()));
......@@ -321,16 +289,6 @@ ImportedFunctionEntry::ImportedFunctionEntry(
DCHECK_LT(index, instance->module()->num_imported_functions);
}
// WasmCapiFunctionData
ACCESSORS(WasmCapiFunctionData, embedder_data, Foreign, kEmbedderDataOffset)
ACCESSORS(WasmCapiFunctionData, serialized_signature, PodArray<wasm::ValueType>,
kSerializedSignatureOffset)
// WasmExceptionObject
ACCESSORS(WasmExceptionObject, serialized_signature, PodArray<wasm::ValueType>,
kSerializedSignatureOffset)
ACCESSORS(WasmExceptionObject, exception_tag, HeapObject, kExceptionTagOffset)
// WasmExceptionPackage
OBJECT_CONSTRUCTORS_IMPL(WasmExceptionPackage, JSReceiver)
CAST_ACCESSOR(WasmExceptionPackage)
......@@ -351,15 +309,6 @@ void WasmFunctionData::set_wrapper_code(Code code, WriteBarrierMode mode) {
TorqueGeneratedClass::set_wrapper_code(ToCodeT(code), mode);
}
// WasmExportedFunctionData
ACCESSORS(WasmExportedFunctionData, instance, WasmInstanceObject,
kInstanceOffset)
SMI_ACCESSORS(WasmExportedFunctionData, function_index, kFunctionIndexOffset)
ACCESSORS(WasmExportedFunctionData, signature, Foreign, kSignatureOffset)
SMI_ACCESSORS(WasmExportedFunctionData, wrapper_budget, kWrapperBudgetOffset)
ACCESSORS(WasmExportedFunctionData, c_wrapper_code, CodeT, kCWrapperCodeOffset)
SMI_ACCESSORS(WasmExportedFunctionData, packed_args_size, kPackedArgsSizeOffset)
wasm::FunctionSig* WasmExportedFunctionData::sig() const {
return reinterpret_cast<wasm::FunctionSig*>(signature().foreign_address());
}
......@@ -371,14 +320,7 @@ WasmJSFunction::WasmJSFunction(Address ptr) : JSFunction(ptr) {
CAST_ACCESSOR(WasmJSFunction)
// WasmJSFunctionData
OBJECT_CONSTRUCTORS_IMPL(WasmJSFunctionData, WasmFunctionData)
CAST_ACCESSOR(WasmJSFunctionData)
SMI_ACCESSORS(WasmJSFunctionData, serialized_return_count,
kSerializedReturnCountOffset)
SMI_ACCESSORS(WasmJSFunctionData, serialized_parameter_count,
kSerializedParameterCountOffset)
ACCESSORS(WasmJSFunctionData, serialized_signature, PodArray<wasm::ValueType>,
kSerializedSignatureOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmJSFunctionData)
ACCESSORS(WasmJSFunctionData, raw_wasm_to_js_wrapper_code, CodeT,
kWasmToJsWrapperCodeOffset)
......@@ -403,16 +345,13 @@ WasmExternalFunction::WasmExternalFunction(Address ptr) : JSFunction(ptr) {
CAST_ACCESSOR(WasmExternalFunction)
// WasmIndirectFunctionTable
OBJECT_CONSTRUCTORS_IMPL(WasmIndirectFunctionTable, Struct)
CAST_ACCESSOR(WasmIndirectFunctionTable)
PRIMITIVE_ACCESSORS(WasmIndirectFunctionTable, size, uint32_t, kSizeOffset)
TQ_OBJECT_CONSTRUCTORS_IMPL(WasmIndirectFunctionTable)
PRIMITIVE_ACCESSORS(WasmIndirectFunctionTable, sig_ids, uint32_t*,
kSigIdsOffset)
PRIMITIVE_ACCESSORS(WasmIndirectFunctionTable, targets, Address*,
kTargetsOffset)
OPTIONAL_ACCESSORS(WasmIndirectFunctionTable, managed_native_allocations,
Foreign, kManagedNativeAllocationsOffset)
ACCESSORS(WasmIndirectFunctionTable, refs, FixedArray, kRefsOffset)
#undef OPTIONAL_ACCESSORS
#undef READ_PRIMITIVE_FIELD
......@@ -425,12 +364,6 @@ wasm::ValueType WasmTableObject::type() {
bool WasmMemoryObject::has_maximum_pages() { return maximum_pages() >= 0; }
// AsmWasmData
ACCESSORS(AsmWasmData, managed_native_module, Managed<wasm::NativeModule>,
kManagedNativeModuleOffset)
ACCESSORS(AsmWasmData, export_wrappers, FixedArray, kExportWrappersOffset)
ACCESSORS(AsmWasmData, uses_bitset, HeapNumber, kUsesBitsetOffset)
// static
Handle<Object> WasmObject::ReadValueAt(Isolate* isolate, Handle<HeapObject> obj,
wasm::ValueType type, uint32_t offset) {
......
......@@ -125,13 +125,9 @@ class ImportedFunctionEntry {
enum InternalizeString : bool { kInternalize = true, kNoInternalize = false };
// Representation of a WebAssembly.Module JavaScript-level object.
class WasmModuleObject : public JSObject {
class WasmModuleObject
: public TorqueGeneratedWasmModuleObject<WasmModuleObject, JSObject> {
public:
DECL_CAST(WasmModuleObject)
DECL_ACCESSORS(managed_native_module, Managed<wasm::NativeModule>)
DECL_ACCESSORS(export_wrappers, FixedArray)
DECL_ACCESSORS(script, Script)
inline wasm::NativeModule* native_module() const;
inline const std::shared_ptr<wasm::NativeModule>& shared_native_module()
const;
......@@ -139,10 +135,6 @@ class WasmModuleObject : public JSObject {
// Dispatched behavior.
DECL_PRINTER(WasmModuleObject)
DECL_VERIFIER(WasmModuleObject)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_WASM_MODULE_OBJECT_FIELDS)
// Creates a new {WasmModuleObject} for an existing {NativeModule} that is
// reference counted and might be shared between multiple Isolates.
......@@ -183,49 +175,30 @@ class WasmModuleObject : public JSObject {
Isolate*, base::Vector<const uint8_t> wire_byte, wasm::WireBytesRef,
InternalizeString);
OBJECT_CONSTRUCTORS(WasmModuleObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(WasmModuleObject)
};
// Representation of a WebAssembly.Table JavaScript-level object.
class V8_EXPORT_PRIVATE WasmTableObject : public JSObject {
class WasmTableObject
: public TorqueGeneratedWasmTableObject<WasmTableObject, JSObject> {
public:
DECL_CAST(WasmTableObject)
// The instance in which this WasmTableObject is defined.
// This field is undefined if the global is defined outside any Wasm module,
// i.e., through the JS API (WebAssembly.Table).
// Because it might be undefined, we declare it as a HeapObject.
DECL_ACCESSORS(instance, HeapObject)
// The entries array is at least as big as {current_length()}, but might be
// bigger to make future growth more efficient.
DECL_ACCESSORS(entries, FixedArray)
DECL_INT_ACCESSORS(current_length)
// TODO(titzer): introduce DECL_I64_ACCESSORS macro
DECL_ACCESSORS(maximum_length, Object)
DECL_ACCESSORS(dispatch_tables, FixedArray)
DECL_INT_ACCESSORS(raw_type)
// Dispatched behavior.
DECL_PRINTER(WasmTableObject)
DECL_VERIFIER(WasmTableObject)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_WASM_TABLE_OBJECT_FIELDS)
inline wasm::ValueType type();
static int Grow(Isolate* isolate, Handle<WasmTableObject> table,
uint32_t count, Handle<Object> init_value);
V8_EXPORT_PRIVATE static int Grow(Isolate* isolate,
Handle<WasmTableObject> table,
uint32_t count, Handle<Object> init_value);
static Handle<WasmTableObject> New(Isolate* isolate,
Handle<WasmInstanceObject> instance,
wasm::ValueType type, uint32_t initial,
bool has_maximum, uint32_t maximum,
Handle<FixedArray>* entries);
V8_EXPORT_PRIVATE static Handle<WasmTableObject> New(
Isolate* isolate, Handle<WasmInstanceObject> instance,
wasm::ValueType type, uint32_t initial, bool has_maximum,
uint32_t maximum, Handle<FixedArray>* entries);
static void AddDispatchTable(Isolate* isolate, Handle<WasmTableObject> table,
Handle<WasmInstanceObject> instance,
int table_index);
V8_EXPORT_PRIVATE static void AddDispatchTable(
Isolate* isolate, Handle<WasmTableObject> table,
Handle<WasmInstanceObject> instance, int table_index);
static bool IsInBounds(Isolate* isolate, Handle<WasmTableObject> table,
uint32_t entry_index);
......@@ -233,14 +206,18 @@ class V8_EXPORT_PRIVATE WasmTableObject : public JSObject {
static bool IsValidElement(Isolate* isolate, Handle<WasmTableObject> table,
Handle<Object> entry);
static void Set(Isolate* isolate, Handle<WasmTableObject> table,
uint32_t index, Handle<Object> entry);
V8_EXPORT_PRIVATE static void Set(Isolate* isolate,
Handle<WasmTableObject> table,
uint32_t index, Handle<Object> entry);
static Handle<Object> Get(Isolate* isolate, Handle<WasmTableObject> table,
uint32_t index);
V8_EXPORT_PRIVATE static Handle<Object> Get(Isolate* isolate,
Handle<WasmTableObject> table,
uint32_t index);
static void Fill(Isolate* isolate, Handle<WasmTableObject> table,
uint32_t start, Handle<Object> entry, uint32_t count);
V8_EXPORT_PRIVATE static void Fill(Isolate* isolate,
Handle<WasmTableObject> table,
uint32_t start, Handle<Object> entry,
uint32_t count);
// TODO(wasm): Unify these three methods into one.
static void UpdateDispatchTables(Isolate* isolate,
......@@ -261,11 +238,9 @@ class V8_EXPORT_PRIVATE WasmTableObject : public JSObject {
static void ClearDispatchTables(Isolate* isolate,
Handle<WasmTableObject> table, int index);
static void SetFunctionTablePlaceholder(Isolate* isolate,
Handle<WasmTableObject> table,
int entry_index,
Handle<WasmInstanceObject> instance,
int func_index);
V8_EXPORT_PRIVATE static void SetFunctionTablePlaceholder(
Isolate* isolate, Handle<WasmTableObject> table, int entry_index,
Handle<WasmInstanceObject> instance, int func_index);
// This function reads the content of a function table entry and returns it
// through the out parameters {is_valid}, {is_null}, {instance},
......@@ -282,24 +257,17 @@ class V8_EXPORT_PRIVATE WasmTableObject : public JSObject {
Handle<FixedArray> entries, int entry_index,
Handle<Object> entry);
OBJECT_CONSTRUCTORS(WasmTableObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(WasmTableObject)
};
// Representation of a WebAssembly.Memory JavaScript-level object.
class WasmMemoryObject : public JSObject {
class WasmMemoryObject
: public TorqueGeneratedWasmMemoryObject<WasmMemoryObject, JSObject> {
public:
DECL_CAST(WasmMemoryObject)
DECL_ACCESSORS(array_buffer, JSArrayBuffer)
DECL_INT_ACCESSORS(maximum_pages)
DECL_OPTIONAL_ACCESSORS(instances, WeakArrayList)
// Dispatched behavior.
DECL_PRINTER(WasmMemoryObject)
DECL_VERIFIER(WasmMemoryObject)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_WASM_MEMORY_OBJECT_FIELDS)
// Add an instance to the internal (weak) list.
V8_EXPORT_PRIVATE static void AddInstance(Isolate* isolate,
......@@ -322,34 +290,19 @@ class WasmMemoryObject : public JSObject {
V8_EXPORT_PRIVATE static int32_t Grow(Isolate*, Handle<WasmMemoryObject>,
uint32_t pages);
OBJECT_CONSTRUCTORS(WasmMemoryObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(WasmMemoryObject)
};
// Representation of a WebAssembly.Global JavaScript-level object.
class WasmGlobalObject : public JSObject {
class WasmGlobalObject
: public TorqueGeneratedWasmGlobalObject<WasmGlobalObject, JSObject> {
public:
DECL_CAST(WasmGlobalObject)
// The instance in which this WasmGlobalObject is defined.
// This field is undefined if the global is defined outside any Wasm module,
// i.e., through the JS API (WebAssembly.Global).
// Because it might be undefined, we declare it as a HeapObject.
DECL_ACCESSORS(instance, HeapObject)
DECL_ACCESSORS(untagged_buffer, JSArrayBuffer)
DECL_ACCESSORS(tagged_buffer, FixedArray)
DECL_INT32_ACCESSORS(offset)
DECL_INT_ACCESSORS(raw_type)
DECL_PRIMITIVE_ACCESSORS(type, wasm::ValueType)
// TODO(7748): If we encode mutability in raw_type, turn this into a boolean
// accessor.
DECL_INT_ACCESSORS(is_mutable)
// Dispatched behavior.
DECL_PRINTER(WasmGlobalObject)
DECL_VERIFIER(WasmGlobalObject)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_WASM_GLOBAL_OBJECT_FIELDS)
V8_EXPORT_PRIVATE static MaybeHandle<WasmGlobalObject> New(
Isolate* isolate, Handle<WasmInstanceObject> instance,
......@@ -378,7 +331,7 @@ class WasmGlobalObject : public JSObject {
// not have a fixed address.
inline Address address() const;
OBJECT_CONSTRUCTORS(WasmGlobalObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(WasmGlobalObject)
};
// Representation of a WebAssembly.Instance JavaScript-level object.
......@@ -588,19 +541,11 @@ class V8_EXPORT_PRIVATE WasmInstanceObject : public JSObject {
};
// Representation of WebAssembly.Exception JavaScript-level object.
class WasmExceptionObject : public JSObject {
class WasmExceptionObject
: public TorqueGeneratedWasmExceptionObject<WasmExceptionObject, JSObject> {
public:
DECL_CAST(WasmExceptionObject)
DECL_ACCESSORS(serialized_signature, PodArray<wasm::ValueType>)
DECL_ACCESSORS(exception_tag, HeapObject)
// Dispatched behavior.
DECL_PRINTER(WasmExceptionObject)
DECL_VERIFIER(WasmExceptionObject)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize,
TORQUE_GENERATED_WASM_EXCEPTION_OBJECT_FIELDS)
// Checks whether the given {sig} has the same parameter types as the
// serialized signature stored within this exception object.
......@@ -610,7 +555,7 @@ class WasmExceptionObject : public JSObject {
const wasm::FunctionSig* sig,
Handle<HeapObject> exception_tag);
OBJECT_CONSTRUCTORS(WasmExceptionObject, JSObject);
TQ_OBJECT_CONSTRUCTORS(WasmExceptionObject)
};
// A Wasm exception that has been thrown out of Wasm code.
......@@ -713,32 +658,25 @@ class WasmExternalFunction : public JSFunction {
OBJECT_CONSTRUCTORS(WasmExternalFunction, JSFunction);
};
class WasmIndirectFunctionTable : public Struct {
class WasmIndirectFunctionTable
: public TorqueGeneratedWasmIndirectFunctionTable<WasmIndirectFunctionTable,
Struct> {
public:
DECL_PRIMITIVE_ACCESSORS(size, uint32_t)
DECL_PRIMITIVE_ACCESSORS(sig_ids, uint32_t*)
DECL_PRIMITIVE_ACCESSORS(targets, Address*)
DECL_OPTIONAL_ACCESSORS(managed_native_allocations, Foreign)
DECL_ACCESSORS(refs, FixedArray)
V8_EXPORT_PRIVATE static Handle<WasmIndirectFunctionTable> New(
Isolate* isolate, uint32_t size);
static void Resize(Isolate* isolate, Handle<WasmIndirectFunctionTable> table,
uint32_t new_size);
DECL_CAST(WasmIndirectFunctionTable)
DECL_PRINTER(WasmIndirectFunctionTable)
DECL_VERIFIER(WasmIndirectFunctionTable)
DEFINE_FIELD_OFFSET_CONSTANTS(
HeapObject::kHeaderSize,
TORQUE_GENERATED_WASM_INDIRECT_FUNCTION_TABLE_FIELDS)
STATIC_ASSERT(kStartOfStrongFieldsOffset == kManagedNativeAllocationsOffset);
using BodyDescriptor = FlexibleBodyDescriptor<kStartOfStrongFieldsOffset>;
OBJECT_CONSTRUCTORS(WasmIndirectFunctionTable, Struct);
TQ_OBJECT_CONSTRUCTORS(WasmIndirectFunctionTable)
};
class WasmFunctionData
......@@ -747,7 +685,6 @@ class WasmFunctionData
DECL_ACCESSORS(ref, Object)
DECL_ACCESSORS(wrapper_code, Code)
DECL_CAST(WasmFunctionData)
DECL_PRINTER(WasmFunctionData)
TQ_OBJECT_CONSTRUCTORS(WasmFunctionData)
......@@ -756,80 +693,50 @@ class WasmFunctionData
// Information for a WasmExportedFunction which is referenced as the function
// data of the SharedFunctionInfo underlying the function. For details please
// see the {SharedFunctionInfo::HasWasmExportedFunctionData} predicate.
class WasmExportedFunctionData : public WasmFunctionData {
class WasmExportedFunctionData
: public TorqueGeneratedWasmExportedFunctionData<WasmExportedFunctionData,
WasmFunctionData> {
public:
// This is the instance that exported the function (which in case of
// imported and re-exported functions is different from the instance
// where the function is defined -- for the latter see WasmFunctionData::ref).
DECL_ACCESSORS(instance, WasmInstanceObject)
DECL_INT_ACCESSORS(function_index)
DECL_ACCESSORS(signature, Foreign)
DECL_INT_ACCESSORS(wrapper_budget)
DECL_ACCESSORS(c_wrapper_code, CodeT)
DECL_INT_ACCESSORS(packed_args_size)
inline wasm::FunctionSig* sig() const;
DECL_CAST(WasmExportedFunctionData)
// Dispatched behavior.
DECL_PRINTER(WasmExportedFunctionData)
DECL_VERIFIER(WasmExportedFunctionData)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(
WasmFunctionData::kSize,
TORQUE_GENERATED_WASM_EXPORTED_FUNCTION_DATA_FIELDS)
class BodyDescriptor;
OBJECT_CONSTRUCTORS(WasmExportedFunctionData, WasmFunctionData);
TQ_OBJECT_CONSTRUCTORS(WasmExportedFunctionData)
};
// Information for a WasmJSFunction which is referenced as the function data of
// the SharedFunctionInfo underlying the function. For details please see the
// {SharedFunctionInfo::HasWasmJSFunctionData} predicate.
class WasmJSFunctionData : public WasmFunctionData {
class WasmJSFunctionData
: public TorqueGeneratedWasmJSFunctionData<WasmJSFunctionData,
WasmFunctionData> {
public:
DECL_INT_ACCESSORS(serialized_return_count)
DECL_INT_ACCESSORS(serialized_parameter_count)
DECL_ACCESSORS(serialized_signature, PodArray<wasm::ValueType>)
DECL_ACCESSORS(wasm_to_js_wrapper_code, Code)
DECL_CAST(WasmJSFunctionData)
// Dispatched behavior.
DECL_PRINTER(WasmJSFunctionData)
DECL_VERIFIER(WasmJSFunctionData)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(WasmFunctionData::kSize,
TORQUE_GENERATED_WASM_JS_FUNCTION_DATA_FIELDS)
class BodyDescriptor;
private:
DECL_ACCESSORS(raw_wasm_to_js_wrapper_code, CodeT)
OBJECT_CONSTRUCTORS(WasmJSFunctionData, WasmFunctionData);
TQ_OBJECT_CONSTRUCTORS(WasmJSFunctionData)
};
class WasmCapiFunctionData : public WasmFunctionData {
class WasmCapiFunctionData
: public TorqueGeneratedWasmCapiFunctionData<WasmCapiFunctionData,
WasmFunctionData> {
public:
DECL_ACCESSORS(embedder_data, Foreign)
DECL_ACCESSORS(serialized_signature, PodArray<wasm::ValueType>)
DECL_CAST(WasmCapiFunctionData)
DECL_PRINTER(WasmCapiFunctionData)
DECL_VERIFIER(WasmCapiFunctionData)
// Layout description.
DEFINE_FIELD_OFFSET_CONSTANTS(WasmFunctionData::kSize,
TORQUE_GENERATED_WASM_CAPI_FUNCTION_DATA_FIELDS)
class BodyDescriptor;
OBJECT_CONSTRUCTORS(WasmCapiFunctionData, WasmFunctionData);
TQ_OBJECT_CONSTRUCTORS(WasmCapiFunctionData)
};
class WasmScript : public AllStatic {
......@@ -907,31 +814,21 @@ class WasmExceptionTag
// Data annotated to the asm.js Module function. Used for later instantiation of
// that function.
class AsmWasmData : public Struct {
class AsmWasmData : public TorqueGeneratedAsmWasmData<AsmWasmData, Struct> {
public:
static Handle<AsmWasmData> New(
Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module,
Handle<FixedArray> export_wrappers, Handle<HeapNumber> uses_bitset);
DECL_ACCESSORS(managed_native_module, Managed<wasm::NativeModule>)
DECL_ACCESSORS(export_wrappers, FixedArray)
DECL_ACCESSORS(uses_bitset, HeapNumber)
DECL_CAST(AsmWasmData)
DECL_PRINTER(AsmWasmData)
DECL_VERIFIER(AsmWasmData)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_ASM_WASM_DATA_FIELDS)
OBJECT_CONSTRUCTORS(AsmWasmData, Struct);
TQ_OBJECT_CONSTRUCTORS(AsmWasmData)
};
class WasmTypeInfo : public TorqueGeneratedWasmTypeInfo<WasmTypeInfo, Foreign> {
public:
inline void clear_foreign_address(Isolate* isolate);
DECL_CAST(WasmTypeInfo)
DECL_PRINTER(WasmTypeInfo)
class BodyDescriptor;
......@@ -939,11 +836,8 @@ class WasmTypeInfo : public TorqueGeneratedWasmTypeInfo<WasmTypeInfo, Foreign> {
TQ_OBJECT_CONSTRUCTORS(WasmTypeInfo)
};
class WasmObject : public JSReceiver {
class WasmObject : public TorqueGeneratedWasmObject<WasmObject, JSReceiver> {
public:
DECL_CAST(WasmObject)
DECL_VERIFIER(WasmObject)
// Prepares given value for being stored into a field of given Wasm type.
V8_WARN_UNUSED_RESULT static inline MaybeHandle<Object> ToWasmValue(
Isolate* isolate, wasm::ValueType type, Handle<Object> value);
......@@ -964,7 +858,7 @@ class WasmObject : public JSReceiver {
template <typename ElementType>
static ElementType FromNumber(Object value);
OBJECT_CONSTRUCTORS(WasmObject, JSReceiver);
TQ_OBJECT_CONSTRUCTORS(WasmObject)
};
class WasmStruct : public TorqueGeneratedWasmStruct<WasmStruct, WasmObject> {
......@@ -991,7 +885,6 @@ class WasmStruct : public TorqueGeneratedWasmStruct<WasmStruct, WasmObject> {
static inline void SetField(Isolate* isolate, Handle<WasmStruct> obj,
uint32_t field_index, Handle<Object> value);
DECL_CAST(WasmStruct)
DECL_PRINTER(WasmStruct)
class BodyDescriptor;
......@@ -1021,7 +914,6 @@ class WasmArray : public TorqueGeneratedWasmArray<WasmArray, WasmObject> {
// Returns the Address of the element at {index}.
Address ElementAddress(uint32_t index);
DECL_CAST(WasmArray)
DECL_PRINTER(WasmArray)
class BodyDescriptor;
......
......@@ -26,7 +26,11 @@ extern class WasmFunctionData extends Foreign {
@ifnot(V8_EXTERNAL_CODE_SPACE) wrapper_code: Code;
}
@generateCppClass
extern class WasmExportedFunctionData extends WasmFunctionData {
// This is the instance that exported the function (which in case of
// imported and re-exported functions is different from the instance
// where the function is defined -- for the latter see WasmFunctionData::ref).
instance: WasmInstanceObject;
function_index: Smi;
signature: Foreign;
......@@ -38,6 +42,7 @@ extern class WasmExportedFunctionData extends WasmFunctionData {
packed_args_size: Smi;
}
@generateCppClass
extern class WasmJSFunctionData extends WasmFunctionData {
@if(V8_EXTERNAL_CODE_SPACE) wasm_to_js_wrapper_code: CodeDataContainer;
@ifnot(V8_EXTERNAL_CODE_SPACE) wasm_to_js_wrapper_code: Code;
......@@ -46,11 +51,13 @@ extern class WasmJSFunctionData extends WasmFunctionData {
serialized_signature: PodArrayOfWasmValueType;
}
@generateCppClass
extern class WasmCapiFunctionData extends WasmFunctionData {
embedder_data: Foreign; // Managed<wasm::FuncData>
serialized_signature: PodArrayOfWasmValueType;
}
@generateCppClass
extern class WasmIndirectFunctionTable extends Struct {
size: uint32;
@if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
......@@ -69,14 +76,22 @@ extern class WasmExceptionTag extends Struct {
index: Smi;
}
@generateCppClass
extern class WasmModuleObject extends JSObject {
native_module: ManagedWasmNativeModule;
managed_native_module: ManagedWasmNativeModule;
export_wrappers: FixedArray;
script: Script;
}
@generateCppClass
extern class WasmTableObject extends JSObject {
// The instance in which this WasmTableObject is defined.
// This field is undefined if the global is defined outside any Wasm module,
// i.e., through the JS API (WebAssembly.Table).
// Because it might be undefined, we declare it as a HeapObject.
instance: WasmInstanceObject|Undefined;
// The entries array is at least as big as {current_length()}, but might be
// bigger to make future growth more efficient.
entries: FixedArray;
current_length: Smi;
maximum_length: Smi|HeapNumber|Undefined;
......@@ -84,21 +99,30 @@ extern class WasmTableObject extends JSObject {
raw_type: Smi;
}
@generateCppClass
extern class WasmMemoryObject extends JSObject {
array_buffer: JSArrayBuffer;
maximum_pages: Smi;
instances: WeakArrayList|Undefined;
}
@generateCppClass
extern class WasmGlobalObject extends JSObject {
// The instance in which this WasmGlobalObject is defined.
// This field is undefined if the global is defined outside any Wasm module,
// i.e., through the JS API (WebAssembly.Global).
// Because it might be undefined, we declare it as a HeapObject.
instance: WasmInstanceObject|Undefined;
untagged_buffer: JSArrayBuffer|Undefined;
tagged_buffer: FixedArray|Undefined;
offset: Smi;
raw_type: Smi;
// TODO(7748): If we encode mutability in raw_type, turn this into a boolean
// accessor.
is_mutable: Smi;
}
@generateCppClass
extern class WasmExceptionObject extends JSObject {
serialized_signature: PodArrayOfWasmValueType;
exception_tag: HeapObject;
......@@ -106,6 +130,7 @@ extern class WasmExceptionObject extends JSObject {
type WasmExportedFunction extends JSFunction;
@generateCppClass
extern class AsmWasmData extends Struct {
managed_native_module: ManagedWasmNativeModule;
export_wrappers: FixedArray;
......@@ -122,6 +147,7 @@ extern class WasmTypeInfo extends Foreign {
// WasmObject corresponds to data ref types which are WasmStruct and WasmArray.
@abstract
@generateCppClass
extern class WasmObject extends JSReceiver {
}
......
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