summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/wasm-compiler.h
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2022-04-12 11:10:15 +0200
committerMichaël Zasso <targos@protonmail.com>2022-04-12 22:08:39 +0200
commitfd4f80ce54d7f7b7503e0999f6a9d293d493846d (patch)
tree00fba34b8aabeb481c7128fccee635719ee44a3b /deps/v8/src/compiler/wasm-compiler.h
parent73d53fe9f56d7ce5de4b9c9ad5257dc601bbce14 (diff)
downloadnode-new-fd4f80ce54d7f7b7503e0999f6a9d293d493846d.tar.gz
deps: update V8 to 10.1.124.6
PR-URL: https://github.com/nodejs/node/pull/42657 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'deps/v8/src/compiler/wasm-compiler.h')
-rw-r--r--deps/v8/src/compiler/wasm-compiler.h79
1 files changed, 53 insertions, 26 deletions
diff --git a/deps/v8/src/compiler/wasm-compiler.h b/deps/v8/src/compiler/wasm-compiler.h
index 93b08a0dd9..9fa017ef84 100644
--- a/deps/v8/src/compiler/wasm-compiler.h
+++ b/deps/v8/src/compiler/wasm-compiler.h
@@ -15,6 +15,7 @@
// Clients of this interface shouldn't depend on lots of compiler internals.
// Do not include anything from src/compiler here!
#include "src/base/small-vector.h"
+#include "src/objects/js-function.h"
#include "src/runtime/runtime.h"
#include "src/wasm/function-body-decoder.h"
#include "src/wasm/function-compiler.h"
@@ -55,6 +56,7 @@ class WasmCode;
class WasmFeatures;
class WireBytesStorage;
enum class LoadTransformationKind : uint8_t;
+enum Suspend : bool { kSuspend = false, kNoSuspend = true };
} // namespace wasm
namespace compiler {
@@ -71,6 +73,7 @@ enum class WasmImportCallKind : uint8_t {
kLinkError, // static Wasm->Wasm type error
kRuntimeTypeError, // runtime Wasm->JS type error
kWasmToCapi, // fast Wasm->C-API call
+ kWasmToJSFastApi, // fast Wasm->JS Fast API C call
kWasmToWasm, // fast Wasm->Wasm call
kJSFunctionArityMatch, // fast Wasm->JS call
kJSFunctionArityMismatch, // Wasm->JS, needs adapter frame
@@ -107,24 +110,34 @@ enum class WasmImportCallKind : uint8_t {
constexpr WasmImportCallKind kDefaultImportCallKind =
WasmImportCallKind::kJSFunctionArityMatch;
+struct WasmImportData {
+ WasmImportCallKind kind;
+ Handle<JSReceiver> callable;
+ Handle<HeapObject> suspender;
+};
// Resolves which import call wrapper is required for the given JS callable.
-// Returns the kind of wrapper need and the ultimate target callable. Note that
-// some callables (e.g. a {WasmExportedFunction} or {WasmJSFunction}) just wrap
-// another target, which is why the ultimate target is returned as well.
-V8_EXPORT_PRIVATE std::pair<WasmImportCallKind, Handle<JSReceiver>>
-ResolveWasmImportCall(Handle<JSReceiver> callable, const wasm::FunctionSig* sig,
- const wasm::WasmModule* module,
- const wasm::WasmFeatures& enabled_features);
+// Returns the kind of wrapper needed, the ultimate target callable, and the
+// suspender object if applicable. Note that some callables (e.g. a
+// {WasmExportedFunction} or {WasmJSFunction}) just wrap another target, which
+// is why the ultimate target is returned as well.
+V8_EXPORT_PRIVATE WasmImportData ResolveWasmImportCall(
+ Handle<JSReceiver> callable, const wasm::FunctionSig* sig,
+ const wasm::WasmModule* module, const wasm::WasmFeatures& enabled_features);
// Compiles an import call wrapper, which allows Wasm to call imports.
V8_EXPORT_PRIVATE wasm::WasmCompilationResult CompileWasmImportCallWrapper(
wasm::CompilationEnv* env, WasmImportCallKind, const wasm::FunctionSig*,
- bool source_positions, int expected_arity);
+ bool source_positions, int expected_arity, wasm::Suspend);
// Compiles a host call wrapper, which allows Wasm to call host functions.
wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::NativeModule*,
const wasm::FunctionSig*);
+// Compiles a wrapper to call a Fast API function from Wasm.
+wasm::WasmCode* CompileWasmJSFastCallWrapper(wasm::NativeModule*,
+ const wasm::FunctionSig*,
+ Handle<JSFunction> target);
+
// Returns an OptimizedCompilationJob object for a JS to Wasm wrapper.
std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
Isolate* isolate, const wasm::FunctionSig* sig,
@@ -134,7 +147,8 @@ std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
MaybeHandle<Code> CompileWasmToJSWrapper(Isolate* isolate,
const wasm::FunctionSig* sig,
WasmImportCallKind kind,
- int expected_arity);
+ int expected_arity,
+ wasm::Suspend suspend);
// Compiles a stub with JS linkage that serves as an adapter for function
// objects constructed via {WebAssembly.Function}. It performs a round-trip
@@ -183,12 +197,14 @@ struct WasmInstanceCacheNodes {
struct WasmLoopInfo {
Node* header;
uint32_t nesting_depth;
- bool is_innermost;
+ // This loop has, to our best knowledge, no other loops nested within it. A
+ // loop can obtain inner loops despite this after inlining.
+ bool can_be_innermost;
- WasmLoopInfo(Node* header, uint32_t nesting_depth, bool is_innermost)
+ WasmLoopInfo(Node* header, uint32_t nesting_depth, bool can_be_innermost)
: header(header),
nesting_depth(nesting_depth),
- is_innermost(is_innermost) {}
+ can_be_innermost(can_be_innermost) {}
};
// Abstracts details of building TurboFan graph nodes for wasm to separate
@@ -214,7 +230,7 @@ class WasmGraphBuilder {
struct ObjectReferenceKnowledge {
bool object_can_be_null;
ReferenceKind reference_kind;
- int8_t rtt_depth;
+ uint8_t rtt_depth;
};
enum EnforceBoundsCheck : bool { // --
kNeedsBoundsCheck = true,
@@ -290,7 +306,8 @@ class WasmGraphBuilder {
void AppendToMerge(Node* merge, Node* from);
void AppendToPhi(Node* phi, Node* from);
- void StackCheck(wasm::WasmCodePosition);
+ void StackCheck(WasmInstanceCacheNodes* shared_memory_instance_cache,
+ wasm::WasmCodePosition);
void PatchInStackCheckIfNeeded();
@@ -410,14 +427,6 @@ class WasmGraphBuilder {
return effect_and_control;
}
- Node* GetImportedMutableGlobals();
-
- void GetGlobalBaseAndOffset(MachineType mem_type, const wasm::WasmGlobal&,
- Node** base_node, Node** offset_node);
-
- void GetBaseAndOffsetForImportedMutableExternRefGlobal(
- const wasm::WasmGlobal& global, Node** base, Node** offset);
-
// Utilities to manipulate sets of instance cache nodes.
void InitInstanceCache(WasmInstanceCacheNodes* instance_cache);
void PrepareInstanceCacheForLoop(WasmInstanceCacheNodes* instance_cache,
@@ -497,13 +506,15 @@ class WasmGraphBuilder {
void ArrayCopy(Node* dst_array, Node* dst_index, CheckForNull dst_null_check,
Node* src_array, Node* src_index, CheckForNull src_null_check,
Node* length, wasm::WasmCodePosition position);
- Node* ArrayInit(uint32_t array_index, const wasm::ArrayType* type, Node* rtt,
+ Node* ArrayInit(const wasm::ArrayType* type, Node* rtt,
base::Vector<Node*> elements);
+ Node* ArrayInitFromData(const wasm::ArrayType* type, uint32_t data_segment,
+ Node* offset, Node* length, Node* rtt,
+ wasm::WasmCodePosition position);
Node* I31New(Node* input);
Node* I31GetS(Node* input);
Node* I31GetU(Node* input);
Node* RttCanon(uint32_t type_index);
- Node* RttSub(uint32_t type_index, Node* parent_rtt, WasmRttSubMode mode);
Node* RefTest(Node* object, Node* rtt, ObjectReferenceKnowledge config);
Node* RefCast(Node* object, Node* rtt, ObjectReferenceKnowledge config,
@@ -523,6 +534,12 @@ class WasmGraphBuilder {
void BrOnFunc(Node* object, Node* rtt, ObjectReferenceKnowledge config,
Node** match_control, Node** match_effect,
Node** no_match_control, Node** no_match_effect);
+ Node* RefIsArray(Node* object, bool object_can_be_null);
+ Node* RefAsArray(Node* object, bool object_can_be_null,
+ wasm::WasmCodePosition position);
+ void BrOnArray(Node* object, Node* rtt, ObjectReferenceKnowledge config,
+ Node** match_control, Node** match_effect,
+ Node** no_match_control, Node** no_match_effect);
Node* RefIsI31(Node* object);
Node* RefAsI31(Node* object, wasm::WasmCodePosition position);
void BrOnI31(Node* object, Node* rtt, ObjectReferenceKnowledge config,
@@ -691,8 +708,14 @@ class WasmGraphBuilder {
// generates {index > max ? Smi(max) : Smi(index)}
Node* BuildConvertUint32ToSmiWithSaturation(Node* index, uint32_t maxval);
+ void MemTypeToUintPtrOrOOBTrap(std::initializer_list<Node**> nodes,
+ wasm::WasmCodePosition position);
+
Node* IsNull(Node* object);
+ void GetGlobalBaseAndOffset(const wasm::WasmGlobal&, Node** base_node,
+ Node** offset_node);
+
using BranchBuilder = std::function<void(Node*, BranchHint)>;
struct Callbacks {
BranchBuilder succeed_if;
@@ -717,7 +740,9 @@ class WasmGraphBuilder {
void TypeCheck(Node* object, Node* rtt, ObjectReferenceKnowledge config,
bool null_succeeds, Callbacks callbacks);
void DataCheck(Node* object, bool object_can_be_null, Callbacks callbacks);
- void FuncCheck(Node* object, bool object_can_be_null, Callbacks callbacks);
+ void ManagedObjectInstanceCheck(Node* object, bool object_can_be_null,
+ InstanceType instance_type,
+ Callbacks callbacks);
void BrOnCastAbs(Node** match_control, Node** match_effect,
Node** no_match_control, Node** no_match_effect,
@@ -757,7 +782,9 @@ class WasmGraphBuilder {
Node* BuildMultiReturnFixedArrayFromIterable(const wasm::FunctionSig* sig,
Node* iterable, Node* context);
- Node* BuildUnsandboxExternalPointer(Node* external_pointer);
+ Node* BuildLoadExternalPointerFromObject(
+ Node* object, int offset,
+ ExternalPointerTag tag = kForeignForeignAddressTag);
Node* BuildLoadCallTargetFromExportedFunctionData(Node* function_data);