1 /* 2 * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_COMPILER_BUILTINS_CALL_SIGNATURE_LIST_H 17 #define ECMASCRIPT_COMPILER_BUILTINS_CALL_SIGNATURE_LIST_H 18 19 #include "ecmascript/base/config.h" 20 21 #define PADDING_BUILTINS_STUB_LIST(V) \ 22 V(NONE) 23 24 // BUILTINS_STUB_LIST is shared both ASM Interpreter and AOT. 25 // AOT_BUILTINS_STUB_LIST is used in AOT only. 26 #define BUILTINS_STUB_LIST(V, D, C) \ 27 BUILTINS_METHOD_STUB_LIST(D, D, D, D) \ 28 BUILTINS_CONTAINERS_STUB_BUILDER(D) \ 29 AOT_AND_BUILTINS_STUB_LIST(V) \ 30 BUILTINS_CONSTRUCTOR_STUB_LIST(C) \ 31 BUILTINS_ARKTOOLS_STUB_BUILDER(D) 32 33 #define BUILTINS_NOSTUB_LIST(V) \ 34 V(ObjectConstructor) \ 35 V(GlobalDecodeURIComponent) 36 37 #define BUILTINS_METHOD_STUB_LIST(V, T, D, K) \ 38 BUILTINS_WITH_STRING_STUB_BUILDER(V) \ 39 BUILTINS_WITH_OBJECT_STUB_BUILDER(T) \ 40 BUILTINS_WITH_ARRAY_STUB_BUILDER(V) \ 41 BUILTINS_WITH_SET_STUB_BUILDER(D) \ 42 BUILTINS_WITH_MAP_STUB_BUILDER(D) \ 43 BUILTINS_WITH_FUNCTION_STUB_BUILDER(V) \ 44 BUILTINS_WITH_NUMBER_STUB_BUILDER(T) \ 45 BUILTINS_WITH_TYPEDARRAY_STUB_BUILDER(V) \ 46 BUILTINS_WITH_DATAVIEW_STUB_BUILDER(K) \ 47 BUILTINS_WITH_REFLECT_STUB_BUILDER(T) \ 48 BUILTINS_WITH_COLLATOR_STUB_BUILDER(V) \ 49 BUILTINS_WITH_REGEXP_STUB_BUILDER(V) 50 51 #define BUILTINS_WITH_STRING_STUB_BUILDER(V) \ 52 V(CharAt, String, Hole(), STRING_CHARAT) \ 53 V(FromCharCode, String, Hole(), STRING_FROM_CHAR_CODE) \ 54 V(CharCodeAt, String, Hole(), STRING_CHAR_CODE_AT) \ 55 V(CodePointAt, String, Undefined(), STRING_CODE_POINT_AT) \ 56 V(IndexOf, String, IntToTaggedPtr(Int32(-1)), STRING_INDEX_OF) \ 57 V(Substring, String, IntToTaggedPtr(Int32(-1)), STRING_SUB_STRING) \ 58 V(SubStr, String, Undefined(), STRING_SUB_STR) \ 59 V(Replace, String, Undefined(), STRING_REPLACE) \ 60 V(Trim, String, Undefined(), STRING_TRIM) \ 61 V(TrimStart, String, Undefined(), STRING_TRIM_START) \ 62 V(TrimEnd, String, Undefined(), STRING_TRIM_END) \ 63 V(TrimLeft, String, Undefined(), STRING_TRIM_LEFT) \ 64 V(TrimRight, String, Undefined(), STRING_TRIM_RIGHT) \ 65 V(PadStart, String, Undefined(), STRING_PAD_START) \ 66 V(PadEnd, String, Undefined(), STRING_PAD_END) \ 67 V(Concat, String, Undefined(), STRING_CONCAT) \ 68 V(Slice, String, Undefined(), STRING_SLICE) \ 69 V(ToLowerCase, String, Undefined(), STRING_TO_LOWER_CASE) \ 70 V(StartsWith, String, TaggedFalse(), STRING_STARTS_WITH) \ 71 V(EndsWith, String, TaggedFalse(), STRING_ENDS_WITH) \ 72 V(GetStringIterator, String, Undefined(), STRING_GET_STRING_ITERATOR) 73 74 #define BUILTINS_WITH_OBJECT_STUB_BUILDER(V) \ 75 V(ToStringFunc, Object, Undefined(), OBJECT_TO_STRING_FUNC) \ 76 V(Create, Object, Undefined(), OBJECT_CREATE) \ 77 V(Assign, Object, Undefined(), OBJECT_ASSIGN) \ 78 V(HasOwnProperty, Object, TaggedFalse(), OBJECT_HAS_OWN_PROPERTY) \ 79 V(Keys, Object, Undefined(), OBJECT_KEYS) \ 80 V(GetPrototypeOf, Object, Undefined(), OBJECT_GET_PROTOTYPE_OF) \ 81 V(GetOwnPropertyNames, Object, Undefined(), OBJECT_GET_OWN_PROPERTY_NAMES) \ 82 V(GetOwnPropertySymbols, Object, Undefined(), OBJECT_GET_OWN_PROPERTY_SYMBOLS) \ 83 V(Entries, Object, Undefined(), OBJECT_ENTRIES) \ 84 V(IsFrozen, Object, Undefined(), OBJECT_IS_FROZEN) \ 85 V(IsSealed, Object, Undefined(), OBJECT_IS_SEALED) \ 86 V(GetOwnPropertyDescriptors, Object, Undefined(), OBJECT_GET_OWN_PROPERTY_DESCRIPTORS) \ 87 V(SetPrototypeOf, Object, Undefined(), OBJECT_SET_PROTOTYPE_OF) 88 89 #define BUILTINS_WITH_ARRAY_STUB_BUILDER(V) \ 90 V(With, Array, Undefined(), ARRAY_WITH) \ 91 V(Unshift, Array, Undefined(), ARRAY_UNSHIFT) \ 92 V(Shift, Array, Undefined(), ARRAY_SHIFT) \ 93 V(Concat, Array, Undefined(), ARRAY_CONCAT) \ 94 V(Filter, Array, Undefined(), ARRAY_FILTER) \ 95 V(Find, Array, Undefined(), ARRAY_FIND) \ 96 V(FindIndex, Array, Undefined(), ARRAY_FINDINDEX) \ 97 V(From, Array, Undefined(), ARRAY_FROM) \ 98 V(Splice, Array, Undefined(), ARRAY_SPLICE) \ 99 V(ToSpliced, Array, Undefined(), ARRAY_TO_SPLICED) \ 100 V(ForEach, Array, Undefined(), ARRAY_FOREACH) \ 101 V(IndexOf, Array, Undefined(), ARRAY_INDEXOF) \ 102 V(LastIndexOf, Array, Undefined(), ARRAY_LAST_INDEX_OF) \ 103 V(Pop, Array, Undefined(), ARRAY_POP) \ 104 V(Slice, Array, Undefined(), ARRAY_SLICE) \ 105 V(Reduce, Array, Undefined(), ARRAY_REDUCE) \ 106 V(Reverse, Array, Undefined(), ARRAY_REVERSE) \ 107 V(ToReversed, Array, Undefined(), ARRAY_TO_REVERSED) \ 108 V(Push, Array, Undefined(), ARRAY_PUSH) \ 109 V(Values, Array, Undefined(), ARRAY_VALUES) \ 110 V(Includes, Array, Undefined(), ARRAY_INCLUDES) \ 111 V(CopyWithin, Array, Undefined(), ARRAY_COPY_WITHIN) \ 112 V(Some, Array, Undefined(), ARRAY_SOME) \ 113 V(Fill, Array, Undefined(), ARRAY_FILL) \ 114 V(Every, Array, Undefined(), ARRAY_EVERY) \ 115 V(FindLastIndex, Array, Undefined(), ARRAY_FIND_LAST_INDEX) \ 116 V(FindLast, Array, Undefined(), ARRAY_FIND_LAST) \ 117 V(ReduceRight, Array, Undefined(), ARRAY_REDUCE_RIGHT) \ 118 V(Map, Array, Undefined(), ARRAY_MAP) \ 119 V(FlatMap, Array, Undefined(), ARRAY_FLAT_MAP) \ 120 V(ToSorted, Array, Undefined(), ARRAY_TO_SORTED) \ 121 V(IsArray, Array, Undefined(), ARRAY_IS_ARRAY) 122 123 #define BUILTINS_WITH_SET_STUB_BUILDER(V) \ 124 V(Clear, Set, Undefined(), SET_CLEAR) \ 125 V(Values, Set, Undefined(), SET_VALUES) \ 126 V(Entries, Set, Undefined(), SET_ENTRIES) \ 127 V(ForEach, Set, Undefined(), SET_FOR_EACH) \ 128 V(Add, Set, Undefined(), SET_ADD) \ 129 V(Delete, Set, Undefined(), SET_DELETE) \ 130 V(Has, Set, Undefined(), SET_HAS) 131 132 #define BUILTINS_WITH_MAP_STUB_BUILDER(V) \ 133 V(Clear, Map, Undefined(), MAP_CLEAR) \ 134 V(Values, Map, Undefined(), MAP_VALUES) \ 135 V(Entries, Map, Undefined(), MAP_ENTRIES) \ 136 V(Keys, Map, Undefined(), MAP_KEYS) \ 137 V(ForEach, Map, Undefined(), MAP_FOR_EACH) \ 138 V(Set, Map, Undefined(), MAP_SET) \ 139 V(Delete, Map, Undefined(), MAP_DELETE) \ 140 V(Has, Map, Undefined(), MAP_HAS) \ 141 V(Get, Map, Undefined(), MAP_GET) 142 143 #define BUILTINS_WITH_FUNCTION_STUB_BUILDER(V) \ 144 V(PrototypeApply, Function, Undefined(), FUNCTION_PROTOTYPE_APPLY) \ 145 V(PrototypeBind, Function, Undefined(), FUNCTION_PROTOTYPE_BIND) \ 146 V(PrototypeCall, Function, Undefined(), FUNCTION_PROTOTYPE_CALL) 147 148 #define BUILTINS_WITH_NUMBER_STUB_BUILDER(V) \ 149 V(ParseFloat, Number, Undefined(), NUMBER_PARSE_FLOAT) \ 150 V(ParseInt, Number, Undefined(), NUMBER_PARSE_INT) \ 151 V(IsFinite, Number, Undefined(), NUMBER_IS_FINITE) \ 152 V(IsNaN, Number, Undefined(), NUMBER_IS_NAN) \ 153 V(IsInteger, Number, Undefined(), NUMBER_IS_INTEGER) \ 154 V(IsSafeInteger, Number, Undefined(), NUMBER_IS_SAFEINTEGER) \ 155 V(ToStringFunc, Number, Undefined(), NUMBER_TO_STRING_FUNC) 156 157 #define BUILTINS_WITH_REFLECT_STUB_BUILDER(V) \ 158 V(Get, Reflect, Undefined(), REFLECT_GET) 159 160 #define BUILTINS_WITH_COLLATOR_STUB_BUILDER(V) \ 161 V(ResolvedOptions, Collator, Undefined(), COLLATOR_RESOLVED_OPTIONS) 162 163 #define BUILTINS_WITH_REGEXP_STUB_BUILDER(V) \ 164 V(GetFlags, RegExp, Undefined(), REGEXP_GET_FLAGS) 165 166 #define BUILTINS_WITH_TYPEDARRAY_STUB_BUILDER(V) \ 167 V(Reverse, TypedArray, Undefined(), TYPED_ARRAY_REVERSE) \ 168 V(LastIndexOf, TypedArray, Undefined(), TYPED_ARRAY_LAST_INDEX_OF) \ 169 V(IndexOf, TypedArray, Undefined(), TYPED_ARRAY_INDEX_OF) \ 170 V(Find, TypedArray, Undefined(), TYPED_ARRAY_FIND) \ 171 V(Includes, TypedArray, Undefined(), TYPED_ARRAY_INCLUDES) \ 172 V(CopyWithin, TypedArray, Undefined(), TYPED_ARRAY_COPY_WITHIN) \ 173 V(ReduceRight, TypedArray, Undefined(), TYPED_ARRAY_REDUCE_RIGHT) \ 174 V(Reduce, TypedArray, Undefined(), TYPED_ARRAY_REDUCE) \ 175 V(Every, TypedArray, Undefined(), TYPED_ARRAY_EVERY) \ 176 V(Some, TypedArray, Undefined(), TYPED_ARRAY_SOME) \ 177 V(Filter, TypedArray, Undefined(), TYPED_ARRAY_FILTER) \ 178 V(With, TypedArray, Undefined(), TYPED_ARRAY_WITH) \ 179 V(Entries, TypedArray, Undefined(), TYPED_ARRAY_ENTRIES) \ 180 V(Keys, TypedArray, Undefined(), TYPED_ARRAY_KEYS) \ 181 V(Values, TypedArray, Undefined(), TYPED_ARRAY_VALUES) \ 182 V(Slice, TypedArray, Undefined(), TYPED_ARRAY_SLICE) \ 183 V(SubArray, TypedArray, Undefined(), TYPED_ARRAY_SUB_ARRAY) \ 184 V(Sort, TypedArray, Undefined(), TYPED_ARRAY_SORT) \ 185 V(Set, TypedArray, Undefined(), TYPED_ARRAY_SET) \ 186 V(FindIndex, TypedArray, Undefined(), TYPED_ARRAY_FIND_INDEX) \ 187 V(FindLastIndex, TypedArray, Undefined(), TYPED_ARRAY_FIND_LAST_INDEX) \ 188 V(ToSorted, TypedArray, Undefined(), TYPED_ARRAY_TO_SORTED) \ 189 V(Map, TypedArray, Undefined(), TYPED_ARRAY_MAP) \ 190 V(ToReversed, TypedArray, Undefined(), TYPED_ARRAY_TO_REVERSED) 191 192 #define BUILTINS_WITH_DATAVIEW_STUB_BUILDER(V) \ 193 V(SetInt32, DataView, INT32, SetTypedValue, Undefined(), DATA_VIEW_SET_INT32) \ 194 V(SetFloat32, DataView, FLOAT32, SetTypedValue, Undefined(), DATA_VIEW_SET_FLOAT32) \ 195 V(SetFloat64, DataView, FLOAT64, SetTypedValue, Undefined(), DATA_VIEW_SET_FLOAT64) 196 197 #define BUILTINS_CONTAINERS_STUB_BUILDER(V) \ 198 BUILTINS_WITH_CONTAINERS_ARRAYLIST_STUB_BUILDER(V) \ 199 BUILTINS_WITH_CONTAINERS_QUEUE_STUB_BUILDER(V) \ 200 BUILTINS_WITH_CONTAINERS_DEQUE_STUB_BUILDER(V) \ 201 BUILTINS_WITH_CONTAINERS_HASHMAP_STUB_BUILDER(V) \ 202 BUILTINS_WITH_CONTAINERS_HASHSET_STUB_BUILDER(V) \ 203 BUILTINS_WITH_CONTAINERS_LIGHTWEIGHTMAP_STUB_BUILDER(V) \ 204 BUILTINS_WITH_CONTAINERS_LIGHTWEIGHTSET_STUB_BUILDER(V) \ 205 BUILTINS_WITH_CONTAINERS_LINKEDLIST_STUB_BUILDER(V) \ 206 BUILTINS_WITH_CONTAINERS_LIST_STUB_BUILDER(V) \ 207 BUILTINS_WITH_CONTAINERS_PLAINARRAY_STUB_BUILDER(V) \ 208 BUILTINS_WITH_CONTAINERS_STACK_STUB_BUILDER(V) \ 209 BUILTINS_WITH_CONTAINERS_VECTOR_STUB_BUILDER(V) 210 211 #define BUILTINS_WITH_CONTAINERS_ARRAYLIST_STUB_BUILDER(V) \ 212 V(ForEach, ArrayList, Undefined()) \ 213 V(ReplaceAllElements, ArrayList, Undefined()) 214 215 #define BUILTINS_WITH_CONTAINERS_QUEUE_STUB_BUILDER(V) \ 216 V(ForEach, Queue, Undefined()) 217 218 #define BUILTINS_WITH_CONTAINERS_DEQUE_STUB_BUILDER(V) \ 219 V(ForEach, Deque, Undefined()) 220 221 #define BUILTINS_WITH_CONTAINERS_HASHMAP_STUB_BUILDER(V) \ 222 V(ForEach, HashMap, Undefined()) 223 224 #define BUILTINS_WITH_CONTAINERS_HASHSET_STUB_BUILDER(V) \ 225 V(ForEach, HashSet, Undefined()) 226 227 #define BUILTINS_WITH_CONTAINERS_LIGHTWEIGHTMAP_STUB_BUILDER(V) \ 228 V(ForEach, LightWeightMap, Undefined()) 229 230 #define BUILTINS_WITH_CONTAINERS_LIGHTWEIGHTSET_STUB_BUILDER(V) \ 231 V(ForEach, LightWeightSet, Undefined()) 232 233 #define BUILTINS_WITH_CONTAINERS_LINKEDLIST_STUB_BUILDER(V) \ 234 V(ForEach, LinkedList, Undefined()) 235 236 #define BUILTINS_WITH_CONTAINERS_LIST_STUB_BUILDER(V) \ 237 V(ForEach, List, Undefined()) 238 239 #define BUILTINS_WITH_CONTAINERS_PLAINARRAY_STUB_BUILDER(V) \ 240 V(ForEach, PlainArray, Undefined()) 241 242 #define BUILTINS_WITH_CONTAINERS_STACK_STUB_BUILDER(V) \ 243 V(ForEach, Stack, Undefined()) 244 245 #define BUILTINS_WITH_CONTAINERS_VECTOR_STUB_BUILDER(V) \ 246 V(ForEach, Vector, Undefined()) \ 247 V(ReplaceAllElements, Vector, Undefined()) 248 249 #define BUILTINS_ARKTOOLS_STUB_BUILDER(V) \ 250 V(HashCode, ArkTools, Undefined()) 251 252 #define BUILTINS_CONSTRUCTOR_STUB_LIST(V) \ 253 V(BooleanConstructor) \ 254 V(NumberConstructor) \ 255 V(ProxyConstructor) \ 256 V(DateConstructor) \ 257 V(ArrayConstructor) \ 258 V(SetConstructor) \ 259 V(MapConstructor) \ 260 V(Int8ArrayConstructor) \ 261 V(Uint8ArrayConstructor) \ 262 V(Uint8ClampedArrayConstructor) \ 263 V(Int16ArrayConstructor) \ 264 V(Uint16ArrayConstructor) \ 265 V(Int32ArrayConstructor) \ 266 V(Uint32ArrayConstructor) \ 267 V(Float32ArrayConstructor) \ 268 V(Float64ArrayConstructor) \ 269 V(BigInt64ArrayConstructor) \ 270 V(BigUint64ArrayConstructor) 271 272 // NEXT_AOT_AND_BUILTINS_STUB_LIST: List of functions that is optimized for Next 273 #if ENABLE_NEXT_OPTIMIZATION 274 #define NEXT_AOT_AND_BUILTINS_STUB_LIST(V) \ 275 V(ArrayIteratorProtoNext) \ 276 V(MapIteratorProtoNext) \ 277 V(SetIteratorProtoNext) 278 #define NEXT_AOT_BUILTINS_STUB_LIST(V) 279 #else 280 #define NEXT_AOT_AND_BUILTINS_STUB_LIST(V) 281 #define NEXT_AOT_BUILTINS_STUB_LIST(V) \ 282 V(ArrayIteratorProtoNext) \ 283 V(MapIteratorProtoNext) \ 284 V(SetIteratorProtoNext) 285 #endif 286 287 #define AOT_AND_BUILTINS_STUB_LIST(V) \ 288 V(StringLocaleCompare) \ 289 V(StringIteratorProtoNext) \ 290 V(ArraySort) \ 291 NEXT_AOT_AND_BUILTINS_STUB_LIST(V) 292 293 #define AOT_BUILTINS_STUB_LIST(V) \ 294 V(JsonStringify) \ 295 V(MapProtoIterator) \ 296 V(SetProtoIterator) \ 297 V(StringProtoIterator) \ 298 V(ArrayProtoIterator) \ 299 V(TypeArrayProtoIterator) \ 300 V(IteratorProtoReturn) \ 301 NEXT_AOT_BUILTINS_STUB_LIST(V) 302 303 // List of builtins which will try to be inlined in TypedNativeInlineLoweringPass 304 #define AOT_BUILTINS_INLINE_LIST(V) \ 305 V(MathAcos) \ 306 V(MathAcosh) \ 307 V(MathAsin) \ 308 V(MathAsinh) \ 309 V(MathAtan) \ 310 V(MathAtan2) \ 311 V(MathAtanh) \ 312 V(MathCos) \ 313 V(MathCosh) \ 314 V(MathSign) \ 315 V(MathSin) \ 316 V(MathSinh) \ 317 V(MathSqrt) \ 318 V(MathTan) \ 319 V(MathCbrt) \ 320 V(MathTanh) \ 321 V(MathLog) \ 322 V(MathLog2) \ 323 V(MathLog10) \ 324 V(MathLog1p) \ 325 V(MathExp) \ 326 V(MathExpm1) \ 327 V(MathClz32) \ 328 V(MathPow) \ 329 V(MathTrunc) \ 330 V(MathCeil) \ 331 V(MathFloor) \ 332 V(MathAbs) \ 333 V(MathRound) \ 334 V(MathFRound) \ 335 V(MathMin) \ 336 V(MathMax) \ 337 V(MathImul) \ 338 V(DateGetTime) \ 339 V(DateNow) \ 340 V(GlobalIsFinite) \ 341 V(GlobalIsNan) \ 342 V(BigIntConstructor) \ 343 V(ArrayBufferIsView) \ 344 V(BigIntAsIntN) \ 345 V(BigIntAsUintN) \ 346 V(DataViewGetFloat32) \ 347 V(DataViewGetFloat64) \ 348 V(DataViewGetInt8) \ 349 V(DataViewGetInt16) \ 350 V(DataViewGetInt32) \ 351 V(DataViewGetUint16) \ 352 V(DataViewGetUint32) \ 353 V(DataViewGetUint8) \ 354 V(DataViewSetInt8) \ 355 V(DataViewSetInt16) \ 356 V(DataViewSetUint8) \ 357 V(DataViewSetUint16) \ 358 V(DataViewSetUint32) \ 359 V(ObjectIs) \ 360 V(ObjectGetProto) \ 361 V(ObjectIsPrototypeOf) \ 362 V(ReflectGetPrototypeOf) \ 363 V(ReflectHas) \ 364 V(ReflectConstruct) \ 365 V(ReflectApply) \ 366 V(FunctionPrototypeHasInstance) \ 367 V(ArrayKeys) \ 368 V(ArrayEntries) \ 369 V(TYPED_BUILTINS_INLINE_FIRST = MathAcos) \ 370 V(TYPED_BUILTINS_INLINE_LAST = ArrayEntries) 371 372 #endif // ECMASCRIPT_COMPILER_BUILTINS_CALL_SIGNATURE_LIST_H 373