5#ifndef V8_WASM_WASM_BUILTIN_LIST_H_
6#define V8_WASM_WASM_BUILTIN_LIST_H_
12#if !V8_ENABLE_WEBASSEMBLY
13#error This header should only be included if WebAssembly is enabled.
20#define WASM_BUILTINS_WITH_JUMP_TABLE_SLOT(V, VTRAP) \
21 FOREACH_WASM_TRAPREASON(VTRAP) \
23 V(WasmTriggerTierUp) \
24 V(WasmLiftoffFrameSetup) \
26 V(WasmInt32ToHeapNumber) \
27 V(WasmFloat64ToString) \
28 V(WasmStringToDouble) \
30 V(WasmTaggedNonSmiToInt32) \
31 V(WasmFloat32ToNumber) \
32 V(WasmFloat64ToNumber) \
33 V(WasmTaggedToFloat64) \
34 V(WasmAllocateJSArray) \
35 V(WasmI32AtomicWait) \
36 V(WasmI64AtomicWait) \
37 V(WasmGetOwnProperty) \
39 V(WasmInternalFunctionCreateExternal) \
47 V(WasmTableGetFuncRef) \
48 V(WasmTableSetFuncRef) \
49 V(WasmFunctionTableGet) \
51 V(WasmGrowableStackGuard) \
52 V(WasmStackOverflow) \
53 V(WasmAllocateFixedArray) \
57 V(WasmRethrowExplicitContext) \
58 V(WasmHandleStackOverflow) \
69 V(RecordWriteSaveFP) \
70 V(RecordWriteIgnoreFP) \
71 V(ThrowDataViewTypeError) \
72 V(ThrowDataViewDetachedError) \
73 V(ThrowDataViewOutOfBounds) \
74 V(ThrowIndexOfCalledOnNull) \
75 V(ThrowToLowerCaseCalledOnNull) \
76 IF_INTL(V, StringToLowerCaseIntl) \
77 IF_TSAN(V, TSANRelaxedStore8IgnoreFP) \
78 IF_TSAN(V, TSANRelaxedStore8SaveFP) \
79 IF_TSAN(V, TSANRelaxedStore16IgnoreFP) \
80 IF_TSAN(V, TSANRelaxedStore16SaveFP) \
81 IF_TSAN(V, TSANRelaxedStore32IgnoreFP) \
82 IF_TSAN(V, TSANRelaxedStore32SaveFP) \
83 IF_TSAN(V, TSANRelaxedStore64IgnoreFP) \
84 IF_TSAN(V, TSANRelaxedStore64SaveFP) \
85 IF_TSAN(V, TSANSeqCstStore8IgnoreFP) \
86 IF_TSAN(V, TSANSeqCstStore8SaveFP) \
87 IF_TSAN(V, TSANSeqCstStore16IgnoreFP) \
88 IF_TSAN(V, TSANSeqCstStore16SaveFP) \
89 IF_TSAN(V, TSANSeqCstStore32IgnoreFP) \
90 IF_TSAN(V, TSANSeqCstStore32SaveFP) \
91 IF_TSAN(V, TSANSeqCstStore64IgnoreFP) \
92 IF_TSAN(V, TSANSeqCstStore64SaveFP) \
93 IF_TSAN(V, TSANRelaxedLoad32IgnoreFP) \
94 IF_TSAN(V, TSANRelaxedLoad32SaveFP) \
95 IF_TSAN(V, TSANRelaxedLoad64IgnoreFP) \
96 IF_TSAN(V, TSANRelaxedLoad64SaveFP) \
97 V(WasmAllocateArray_Uninitialized) \
99 V(WasmArrayNewSegment) \
100 V(WasmArrayInitSegment) \
101 V(WasmAllocateStructWithRtt) \
102 V(WasmAllocateDescriptorStruct) \
103 V(WasmOnStackReplace) \
105 V(WasmStringNewWtf8) \
106 V(WasmStringNewWtf16) \
108 V(WasmStringMeasureUtf8) \
109 V(WasmStringMeasureWtf8) \
110 V(WasmStringEncodeWtf8) \
111 V(WasmStringEncodeWtf16) \
112 V(WasmStringConcat) \
114 V(WasmStringIsUSVSequence) \
115 V(WasmStringAsWtf16) \
116 V(WasmStringViewWtf16GetCodeUnit) \
117 V(WasmStringCodePointAt) \
118 V(WasmStringViewWtf16Encode) \
119 V(WasmStringViewWtf16Slice) \
120 V(WasmStringNewWtf8Array) \
121 V(WasmStringNewWtf16Array) \
122 V(WasmStringEncodeWtf8Array) \
123 V(WasmStringToUtf8Array) \
124 V(WasmStringEncodeWtf16Array) \
125 V(WasmStringAsWtf8) \
126 V(WasmStringViewWtf8Advance) \
127 V(WasmStringViewWtf8Encode) \
128 V(WasmStringViewWtf8Slice) \
129 V(WasmStringAsIter) \
130 V(WasmStringViewIterNext) \
131 V(WasmStringViewIterAdvance) \
132 V(WasmStringViewIterRewind) \
133 V(WasmStringViewIterSlice) \
136 V(WasmStringFromCodePoint) \
138 V(WasmAnyConvertExtern) \
139 V(WasmStringFromDataSegment) \
140 V(StringAdd_CheckNone) \
141 V(DebugPrintFloat64) \
142 V(DebugPrintWordPtr) \
143 V(WasmFastApiCallTypeCheckAndUpdateIC) \
144 V(DeoptimizationEntry_Eager) \
145 V(WasmLiftoffDeoptFinish) \
146 V(WasmPropagateException) \
147 IF_SHADOW_STACK(V, AdaptShadowStackForDeopt)
151#define WASM_BUILTINS_WITHOUT_JUMP_TABLE_SLOT(V) \
152 V(IterableToFixedArrayForWasm) \
153 V(WasmAllocateInYoungGeneration) \
154 V(WasmAllocateInOldGeneration) \
155 V(WasmAllocateZeroedFixedArray) \
157 V(WasmToJsWrapperInvalidSig) \
159 V(WasmTrapHandlerThrowTrap)
161#define WASM_BUILTIN_LIST(V, VTRAP) \
162 WASM_BUILTINS_WITH_JUMP_TABLE_SLOT(V, VTRAP) \
163 WASM_BUILTINS_WITHOUT_JUMP_TABLE_SLOT(V)
166constexpr std::array<uint8_t, static_cast<int>(Builtin::kFirstBytecodeHandler)>
168 std::array<uint8_t, static_cast<int>(Builtin::kFirstBytecodeHandler)>
170 uint8_t next_index = 0;
171#define DEF_INIT_LOOKUP(NAME) \
172 result[static_cast<int>(Builtin::k##NAME)] = next_index++;
173#define DEF_INIT_LOOKUP_TRAP(NAME) DEF_INIT_LOOKUP(ThrowWasm##NAME)
175#undef DEF_INIT_LOOKUP_TRAP
176#undef DEF_INIT_LOOKUP
198#define BUILTIN_ID(Name) \
199 case Builtin::k##Name: \
201#define BUILTIN_ID_TRAP(Name) \
202 case Builtin::kThrowWasm##Name: \
211#define BUILTIN_COUNTER(NAME) +1
214#undef BUILTIN_COUNTER
218 size_t next_index = 0;
219#define DEF_INIT_LOOKUP(NAME) \
220 if (index == next_index) { \
221 return Builtin::k##NAME; \
224#define DEF_INIT_LOOKUP_TRAP(NAME) DEF_INIT_LOOKUP(ThrowWasm##NAME)
227#undef DEF_INIT_LOOKUP_TRAP
228#undef DEF_INIT_LOOKUP
238#undef WASM_BUILTIN_LIST
239#undef WASM_BUILTINS_WITHOUT_JUMP_TABLE_SLOT
240#undef WASM_BUILTINS_WITH_JUMP_TABLE_SLOT
static constexpr auto kFarJumpTableIndexToBuiltin
static constexpr int JumptableIndexForBuiltin(Builtin builtin)
static constexpr int kBuiltinCount
static constexpr Builtin BuiltinForJumptableIndex(int index)
static bool IsWasmBuiltinId(Builtin id)
static constexpr int BuiltinCount()
static constexpr auto kBuiltinToFarJumpTableIndex
ZoneVector< RpoNumber > & result
constexpr auto make_array(Function f)
constexpr std::array< uint8_t, static_cast< int >(Builtin::kFirstBytecodeHandler)> InitBuiltinToFarJumpTableIndex()
#define DCHECK_EQ(v1, v2)
#define BUILTIN_COUNTER(NAME)
#define WASM_BUILTIN_LIST(V, VTRAP)
#define DEF_INIT_LOOKUP(NAME)
#define DEF_INIT_LOOKUP_TRAP(NAME)
#define BUILTIN_ID_TRAP(Name)
#define WASM_BUILTINS_WITH_JUMP_TABLE_SLOT(V, VTRAP)