v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
turboshaft-graph-interface.h
Go to the documentation of this file.
1// Copyright 2023 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_TURBOSHAFT_GRAPH_INTERFACE_H_
6#define V8_WASM_TURBOSHAFT_GRAPH_INTERFACE_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 "src/base/macros.h"
18#include "src/wasm/decoder.h"
20#include "src/wasm/value-type.h"
22
23namespace v8::internal {
24class AccountingAllocator;
25struct WasmInliningPosition;
26
27namespace compiler {
28class NodeOriginTable;
29namespace turboshaft {
30class Graph;
31class PipelineData;
32}
33} // namespace compiler
34
35namespace wasm {
36class AssumptionsJournal;
37struct FunctionBody;
38class WasmDetectedFeatures;
39struct WasmModule;
40class WireBytesStorage;
41class TurboshaftGraphBuildingInterface;
42struct CompilationEnv;
43
45 compiler::turboshaft::PipelineData* data, AccountingAllocator* allocator,
46 CompilationEnv* env, WasmDetectedFeatures* detected,
47 compiler::turboshaft::Graph& graph, const FunctionBody& func_body,
48 const WireBytesStorage* wire_bytes,
49 std::unique_ptr<AssumptionsJournal>* assumptions,
50 ZoneVector<WasmInliningPosition>* inlining_positions, int func_index);
51
52void BuildWasmWrapper(compiler::turboshaft::PipelineData* data,
53 AccountingAllocator* allocator,
54 compiler::turboshaft::Graph& graph,
55 const wasm::CanonicalSig* sig, WrapperCompilationInfo);
56
57// Base class for the decoder graph builder interface and for the wrapper
58// builder.
60 public:
65 template <typename T>
67 template <typename T>
69 template <typename T, typename A>
71 template <typename T, typename A>
73
74 public:
76 void BuildModifyThreadInWasmFlagHelper(Zone* zone,
77 OpIndex thread_in_wasm_flag_address,
78 bool new_value);
79 void BuildModifyThreadInWasmFlag(Zone* zone, bool new_value);
80
81 protected:
83 : zone_(zone), asm_(assembler) {}
84
93
94 template <typename T>
96 template <typename T>
98
100 std::initializer_list<const OpIndex> args,
101 V<Context> context);
102
103 OpIndex GetBuiltinPointerTarget(Builtin builtin);
104 V<WordPtr> GetTargetForBuiltinCall(Builtin builtin, StubCallMode stub_mode);
105 V<BigInt> BuildChangeInt64ToBigInt(V<Word64> input, StubCallMode stub_mode);
106
107 std::pair<V<Word32>, V<HeapObject>> BuildImportedFunctionTargetAndImplicitArg(
108 ConstOrV<Word32> func_index,
109 V<WasmTrustedInstanceData> trusted_instance_data);
110
111 std::pair<V<Word32>, V<ExposedTrustedObject>>
112 BuildFunctionTargetAndImplicitArg(V<WasmInternalFunction> internal_function);
113
114 RegisterRepresentation RepresentationFor(ValueTypeBase type);
115 V<WasmTrustedInstanceData> LoadTrustedDataFromInstanceObject(
116 V<HeapObject> instance_object);
117
118 OpIndex CallC(const MachineSignature* sig, ExternalReference ref,
119 std::initializer_list<OpIndex> args);
120 OpIndex CallC(const MachineSignature* sig, OpIndex function,
121 std::initializer_list<OpIndex> args);
123 OpIndex arg) {
124 return CallC(sig, ref, {arg});
125 }
126
127 void BuildSetNewStackLimit(V<WordPtr> old_limit, V<WordPtr> new_limit);
128 V<WordPtr> BuildSwitchToTheCentralStack(V<WordPtr> old_limit);
129 std::pair<V<WordPtr>, V<WordPtr>> BuildSwitchToTheCentralStackIfNeeded();
130 void BuildSwitchBackFromCentralStack(V<WordPtr> old_sp, V<WordPtr> old_limit);
131
132 Assembler& Asm() { return asm_; }
133
136};
137
138} // namespace wasm
139} // namespace v8::internal
140
141#endif // V8_WASM_TURBOSHAFT_GRAPH_INTERFACE_H_
OpIndex CallC(const MachineSignature *sig, ExternalReference ref, OpIndex arg)
WasmGraphBuilderBase(Zone *zone, Assembler &assembler)
Zone * zone_
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
LiftoffAssembler asm_
std::conditional_t< Is64(), Word64, Word32 > WordPtr
Definition index.h:225
V8_EXPORT_PRIVATE void BuildTSGraph(compiler::turboshaft::PipelineData *data, AccountingAllocator *allocator, CompilationEnv *env, WasmDetectedFeatures *detected, Graph &graph, const FunctionBody &func_body, const WireBytesStorage *wire_bytes, std::unique_ptr< AssumptionsJournal > *assumptions, ZoneVector< WasmInliningPosition > *inlining_positions, int func_index)
void BuildWasmWrapper(compiler::turboshaft::PipelineData *data, AccountingAllocator *allocator, compiler::turboshaft::Graph &graph, const wasm::CanonicalSig *sig, WrapperCompilationInfo)
Definition wrappers.cc:1284
wasm::WasmModule WasmModule
kWasmInternalFunctionIndirectPointerTag kProtectedInstanceDataOffset sig
Definition c-api.cc:87
#define V8_EXPORT_PRIVATE
Definition macros.h:460