Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / js / src / jit / ABIFunctionList-inl.h
blobf8a52beeff0101437e37788482e621f57f05d748
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jit_ABIFunctionList_inl_h
8 #define jit_ABIFunctionList_inl_h
10 #include "mozilla/SIMD.h" // mozilla::SIMD::memchr{,2x}{8,16}
12 #include "jslibmath.h" // js::NumberMod
13 #include "jsmath.h" // js::ecmaPow, js::ecmaHypot, js::hypot3, js::hypot4,
14 // js::ecmaAtan2, js::UnaryMathFunctionType, js::powi
15 #include "jsnum.h" // js::StringToNumberPure, js::Int32ToStringPure,
16 // js::NumberToStringPure
18 #include "builtin/Array.h" // js::ArrayShiftMoveElements
19 #include "builtin/MapObject.h" // js::MapIteratorObject::next,
20 // js::SetIteratorObject::next
21 #include "builtin/Object.h" // js::ObjectClassToString
22 #include "builtin/RegExp.h" // js::RegExpPrototypeOptimizableRaw,
23 // js::RegExpInstanceOptimizableRaw
24 #include "builtin/TestingFunctions.h" // js::FuzzilliHash*
26 #include "irregexp/RegExpAPI.h"
27 // js::irregexp::CaseInsensitiveCompareNonUnicode,
28 // js::irregexp::CaseInsensitiveCompareUnicode,
29 // js::irregexp::GrowBacktrackStack,
30 // js::irregexp::IsCharacterInRangeArray
32 #include "jit/ABIFunctions.h"
33 #include "jit/Bailouts.h" // js::jit::FinishBailoutToBaseline, js::jit::Bailout,
34 // js::jit::InvalidationBailout
36 #include "jit/Ion.h" // js::jit::LazyLinkTopActivation
37 #include "jit/JitFrames.h" // HandleException
38 #include "jit/VMFunctions.h" // Rest of js::jit::* functions.
40 #include "js/CallArgs.h" // JSNative
41 #include "js/Conversions.h" // JS::ToInt32
42 // JSJitGetterOp, JSJitSetterOp, JSJitMethodOp
43 #include "js/experimental/JitInfo.h"
44 #include "js/Utility.h" // js_free
46 #include "proxy/Proxy.h" // js::ProxyGetProperty
48 #include "vm/ArgumentsObject.h" // js::ArgumentsObject::finishForIonPure
49 #include "vm/Interpreter.h" // js::TypeOfObject
50 #include "vm/NativeObject.h" // js::NativeObject
51 #include "vm/RegExpShared.h" // js::ExecuteRegExpAtomRaw
52 #include "wasm/WasmBuiltins.h" // js::wasm::*
54 #include "builtin/Boolean-inl.h" // js::EmulatesUndefined
56 namespace js {
58 namespace wasm {
60 class AnyRef;
62 } // namespace wasm
64 namespace jit {
66 // List of all ABI functions to be used with callWithABI. Each entry stores
67 // the fully qualified name of the C++ function. This list must be sorted.
68 #if JS_GC_PROBES
69 # define ABIFUNCTION_JS_GC_PROBES_LIST(_) _(js::jit::TraceCreateObject)
70 #else
71 # define ABIFUNCTION_JS_GC_PROBES_LIST(_)
72 #endif
74 #if defined(JS_CODEGEN_ARM)
75 # define ABIFUNCTION_JS_CODEGEN_ARM_LIST(_) \
76 _(__aeabi_idivmod) \
77 _(__aeabi_uidivmod)
78 #else
79 # define ABIFUNCTION_JS_CODEGEN_ARM_LIST(_)
80 #endif
82 #ifdef WASM_CODEGEN_DEBUG
83 # define ABIFUNCTION_WASM_CODEGEN_DEBUG_LIST(_) \
84 _(js::wasm::PrintF32) \
85 _(js::wasm::PrintF64) \
86 _(js::wasm::PrintI32) \
87 _(js::wasm::PrintPtr) \
88 _(js::wasm::PrintText)
89 #else
90 # define ABIFUNCTION_WASM_CODEGEN_DEBUG_LIST(_)
91 #endif
93 #ifdef FUZZING_JS_FUZZILLI
94 # define ABIFUNCTION_FUZZILLI_LIST(_) _(js::FuzzilliHashBigInt)
95 #else
96 # define ABIFUNCTION_FUZZILLI_LIST(_)
97 #endif
99 #define ABIFUNCTION_LIST(_) \
100 ABIFUNCTION_JS_GC_PROBES_LIST(_) \
101 ABIFUNCTION_JS_CODEGEN_ARM_LIST(_) \
102 ABIFUNCTION_WASM_CODEGEN_DEBUG_LIST(_) \
103 _(js::ArgumentsObject::finishForIonPure) \
104 _(js::ArgumentsObject::finishInlineForIonPure) \
105 _(js::ArrayShiftMoveElements) \
106 _(js::ecmaAtan2) \
107 _(js::ecmaHypot) \
108 _(js::ecmaPow) \
109 _(js::EmulatesUndefined) \
110 _(js::EmulatesUndefinedCheckFuse) \
111 _(js::ExecuteRegExpAtomRaw) \
112 _(js_free) \
113 _(js::hypot3) \
114 _(js::hypot4) \
115 _(js::Interpret) \
116 _(js::Int32ToStringPure) \
117 _(js::irregexp::CaseInsensitiveCompareNonUnicode) \
118 _(js::irregexp::CaseInsensitiveCompareUnicode) \
119 _(js::irregexp::GrowBacktrackStack) \
120 _(js::irregexp::IsCharacterInRangeArray) \
121 _(js::jit::AllocateAndInitTypedArrayBuffer) \
122 _(js::jit::AllocateBigIntNoGC) \
123 _(js::jit::AllocateFatInlineString) \
124 _(js::jit::AllocateDependentString) \
125 _(js::jit::AssertMapObjectHash) \
126 _(js::jit::AssertPropertyLookup) \
127 _(js::jit::AssertSetObjectHash) \
128 _(js::jit::AssertValidBigIntPtr) \
129 _(js::jit::AssertValidObjectPtr) \
130 _(js::jit::AssertValidStringPtr) \
131 _(js::jit::AssertValidSymbolPtr) \
132 _(js::jit::AssertValidValue) \
133 _(js::jit::AssumeUnreachable) \
134 _(js::jit::AtomicsStore64) \
135 _(js::jit::AtomizeStringNoGC) \
136 _(js::jit::Bailout) \
137 _(js::jit::BigIntNumberEqual<EqualityKind::Equal>) \
138 _(js::jit::BigIntNumberEqual<EqualityKind::NotEqual>) \
139 _(js::jit::BigIntNumberCompare<ComparisonKind::LessThan>) \
140 _(js::jit::NumberBigIntCompare<ComparisonKind::LessThan>) \
141 _(js::jit::NumberBigIntCompare<ComparisonKind::GreaterThanOrEqual>) \
142 _(js::jit::BigIntNumberCompare<ComparisonKind::GreaterThanOrEqual>) \
143 _(js::jit::EqualStringsHelperPure) \
144 _(js::jit::FinishBailoutToBaseline) \
145 _(js::jit::FrameIsDebuggeeCheck) \
146 _(js::jit::GetContextSensitiveInterpreterStub) \
147 _(js::jit::GetIndexFromString) \
148 _(js::jit::GetInt32FromStringPure) \
149 _(js::jit::GetNativeDataPropertyPure) \
150 _(js::jit::GetNativeDataPropertyPureWithCacheLookup) \
151 _(js::jit::GetNativeDataPropertyByValuePure) \
152 _(js::jit::GlobalHasLiveOnDebuggerStatement) \
153 _(js::jit::HandleCodeCoverageAtPC) \
154 _(js::jit::HandleCodeCoverageAtPrologue) \
155 _(js::jit::HandleException) \
156 _(js::jit::HasNativeDataPropertyPure<false>) \
157 _(js::jit::HasNativeDataPropertyPure<true>) \
158 _(js::jit::HasNativeElementPure) \
159 _(js::jit::InitBaselineFrameForOsr) \
160 _(js::jit::InvalidationBailout) \
161 _(js::jit::InvokeFromInterpreterStub) \
162 _(js::jit::LazyLinkTopActivation) \
163 _(js::jit::LinearizeForCharAccessPure) \
164 _(js::jit::ObjectHasGetterSetterPure) \
165 _(js::jit::ObjectIsCallable) \
166 _(js::jit::ObjectIsConstructor) \
167 _(js::jit::PostGlobalWriteBarrier) \
168 _(js::jit::PostWriteBarrier) \
169 _(js::jit::PostWriteElementBarrier) \
170 _(js::jit::Printf0) \
171 _(js::jit::Printf1) \
172 _(js::jit::StringFromCharCodeNoGC) \
173 _(js::jit::StringTrimEndIndex) \
174 _(js::jit::StringTrimStartIndex) \
175 _(js::jit::TypeOfNameObject) \
176 _(js::jit::WrapObjectPure) \
177 ABIFUNCTION_FUZZILLI_LIST(_) \
178 _(js::MapIteratorObject::next) \
179 _(js::NativeObject::addDenseElementPure) \
180 _(js::NativeObject::growSlotsPure) \
181 _(js::NumberMod) \
182 _(js::NumberToStringPure) \
183 _(js::ObjectClassToString) \
184 _(js::powi) \
185 _(js::ProxyGetProperty) \
186 _(js::RegExpInstanceOptimizableRaw) \
187 _(js::RegExpPrototypeOptimizableRaw) \
188 _(js::SetIteratorObject::next) \
189 _(js::StringToNumberPure) \
190 _(js::TypeOfObject) \
191 _(mozilla::SIMD::memchr16) \
192 _(mozilla::SIMD::memchr2x16) \
193 _(mozilla::SIMD::memchr2x8) \
194 _(mozilla::SIMD::memchr8)
196 // List of all ABI functions to be used with callWithABI, which are
197 // overloaded. Each entry stores the fully qualified name of the C++ function,
198 // followed by the signature of the function to be called. When the function
199 // is not overloaded, you should prefer adding the function to
200 // ABIFUNCTION_LIST instead. This list must be sorted with the name of the C++
201 // function.
202 #define ABIFUNCTION_AND_TYPE_LIST(_) _(JS::ToInt32, int32_t (*)(double))
204 // List of all ABI function signature which are using a computed function
205 // pointer instead of a statically known function pointer.
206 #define ABIFUNCTIONSIG_LIST(_) \
207 _(AtomicsCompareExchangeFn) \
208 _(AtomicsReadWriteModifyFn) \
209 _(bool (*)(BigInt*, BigInt*)) \
210 _(bool (*)(BigInt*, double)) \
211 _(bool (*)(double, BigInt*)) \
212 _(float (*)(float)) \
213 _(JSJitGetterOp) \
214 _(JSJitMethodOp) \
215 _(JSJitSetterOp) \
216 _(JSNative) \
217 _(js::UnaryMathFunctionType) \
218 _(void (*)(js::gc::StoreBuffer*, js::gc::Cell**)) \
219 _(void (*)(JSRuntime * rt, JSObject * *objp)) \
220 _(void (*)(JSRuntime * rt, JSString * *stringp)) \
221 _(void (*)(JSRuntime * rt, Shape * *shapep)) \
222 _(void (*)(JSRuntime * rt, wasm::AnyRef * refp)) \
223 _(void (*)(JSRuntime * rt, Value * vp))
225 // GCC warns when the signature does not have matching attributes (for example
226 // [[nodiscard]]). Squelch this warning to avoid a GCC-only footgun.
227 #if MOZ_IS_GCC
228 # pragma GCC diagnostic push
229 # pragma GCC diagnostic ignored "-Wignored-attributes"
230 #endif
232 // Note: the use of ::fp instead of fp is intentional to enforce use of
233 // fully-qualified names in the list above.
234 #define DEF_TEMPLATE(fp) \
235 template <> \
236 struct ABIFunctionData<decltype(&(::fp)), ::fp> { \
237 static constexpr bool registered = true; \
239 ABIFUNCTION_LIST(DEF_TEMPLATE)
240 #undef DEF_TEMPLATE
242 #define DEF_TEMPLATE(fp, ...) \
243 template <> \
244 struct ABIFunctionData<__VA_ARGS__, ::fp> { \
245 static constexpr bool registered = true; \
247 ABIFUNCTION_AND_TYPE_LIST(DEF_TEMPLATE)
248 #undef DEF_TEMPLATE
250 // Define a known list of function signatures.
251 #define DEF_TEMPLATE(...) \
252 template <> \
253 struct ABIFunctionSignatureData<__VA_ARGS__> { \
254 static constexpr bool registered = true; \
256 ABIFUNCTIONSIG_LIST(DEF_TEMPLATE)
257 #undef DEF_TEMPLATE
259 #if MOZ_IS_GCC
260 # pragma GCC diagnostic pop
261 #endif
263 } // namespace jit
264 } // namespace js
266 #endif // jit_VMFunctionList_inl_h