1 /* 2 * Copyright (c) 2022 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_BC_CALL_SIGNATURE_H 17 #define ECMASCRIPT_COMPILER_BC_CALL_SIGNATURE_H 18 19 #include "ecmascript/base/config.h" 20 #include "ecmascript/compiler/rt_call_signature.h" 21 22 namespace panda::ecmascript::kungfu { 23 #define IGNORE_BC_STUB(...) 24 #define ASM_UNUSED_BC_STUB_LIST(T) \ 25 T(HandleOverflowD8) \ 26 T(HandleOverflowD9) \ 27 T(HandleOverflowDA) \ 28 T(HandleOverflowDB) \ 29 T(HandleOverflowDC) \ 30 T(HandleOverflowDD) \ 31 T(HandleOverflowDE) \ 32 T(HandleOverflowDF) \ 33 T(HandleOverflowE0) \ 34 T(HandleOverflowE1) \ 35 T(HandleOverflowE2) \ 36 T(HandleOverflowE3) \ 37 T(HandleOverflowE4) \ 38 T(HandleOverflowE5) \ 39 T(HandleOverflowE6) \ 40 T(HandleOverflowE7) \ 41 T(HandleOverflowE8) \ 42 T(HandleOverflowE9) \ 43 T(HandleOverflowEA) \ 44 T(HandleOverflowEB) \ 45 T(HandleOverflowEC) \ 46 T(HandleOverflowED) \ 47 T(HandleOverflowEE) \ 48 T(HandleOverflowEF) \ 49 T(HandleOverflowF0) \ 50 T(HandleOverflowF1) \ 51 T(HandleOverflowF2) \ 52 T(HandleOverflowF3) \ 53 T(HandleOverflowF4) \ 54 T(HandleOverflowF5) \ 55 T(HandleOverflowF6) \ 56 T(HandleOverflowF7) \ 57 T(HandleOverflowF8) \ 58 T(HandleOverflowF9) \ 59 T(HandleOverflowFA) \ 60 61 62 // V: Not Enabled, T: Enabled, D: Always Disable SingleStepDebugging 63 #define ASM_INTERPRETER_BC_STUB_LIST(V, T, D) \ 64 T(HandleLdundefined) \ 65 T(HandleLdnull) \ 66 T(HandleLdtrue) \ 67 T(HandleLdfalse) \ 68 T(HandleCreateemptyobject) \ 69 T(HandleCreateemptyarrayImm8) \ 70 T(HandleCreatearraywithbufferImm8Id16) \ 71 T(HandleCreateobjectwithbufferImm8Id16) \ 72 T(HandleNewobjrangeImm8Imm8V8) \ 73 T(HandleNewlexenvImm8) \ 74 T(HandleAdd2Imm8V8) \ 75 T(HandleSub2Imm8V8) \ 76 T(HandleMul2Imm8V8) \ 77 T(HandleDiv2Imm8V8) \ 78 T(HandleMod2Imm8V8) \ 79 T(HandleEqImm8V8) \ 80 T(HandleNoteqImm8V8) \ 81 T(HandleLessImm8V8) \ 82 T(HandleLesseqImm8V8) \ 83 T(HandleGreaterImm8V8) \ 84 T(HandleGreatereqImm8V8) \ 85 T(HandleShl2Imm8V8) \ 86 T(HandleShr2Imm8V8) \ 87 T(HandleAshr2Imm8V8) \ 88 T(HandleAnd2Imm8V8) \ 89 T(HandleOr2Imm8V8) \ 90 T(HandleXor2Imm8V8) \ 91 T(HandleExpImm8V8) \ 92 T(HandleTypeofImm8) \ 93 T(HandleTonumberImm8) \ 94 T(HandleTonumericImm8) \ 95 T(HandleNegImm8) \ 96 T(HandleNotImm8) \ 97 T(HandleIncImm8) \ 98 T(HandleDecImm8) \ 99 T(HandleIstrue) \ 100 T(HandleIsfalse) \ 101 T(HandleIsinImm8V8) \ 102 T(HandleInstanceofImm8V8) \ 103 T(HandleStrictnoteqImm8V8) \ 104 T(HandleStricteqImm8V8) \ 105 D(HandleCallarg0Imm8) \ 106 D(HandleCallarg1Imm8V8) \ 107 D(HandleCallargs2Imm8V8V8) \ 108 D(HandleCallargs3Imm8V8V8V8) \ 109 D(HandleCallthis0Imm8V8) \ 110 D(HandleCallthis1Imm8V8V8) \ 111 D(HandleCallthis2Imm8V8V8V8) \ 112 D(HandleCallthis3Imm8V8V8V8V8) \ 113 D(HandleCallthisrangeImm8Imm8V8) \ 114 T(HandleSupercallthisrangeImm8Imm8V8) \ 115 T(HandleDefinefuncImm8Id16Imm8) \ 116 T(HandleDefinemethodImm8Id16Imm8) \ 117 T(HandleDefineclasswithbufferImm8Id16Id16Imm16V8) \ 118 T(HandleGetnextpropnameV8) \ 119 T(HandleLdobjbyvalueImm8V8) \ 120 T(HandleStobjbyvalueImm8V8V8) \ 121 T(HandleLdsuperbyvalueImm8V8) \ 122 T(HandleLdobjbyindexImm8Imm16) \ 123 T(HandleStobjbyindexImm8V8Imm16) \ 124 T(HandleLdlexvarImm4Imm4) \ 125 T(HandleStlexvarImm4Imm4) \ 126 T(HandleLdaStrId16) \ 127 T(HandleTryldglobalbynameImm8Id16) \ 128 T(HandleTrystglobalbynameImm8Id16) \ 129 T(HandleLdglobalvarImm16Id16) \ 130 T(HandleLdobjbynameImm8Id16) \ 131 T(HandleStobjbynameImm8Id16V8) \ 132 T(HandleMovV4V4) \ 133 T(HandleMovV8V8) \ 134 T(HandleLdsuperbynameImm8Id16) \ 135 T(HandleStconsttoglobalrecordImm16Id16) \ 136 T(HandleSttoglobalrecordImm16Id16) \ 137 T(HandleLdthisbynameImm8Id16) \ 138 T(HandleStthisbynameImm8Id16) \ 139 T(HandleLdthisbyvalueImm8) \ 140 T(HandleStthisbyvalueImm8V8) \ 141 T(HandleJmpImm8) \ 142 T(HandleJmpImm16) \ 143 T(HandleJeqzImm8) \ 144 T(HandleJeqzImm16) \ 145 T(HandleJnezImm8) \ 146 T(HandleJstricteqzImm8) \ 147 T(HandleJnstricteqzImm8) \ 148 T(HandleJeqnullImm8) \ 149 T(HandleJnenullImm8) \ 150 T(HandleJstricteqnullImm8) \ 151 T(HandleJnstricteqnullImm8) \ 152 T(HandleJequndefinedImm8) \ 153 T(HandleJneundefinedImm8) \ 154 T(HandleJstrictequndefinedImm8) \ 155 T(HandleJnstrictequndefinedImm8) \ 156 T(HandleJeqV8Imm8) \ 157 T(HandleJneV8Imm8) \ 158 T(HandleJstricteqV8Imm8) \ 159 T(HandleJnstricteqV8Imm8) \ 160 T(HandleLdaV8) \ 161 T(HandleStaV8) \ 162 T(HandleLdaiImm32) \ 163 T(HandleFldaiImm64) \ 164 T(HandleReturn) \ 165 T(HandleReturnundefined) \ 166 T(HandleGetpropiterator) \ 167 T(HandleGetiteratorImm8) \ 168 T(HandleCloseiteratorImm8V8) \ 169 T(HandlePoplexenv) \ 170 T(HandleLdnan) \ 171 T(HandleLdinfinity) \ 172 T(HandleGetunmappedargs) \ 173 T(HandleLdglobal) \ 174 T(HandleLdnewtarget) \ 175 T(HandleLdthis) \ 176 T(HandleLdhole) \ 177 T(HandleCreateregexpwithliteralImm8Id16Imm8) \ 178 T(HandleCreateregexpwithliteralImm16Id16Imm8) \ 179 D(HandleCallrangeImm8Imm8V8) \ 180 T(HandleDefinefuncImm16Id16Imm8) \ 181 T(HandleDefineclasswithbufferImm16Id16Id16Imm16V8) \ 182 T(HandleGettemplateobjectImm8) \ 183 T(HandleSetobjectwithprotoImm8V8) \ 184 T(HandleStownbyvalueImm8V8V8) \ 185 T(HandleStownbyindexImm8V8Imm16) \ 186 T(HandleStownbynameImm8Id16V8) \ 187 T(HandleGetmodulenamespaceImm8) \ 188 T(HandleStmodulevarImm8) \ 189 T(HandleLdlocalmodulevarImm8) \ 190 T(HandleLdexternalmodulevarImm8) \ 191 T(HandleStglobalvarImm16Id16) \ 192 T(HandleCreateemptyarrayImm16) \ 193 T(HandleCreatearraywithbufferImm16Id16) \ 194 T(HandleCreateobjectwithbufferImm16Id16) \ 195 T(HandleNewobjrangeImm16Imm8V8) \ 196 T(HandleTypeofImm16) \ 197 T(HandleLdobjbyvalueImm16V8) \ 198 T(HandleStobjbyvalueImm16V8V8) \ 199 T(HandleLdsuperbyvalueImm16V8) \ 200 T(HandleLdobjbyindexImm16Imm16) \ 201 T(HandleStobjbyindexImm16V8Imm16) \ 202 T(HandleLdlexvarImm8Imm8) \ 203 T(HandleStlexvarImm8Imm8) \ 204 T(HandleTryldglobalbynameImm16Id16) \ 205 T(HandleTrystglobalbynameImm16Id16) \ 206 T(HandleStownbynamewithnamesetImm8Id16V8) \ 207 T(HandleMovV16V16) \ 208 T(HandleLdobjbynameImm16Id16) \ 209 T(HandleStobjbynameImm16Id16V8) \ 210 T(HandleLdsuperbynameImm16Id16) \ 211 T(HandleLdthisbynameImm16Id16) \ 212 T(HandleStthisbynameImm16Id16) \ 213 T(HandleLdthisbyvalueImm16) \ 214 T(HandleStthisbyvalueImm16V8) \ 215 T(HandleAsyncgeneratorrejectV8) \ 216 T(HandleJmpImm32) \ 217 T(HandleStownbyvaluewithnamesetImm8V8V8) \ 218 T(HandleJeqzImm32) \ 219 T(HandleJnezImm16) \ 220 T(HandleJnezImm32) \ 221 T(HandleJstricteqzImm16) \ 222 T(HandleJnstricteqzImm16) \ 223 T(HandleJeqnullImm16) \ 224 T(HandleJnenullImm16) \ 225 T(HandleJstricteqnullImm16) \ 226 T(HandleJnstricteqnullImm16) \ 227 T(HandleJequndefinedImm16) \ 228 T(HandleJneundefinedImm16) \ 229 T(HandleJstrictequndefinedImm16) \ 230 T(HandleJnstrictequndefinedImm16) \ 231 T(HandleJeqV8Imm16) \ 232 T(HandleJneV8Imm16) \ 233 T(HandleJstricteqV8Imm16) \ 234 T(HandleJnstricteqV8Imm16) \ 235 T(HandleGetiteratorImm16) \ 236 T(HandleCloseiteratorImm16V8) \ 237 T(HandleLdsymbol) \ 238 T(HandleAsyncfunctionenter) \ 239 T(HandleLdfunction) \ 240 T(HandleDebugger) \ 241 T(HandleCreategeneratorobjV8) \ 242 T(HandleCreateiterresultobjV8V8) \ 243 T(HandleCreateobjectwithexcludedkeysImm8V8V8) \ 244 T(HandleNewobjapplyImm8V8) \ 245 T(HandleNewobjapplyImm16V8) \ 246 T(HandleNewlexenvwithnameImm8Id16) \ 247 T(HandleCreateasyncgeneratorobjV8) \ 248 T(HandleAsyncgeneratorresolveV8V8V8) \ 249 T(HandleSupercallspreadImm8V8) \ 250 T(HandleApplyImm8V8V8) \ 251 T(HandleSupercallarrowrangeImm8Imm8V8) \ 252 T(HandleDefinegettersetterbyvalueV8V8V8V8) \ 253 T(HandleDynamicimport) \ 254 T(HandleDefinemethodImm16Id16Imm8) \ 255 T(HandleResumegenerator) \ 256 T(HandleGetresumemode) \ 257 T(HandleGettemplateobjectImm16) \ 258 T(HandleDelobjpropV8) \ 259 T(HandleSuspendgeneratorV8) \ 260 T(HandleAsyncfunctionawaituncaughtV8) \ 261 T(HandleCopydatapropertiesV8) \ 262 T(HandleStarrayspreadV8V8) \ 263 T(HandleSetobjectwithprotoImm16V8) \ 264 T(HandleStownbyvalueImm16V8V8) \ 265 T(HandleStsuperbyvalueImm8V8V8) \ 266 T(HandleStsuperbyvalueImm16V8V8) \ 267 T(HandleStownbyindexImm16V8Imm16) \ 268 T(HandleStownbynameImm16Id16V8) \ 269 T(HandleAsyncfunctionresolveV8) \ 270 T(HandleAsyncfunctionrejectV8) \ 271 T(HandleCopyrestargsImm8) \ 272 T(HandleStsuperbynameImm8Id16V8) \ 273 T(HandleStsuperbynameImm16Id16V8) \ 274 T(HandleStownbyvaluewithnamesetImm16V8V8) \ 275 T(HandleLdbigintId16) \ 276 T(HandleStownbynamewithnamesetImm16Id16V8) \ 277 T(HandleNop) \ 278 T(HandleSetgeneratorstateImm8) \ 279 T(HandleGetasynciteratorImm8) \ 280 ASM_UNUSED_BC_STUB_LIST(T) \ 281 T(HandleCallRuntime) \ 282 T(HandleDeprecated) \ 283 T(HandleWide) \ 284 T(HandleThrow) \ 285 D(ExceptionHandler) 286 287 // V: Not Enabled, T: Enabled, D: Always Disable SingleStepDebugging 288 #define ASM_INTERPRETER_DEPRECATED_STUB_LIST(V, T, D) \ 289 T(HandleDeprecatedLdlexenvPrefNone) \ 290 T(HandleDeprecatedPoplexenvPrefNone) \ 291 T(HandleDeprecatedGetiteratornextPrefV8V8) \ 292 T(HandleDeprecatedCreatearraywithbufferPrefImm16) \ 293 T(HandleDeprecatedCreateobjectwithbufferPrefImm16) \ 294 T(HandleDeprecatedTonumberPrefV8) \ 295 T(HandleDeprecatedTonumericPrefV8) \ 296 T(HandleDeprecatedNegPrefV8) \ 297 T(HandleDeprecatedNotPrefV8) \ 298 T(HandleDeprecatedIncPrefV8) \ 299 T(HandleDeprecatedDecPrefV8) \ 300 D(HandleDeprecatedCallarg0PrefV8) \ 301 D(HandleDeprecatedCallarg1PrefV8V8) \ 302 D(HandleDeprecatedCallargs2PrefV8V8V8) \ 303 D(HandleDeprecatedCallargs3PrefV8V8V8V8) \ 304 D(HandleDeprecatedCallrangePrefImm16V8) \ 305 D(HandleDeprecatedCallspreadPrefV8V8V8) \ 306 D(HandleDeprecatedCallthisrangePrefImm16V8) \ 307 T(HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8) \ 308 T(HandleDeprecatedResumegeneratorPrefV8) \ 309 T(HandleDeprecatedGetresumemodePrefV8) \ 310 T(HandleDeprecatedGettemplateobjectPrefV8) \ 311 T(HandleDeprecatedDelobjpropPrefV8V8) \ 312 T(HandleDeprecatedSuspendgeneratorPrefV8V8) \ 313 T(HandleDeprecatedAsyncfunctionawaituncaughtPrefV8V8) \ 314 T(HandleDeprecatedCopydatapropertiesPrefV8V8) \ 315 T(HandleDeprecatedSetobjectwithprotoPrefV8V8) \ 316 T(HandleDeprecatedLdobjbyvaluePrefV8V8) \ 317 T(HandleDeprecatedLdsuperbyvaluePrefV8V8) \ 318 T(HandleDeprecatedLdobjbyindexPrefV8Imm32) \ 319 T(HandleDeprecatedAsyncfunctionresolvePrefV8V8V8) \ 320 T(HandleDeprecatedAsyncfunctionrejectPrefV8V8V8) \ 321 T(HandleDeprecatedStlexvarPrefImm4Imm4V8) \ 322 T(HandleDeprecatedStlexvarPrefImm8Imm8V8) \ 323 T(HandleDeprecatedStlexvarPrefImm16Imm16V8) \ 324 T(HandleDeprecatedGetmodulenamespacePrefId32) \ 325 T(HandleDeprecatedStmodulevarPrefId32) \ 326 T(HandleDeprecatedLdobjbynamePrefId32V8) \ 327 T(HandleDeprecatedLdsuperbynamePrefId32V8) \ 328 T(HandleDeprecatedLdmodulevarPrefId32Imm8) \ 329 T(HandleDeprecatedStconsttoglobalrecordPrefId32) \ 330 T(HandleDeprecatedStlettoglobalrecordPrefId32) \ 331 T(HandleDeprecatedStclasstoglobalrecordPrefId32) \ 332 T(HandleDeprecatedLdhomeobjectPrefNone) \ 333 T(HandleDeprecatedCreateobjecthavingmethodPrefImm16) \ 334 T(HandleDeprecatedDynamicimportPrefV8) \ 335 T(HandleDeprecatedAsyncgeneratorrejectPrefV8V8) 336 337 // V: Not Enabled, T: Enabled, D: Always Disable SingleStepDebugging 338 #define ASM_INTERPRETER_WIDE_STUB_LIST(V, T, D) \ 339 T(HandleWideCreateobjectwithexcludedkeysPrefImm16V8V8) \ 340 T(HandleWideNewobjrangePrefImm16V8) \ 341 T(HandleWideNewlexenvPrefImm16) \ 342 T(HandleWideNewlexenvwithnamePrefImm16Id16) \ 343 D(HandleWideCallrangePrefImm16V8) \ 344 D(HandleWideCallthisrangePrefImm16V8) \ 345 T(HandleWideSupercallthisrangePrefImm16V8) \ 346 T(HandleWideSupercallarrowrangePrefImm16V8) \ 347 T(HandleWideLdobjbyindexPrefImm32) \ 348 T(HandleWideStobjbyindexPrefV8Imm32) \ 349 T(HandleWideStownbyindexPrefV8Imm32) \ 350 T(HandleWideCopyrestargsPrefImm16) \ 351 T(HandleWideLdlexvarPrefImm16Imm16) \ 352 T(HandleWideStlexvarPrefImm16Imm16) \ 353 T(HandleWideGetmodulenamespacePrefImm16) \ 354 T(HandleWideStmodulevarPrefImm16) \ 355 T(HandleWideLdlocalmodulevarPrefImm16) \ 356 T(HandleWideLdexternalmodulevarPrefImm16) \ 357 T(HandleWideLdpatchvarPrefImm16) \ 358 T(HandleWideStpatchvarPrefImm16) 359 360 // V: Not Enabled, T: Enabled, D: Always Disable SingleStepDebugging 361 #define ASM_INTERPRETER_THROW_STUB_LIST(V, T, D) \ 362 T(HandleThrowPrefNone) \ 363 T(HandleThrowNotexistsPrefNone) \ 364 T(HandleThrowPatternnoncoerciblePrefNone) \ 365 T(HandleThrowDeletesuperpropertyPrefNone) \ 366 T(HandleThrowConstassignmentPrefV8) \ 367 T(HandleThrowIfnotobjectPrefV8) \ 368 T(HandleThrowUndefinedifholePrefV8V8) \ 369 T(HandleThrowIfsupernotcorrectcallPrefImm8) \ 370 T(HandleThrowIfsupernotcorrectcallPrefImm16) \ 371 T(HandleThrowUndefinedifholewithnamePrefId16) 372 373 // V: Not Enabled, T: Enabled, D: Always Disable SingleStepDebugging 374 #define ASM_INTERPRETER_CALLRUNTIME_STUB_LIST(V, T, D) \ 375 T(HandleCallRuntimeNotifyConcurrentResultPrefNone) 376 377 #define ASM_INTERPRETER_BC_HELPER_STUB_LIST(V) \ 378 V(SingleStepDebugging) \ 379 V(BCDebuggerEntry) \ 380 V(BCDebuggerExceptionEntry) \ 381 V(NewObjectRangeThrowException) \ 382 V(ThrowStackOverflowException) 383 384 #define APPEND_SUFFIX(name, V) \ 385 V(name##WithProf, name) 386 387 #define ASM_INTERPRETER_BC_PROFILER_STUB_LIST(V) \ 388 ASM_INTERPRETER_BC_TYPE_PROFILER_STUB_LIST(V) \ 389 ASM_INTERPRETER_BC_LAYOUT_PROFILER_STUB_LIST(V) \ 390 ASM_INTERPRETER_BC_FUNC_HOT_PROFILER_STUB_LIST(V) \ 391 ASM_INTERPRETER_BC_FUNC_COUNT_PROFILER_STUB_LIST(V) \ 392 393 #define ASM_INTERPRETER_BC_TYPE_PROFILER_STUB_LIST(V) \ 394 APPEND_SUFFIX(HandleAdd2Imm8V8, V) \ 395 APPEND_SUFFIX(HandleSub2Imm8V8, V) \ 396 APPEND_SUFFIX(HandleMul2Imm8V8, V) \ 397 APPEND_SUFFIX(HandleDiv2Imm8V8, V) \ 398 APPEND_SUFFIX(HandleMod2Imm8V8, V) \ 399 APPEND_SUFFIX(HandleShl2Imm8V8, V) \ 400 APPEND_SUFFIX(HandleShr2Imm8V8, V) \ 401 APPEND_SUFFIX(HandleAnd2Imm8V8, V) \ 402 APPEND_SUFFIX(HandleOr2Imm8V8, V) \ 403 APPEND_SUFFIX(HandleXor2Imm8V8, V) \ 404 APPEND_SUFFIX(HandleAshr2Imm8V8, V) \ 405 APPEND_SUFFIX(HandleExpImm8V8, V) \ 406 APPEND_SUFFIX(HandleNegImm8, V) \ 407 APPEND_SUFFIX(HandleNotImm8, V) \ 408 APPEND_SUFFIX(HandleEqImm8V8, V) \ 409 APPEND_SUFFIX(HandleIncImm8, V) \ 410 APPEND_SUFFIX(HandleDecImm8, V) \ 411 APPEND_SUFFIX(HandleNoteqImm8V8, V) \ 412 APPEND_SUFFIX(HandleLessImm8V8, V) \ 413 APPEND_SUFFIX(HandleLesseqImm8V8, V) \ 414 APPEND_SUFFIX(HandleGreaterImm8V8, V) \ 415 APPEND_SUFFIX(HandleGreatereqImm8V8, V) \ 416 APPEND_SUFFIX(HandleStrictnoteqImm8V8, V) \ 417 APPEND_SUFFIX(HandleStricteqImm8V8, V) 418 419 #define ASM_INTERPRETER_BC_FUNC_HOT_PROFILER_STUB_LIST(V) \ 420 APPEND_SUFFIX(HandleJmpImm8, V) \ 421 APPEND_SUFFIX(HandleJmpImm16, V) \ 422 APPEND_SUFFIX(HandleJmpImm32, V) \ 423 APPEND_SUFFIX(HandleJeqzImm8, V) \ 424 APPEND_SUFFIX(HandleJeqzImm16, V) \ 425 APPEND_SUFFIX(HandleJeqzImm32, V) \ 426 APPEND_SUFFIX(HandleJnezImm8, V) \ 427 APPEND_SUFFIX(HandleJnezImm16, V) \ 428 APPEND_SUFFIX(HandleJnezImm32, V) \ 429 APPEND_SUFFIX(HandleReturn, V) \ 430 APPEND_SUFFIX(HandleReturnundefined, V) \ 431 APPEND_SUFFIX(HandleSuspendgeneratorV8, V) \ 432 APPEND_SUFFIX(HandleDeprecatedSuspendgeneratorPrefV8V8, V) \ 433 APPEND_SUFFIX(HandleAsyncgeneratorresolveV8V8V8, V) 434 435 #define ASM_INTERPRETER_BC_FUNC_COUNT_PROFILER_STUB_LIST(V) \ 436 APPEND_SUFFIX(HandleCallarg0Imm8, V) \ 437 APPEND_SUFFIX(HandleDeprecatedCallarg0PrefV8, V) \ 438 APPEND_SUFFIX(HandleCallarg1Imm8V8, V) \ 439 APPEND_SUFFIX(HandleDeprecatedCallarg1PrefV8V8, V) \ 440 APPEND_SUFFIX(HandleCallargs2Imm8V8V8, V) \ 441 APPEND_SUFFIX(HandleDeprecatedCallargs2PrefV8V8V8, V) \ 442 APPEND_SUFFIX(HandleCallargs3Imm8V8V8V8, V) \ 443 APPEND_SUFFIX(HandleDeprecatedCallargs3PrefV8V8V8V8, V) \ 444 APPEND_SUFFIX(HandleCallrangeImm8Imm8V8, V) \ 445 APPEND_SUFFIX(HandleWideCallrangePrefImm16V8, V) \ 446 APPEND_SUFFIX(HandleDeprecatedCallrangePrefImm16V8, V) \ 447 APPEND_SUFFIX(HandleCallthisrangeImm8Imm8V8, V) \ 448 APPEND_SUFFIX(HandleWideCallthisrangePrefImm16V8, V) \ 449 APPEND_SUFFIX(HandleDeprecatedCallthisrangePrefImm16V8, V) \ 450 APPEND_SUFFIX(HandleCallthis0Imm8V8, V) \ 451 APPEND_SUFFIX(HandleCallthis1Imm8V8V8, V) \ 452 APPEND_SUFFIX(HandleCallthis2Imm8V8V8V8, V) \ 453 APPEND_SUFFIX(HandleCallthis3Imm8V8V8V8V8, V) \ 454 APPEND_SUFFIX(HandleNewobjrangeImm8Imm8V8, V) \ 455 APPEND_SUFFIX(HandleNewobjrangeImm16Imm8V8, V) \ 456 APPEND_SUFFIX(HandleWideNewobjrangePrefImm16V8, V) \ 457 APPEND_SUFFIX(HandleInstanceofImm8V8, V) \ 458 APPEND_SUFFIX(HandleTryldglobalbynameImm8Id16, V) \ 459 APPEND_SUFFIX(HandleTryldglobalbynameImm16Id16, V) \ 460 APPEND_SUFFIX(HandleTrystglobalbynameImm8Id16, V) \ 461 APPEND_SUFFIX(HandleTrystglobalbynameImm16Id16, V) \ 462 APPEND_SUFFIX(HandleLdglobalvarImm16Id16, V) 463 464 #define ASM_INTERPRETER_BC_LAYOUT_PROFILER_STUB_LIST(V) \ 465 APPEND_SUFFIX(HandleDefineclasswithbufferImm8Id16Id16Imm16V8, V) \ 466 APPEND_SUFFIX(HandleDefineclasswithbufferImm16Id16Id16Imm16V8, V) \ 467 APPEND_SUFFIX(HandleDefinegettersetterbyvalueV8V8V8V8, V) \ 468 APPEND_SUFFIX(HandleCreateobjectwithbufferImm8Id16, V) \ 469 APPEND_SUFFIX(HandleCreateobjectwithbufferImm16Id16, V) \ 470 APPEND_SUFFIX(HandleCreatearraywithbufferImm8Id16, V) \ 471 APPEND_SUFFIX(HandleCreatearraywithbufferImm16Id16, V) \ 472 APPEND_SUFFIX(HandleCreateemptyobject, V) \ 473 APPEND_SUFFIX(HandleCreateemptyarrayImm8, V) \ 474 APPEND_SUFFIX(HandleCreateemptyarrayImm16, V) \ 475 APPEND_SUFFIX(HandleLdobjbynameImm8Id16, V) \ 476 APPEND_SUFFIX(HandleLdobjbynameImm16Id16, V) \ 477 APPEND_SUFFIX(HandleLdthisbynameImm16Id16, V) \ 478 APPEND_SUFFIX(HandleLdthisbynameImm8Id16, V) \ 479 APPEND_SUFFIX(HandleStthisbynameImm8Id16, V) \ 480 APPEND_SUFFIX(HandleStthisbynameImm16Id16, V) \ 481 APPEND_SUFFIX(HandleStthisbyvalueImm8V8, V) \ 482 APPEND_SUFFIX(HandleStthisbyvalueImm16V8, V) \ 483 APPEND_SUFFIX(HandleStobjbyvalueImm16V8V8, V) \ 484 APPEND_SUFFIX(HandleStobjbynameImm8Id16V8, V) \ 485 APPEND_SUFFIX(HandleStobjbynameImm16Id16V8, V) \ 486 APPEND_SUFFIX(HandleStobjbyvalueImm8V8V8, V) \ 487 APPEND_SUFFIX(HandleStobjbyindexImm8V8Imm16, V) \ 488 APPEND_SUFFIX(HandleStobjbyindexImm16V8Imm16, V) \ 489 APPEND_SUFFIX(HandleLdobjbyvalueImm8V8, V) \ 490 APPEND_SUFFIX(HandleLdobjbyvalueImm16V8, V) \ 491 APPEND_SUFFIX(HandleLdthisbyvalueImm16, V) \ 492 APPEND_SUFFIX(HandleLdthisbyvalueImm8, V) \ 493 APPEND_SUFFIX(HandleLdobjbyindexImm8Imm16, V) \ 494 APPEND_SUFFIX(HandleLdobjbyindexImm16Imm16, V) \ 495 APPEND_SUFFIX(HandleWideLdobjbyindexPrefImm32, V) \ 496 APPEND_SUFFIX(HandleWideStobjbyindexPrefV8Imm32, V) \ 497 APPEND_SUFFIX(HandleStownbyindexImm16V8Imm16, V) \ 498 APPEND_SUFFIX(HandleStownbyindexImm8V8Imm16, V) \ 499 APPEND_SUFFIX(HandleWideStownbyindexPrefV8Imm32, V) \ 500 APPEND_SUFFIX(HandleStownbyvaluewithnamesetImm16V8V8, V) \ 501 APPEND_SUFFIX(HandleStownbyvaluewithnamesetImm8V8V8, V) \ 502 APPEND_SUFFIX(HandleStownbyvalueImm8V8V8, V) \ 503 APPEND_SUFFIX(HandleStownbyvalueImm16V8V8, V) \ 504 APPEND_SUFFIX(HandleStownbynamewithnamesetImm16Id16V8, V) \ 505 APPEND_SUFFIX(HandleStownbynamewithnamesetImm8Id16V8, V) \ 506 APPEND_SUFFIX(HandleStownbynameImm16Id16V8, V) \ 507 APPEND_SUFFIX(HandleStownbynameImm8Id16V8, V) 508 509 #define INTERPRETER_DISABLE_SINGLE_STEP_DEBUGGING_BC_STUB_LIST(V) \ 510 ASM_INTERPRETER_BC_STUB_LIST(IGNORE_BC_STUB, IGNORE_BC_STUB, V) \ 511 ASM_INTERPRETER_DEPRECATED_STUB_LIST(IGNORE_BC_STUB, IGNORE_BC_STUB, V) \ 512 ASM_INTERPRETER_WIDE_STUB_LIST(IGNORE_BC_STUB, IGNORE_BC_STUB, V) \ 513 ASM_INTERPRETER_THROW_STUB_LIST(IGNORE_BC_STUB, IGNORE_BC_STUB, V) \ 514 ASM_INTERPRETER_CALLRUNTIME_STUB_LIST(IGNORE_BC_STUB, IGNORE_BC_STUB, V) 515 516 #define INTERPRETER_BC_STUB_LIST(V) \ 517 ASM_INTERPRETER_BC_STUB_LIST(IGNORE_BC_STUB, V, V) \ 518 ASM_INTERPRETER_DEPRECATED_STUB_LIST(IGNORE_BC_STUB, V, V) \ 519 ASM_INTERPRETER_WIDE_STUB_LIST(IGNORE_BC_STUB, V, V) \ 520 ASM_INTERPRETER_THROW_STUB_LIST(IGNORE_BC_STUB, V, V) \ 521 ASM_INTERPRETER_CALLRUNTIME_STUB_LIST(IGNORE_BC_STUB, V, V) 522 523 #define ASM_INTERPRETER_BC_STUB_ID_LIST(V) \ 524 ASM_INTERPRETER_BC_STUB_LIST(V, V, V) 525 526 #define ASM_INTERPRETER_SECOND_BC_STUB_ID_LIST(V) \ 527 ASM_INTERPRETER_WIDE_STUB_LIST(V, V, V) \ 528 ASM_INTERPRETER_THROW_STUB_LIST(V, V, V) \ 529 ASM_INTERPRETER_DEPRECATED_STUB_LIST(V, V, V) \ 530 ASM_INTERPRETER_CALLRUNTIME_STUB_LIST(V, V, V) 531 532 class BytecodeStubCSigns { 533 public: 534 // is uint8 max 535 static constexpr size_t LAST_VALID_OPCODE = 0xFF; 536 // all valid stub, include normal and helper stub 537 enum ValidID { 538 #define DEF_VALID_BC_STUB_ID(name) name, 539 INTERPRETER_BC_STUB_LIST(DEF_VALID_BC_STUB_ID) 540 ASM_INTERPRETER_BC_HELPER_STUB_LIST(DEF_VALID_BC_STUB_ID) 541 #undef DEF_VALID_BC_STUB_ID 542 #define DEF_VALID_BC_STUB_ID(name, ...) name, 543 ASM_INTERPRETER_BC_PROFILER_STUB_LIST(DEF_VALID_BC_STUB_ID) 544 #undef DEF_VALID_BC_STUB_ID 545 NUM_OF_VALID_STUBS 546 }; 547 548 #define DEF_BC_STUB_ID(name) PREF_ID_##name, 549 enum WideID { 550 ASM_INTERPRETER_WIDE_STUB_LIST(DEF_BC_STUB_ID, DEF_BC_STUB_ID, DEF_BC_STUB_ID) 551 NUM_OF_WIDE_STUBS 552 }; 553 enum ThrowID { 554 ASM_INTERPRETER_THROW_STUB_LIST(DEF_BC_STUB_ID, DEF_BC_STUB_ID, DEF_BC_STUB_ID) 555 NUM_OF_THROW_STUBS 556 }; 557 enum DeprecatedID { 558 ASM_INTERPRETER_DEPRECATED_STUB_LIST(DEF_BC_STUB_ID, DEF_BC_STUB_ID, DEF_BC_STUB_ID) 559 NUM_OF_DEPRECATED_STUBS 560 }; 561 enum CallRuntimeID { 562 ASM_INTERPRETER_CALLRUNTIME_STUB_LIST(DEF_BC_STUB_ID, DEF_BC_STUB_ID, DEF_BC_STUB_ID) 563 NUM_OF_CALLRUNTIME_STUBS 564 }; 565 #undef DEF_BC_STUB_ID 566 567 #define DEF_BC_STUB_ID(name) ID_##name, 568 enum ID { 569 ASM_INTERPRETER_BC_STUB_ID_LIST(DEF_BC_STUB_ID) 570 NUM_OF_ALL_NORMAL_STUBS, 571 lastOpcode = LAST_VALID_OPCODE, // last Opcode is max opcode size 572 ASM_INTERPRETER_SECOND_BC_STUB_ID_LIST(DEF_BC_STUB_ID) 573 ASM_INTERPRETER_BC_HELPER_STUB_LIST(DEF_BC_STUB_ID) 574 #undef DEF_BC_STUB_ID 575 #define DEF_BC_STUB_ID(name, ...) ID_##name, 576 ASM_INTERPRETER_BC_PROFILER_STUB_LIST(DEF_BC_STUB_ID) 577 NUM_OF_STUBS, 578 ID_Wide_Start = lastOpcode + 1, 579 ID_Throw_Start = ID_Wide_Start + NUM_OF_WIDE_STUBS, 580 ID_Deprecated_Start = ID_Throw_Start + NUM_OF_THROW_STUBS, 581 ID_CallRuntime_Start = ID_Deprecated_Start + NUM_OF_DEPRECATED_STUBS 582 }; 583 #undef DEF_BC_STUB_ID 584 585 static void Initialize(); 586 587 static void GetCSigns(std::vector<const CallSignature*>& outCSigns); 588 Get(size_t index)589 static const CallSignature* Get(size_t index) 590 { 591 ASSERT(index < NUM_OF_VALID_STUBS); 592 return &callSigns_[index]; 593 } 594 BCDebuggerHandler()595 static const CallSignature* BCDebuggerHandler() 596 { 597 return &bcDebuggerHandlerCSign_; 598 } 599 BCHandler()600 static const CallSignature* BCHandler() 601 { 602 return &bcHandlerCSign_; 603 } 604 605 private: 606 static CallSignature callSigns_[NUM_OF_VALID_STUBS]; 607 static CallSignature bcHandlerCSign_; 608 static CallSignature bcDebuggerHandlerCSign_; 609 }; 610 611 enum class InterpreterHandlerInputs : size_t { 612 GLUE = 0, 613 SP, 614 PC, 615 CONSTPOOL, 616 PROFILE_TYPE_INFO, 617 ACC, 618 HOTNESS_COUNTER, 619 NUM_OF_INPUTS 620 }; 621 622 enum class CallDispatchInputs : size_t { 623 GLUE = 0, 624 SP, 625 CALL_TARGET, 626 METHOD, 627 CALL_FIELD, 628 ARG0, 629 ARG1, 630 ARG2, 631 ARG3, 632 NUM_OF_INPUTS, 633 634 ARGC = ARG0, 635 ARGV = ARG1, 636 }; 637 638 #define BYTECODE_STUB_END_ID BytecodeStubCSigns::ID_ExceptionHandler 639 #define BCSTUB_ID(name) kungfu::BytecodeStubCSigns::ID_##name 640 } // namespace panda::ecmascript::kungfu 641 #endif // ECMASCRIPT_COMPILER_BC_CALL_SIGNATURE_H 642