v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
wasm-js.h
Go to the documentation of this file.
1// Copyright 2015 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_JS_H_
6#define V8_WASM_WASM_JS_H_
7
8#if !V8_ENABLE_WEBASSEMBLY
9#error This header should only be included if WebAssembly is enabled.
10#endif // !V8_ENABLE_WEBASSEMBLY
11
12#include <memory>
13
14#include "src/common/globals.h"
15
16namespace v8 {
17class Value;
18template <typename T>
19class FunctionCallbackInfo;
20class WasmStreaming;
21} // namespace v8
22
23namespace v8::internal {
24
25namespace wasm {
26class CompilationResultResolver;
27class StreamingDecoder;
28
29V8_EXPORT_PRIVATE std::unique_ptr<WasmStreaming> StartStreamingForTesting(
30 Isolate*, std::shared_ptr<wasm::CompilationResultResolver>);
31
32#define WASM_JS_EXTERNAL_REFERENCE_LIST(V) \
33 V(WebAssemblyCompile) \
34 V(WebAssemblyException) \
35 V(WebAssemblyExceptionGetArg) \
36 V(WebAssemblyExceptionIs) \
37 V(WebAssemblyGlobal) \
38 V(WebAssemblyGlobalGetValue) \
39 V(WebAssemblyGlobalSetValue) \
40 V(WebAssemblyGlobalValueOf) \
41 V(WebAssemblyInstance) \
42 V(WebAssemblyInstanceGetExports) \
43 V(WebAssemblyInstantiate) \
44 V(WebAssemblyMemory) \
45 V(WebAssemblyMemoryMapDescriptor) \
46 V(WebAssemblyMemoryGetBuffer) \
47 V(WebAssemblyMemoryGrow) \
48 V(WebAssemblyMemoryMapDescriptorMap) \
49 V(WebAssemblyMemoryMapDescriptorUnmap) \
50 V(WebAssemblyMemoryToFixedLengthBuffer) \
51 V(WebAssemblyMemoryToResizableBuffer) \
52 V(WebAssemblyModule) \
53 V(WebAssemblyModuleCustomSections) \
54 V(WebAssemblyModuleExports) \
55 V(WebAssemblyModuleImports) \
56 V(WebAssemblyTable) \
57 V(WebAssemblyTableGet) \
58 V(WebAssemblyTableGetLength) \
59 V(WebAssemblyTableGrow) \
60 V(WebAssemblyTableSet) \
61 V(WebAssemblyTag) \
62 V(WebAssemblySuspending) \
63 V(WebAssemblyValidate)
64
65#define DECL_WASM_JS_EXTERNAL_REFERENCE(Name) \
66 V8_EXPORT_PRIVATE void Name(const v8::FunctionCallbackInfo<v8::Value>& info);
68#undef DECL_WASM_JS_EXTERNAL_REFERENCE
69} // namespace wasm
70
71// Exposes a WebAssembly API to JavaScript through the V8 API.
72class WasmJs {
73 public:
74 // Creates all API objects before the snapshot is serialized.
75 V8_EXPORT_PRIVATE static void PrepareForSnapshot(Isolate* isolate);
76
77 // Finalizes API object setup:
78 // - installs the WebAssembly object on the global object (depending on
79 // flags), and
80 // - creates API objects and properties that depend on runtime-enabled flags.
81 V8_EXPORT_PRIVATE static void Install(Isolate* isolate);
82
83 // Extend the API based on late-enabled features, mostly from origin trial.
85 Isolate* isolate, DirectHandle<NativeContext> context);
86
87 private:
89 Isolate* isolate, DirectHandle<JSObject> webassembly);
90
92 Isolate* isolate, DirectHandle<NativeContext> context,
93 DirectHandle<JSObject> webassembly);
94
96 Isolate* isolate, DirectHandle<NativeContext> context,
97 DirectHandle<JSObject> webassembly);
98
100 Isolate* isolate, DirectHandle<NativeContext> context,
101 DirectHandle<JSObject> webassembly);
102
104 Isolate* isolate, DirectHandle<NativeContext> context,
105 DirectHandle<JSObject> webassembly);
106};
107
108} // namespace v8::internal
109
110#endif // V8_WASM_WASM_JS_H_
static V8_EXPORT_PRIVATE void InstallModule(Isolate *isolate, DirectHandle< JSObject > webassembly)
Definition wasm-js.cc:3544
static V8_EXPORT_PRIVATE bool InstallJSPromiseIntegration(Isolate *isolate, DirectHandle< NativeContext > context, DirectHandle< JSObject > webassembly)
Definition wasm-js.cc:3725
static V8_EXPORT_PRIVATE void Install(Isolate *isolate)
Definition wasm-js.cc:3601
static V8_EXPORT_PRIVATE bool InstallTypeReflection(Isolate *isolate, DirectHandle< NativeContext > context, DirectHandle< JSObject > webassembly)
Definition wasm-js.cc:3785
static V8_EXPORT_PRIVATE void InstallMemoryControl(Isolate *isolate, DirectHandle< NativeContext > context, DirectHandle< JSObject > webassembly)
Definition wasm-js.cc:3759
static V8_EXPORT_PRIVATE void InstallConditionalFeatures(Isolate *isolate, DirectHandle< NativeContext > context)
Definition wasm-js.cc:3694
static V8_EXPORT_PRIVATE void InstallResizableBufferIntegration(Isolate *isolate, DirectHandle< NativeContext > context, DirectHandle< JSObject > webassembly)
Definition wasm-js.cc:3870
static V8_EXPORT_PRIVATE void PrepareForSnapshot(Isolate *isolate)
Definition wasm-js.cc:3378
std::unique_ptr< WasmStreaming > StartStreamingForTesting(Isolate *isolate, std::shared_ptr< wasm::CompilationResultResolver > resolver)
Definition wasm-js.cc:3888
Definition c-api.cc:87
#define V8_EXPORT_PRIVATE
Definition macros.h:460
#define WASM_JS_EXTERNAL_REFERENCE_LIST(V)
Definition wasm-js.h:32
#define DECL_WASM_JS_EXTERNAL_REFERENCE(Name)
Definition wasm-js.h:65