diff --git a/src/objects-debug.cc b/src/objects-debug.cc index 2a02c4387e..d4ed349da3 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -199,12 +199,14 @@ void HeapObject::HeapObjectVerify() { case JS_SPECIAL_API_OBJECT_TYPE: case JS_CONTEXT_EXTENSION_OBJECT_TYPE: case WASM_GLOBAL_TYPE: - case WASM_INSTANCE_TYPE: case WASM_MEMORY_TYPE: case WASM_MODULE_TYPE: case WASM_TABLE_TYPE: JSObject::cast(this)->JSObjectVerify(); break; + case WASM_INSTANCE_TYPE: + WasmInstanceObject::cast(this)->WasmInstanceObjectVerify(); + break; case JS_ARGUMENTS_TYPE: JSArgumentsObject::cast(this)->JSArgumentsObjectVerify(); break; @@ -1581,6 +1583,19 @@ void WasmDebugInfo::WasmDebugInfoVerify() { VerifyObjectField(kCWasmEntryMapOffset); } +void WasmInstanceObject::WasmInstanceObjectVerify() { + JSObjectVerify(); + CHECK(IsWasmInstanceObject()); + + // Just generically check all tagged fields. Don't check the untagged fields, + // as some of them might still contain the "undefined" value if the + // WasmInstanceObject is not fully set up yet. + for (int offset = kHeaderSize; offset < kFirstUntaggedOffset; + offset += kPointerSize) { + VerifyObjectField(offset); + } +} + void WasmExportedFunctionData::WasmExportedFunctionDataVerify() { CHECK(IsWasmExportedFunctionData()); VerifyObjectField(kWrapperCodeOffset); diff --git a/src/objects-printer.cc b/src/objects-printer.cc index 43f30fa419..56efb170ee 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -151,13 +151,16 @@ void HeapObject::HeapObjectPrint(std::ostream& os) { // NOLINT case JS_ASYNC_GENERATOR_OBJECT_TYPE: case JS_ARGUMENTS_TYPE: case JS_ERROR_TYPE: + // TODO(titzer): debug printing for more wasm objects case WASM_GLOBAL_TYPE: - case WASM_INSTANCE_TYPE: // TODO(titzer): debug printing for wasm objects case WASM_MEMORY_TYPE: case WASM_MODULE_TYPE: case WASM_TABLE_TYPE: JSObject::cast(this)->JSObjectPrint(os); break; + case WASM_INSTANCE_TYPE: + WasmInstanceObject::cast(this)->WasmInstanceObjectPrint(os); + break; case JS_GENERATOR_OBJECT_TYPE: JSGeneratorObject::cast(this)->JSGeneratorObjectPrint(os); break; @@ -1661,6 +1664,43 @@ void WasmDebugInfo::WasmDebugInfoPrint(std::ostream& os) { // NOLINT os << "\n"; } +void WasmInstanceObject::WasmInstanceObjectPrint(std::ostream& os) { // NOLINT + HeapObject::PrintHeader(os, "WasmInstanceObject"); + os << "\n - compiled_module: " << Brief(compiled_module()); + os << "\n - module_object: " << Brief(module_object()); + os << "\n - exports_object: " << Brief(exports_object()); + os << "\n - native_context: " << Brief(native_context()); + os << "\n - memory_object: " << Brief(memory_object()); + os << "\n - globals_buffer: " << Brief(globals_buffer()); + os << "\n - imported_mutable_globals_buffers: " + << Brief(imported_mutable_globals_buffers()); + os << "\n - debug_info: " << Brief(debug_info()); + os << "\n - table_object: " << Brief(table_object()); + os << "\n - imported_function_instances: " + << Brief(imported_function_instances()); + os << "\n - imported_function_callables: " + << Brief(imported_function_callables()); + os << "\n - indirect_function_table_instances: " + << Brief(indirect_function_table_instances()); + os << "\n - managed_native_allocations: " + << Brief(managed_native_allocations()); + os << "\n - managed_indirect_patcher: " << Brief(managed_indirect_patcher()); + os << "\n - memory_start: " << static_cast(memory_start()); + os << "\n - memory_size: " << memory_size(); + os << "\n - memory_mask: " << AsHex(memory_mask()); + os << "\n - imported_function_targets: " + << static_cast(imported_function_targets()); + os << "\n - globals_start: " << static_cast(globals_start()); + os << "\n - imported_mutable_globals: " + << static_cast(imported_mutable_globals()); + os << "\n - indirect_function_table_size: " << indirect_function_table_size(); + os << "\n - indirect_function_table_sig_ids: " + << static_cast(indirect_function_table_sig_ids()); + os << "\n - indirect_function_table_targets: " + << static_cast(indirect_function_table_targets()); + os << "\n"; +} + void WasmExportedFunctionData::WasmExportedFunctionDataPrint( std::ostream& os) { // NOLINT HeapObject::PrintHeader(os, "WasmExportedFunctionData"); diff --git a/src/wasm/wasm-objects-inl.h b/src/wasm/wasm-objects-inl.h index 7628ec2ae0..34b08666f9 100644 --- a/src/wasm/wasm-objects-inl.h +++ b/src/wasm/wasm-objects-inl.h @@ -137,10 +137,10 @@ ACCESSORS(WasmInstanceObject, exports_object, JSObject, kExportsObjectOffset) ACCESSORS(WasmInstanceObject, native_context, Context, kNativeContextOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, memory_object, WasmMemoryObject, kMemoryObjectOffset) -ACCESSORS(WasmInstanceObject, globals_buffer, JSArrayBuffer, - kGlobalsBufferOffset) -ACCESSORS(WasmInstanceObject, imported_mutable_globals_buffers, FixedArray, - kImportedMutableGlobalsBuffersOffset) +OPTIONAL_ACCESSORS(WasmInstanceObject, globals_buffer, JSArrayBuffer, + kGlobalsBufferOffset) +OPTIONAL_ACCESSORS(WasmInstanceObject, imported_mutable_globals_buffers, + FixedArray, kImportedMutableGlobalsBuffersOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, debug_info, WasmDebugInfo, kDebugInfoOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, table_object, WasmTableObject, @@ -151,8 +151,8 @@ ACCESSORS(WasmInstanceObject, imported_function_callables, FixedArray, kImportedFunctionCallablesOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, indirect_function_table_instances, FixedArray, kIndirectFunctionTableInstancesOffset) -ACCESSORS(WasmInstanceObject, managed_native_allocations, Foreign, - kManagedNativeAllocationsOffset) +OPTIONAL_ACCESSORS(WasmInstanceObject, managed_native_allocations, Foreign, + kManagedNativeAllocationsOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, managed_indirect_patcher, Foreign, kManagedIndirectPatcherOffset) diff --git a/src/wasm/wasm-objects.h b/src/wasm/wasm-objects.h index 644b48cb1f..b65f4649b2 100644 --- a/src/wasm/wasm-objects.h +++ b/src/wasm/wasm-objects.h @@ -298,6 +298,10 @@ class WasmInstanceObject : public JSObject { DECL_PRIMITIVE_ACCESSORS(indirect_function_table_sig_ids, uint32_t*) DECL_PRIMITIVE_ACCESSORS(indirect_function_table_targets, Address*) + // Dispatched behavior. + DECL_PRINTER(WasmInstanceObject) + DECL_VERIFIER(WasmInstanceObject) + // Layout description. #define WASM_INSTANCE_OBJECT_FIELDS(V) \ V(kCompiledModuleOffset, kPointerSize) \