V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
wasm-serialization.h
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_WASM_WASM_SERIALIZATION_H_
6 #define V8_WASM_WASM_SERIALIZATION_H_
7 
8 #include "src/wasm/wasm-objects.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace wasm {
13 
14 // Support for serializing WebAssembly {NativeModule} objects. This class takes
15 // a snapshot of the module state at instantiation, and other code that modifies
16 // the module after that won't affect the serialized result.
18  public:
19  WasmSerializer(Isolate* isolate, NativeModule* native_module);
20 
21  // Measure the required buffer size needed for serialization.
22  size_t GetSerializedNativeModuleSize() const;
23 
24  // Serialize the {NativeModule} into the provided {buffer}. Returns true on
25  // success and false if the given buffer it too small for serialization.
26  bool SerializeNativeModule(Vector<byte> buffer) const;
27 
28  private:
29  Isolate* isolate_;
30  NativeModule* native_module_;
31  std::vector<WasmCode*> code_table_;
32 };
33 
34 // Support for deserializing WebAssembly {NativeModule} objects.
35 // Checks the version header of the data against the current version.
36 bool IsSupportedVersion(Isolate* isolate, Vector<const byte> data);
37 
38 // Deserializes the given data to create a compiled Wasm module.
39 MaybeHandle<WasmModuleObject> DeserializeNativeModule(
40  Isolate* isolate, Vector<const byte> data, Vector<const byte> wire_bytes);
41 
42 } // namespace wasm
43 } // namespace internal
44 } // namespace v8
45 
46 #endif // V8_WASM_WASM_SERIALIZATION_H_
Definition: libplatform.h:13