v8/src/wasm/wasm-objects.tq

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

118 lines
3.2 KiB
Plaintext
Raw Normal View History

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
type PodArrayOfWasmValueType extends ByteArray
constexpr 'PodArray<wasm::ValueType>';
type ManagedWasmNativeModule extends Foreign
constexpr 'Managed<wasm::NativeModule>';
type WasmValueType extends uint8 constexpr 'wasm::ValueType::Kind';
extern class WasmInstanceObject extends JSObject;
extern class WasmExportedFunctionData extends Struct {
wrapper_code: Code;
instance: WasmInstanceObject;
jump_table_offset: Smi;
function_index: Smi;
// The remaining fields are for fast calling from C++. The contract is
// that they are lazily populated, and either all will be present or none.
c_wrapper_code: Object;
wasm_call_target: Smi|Foreign;
packed_args_size: Smi;
signature: Foreign;
}
extern class WasmJSFunctionData extends Struct {
callable: JSReceiver;
wrapper_code: Code;
serialized_return_count: Smi;
serialized_parameter_count: Smi;
serialized_signature: PodArrayOfWasmValueType;
}
extern class WasmCapiFunctionData extends Struct {
call_target: RawPtr;
embedder_data: Foreign; // Managed<wasm::FuncData>
wrapper_code: Code;
serialized_signature: PodArrayOfWasmValueType;
}
extern class WasmIndirectFunctionTable extends Struct {
size: uint32;
@if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
@ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
sig_ids: RawPtr;
targets: RawPtr;
managed_native_allocations: Foreign|Undefined;
refs: FixedArray;
}
@generateCppClass
extern class WasmExceptionTag extends Struct {
// Note that this index is only useful for debugging purposes and it is not
// unique across modules. The GC however does not allow objects without at
// least one field, hence this also serves as a padding field for now.
index: Smi;
}
extern class WasmModuleObject extends JSObject {
native_module: ManagedWasmNativeModule;
export_wrappers: FixedArray;
script: Script;
}
extern class WasmTableObject extends JSObject {
entries: FixedArray;
current_length: Smi;
maximum_length: Smi|HeapNumber|Undefined;
dispatch_tables: FixedArray;
raw_type: Smi;
}
extern class WasmMemoryObject extends JSObject {
array_buffer: JSArrayBuffer;
maximum_pages: Smi;
instances: WeakArrayList|Undefined;
}
extern class WasmGlobalObject extends JSObject {
instance: WasmInstanceObject|Undefined;
untagged_buffer: JSArrayBuffer|Undefined;
tagged_buffer: FixedArray|Undefined;
offset: Smi;
[wasm-gc] Change ValueType representation to account for new types Motivation: Changes to the typed function references and gc proposals solidified the notion of heap type, clarified nullable vs. non-nullable reference types, and introduced rtts, which contain an integer depth field in addition to a heap type. This required us to overhaul our ValueType representation, which results in extensive changes. To keep this CL "small", we do not try to implement the binary encoding as described in the proposals, but rather devise a simpler one of our own (see below). Also, we do not try to implement additional functionality for the new types. Changes: - Introduce HeapType. Move heap types from ValueType to HeapType. - Introduce Nullability for reference types. - Rework ValueType helper methods. - Introduce rtts in ValueType with an integer depth field. Include depth in the ValueType encoding. - Make the constructor of ValueType private, instead expose static functions which explicitly state what they create. - Change every switch statement on ValueType::Kind. Sometimes, we need nested switches. - Introduce temporary constants in ValueTypeCode for nullable types, use them for decoding. - In WasmGlobalObject, split 'flags' into 'raw_type' and 'is_mutable'. - Change IsSubtypeOfRef to IsSubtypeOfHeap and implement changes in subtyping. - kWasmFuncRef initializers are now non-nullable. Initializers are only required to be subtypes of the declared global type. - Change tests and fuzzers as needed. Bug: v8:7748 Change-Id: If41f783bd4128443b07e94188cea7dd53ab0bfa5 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2247657 Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#68408}
2020-06-18 11:24:07 +00:00
raw_type: Smi;
is_mutable: Smi;
}
extern class WasmExceptionObject extends JSObject {
serialized_signature: PodArrayOfWasmValueType;
exception_tag: HeapObject;
}
type WasmExportedFunction extends JSFunction;
extern class AsmWasmData extends Struct {
managed_native_module: ManagedWasmNativeModule;
export_wrappers: FixedArray;
uses_bitset: HeapNumber;
}
@generateCppClass
extern class WasmTypeInfo extends Foreign {
parent: Map;
subtypes: ArrayList;
}
@generateCppClass
extern class WasmStruct extends HeapObject {
}
@generateCppClass
extern class WasmArray extends HeapObject {
length: uint32;
@if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
@ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
}