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