1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 * 4 * Copyright 2021 Mozilla Foundation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef wasm_type_decls_h 20 #define wasm_type_decls_h 21 22 #include "NamespaceImports.h" 23 #include "gc/Barrier.h" 24 #include "js/GCVector.h" 25 #include "js/HashTable.h" 26 #include "js/RootingAPI.h" 27 #include "js/UniquePtr.h" 28 #include "js/Utility.h" 29 #include "js/Vector.h" 30 31 namespace js { 32 33 using JSFunctionVector = GCVector<JSFunction*, 0, SystemAllocPolicy>; 34 35 class WasmMemoryObject; 36 using GCPtrWasmMemoryObject = GCPtr<WasmMemoryObject*>; 37 using RootedWasmMemoryObject = Rooted<WasmMemoryObject*>; 38 using HandleWasmMemoryObject = Handle<WasmMemoryObject*>; 39 using MutableHandleWasmMemoryObject = MutableHandle<WasmMemoryObject*>; 40 41 class WasmModuleObject; 42 using RootedWasmModuleObject = Rooted<WasmModuleObject*>; 43 using HandleWasmModuleObject = Handle<WasmModuleObject*>; 44 using MutableHandleWasmModuleObject = MutableHandle<WasmModuleObject*>; 45 46 class WasmInstanceObject; 47 using WasmInstanceObjectVector = GCVector<WasmInstanceObject*>; 48 using RootedWasmInstanceObject = Rooted<WasmInstanceObject*>; 49 using HandleWasmInstanceObject = Handle<WasmInstanceObject*>; 50 using MutableHandleWasmInstanceObject = MutableHandle<WasmInstanceObject*>; 51 52 class WasmTableObject; 53 using WasmTableObjectVector = GCVector<WasmTableObject*, 0, SystemAllocPolicy>; 54 using RootedWasmTableObject = Rooted<WasmTableObject*>; 55 using HandleWasmTableObject = Handle<WasmTableObject*>; 56 using MutableHandleWasmTableObject = MutableHandle<WasmTableObject*>; 57 58 class WasmGlobalObject; 59 using WasmGlobalObjectVector = 60 GCVector<WasmGlobalObject*, 0, SystemAllocPolicy>; 61 using RootedWasmGlobalObject = Rooted<WasmGlobalObject*>; 62 63 class WasmTagObject; 64 using GCPtrWasmTagObject = GCPtr<WasmTagObject*>; 65 using WasmTagObjectVector = GCVector<WasmTagObject*, 0, SystemAllocPolicy>; 66 using RootedWasmTagObject = Rooted<WasmTagObject*>; 67 using HandleWasmTagObject = Handle<WasmTagObject*>; 68 69 class WasmExceptionObject; 70 using RootedWasmExceptionObject = Rooted<WasmExceptionObject*>; 71 72 namespace wasm { 73 74 struct ModuleEnvironment; 75 class Code; 76 class CodeRange; 77 class DebugState; 78 class Decoder; 79 class GeneratedSourceMap; 80 class Instance; 81 class Module; 82 class Table; 83 84 // Uint32Vector has initial size 8 on the basis that the dominant use cases 85 // (line numbers and control stacks) tend to have a small but nonzero number 86 // of elements. 87 using Uint32Vector = Vector<uint32_t, 8, SystemAllocPolicy>; 88 89 using Bytes = Vector<uint8_t, 0, SystemAllocPolicy>; 90 using UniqueBytes = UniquePtr<Bytes>; 91 using UniqueConstBytes = UniquePtr<const Bytes>; 92 using UTF8Bytes = Vector<char, 0, SystemAllocPolicy>; 93 using InstanceVector = Vector<Instance*, 0, SystemAllocPolicy>; 94 using UniqueCharsVector = Vector<UniqueChars, 0, SystemAllocPolicy>; 95 using RenumberVector = Vector<uint32_t, 0, SystemAllocPolicy>; 96 97 } // namespace wasm 98 } // namespace js 99 100 #endif // wasm_type_decls_h 101