wasm-objects.tq 3.39 KB
Newer Older
Tobias Tebbi's avatar
Tobias Tebbi committed
1 2 3 4
// 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.

5
@useParentTypeChecker
6
type PodArrayOfWasmValueType extends ByteArray
7 8
    constexpr 'PodArray<wasm::ValueType>';
@useParentTypeChecker
9
type ManagedWasmNativeModule extends Foreign
10
    constexpr 'Managed<wasm::NativeModule>';
11 12
type WasmValueType extends uint8 constexpr 'wasm::ValueType::Kind';

Tobias Tebbi's avatar
Tobias Tebbi committed
13 14 15 16 17 18 19
extern class WasmInstanceObject extends JSObject;

extern class WasmExportedFunctionData extends Struct {
  wrapper_code: Code;
  instance: WasmInstanceObject;
  jump_table_offset: Smi;
  function_index: Smi;
20
  signature: Foreign;
21
  wrapper_budget: Smi;
Tobias Tebbi's avatar
Tobias Tebbi committed
22 23 24 25 26 27 28 29 30 31
  // 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;
}

extern class WasmJSFunctionData extends Struct {
  callable: JSReceiver;
  wrapper_code: Code;
32
  wasm_to_js_wrapper_code: Code;
Tobias Tebbi's avatar
Tobias Tebbi committed
33 34
  serialized_return_count: Smi;
  serialized_parameter_count: Smi;
35
  serialized_signature: PodArrayOfWasmValueType;
Tobias Tebbi's avatar
Tobias Tebbi committed
36 37
}

38 39
@export
class WasmCapiFunctionData extends HeapObject {
Tobias Tebbi's avatar
Tobias Tebbi committed
40 41 42
  call_target: RawPtr;
  embedder_data: Foreign;  // Managed<wasm::FuncData>
  wrapper_code: Code;
43
  serialized_signature: PodArrayOfWasmValueType;
Tobias Tebbi's avatar
Tobias Tebbi committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57
}

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 {
58 59 60
  // 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.
Tobias Tebbi's avatar
Tobias Tebbi committed
61 62 63 64
  index: Smi;
}

extern class WasmModuleObject extends JSObject {
65
  native_module: ManagedWasmNativeModule;
Tobias Tebbi's avatar
Tobias Tebbi committed
66 67 68 69 70
  export_wrappers: FixedArray;
  script: Script;
}

extern class WasmTableObject extends JSObject {
71
  instance: WasmInstanceObject|Undefined;
Tobias Tebbi's avatar
Tobias Tebbi committed
72
  entries: FixedArray;
73
  current_length: Smi;
Tobias Tebbi's avatar
Tobias Tebbi committed
74 75 76 77 78 79 80 81 82 83 84 85
  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 {
86
  instance: WasmInstanceObject|Undefined;
Tobias Tebbi's avatar
Tobias Tebbi committed
87 88 89
  untagged_buffer: JSArrayBuffer|Undefined;
  tagged_buffer: FixedArray|Undefined;
  offset: Smi;
90 91
  raw_type: Smi;
  is_mutable: Smi;
Tobias Tebbi's avatar
Tobias Tebbi committed
92 93 94
}

extern class WasmExceptionObject extends JSObject {
95
  serialized_signature: PodArrayOfWasmValueType;
Tobias Tebbi's avatar
Tobias Tebbi committed
96 97 98 99 100 101
  exception_tag: HeapObject;
}

type WasmExportedFunction extends JSFunction;

extern class AsmWasmData extends Struct {
102
  managed_native_module: ManagedWasmNativeModule;
Tobias Tebbi's avatar
Tobias Tebbi committed
103 104 105
  export_wrappers: FixedArray;
  uses_bitset: HeapNumber;
}
106

107 108 109
@generateCppClass
extern class WasmTypeInfo extends Foreign {
  parent: Map;
110
  supertypes: FixedArray;
111
  subtypes: ArrayList;
112 113
}

114 115 116
@generateCppClass
extern class WasmStruct extends HeapObject {
}
117 118 119 120 121 122 123 124

@generateCppClass
extern class WasmArray extends HeapObject {
  length: uint32;

  @if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
  @ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
}