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) {
......
This diff is collapsed.
......@@ -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