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#include "ecmascript/compiler/bytecode_circuit_builder.h" 16#include "ecmascript/compiler/bytecodes.h" 17#include "ecmascript/interpreter/interpreter-inl.h" 18 19namespace panda::ecmascript::kungfu { 20BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc) 21{ 22 BytecodeInstruction inst(pc); 23 uint32_t flags = 0; 24 BytecodeKind kind = BytecodeKind::GENERAL; 25 if (inst.HasFlag(BytecodeInstruction::Flags::ACC_READ)) { 26 flags |= BytecodeFlags::READ_ACC; 27 } 28 if (inst.HasFlag(BytecodeInstruction::Flags::ACC_WRITE)) { 29 flags |= BytecodeFlags::WRITE_ACC; 30 } 31 32 switch (inst.GetOpcode()) { 33 case EcmaOpcode::GETPROPITERATOR: 34 case EcmaOpcode::TYPEOF_IMM8: 35 case EcmaOpcode::TYPEOF_IMM16: 36 case EcmaOpcode::LDSYMBOL: 37 case EcmaOpcode::LDGLOBAL: 38 case EcmaOpcode::LDBIGINT_ID16: 39 case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8: 40 case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16: 41 case EcmaOpcode::GETMODULENAMESPACE_IMM8: 42 case EcmaOpcode::WIDE_GETMODULENAMESPACE_PREF_IMM16: 43 case EcmaOpcode::ISTRUE: 44 case EcmaOpcode::ISFALSE: 45 case EcmaOpcode::CALLRUNTIME_ISTRUE_PREF_IMM8: 46 case EcmaOpcode::CALLRUNTIME_ISFALSE_PREF_IMM8: 47 case EcmaOpcode::LDGLOBALVAR_IMM16_ID16: 48 case EcmaOpcode::LDOBJBYINDEX_IMM8_IMM16: 49 case EcmaOpcode::LDOBJBYINDEX_IMM16_IMM16: 50 case EcmaOpcode::WIDE_LDOBJBYINDEX_PREF_IMM32: 51 case EcmaOpcode::LDLEXVAR_IMM4_IMM4: 52 case EcmaOpcode::LDLEXVAR_IMM8_IMM8: 53 case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16: 54 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: 55 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: 56 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: 57 case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16: 58 case EcmaOpcode::LDLOCALMODULEVAR_IMM8: 59 case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16: 60 case EcmaOpcode::LDA_STR_ID16: 61 case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16: 62 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 63 break; 64 default: 65 break; 66 } 67 68 switch (inst.GetOpcode()) { 69 case EcmaOpcode::MOV_V4_V4: 70 case EcmaOpcode::MOV_V8_V8: 71 case EcmaOpcode::MOV_V16_V16: 72 case EcmaOpcode::STA_V8: 73 case EcmaOpcode::LDA_V8: 74 case EcmaOpcode::LDHOLE: 75 case EcmaOpcode::LDAI_IMM32: 76 case EcmaOpcode::FLDAI_IMM64: 77 case EcmaOpcode::LDFUNCTION: 78 case EcmaOpcode::TYPEOF_IMM8: 79 case EcmaOpcode::TYPEOF_IMM16: 80 case EcmaOpcode::LDNAN: 81 case EcmaOpcode::LDINFINITY: 82 case EcmaOpcode::LDUNDEFINED: 83 case EcmaOpcode::LDNULL: 84 case EcmaOpcode::LDTRUE: 85 case EcmaOpcode::LDFALSE: 86 case EcmaOpcode::LDSYMBOL: 87 case EcmaOpcode::LDGLOBAL: 88 case EcmaOpcode::LDBIGINT_ID16: 89 case EcmaOpcode::LDLEXVAR_IMM4_IMM4: 90 case EcmaOpcode::LDLEXVAR_IMM8_IMM8: 91 case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16: 92 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: 93 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: 94 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: 95 case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16: 96 case EcmaOpcode::LDA_STR_ID16: 97 case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16: 98 case EcmaOpcode::RETURN: 99 case EcmaOpcode::RETURNUNDEFINED: 100 flags |= BytecodeFlags::NO_GC; 101 break; 102 default: 103 break; 104 } 105 106 switch (inst.GetOpcode()) { 107 case EcmaOpcode::MOV_V4_V4: 108 case EcmaOpcode::MOV_V8_V8: 109 case EcmaOpcode::MOV_V16_V16: 110 case EcmaOpcode::STA_V8: 111 case EcmaOpcode::LDA_V8: 112 case EcmaOpcode::LDNAN: 113 case EcmaOpcode::LDINFINITY: 114 case EcmaOpcode::LDUNDEFINED: 115 case EcmaOpcode::LDNULL: 116 case EcmaOpcode::LDTRUE: 117 case EcmaOpcode::LDFALSE: 118 case EcmaOpcode::LDHOLE: 119 case EcmaOpcode::LDAI_IMM32: 120 case EcmaOpcode::FLDAI_IMM64: 121 case EcmaOpcode::LDFUNCTION: 122 case EcmaOpcode::LDA_STR_ID16: 123 case EcmaOpcode::TYPEOF_IMM8: 124 case EcmaOpcode::TYPEOF_IMM16: 125 case EcmaOpcode::ISTRUE: 126 case EcmaOpcode::ISFALSE: 127 case EcmaOpcode::CALLRUNTIME_ISTRUE_PREF_IMM8: 128 case EcmaOpcode::CALLRUNTIME_ISFALSE_PREF_IMM8: 129 case EcmaOpcode::JEQZ_IMM8: 130 case EcmaOpcode::JEQZ_IMM16: 131 case EcmaOpcode::JEQZ_IMM32: 132 case EcmaOpcode::JNEZ_IMM8: 133 case EcmaOpcode::JNEZ_IMM16: 134 case EcmaOpcode::JNEZ_IMM32: 135 case EcmaOpcode::JMP_IMM8: 136 case EcmaOpcode::JMP_IMM16: 137 case EcmaOpcode::JMP_IMM32: 138 case EcmaOpcode::STMODULEVAR_IMM8: 139 case EcmaOpcode::WIDE_STMODULEVAR_PREF_IMM16: 140 case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8: 141 case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16: 142 case EcmaOpcode::NEWLEXENV_IMM8: 143 case EcmaOpcode::WIDE_NEWLEXENV_PREF_IMM16: 144 case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8: 145 case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16: 146 case EcmaOpcode::POPLEXENV: 147 case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16: 148 case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16: 149 case EcmaOpcode::ASYNCFUNCTIONENTER: 150 case EcmaOpcode::SETGENERATORSTATE_IMM8: 151 case EcmaOpcode::GETRESUMEMODE: 152 case EcmaOpcode::RESUMEGENERATOR: 153 case EcmaOpcode::RETURN: 154 case EcmaOpcode::RETURNUNDEFINED: 155 case EcmaOpcode::LDLEXVAR_IMM4_IMM4: 156 case EcmaOpcode::LDLEXVAR_IMM8_IMM8: 157 case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16: 158 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: 159 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: 160 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: 161 case EcmaOpcode::STLEXVAR_IMM4_IMM4: 162 case EcmaOpcode::STLEXVAR_IMM8_IMM8: 163 case EcmaOpcode::WIDE_STLEXVAR_PREF_IMM16_IMM16: 164 case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4: 165 case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8: 166 case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16: 167 case EcmaOpcode::STRICTNOTEQ_IMM8_V8: 168 case EcmaOpcode::STRICTEQ_IMM8_V8: 169 case EcmaOpcode::CREATEEMPTYARRAY_IMM8: 170 case EcmaOpcode::CREATEEMPTYARRAY_IMM16: 171 case EcmaOpcode::CREATEEMPTYOBJECT: 172 case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16: 173 case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16: 174 case EcmaOpcode::CREATEITERRESULTOBJ_V8_V8: 175 case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8: 176 case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8: 177 case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8: 178 case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8: 179 case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16: 180 case EcmaOpcode::DEBUGGER: 181 case EcmaOpcode::NOP: 182 flags |= BytecodeFlags::NO_THROW; 183 break; 184 default: 185 break; 186 } 187 188 switch (inst.GetOpcode()) { 189 case EcmaOpcode::MOV_V4_V4: 190 case EcmaOpcode::MOV_V8_V8: 191 case EcmaOpcode::MOV_V16_V16: 192 case EcmaOpcode::STA_V8: 193 case EcmaOpcode::LDA_V8: 194 kind = BytecodeKind::MOV; 195 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 196 break; 197 case EcmaOpcode::LDNAN: 198 case EcmaOpcode::LDINFINITY: 199 case EcmaOpcode::LDUNDEFINED: 200 case EcmaOpcode::LDNULL: 201 case EcmaOpcode::LDTRUE: 202 case EcmaOpcode::LDFALSE: 203 case EcmaOpcode::LDHOLE: 204 case EcmaOpcode::LDAI_IMM32: 205 case EcmaOpcode::FLDAI_IMM64: 206 case EcmaOpcode::LDFUNCTION: 207 kind = BytecodeKind::SET_CONSTANT; 208 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 209 break; 210 case EcmaOpcode::LDTHISBYVALUE_IMM8: 211 case EcmaOpcode::LDTHISBYVALUE_IMM16: 212 case EcmaOpcode::STTHISBYVALUE_IMM8_V8: 213 case EcmaOpcode::STTHISBYVALUE_IMM16_V8: 214 flags |= BytecodeFlags::READ_THIS_OBJECT; 215 break; 216 case EcmaOpcode::LDTHISBYNAME_IMM8_ID16: 217 case EcmaOpcode::LDTHISBYNAME_IMM16_ID16: 218 case EcmaOpcode::STTHISBYNAME_IMM8_ID16: 219 case EcmaOpcode::STTHISBYNAME_IMM16_ID16: 220 flags |= BytecodeFlags::READ_THIS_OBJECT; 221 [[fallthrough]]; 222 case EcmaOpcode::ADD2_IMM8_V8: 223 case EcmaOpcode::SUB2_IMM8_V8: 224 case EcmaOpcode::MUL2_IMM8_V8: 225 case EcmaOpcode::DIV2_IMM8_V8: 226 case EcmaOpcode::EQ_IMM8_V8: 227 case EcmaOpcode::NOTEQ_IMM8_V8: 228 case EcmaOpcode::LESS_IMM8_V8: 229 case EcmaOpcode::LESSEQ_IMM8_V8: 230 case EcmaOpcode::GREATER_IMM8_V8: 231 case EcmaOpcode::GREATEREQ_IMM8_V8: 232 case EcmaOpcode::STRICTEQ_IMM8_V8: 233 case EcmaOpcode::STRICTNOTEQ_IMM8_V8: 234 case EcmaOpcode::TONUMERIC_IMM8: 235 case EcmaOpcode::ISTRUE: 236 case EcmaOpcode::ISFALSE: 237 case EcmaOpcode::CALLRUNTIME_ISTRUE_PREF_IMM8: 238 case EcmaOpcode::CALLRUNTIME_ISFALSE_PREF_IMM8: 239 case EcmaOpcode::INC_IMM8: 240 case EcmaOpcode::DEC_IMM8: 241 case EcmaOpcode::NEG_IMM8: 242 case EcmaOpcode::NOT_IMM8: 243 case EcmaOpcode::MOD2_IMM8_V8: 244 case EcmaOpcode::SHL2_IMM8_V8: 245 case EcmaOpcode::SHR2_IMM8_V8: 246 case EcmaOpcode::ASHR2_IMM8_V8: 247 case EcmaOpcode::AND2_IMM8_V8: 248 case EcmaOpcode::OR2_IMM8_V8: 249 case EcmaOpcode::XOR2_IMM8_V8: 250 case EcmaOpcode::LDOBJBYNAME_IMM8_ID16: 251 case EcmaOpcode::LDOBJBYNAME_IMM16_ID16: 252 case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8: 253 case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8: 254 case EcmaOpcode::LDOBJBYINDEX_IMM8_IMM16: 255 case EcmaOpcode::LDOBJBYINDEX_IMM16_IMM16: 256 case EcmaOpcode::WIDE_LDOBJBYINDEX_PREF_IMM32: 257 case EcmaOpcode::STOBJBYINDEX_IMM8_V8_IMM16: 258 case EcmaOpcode::STOBJBYINDEX_IMM16_V8_IMM16: 259 case EcmaOpcode::WIDE_STOBJBYINDEX_PREF_V8_IMM32: 260 case EcmaOpcode::LDOBJBYVALUE_IMM8_V8: 261 case EcmaOpcode::LDOBJBYVALUE_IMM16_V8: 262 case EcmaOpcode::STOBJBYVALUE_IMM8_V8_V8: 263 case EcmaOpcode::STOBJBYVALUE_IMM16_V8_V8: 264 case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8: 265 case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8: 266 case EcmaOpcode::LDPRIVATEPROPERTY_IMM8_IMM16_IMM16: 267 case EcmaOpcode::STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8: 268 case EcmaOpcode::TESTIN_IMM8_IMM16_IMM16: 269 case EcmaOpcode::DEFINEFIELDBYNAME_IMM8_ID16_V8: 270 case EcmaOpcode::DEFINEPROPERTYBYNAME_IMM8_ID16_V8: 271 case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8: 272 case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYINDEX_PREF_IMM8_IMM32_V8: 273 case EcmaOpcode::CALLRUNTIME_TOPROPERTYKEY_PREF_NONE: 274 case EcmaOpcode::CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16: 275 case EcmaOpcode::CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8: 276 flags |= BytecodeFlags::SUPPORT_DEOPT; 277 break; 278 case EcmaOpcode::CALLTHIS1_IMM8_V8_V8: 279 case EcmaOpcode::CALLARG0_IMM8: 280 case EcmaOpcode::CALLARG1_IMM8_V8: 281 case EcmaOpcode::CALLARGS2_IMM8_V8_V8: 282 case EcmaOpcode::CALLARGS3_IMM8_V8_V8_V8: 283 case EcmaOpcode::CALLRANGE_IMM8_IMM8_V8: 284 case EcmaOpcode::CALLTHIS0_IMM8_V8: 285 case EcmaOpcode::CALLTHIS2_IMM8_V8_V8_V8: 286 case EcmaOpcode::CALLTHIS3_IMM8_V8_V8_V8_V8: 287 case EcmaOpcode::CALLTHISRANGE_IMM8_IMM8_V8: 288 case EcmaOpcode::CALLRUNTIME_CALLINIT_PREF_IMM8_V8: 289 case EcmaOpcode::NEWOBJRANGE_IMM8_IMM8_V8: 290 case EcmaOpcode::NEWOBJRANGE_IMM16_IMM8_V8: 291 case EcmaOpcode::WIDE_NEWOBJRANGE_PREF_IMM16_V8: 292 flags |= BytecodeFlags::SUPPORT_DEOPT; 293 kind = BytecodeKind::CALL_BC; 294 break; 295 case EcmaOpcode::RETURN: 296 flags |= BytecodeFlags::READ_ACC; 297 [[fallthrough]]; 298 case EcmaOpcode::RETURNUNDEFINED: 299 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 300 kind = BytecodeKind::RETURN_BC; 301 break; 302 case EcmaOpcode::SUSPENDGENERATOR_V8: 303 flags |= BytecodeFlags::READ_THIS_OBJECT; 304 U_FALLTHROUGH; 305 case EcmaOpcode::DEPRECATED_SUSPENDGENERATOR_PREF_V8_V8: 306 kind = BytecodeKind::SUSPEND; 307 break; 308 case EcmaOpcode::RESUMEGENERATOR: 309 kind = BytecodeKind::RESUME; 310 break; 311 case EcmaOpcode::DEBUGGER: 312 flags |= BytecodeFlags::DEBUGGER_STMT; 313 break; 314 case EcmaOpcode::NOP: 315 kind = BytecodeKind::DISCARDED; 316 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 317 break; 318 case EcmaOpcode::THROW_PREF_NONE: 319 case EcmaOpcode::THROW_NOTEXISTS_PREF_NONE: 320 case EcmaOpcode::THROW_PATTERNNONCOERCIBLE_PREF_NONE: 321 case EcmaOpcode::THROW_DELETESUPERPROPERTY_PREF_NONE: 322 case EcmaOpcode::THROW_CONSTASSIGNMENT_PREF_V8: 323 kind = BytecodeKind::THROW_BC; 324 break; 325 case EcmaOpcode::JEQZ_IMM8: 326 case EcmaOpcode::JEQZ_IMM16: 327 case EcmaOpcode::JEQZ_IMM32: 328 case EcmaOpcode::JNEZ_IMM8: 329 case EcmaOpcode::JNEZ_IMM16: 330 case EcmaOpcode::JNEZ_IMM32: 331 kind = BytecodeKind::CONDITIONAL_JUMP; 332 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 333 break; 334 case EcmaOpcode::JMP_IMM8: 335 case EcmaOpcode::JMP_IMM16: 336 case EcmaOpcode::JMP_IMM32: 337 kind = BytecodeKind::JUMP_IMM; 338 flags |= BytecodeFlags::NO_SIDE_EFFECTS; 339 break; 340 case EcmaOpcode::CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE: 341 flags |= BytecodeFlags::READ_FUNC; 342 break; 343 case EcmaOpcode::ASYNCGENERATORRESOLVE_V8_V8_V8: 344 flags |= BytecodeFlags::READ_THIS_OBJECT; 345 flags |= BytecodeFlags::READ_ACC; 346 kind = BytecodeKind::GENERATOR_RESOLVE; 347 break; 348 default: 349 break; 350 } 351 352 switch (inst.GetOpcode()) { 353 case EcmaOpcode::NEWLEXENV_IMM8: 354 case EcmaOpcode::WIDE_NEWLEXENV_PREF_IMM16: 355 case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16: 356 case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16: 357 case EcmaOpcode::POPLEXENV: 358 flags |= BytecodeFlags::WRITE_ENV; 359 [[fallthrough]]; 360 case EcmaOpcode::LDLEXVAR_IMM4_IMM4: 361 case EcmaOpcode::LDLEXVAR_IMM8_IMM8: 362 case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16: 363 case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16: 364 case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16: 365 case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8: 366 case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8: 367 case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8: 368 case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8: 369 case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8: 370 case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8: 371 case EcmaOpcode::LDPRIVATEPROPERTY_IMM8_IMM16_IMM16: 372 case EcmaOpcode::STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8: 373 case EcmaOpcode::TESTIN_IMM8_IMM16_IMM16: 374 case EcmaOpcode::CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16: 375 case EcmaOpcode::CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8: 376 case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16: 377 flags |= BytecodeFlags::READ_ENV; 378 break; 379 default: 380 break; 381 } 382 383 switch (inst.GetOpcode()) { 384 case EcmaOpcode::SUSPENDGENERATOR_V8: 385 case EcmaOpcode::RESUMEGENERATOR: 386 case EcmaOpcode::TRYLDGLOBALBYNAME_IMM8_ID16: 387 case EcmaOpcode::TRYLDGLOBALBYNAME_IMM16_ID16: 388 case EcmaOpcode::STGLOBALVAR_IMM16_ID16: 389 case EcmaOpcode::THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16: 390 case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8: 391 case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8: 392 case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8: 393 case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8: 394 case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8: 395 case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8: 396 case EcmaOpcode::INSTANCEOF_IMM8_V8: 397 case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16: 398 case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16: 399 case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16: 400 case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16: 401 case EcmaOpcode::STMODULEVAR_IMM8: 402 case EcmaOpcode::WIDE_STMODULEVAR_PREF_IMM16: 403 case EcmaOpcode::SETGENERATORSTATE_IMM8: 404 case EcmaOpcode::DYNAMICIMPORT: 405 case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8: 406 case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16: 407 case EcmaOpcode::GETMODULENAMESPACE_IMM8: 408 case EcmaOpcode::WIDE_GETMODULENAMESPACE_PREF_IMM16: 409 case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16: 410 case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16: 411 case EcmaOpcode::LDSUPERBYVALUE_IMM8_V8: 412 case EcmaOpcode::LDSUPERBYVALUE_IMM16_V8: 413 case EcmaOpcode::STSUPERBYVALUE_IMM16_V8_V8: 414 case EcmaOpcode::STSUPERBYVALUE_IMM8_V8_V8: 415 case EcmaOpcode::TRYSTGLOBALBYNAME_IMM8_ID16: 416 case EcmaOpcode::TRYSTGLOBALBYNAME_IMM16_ID16: 417 case EcmaOpcode::LDGLOBALVAR_IMM16_ID16: 418 case EcmaOpcode::LDOBJBYNAME_IMM8_ID16: 419 case EcmaOpcode::LDOBJBYNAME_IMM16_ID16: 420 case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8: 421 case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8: 422 case EcmaOpcode::LDOBJBYVALUE_IMM8_V8: 423 case EcmaOpcode::LDOBJBYVALUE_IMM16_V8: 424 case EcmaOpcode::LDTHISBYVALUE_IMM8: 425 case EcmaOpcode::LDTHISBYVALUE_IMM16: 426 case EcmaOpcode::STOBJBYVALUE_IMM8_V8_V8: 427 case EcmaOpcode::STOBJBYVALUE_IMM16_V8_V8: 428 case EcmaOpcode::STTHISBYVALUE_IMM8_V8: 429 case EcmaOpcode::STTHISBYVALUE_IMM16_V8: 430 case EcmaOpcode::LDSUPERBYNAME_IMM8_ID16: 431 case EcmaOpcode::LDSUPERBYNAME_IMM16_ID16: 432 case EcmaOpcode::STSUPERBYNAME_IMM8_ID16_V8: 433 case EcmaOpcode::STSUPERBYNAME_IMM16_ID16_V8: 434 case EcmaOpcode::LDLOCALMODULEVAR_IMM8: 435 case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16: 436 case EcmaOpcode::LDTHISBYNAME_IMM8_ID16: 437 case EcmaOpcode::LDTHISBYNAME_IMM16_ID16: 438 case EcmaOpcode::STTHISBYNAME_IMM8_ID16: 439 case EcmaOpcode::STTHISBYNAME_IMM16_ID16: 440 case EcmaOpcode::ASYNCGENERATORRESOLVE_V8_V8_V8: 441 case EcmaOpcode::CALLARG0_IMM8: 442 case EcmaOpcode::CALLARG1_IMM8_V8: 443 case EcmaOpcode::CALLARGS2_IMM8_V8_V8: 444 case EcmaOpcode::CALLARGS3_IMM8_V8_V8_V8: 445 case EcmaOpcode::CALLRANGE_IMM8_IMM8_V8: 446 case EcmaOpcode::WIDE_CALLRANGE_PREF_IMM16_V8: 447 case EcmaOpcode::CALLTHIS0_IMM8_V8: 448 case EcmaOpcode::CALLTHIS1_IMM8_V8_V8: 449 case EcmaOpcode::CALLTHIS2_IMM8_V8_V8_V8: 450 case EcmaOpcode::CALLTHIS3_IMM8_V8_V8_V8_V8: 451 case EcmaOpcode::CALLTHISRANGE_IMM8_IMM8_V8: 452 case EcmaOpcode::WIDE_CALLTHISRANGE_PREF_IMM16_V8: 453 case EcmaOpcode::LDA_STR_ID16: 454 case EcmaOpcode::STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8: 455 case EcmaOpcode::STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8: 456 case EcmaOpcode::STTOGLOBALRECORD_IMM16_ID16: 457 case EcmaOpcode::STCONSTTOGLOBALRECORD_IMM16_ID16: 458 case EcmaOpcode::STOWNBYNAME_IMM8_ID16_V8: 459 case EcmaOpcode::STOWNBYNAME_IMM16_ID16_V8: 460 case EcmaOpcode::CREATEREGEXPWITHLITERAL_IMM8_ID16_IMM8: 461 case EcmaOpcode::CREATEREGEXPWITHLITERAL_IMM16_ID16_IMM8: 462 case EcmaOpcode::LDBIGINT_ID16: 463 case EcmaOpcode::DEFINEFIELDBYNAME_IMM8_ID16_V8: 464 case EcmaOpcode::DEFINEPROPERTYBYNAME_IMM8_ID16_V8: 465 case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8: 466 case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYINDEX_PREF_IMM8_IMM32_V8: 467 case EcmaOpcode::CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16: 468 case EcmaOpcode::CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8: 469 case EcmaOpcode::CALLRUNTIME_CALLINIT_PREF_IMM8_V8: 470 case EcmaOpcode::CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8: 471 case EcmaOpcode::CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8: 472 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16: 473 case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4: 474 case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8: 475 case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16: 476 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: 477 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: 478 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: 479 case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8: 480 case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16: 481 case EcmaOpcode::CALLRUNTIME_LDLAZYMODULEVAR_PREF_IMM8: 482 case EcmaOpcode::CALLRUNTIME_WIDELDLAZYMODULEVAR_PREF_IMM16: 483 case EcmaOpcode::CALLRUNTIME_LDLAZYSENDABLEMODULEVAR_PREF_IMM8: 484 case EcmaOpcode::CALLRUNTIME_WIDELDLAZYSENDABLEMODULEVAR_PREF_IMM16: 485 flags |= BytecodeFlags::READ_FUNC; 486 break; 487 case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8: 488 case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8: 489 flags |= BytecodeFlags::READ_FUNC; 490 flags |= BytecodeFlags::READ_NEWTARGET; 491 break; 492 case EcmaOpcode::SUPERCALLARROWRANGE_IMM8_IMM8_V8: 493 case EcmaOpcode::WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8: 494 case EcmaOpcode::SUPERCALLSPREAD_IMM8_V8: 495 case EcmaOpcode::CALLRUNTIME_SUPERCALLFORWARDALLARGS_PREF_V8: 496 flags |= BytecodeFlags::READ_NEWTARGET; 497 break; 498 case EcmaOpcode::GETUNMAPPEDARGS: 499 case EcmaOpcode::COPYRESTARGS_IMM8: 500 case EcmaOpcode::WIDE_COPYRESTARGS_PREF_IMM16: 501 flags |= BytecodeFlags::READ_ARGC; 502 [[fallthrough]]; 503 default: 504 break; 505 } 506 507 switch (inst.GetOpcode()) { 508 case EcmaOpcode::LDOBJBYNAME_IMM8_ID16: 509 case EcmaOpcode::LDOBJBYNAME_IMM16_ID16: 510 case EcmaOpcode::LDTHISBYNAME_IMM8_ID16: 511 case EcmaOpcode::LDTHISBYNAME_IMM16_ID16: 512 case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8: 513 case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8: 514 case EcmaOpcode::STTHISBYNAME_IMM8_ID16: 515 case EcmaOpcode::STTHISBYNAME_IMM16_ID16: 516 case EcmaOpcode::DEFINEFIELDBYNAME_IMM8_ID16_V8: 517 case EcmaOpcode::DEFINEPROPERTYBYNAME_IMM8_ID16_V8: 518 kind = BytecodeKind::ACCESSOR_BC; 519 break; 520 default: 521 break; 522 } 523 524 if (kind == BytecodeKind::GENERAL || 525 kind == BytecodeKind::THROW_BC || 526 kind == BytecodeKind::RESUME || 527 kind == BytecodeKind::SUSPEND || 528 kind == BytecodeKind::GENERATOR_RESOLVE || 529 kind == BytecodeKind::CALL_BC || 530 kind == BytecodeKind::ACCESSOR_BC) { 531 flags |= BytecodeFlags::GENERAL_BC; 532 } 533 auto size = inst.GetSize(); 534 auto vregCount = GetVRegCount(inst); 535 uint64_t value = SizeField::Encode(size) | KindField::Encode(kind) | 536 FlagsField::Encode(static_cast<BytecodeFlags>(flags)) | 537 OpcodeField::Encode(inst.GetOpcode()) | VRegCountField::Encode(vregCount); 538 return BytecodeMetaData(value); 539} 540 541// static 542size_t BytecodeMetaData::GetVRegCount(const BytecodeInstruction &inst) 543{ 544 size_t idx = 0; 545 BytecodeInstruction::Format format = inst.GetFormat(); 546 while (inst.HasVReg(format, idx)) { 547 idx++; 548 } 549 return idx; 550} 551 552Bytecodes::Bytecodes() 553{ 554 for (uint8_t pc = 0; pc <= static_cast<uint8_t>(Bytecodes::LAST_OPCODE); pc++) { 555 auto info = BytecodeMetaData::InitBytecodeMetaData(&pc); 556 bytecodes_[pc] = info; 557 } 558 auto last = (static_cast<uint16_t>(Bytecodes::LAST_CALLRUNTIME_OPCODE) & OPCODE_MASK) >> BYTE_SIZE; 559 for (uint8_t pc = 0; pc <= last; pc++) { 560 std::array<uint8_t, 2> bytecode{CALLRUNTIME_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode 561 auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]); 562 callRuntimeBytecodes_[pc] = info; 563 } 564 last = (static_cast<uint16_t>(Bytecodes::LAST_DEPRECATED_OPCODE) & OPCODE_MASK) >> BYTE_SIZE; 565 for (uint8_t pc = 0; pc <= last; pc++) { 566 std::array<uint8_t, 2> bytecode{DEPRECATED_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode 567 auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]); 568 deprecatedBytecodes_[pc] = info; 569 } 570 last = (static_cast<uint16_t>(Bytecodes::LAST_WIDE_OPCODE) & OPCODE_MASK) >> BYTE_SIZE; 571 for (uint8_t pc = 0; pc <= last; pc++) { 572 std::array<uint8_t, 2> bytecode{WIDE_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode 573 auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]); 574 wideBytecodes_[pc] = info; 575 } 576 last = (static_cast<uint16_t>(Bytecodes::LAST_THROW_OPCODE) & OPCODE_MASK) >> BYTE_SIZE; 577 for (uint8_t pc = 0; pc <= last; pc++) { 578 std::array<uint8_t, 2> bytecode{THROW_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode 579 auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]); 580 throwBytecodes_[pc] = info; 581 } 582} 583 584void BytecodeInfo::InitBytecodeInfo(BytecodeCircuitBuilder *builder, 585 BytecodeInfo &info, const uint8_t *pc) 586{ 587 auto opcode = info.GetOpcode(); 588 switch (opcode) { 589 case EcmaOpcode::MOV_V4_V4: { 590 uint16_t vdst = READ_INST_4_0(); 591 uint16_t vsrc = READ_INST_4_1(); 592 info.vregOut.emplace_back(vdst); 593 info.inputs.emplace_back(VirtualRegister(vsrc)); 594 break; 595 } 596 case EcmaOpcode::MOV_V8_V8: { 597 uint16_t vdst = READ_INST_8_0(); 598 uint16_t vsrc = READ_INST_8_1(); 599 info.vregOut.emplace_back(vdst); 600 info.inputs.emplace_back(VirtualRegister(vsrc)); 601 break; 602 } 603 case EcmaOpcode::MOV_V16_V16: { 604 uint16_t vdst = READ_INST_16_0(); 605 uint16_t vsrc = READ_INST_16_2(); 606 info.vregOut.emplace_back(vdst); 607 info.inputs.emplace_back(VirtualRegister(vsrc)); 608 break; 609 } 610 case EcmaOpcode::LDA_STR_ID16: { 611 uint16_t stringId = READ_INST_16_0(); 612 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 613 break; 614 } 615 case EcmaOpcode::LDA_V8: { 616 uint16_t vsrc = READ_INST_8_0(); 617 info.inputs.emplace_back(VirtualRegister(vsrc)); 618 break; 619 } 620 case EcmaOpcode::STA_V8: { 621 uint16_t vdst = READ_INST_8_0(); 622 info.vregOut.emplace_back(vdst); 623 break; 624 } 625 case EcmaOpcode::LDAI_IMM32: { 626 info.inputs.emplace_back(Immediate(READ_INST_32_0())); 627 break; 628 } 629 case EcmaOpcode::FLDAI_IMM64: { 630 info.inputs.emplace_back(Immediate(READ_INST_64_0())); 631 break; 632 } 633 case EcmaOpcode::CALLARG1_IMM8_V8: { 634 uint32_t a0 = READ_INST_8_1(); 635 info.inputs.emplace_back(VirtualRegister(a0)); 636 break; 637 } 638 case EcmaOpcode::CALLTHIS1_IMM8_V8_V8: { 639 uint32_t startReg = READ_INST_8_1(); // this 640 uint32_t a0 = READ_INST_8_2(); 641 info.inputs.emplace_back(VirtualRegister(startReg)); 642 info.inputs.emplace_back(VirtualRegister(a0)); 643 break; 644 } 645 case EcmaOpcode::CALLARGS2_IMM8_V8_V8: { 646 uint32_t a0 = READ_INST_8_1(); 647 uint32_t a1 = READ_INST_8_2(); 648 info.inputs.emplace_back(VirtualRegister(a0)); 649 info.inputs.emplace_back(VirtualRegister(a1)); 650 break; 651 } 652 case EcmaOpcode::CALLARGS3_IMM8_V8_V8_V8: { 653 uint32_t a0 = READ_INST_8_1(); 654 uint32_t a1 = READ_INST_8_2(); 655 uint32_t a2 = READ_INST_8_3(); 656 info.inputs.emplace_back(VirtualRegister(a0)); 657 info.inputs.emplace_back(VirtualRegister(a1)); 658 info.inputs.emplace_back(VirtualRegister(a2)); 659 break; 660 } 661 case EcmaOpcode::CALLTHISRANGE_IMM8_IMM8_V8: { 662 uint32_t actualNumArgs = READ_INST_8_1(); 663 uint32_t startReg = READ_INST_8_2(); 664 info.inputs.emplace_back(VirtualRegister(startReg)); 665 for (size_t i = 1; i <= actualNumArgs; i++) { 666 info.inputs.emplace_back(VirtualRegister(startReg + i)); 667 } 668 break; 669 } 670 case EcmaOpcode::WIDE_CALLTHISRANGE_PREF_IMM16_V8: { 671 uint32_t actualNumArgs = READ_INST_16_1(); 672 uint32_t startReg = READ_INST_8_3(); 673 info.inputs.emplace_back(VirtualRegister(startReg)); 674 for (size_t i = 1; i <= actualNumArgs; i++) { 675 info.inputs.emplace_back(VirtualRegister(startReg + i)); 676 } 677 break; 678 } 679 case EcmaOpcode::CALLTHIS0_IMM8_V8: { 680 int32_t startReg = READ_INST_8_1(); 681 info.inputs.emplace_back(VirtualRegister(startReg)); 682 break; 683 } 684 case EcmaOpcode::CALLTHIS2_IMM8_V8_V8_V8: { 685 int32_t startReg = READ_INST_8_1(); 686 uint32_t a0 = READ_INST_8_2(); 687 uint32_t a1 = READ_INST_8_3(); 688 info.inputs.emplace_back(VirtualRegister(startReg)); 689 info.inputs.emplace_back(VirtualRegister(a0)); 690 info.inputs.emplace_back(VirtualRegister(a1)); 691 break; 692 } 693 case EcmaOpcode::CALLTHIS3_IMM8_V8_V8_V8_V8: { 694 int32_t startReg = READ_INST_8_1(); 695 uint32_t a0 = READ_INST_8_2(); 696 uint32_t a1 = READ_INST_8_3(); 697 uint32_t a2 = READ_INST_8_4(); 698 info.inputs.emplace_back(VirtualRegister(startReg)); 699 info.inputs.emplace_back(VirtualRegister(a0)); 700 info.inputs.emplace_back(VirtualRegister(a1)); 701 info.inputs.emplace_back(VirtualRegister(a2)); 702 break; 703 } 704 case EcmaOpcode::CALLRUNTIME_CALLINIT_PREF_IMM8_V8: { 705 int32_t startReg = READ_INST_8_2(); 706 info.inputs.emplace_back(VirtualRegister(startReg)); 707 break; 708 } 709 710 case EcmaOpcode::APPLY_IMM8_V8_V8: { 711 uint16_t v0 = READ_INST_8_1(); 712 uint16_t v1 = READ_INST_8_2(); 713 info.inputs.emplace_back(VirtualRegister(v0)); 714 info.inputs.emplace_back(VirtualRegister(v1)); 715 break; 716 } 717 case EcmaOpcode::CALLRANGE_IMM8_IMM8_V8: { 718 int32_t actualNumArgs = READ_INST_8_1(); 719 int32_t startReg = READ_INST_8_2(); 720 for (int i = 0; i < actualNumArgs; i++) { 721 info.inputs.emplace_back(VirtualRegister(startReg + i)); 722 } 723 break; 724 } 725 case EcmaOpcode::WIDE_CALLRANGE_PREF_IMM16_V8: { 726 int32_t actualNumArgs = READ_INST_16_1(); 727 int32_t startReg = READ_INST_8_3(); 728 for (int i = 0; i < actualNumArgs; i++) { 729 info.inputs.emplace_back(VirtualRegister(startReg + i)); 730 } 731 break; 732 } 733 case EcmaOpcode::THROW_CONSTASSIGNMENT_PREF_V8: { 734 uint16_t v0 = READ_INST_8_1(); 735 info.inputs.emplace_back(VirtualRegister(v0)); 736 break; 737 } 738 case EcmaOpcode::THROW_IFNOTOBJECT_PREF_V8: { 739 uint16_t v0 = READ_INST_8_1(); 740 info.inputs.emplace_back(VirtualRegister(v0)); 741 break; 742 } 743 case EcmaOpcode::THROW_UNDEFINEDIFHOLE_PREF_V8_V8: { 744 uint16_t v0 = READ_INST_8_1(); 745 uint16_t v1 = READ_INST_8_2(); 746 info.inputs.emplace_back(VirtualRegister(v0)); 747 info.inputs.emplace_back(VirtualRegister(v1)); 748 break; 749 } 750 case EcmaOpcode::THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16: { 751 uint16_t stringId = READ_INST_16_1(); 752 info.inputs.emplace_back(ICSlotId(stringId)); 753 break; 754 } 755 case EcmaOpcode::THROW_IFSUPERNOTCORRECTCALL_PREF_IMM8: { 756 uint8_t imm = READ_INST_8_1(); 757 info.inputs.emplace_back(Immediate(imm)); 758 break; 759 } 760 case EcmaOpcode::THROW_IFSUPERNOTCORRECTCALL_PREF_IMM16: { 761 uint16_t imm = READ_INST_16_1(); 762 info.inputs.emplace_back(Immediate(imm)); 763 break; 764 } 765 case EcmaOpcode::CLOSEITERATOR_IMM8_V8: { 766 uint16_t v0 = READ_INST_8_1(); 767 info.inputs.emplace_back(VirtualRegister(v0)); 768 break; 769 } 770 case EcmaOpcode::ADD2_IMM8_V8: { 771 uint16_t v0 = READ_INST_8_1(); 772 info.inputs.emplace_back(VirtualRegister(v0)); 773 break; 774 } 775 case EcmaOpcode::SUB2_IMM8_V8: { 776 uint16_t v0 = READ_INST_8_1(); 777 info.inputs.emplace_back(VirtualRegister(v0)); 778 break; 779 } 780 case EcmaOpcode::MUL2_IMM8_V8: { 781 uint16_t v0 = READ_INST_8_1(); 782 info.inputs.emplace_back(VirtualRegister(v0)); 783 break; 784 } 785 case EcmaOpcode::DIV2_IMM8_V8: { 786 uint16_t v0 = READ_INST_8_1(); 787 info.inputs.emplace_back(VirtualRegister(v0)); 788 break; 789 } 790 case EcmaOpcode::MOD2_IMM8_V8: { 791 uint16_t v0 = READ_INST_8_1(); 792 info.inputs.emplace_back(VirtualRegister(v0)); 793 break; 794 } 795 case EcmaOpcode::EQ_IMM8_V8: { 796 uint16_t v0 = READ_INST_8_1(); 797 info.inputs.emplace_back(VirtualRegister(v0)); 798 break; 799 } 800 case EcmaOpcode::NOTEQ_IMM8_V8: { 801 uint16_t v0 = READ_INST_8_1(); 802 info.inputs.emplace_back(VirtualRegister(v0)); 803 break; 804 } 805 case EcmaOpcode::LESS_IMM8_V8: { 806 uint16_t v0 = READ_INST_8_1(); 807 info.inputs.emplace_back(VirtualRegister(v0)); 808 break; 809 } 810 case EcmaOpcode::LESSEQ_IMM8_V8: { 811 uint16_t v0 = READ_INST_8_1(); 812 info.inputs.emplace_back(VirtualRegister(v0)); 813 break; 814 } 815 case EcmaOpcode::GREATER_IMM8_V8: { 816 uint16_t v0 = READ_INST_8_1(); 817 info.inputs.emplace_back(VirtualRegister(v0)); 818 break; 819 } 820 case EcmaOpcode::GREATEREQ_IMM8_V8: { 821 uint16_t vs = READ_INST_8_1(); 822 info.inputs.emplace_back(VirtualRegister(vs)); 823 break; 824 } 825 case EcmaOpcode::SHL2_IMM8_V8: { 826 uint16_t v0 = READ_INST_8_1(); 827 info.inputs.emplace_back(VirtualRegister(v0)); 828 break; 829 } 830 case EcmaOpcode::SHR2_IMM8_V8: { 831 uint16_t v0 = READ_INST_8_1(); 832 info.inputs.emplace_back(VirtualRegister(v0)); 833 break; 834 } 835 case EcmaOpcode::ASHR2_IMM8_V8: { 836 uint16_t v0 = READ_INST_8_1(); 837 info.inputs.emplace_back(VirtualRegister(v0)); 838 break; 839 } 840 case EcmaOpcode::AND2_IMM8_V8: { 841 uint16_t v0 = READ_INST_8_1(); 842 info.inputs.emplace_back(VirtualRegister(v0)); 843 break; 844 } 845 case EcmaOpcode::OR2_IMM8_V8: { 846 uint16_t v0 = READ_INST_8_1(); 847 info.inputs.emplace_back(VirtualRegister(v0)); 848 break; 849 } 850 case EcmaOpcode::XOR2_IMM8_V8: { 851 uint16_t v0 = READ_INST_8_1(); 852 info.inputs.emplace_back(VirtualRegister(v0)); 853 break; 854 } 855 case EcmaOpcode::EXP_IMM8_V8: { 856 uint16_t v0 = READ_INST_8_1(); 857 info.inputs.emplace_back(VirtualRegister(v0)); 858 break; 859 } 860 case EcmaOpcode::ISIN_IMM8_V8: { 861 uint16_t v0 = READ_INST_8_1(); 862 info.inputs.emplace_back(VirtualRegister(v0)); 863 break; 864 } 865 case EcmaOpcode::INSTANCEOF_IMM8_V8: { 866 uint16_t slotId = READ_INST_8_0(); 867 uint16_t v0 = READ_INST_8_1(); 868 info.inputs.emplace_back(ICSlotId(slotId)); 869 info.inputs.emplace_back(VirtualRegister(v0)); 870 break; 871 } 872 case EcmaOpcode::STRICTNOTEQ_IMM8_V8: { 873 uint16_t v0 = READ_INST_8_1(); 874 info.inputs.emplace_back(VirtualRegister(v0)); 875 break; 876 } 877 case EcmaOpcode::STRICTEQ_IMM8_V8: { 878 uint16_t v0 = READ_INST_8_1(); 879 info.inputs.emplace_back(VirtualRegister(v0)); 880 break; 881 } 882 case EcmaOpcode::DELOBJPROP_V8: { 883 uint16_t v0 = READ_INST_8_0(); 884 info.inputs.emplace_back(VirtualRegister(v0)); 885 break; 886 } 887 case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8: { 888 uint16_t slotId = READ_INST_8_0(); 889 uint16_t methodId = READ_INST_16_1(); 890 uint16_t length = READ_INST_8_3(); 891 info.inputs.emplace_back(ICSlotId(slotId)); 892 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 893 info.inputs.emplace_back(Immediate(length)); 894 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 895 break; 896 } 897 case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8: { 898 uint16_t slotId = READ_INST_16_0(); 899 uint16_t methodId = READ_INST_16_2(); 900 uint16_t length = READ_INST_8_4(); 901 info.inputs.emplace_back(ICSlotId(slotId)); 902 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 903 info.inputs.emplace_back(Immediate(length)); 904 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 905 break; 906 } 907 case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8: { 908 uint16_t slotId = READ_INST_8_0(); 909 uint16_t methodId = READ_INST_16_1(); 910 uint16_t length = READ_INST_8_3(); 911 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 912 info.inputs.emplace_back(Immediate(length)); 913 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 914 info.inputs.emplace_back(ICSlotId(slotId)); 915 break; 916 } 917 case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8: { 918 uint16_t slotId = READ_INST_16_0(); 919 uint16_t methodId = READ_INST_16_2(); 920 uint16_t length = READ_INST_8_4(); 921 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 922 info.inputs.emplace_back(Immediate(length)); 923 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 924 info.inputs.emplace_back(ICSlotId(slotId)); 925 break; 926 } 927 case EcmaOpcode::NEWOBJRANGE_IMM8_IMM8_V8: { 928 uint16_t numArgs = READ_INST_8_1(); 929 uint16_t firstArgRegIdx = READ_INST_8_2(); 930 for (uint16_t i = 0; i < numArgs; ++i) { 931 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i)); 932 } 933 break; 934 } 935 case EcmaOpcode::NEWOBJRANGE_IMM16_IMM8_V8: { 936 uint16_t numArgs = READ_INST_8_2(); 937 uint16_t firstArgRegIdx = READ_INST_8_3(); 938 for (uint16_t i = 0; i < numArgs; ++i) { 939 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i)); 940 } 941 break; 942 } 943 case EcmaOpcode::WIDE_NEWOBJRANGE_PREF_IMM16_V8: { 944 uint16_t numArgs = READ_INST_16_1(); 945 uint16_t firstArgRegIdx = READ_INST_8_3(); 946 for (uint16_t i = 0; i < numArgs; ++i) { 947 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i)); 948 } 949 break; 950 } 951 case EcmaOpcode::LDLEXVAR_IMM4_IMM4: { 952 uint16_t level = READ_INST_4_0(); 953 uint16_t slot = READ_INST_4_1(); 954 info.inputs.emplace_back(Immediate(level)); 955 info.inputs.emplace_back(Immediate(slot)); 956 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 957 break; 958 } 959 case EcmaOpcode::LDLEXVAR_IMM8_IMM8: { 960 uint16_t level = READ_INST_8_0(); 961 uint16_t slot = READ_INST_8_1(); 962 info.inputs.emplace_back(Immediate(level)); 963 info.inputs.emplace_back(Immediate(slot)); 964 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 965 break; 966 } 967 case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16: { 968 uint16_t level = READ_INST_16_1(); 969 uint16_t slot = READ_INST_16_3(); 970 info.inputs.emplace_back(Immediate(level)); 971 info.inputs.emplace_back(Immediate(slot)); 972 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 973 break; 974 } 975 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: { 976 uint16_t level = READ_INST_4_2(); 977 uint16_t slot = READ_INST_4_3(); 978 info.inputs.emplace_back(Immediate(level)); 979 info.inputs.emplace_back(Immediate(slot)); 980 break; 981 } 982 case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: { 983 uint16_t level = READ_INST_8_1(); 984 uint16_t slot = READ_INST_8_2(); 985 info.inputs.emplace_back(Immediate(level)); 986 info.inputs.emplace_back(Immediate(slot)); 987 break; 988 } 989 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: { 990 uint16_t level = READ_INST_16_1(); 991 uint16_t slot = READ_INST_16_3(); 992 info.inputs.emplace_back(Immediate(level)); 993 info.inputs.emplace_back(Immediate(slot)); 994 break; 995 } 996 case EcmaOpcode::STLEXVAR_IMM4_IMM4: { 997 uint16_t level = READ_INST_4_0(); 998 uint16_t slot = READ_INST_4_1(); 999 info.inputs.emplace_back(Immediate(level)); 1000 info.inputs.emplace_back(Immediate(slot)); 1001 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1002 break; 1003 } 1004 case EcmaOpcode::STLEXVAR_IMM8_IMM8: { 1005 uint16_t level = READ_INST_8_0(); 1006 uint16_t slot = READ_INST_8_1(); 1007 info.inputs.emplace_back(Immediate(level)); 1008 info.inputs.emplace_back(Immediate(slot)); 1009 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1010 break; 1011 } 1012 case EcmaOpcode::WIDE_STLEXVAR_PREF_IMM16_IMM16: { 1013 uint16_t level = READ_INST_16_1(); 1014 uint16_t slot = READ_INST_16_3(); 1015 info.inputs.emplace_back(Immediate(level)); 1016 info.inputs.emplace_back(Immediate(slot)); 1017 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1018 break; 1019 } 1020 case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4: { 1021 uint16_t level = READ_INST_4_2(); 1022 uint16_t slot = READ_INST_4_3(); 1023 info.inputs.emplace_back(Immediate(level)); 1024 info.inputs.emplace_back(Immediate(slot)); 1025 break; 1026 } 1027 case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8: { 1028 uint16_t level = READ_INST_8_1(); 1029 uint16_t slot = READ_INST_8_2(); 1030 info.inputs.emplace_back(Immediate(level)); 1031 info.inputs.emplace_back(Immediate(slot)); 1032 break; 1033 } 1034 case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16: { 1035 uint16_t level = READ_INST_16_1(); 1036 uint16_t slot = READ_INST_16_3(); 1037 info.inputs.emplace_back(Immediate(level)); 1038 info.inputs.emplace_back(Immediate(slot)); 1039 break; 1040 } 1041 case EcmaOpcode::NEWLEXENV_IMM8: { 1042 uint8_t numVars = READ_INST_8_0(); 1043 info.inputs.emplace_back(Immediate(numVars)); 1044 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1045 info.vregOut.emplace_back(builder->GetEnvVregIdx()); 1046 break; 1047 } 1048 case EcmaOpcode::WIDE_NEWLEXENV_PREF_IMM16: { 1049 uint16_t numVars = READ_INST_16_1(); 1050 info.inputs.emplace_back(Immediate(numVars)); 1051 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1052 info.vregOut.emplace_back(builder->GetEnvVregIdx()); 1053 break; 1054 } 1055 case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8: { 1056 uint8_t numVars = READ_INST_8_1(); 1057 info.inputs.emplace_back(Immediate(numVars)); 1058 break; 1059 } 1060 case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16: { 1061 uint16_t numVars = READ_INST_16_1(); 1062 info.inputs.emplace_back(Immediate(numVars)); 1063 break; 1064 } 1065 case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16: { 1066 uint16_t numVars = READ_INST_8_0(); 1067 uint16_t scopeId = READ_INST_16_1(); 1068 info.inputs.emplace_back(Immediate(numVars)); 1069 info.inputs.emplace_back(Immediate(scopeId)); 1070 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1071 info.vregOut.emplace_back(builder->GetEnvVregIdx()); 1072 break; 1073 } 1074 case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16: { 1075 uint16_t numVars = READ_INST_16_1(); 1076 uint16_t scopeId = READ_INST_16_3(); 1077 info.inputs.emplace_back(Immediate(numVars)); 1078 info.inputs.emplace_back(Immediate(scopeId)); 1079 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1080 info.vregOut.emplace_back(builder->GetEnvVregIdx()); 1081 break; 1082 } 1083 case EcmaOpcode::CREATEITERRESULTOBJ_V8_V8: { 1084 uint16_t v0 = READ_INST_8_0(); 1085 uint16_t v1 = READ_INST_8_1(); 1086 info.inputs.emplace_back(VirtualRegister(v0)); 1087 info.inputs.emplace_back(VirtualRegister(v1)); 1088 break; 1089 } 1090 case EcmaOpcode::SUSPENDGENERATOR_V8: { 1091 uint16_t v0 = READ_INST_8_0(); 1092 uint32_t offset = builder->GetPcOffset(pc); 1093 offset += BytecodeInstruction::Size(EcmaOpcode::SUSPENDGENERATOR_V8); // skip suspend bc 1094 info.inputs.emplace_back(Immediate(offset)); // Save the pc offset when suspend 1095 info.inputs.emplace_back(VirtualRegister(v0)); 1096 break; 1097 } 1098 case EcmaOpcode::ASYNCFUNCTIONAWAITUNCAUGHT_V8: { 1099 uint16_t v0 = READ_INST_8_0(); 1100 info.inputs.emplace_back(VirtualRegister(v0)); 1101 break; 1102 } 1103 case EcmaOpcode::ASYNCFUNCTIONRESOLVE_V8: { 1104 uint16_t v0 = READ_INST_8_0(); 1105 info.inputs.emplace_back(VirtualRegister(v0)); 1106 break; 1107 } 1108 case EcmaOpcode::ASYNCFUNCTIONREJECT_V8: { 1109 uint16_t v0 = READ_INST_8_0(); 1110 info.inputs.emplace_back(VirtualRegister(v0)); 1111 break; 1112 } 1113 case EcmaOpcode::CLOSEITERATOR_IMM16_V8: { 1114 uint16_t v0 = READ_INST_8_2(); 1115 info.inputs.emplace_back(VirtualRegister(v0)); 1116 break; 1117 } 1118 case EcmaOpcode::NEWOBJAPPLY_IMM8_V8: { 1119 uint16_t v0 = READ_INST_8_1(); 1120 info.inputs.emplace_back(VirtualRegister(v0)); 1121 break; 1122 } 1123 case EcmaOpcode::NEWOBJAPPLY_IMM16_V8: { 1124 uint16_t v0 = READ_INST_8_2(); 1125 info.inputs.emplace_back(VirtualRegister(v0)); 1126 break; 1127 } 1128 case EcmaOpcode::STOWNBYNAME_IMM8_ID16_V8: { 1129 uint16_t stringId = READ_INST_16_1(); 1130 uint32_t v0 = READ_INST_8_3(); 1131 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1132 info.inputs.emplace_back(VirtualRegister(v0)); 1133 break; 1134 } 1135 case EcmaOpcode::STOWNBYNAME_IMM16_ID16_V8: { 1136 uint16_t stringId = READ_INST_16_2(); 1137 uint32_t v0 = READ_INST_8_4(); 1138 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1139 info.inputs.emplace_back(VirtualRegister(v0)); 1140 break; 1141 } 1142 case EcmaOpcode::CREATEREGEXPWITHLITERAL_IMM8_ID16_IMM8: { 1143 uint16_t stringId = READ_INST_16_1(); 1144 uint8_t flags = READ_INST_8_3(); 1145 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1146 info.inputs.emplace_back(Immediate(flags)); 1147 break; 1148 } 1149 case EcmaOpcode::CREATEREGEXPWITHLITERAL_IMM16_ID16_IMM8: { 1150 uint16_t stringId = READ_INST_16_2(); 1151 uint8_t flags = READ_INST_8_4(); 1152 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1153 info.inputs.emplace_back(Immediate(flags)); 1154 break; 1155 } 1156 case EcmaOpcode::GETNEXTPROPNAME_V8: { 1157 uint16_t v0 = READ_INST_8_0(); 1158 info.inputs.emplace_back(VirtualRegister(v0)); 1159 break; 1160 } 1161 case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16: { 1162 uint16_t imm = READ_INST_16_1(); 1163 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ObjectLiteralIDType, imm)); 1164 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1165 break; 1166 } 1167 case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16: { 1168 uint16_t imm = READ_INST_16_2(); 1169 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ObjectLiteralIDType, imm)); 1170 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1171 break; 1172 } 1173 case EcmaOpcode::SETOBJECTWITHPROTO_IMM8_V8: { 1174 uint16_t v0 = READ_INST_8_1(); 1175 info.inputs.emplace_back(VirtualRegister(v0)); 1176 break; 1177 } 1178 case EcmaOpcode::SETOBJECTWITHPROTO_IMM16_V8: { 1179 uint16_t v0 = READ_INST_8_2(); 1180 info.inputs.emplace_back(VirtualRegister(v0)); 1181 break; 1182 } 1183 case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16: { 1184 uint16_t imm = READ_INST_16_1(); 1185 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ArrayLiteralIDType, imm)); 1186 break; 1187 } 1188 case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16: { 1189 uint16_t imm = READ_INST_16_2(); 1190 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ArrayLiteralIDType, imm)); 1191 break; 1192 } 1193 case EcmaOpcode::GETMODULENAMESPACE_IMM8: { 1194 int32_t index = READ_INST_8_0(); 1195 info.inputs.emplace_back(Immediate(index)); 1196 break; 1197 } 1198 case EcmaOpcode::WIDE_GETMODULENAMESPACE_PREF_IMM16: { 1199 int32_t index = READ_INST_16_1(); 1200 info.inputs.emplace_back(Immediate(index)); 1201 break; 1202 } 1203 case EcmaOpcode::STMODULEVAR_IMM8: { 1204 int32_t index = READ_INST_8_0(); 1205 info.inputs.emplace_back(Immediate(index)); 1206 break; 1207 } 1208 case EcmaOpcode::SETGENERATORSTATE_IMM8: { 1209 int32_t index = READ_INST_8_0(); 1210 info.inputs.emplace_back(Immediate(index)); 1211 break; 1212 } 1213 case EcmaOpcode::WIDE_STMODULEVAR_PREF_IMM16: { 1214 int32_t index = READ_INST_16_1(); 1215 info.inputs.emplace_back(Immediate(index)); 1216 break; 1217 } 1218 case EcmaOpcode::LDLOCALMODULEVAR_IMM8: { 1219 int32_t index = READ_INST_8_0(); 1220 info.inputs.emplace_back(Immediate(index)); 1221 break; 1222 } 1223 case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16: { 1224 int32_t index = READ_INST_16_1(); 1225 info.inputs.emplace_back(Immediate(index)); 1226 break; 1227 } 1228 case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8: { 1229 int32_t index = READ_INST_8_0(); 1230 info.inputs.emplace_back(Immediate(index)); 1231 break; 1232 } 1233 case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16: { 1234 int32_t index = READ_INST_16_1(); 1235 info.inputs.emplace_back(Immediate(index)); 1236 break; 1237 } 1238 case EcmaOpcode::CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8: { 1239 int32_t index = READ_INST_8_1(); 1240 info.inputs.emplace_back(Immediate(index)); 1241 break; 1242 } 1243 case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16: { 1244 int32_t index = READ_INST_16_1(); 1245 info.inputs.emplace_back(Immediate(index)); 1246 break; 1247 } 1248 case EcmaOpcode::CALLRUNTIME_LDLAZYMODULEVAR_PREF_IMM8: { 1249 int32_t index = READ_INST_8_1(); 1250 info.inputs.emplace_back(Immediate(index)); 1251 break; 1252 } 1253 case EcmaOpcode::CALLRUNTIME_WIDELDLAZYMODULEVAR_PREF_IMM16: { 1254 int32_t index = READ_INST_16_1(); 1255 info.inputs.emplace_back(Immediate(index)); 1256 break; 1257 } 1258 case EcmaOpcode::CALLRUNTIME_LDLAZYSENDABLEMODULEVAR_PREF_IMM8: { 1259 int32_t index = READ_INST_8_1(); 1260 info.inputs.emplace_back(Immediate(index)); 1261 break; 1262 } 1263 case EcmaOpcode::CALLRUNTIME_WIDELDLAZYSENDABLEMODULEVAR_PREF_IMM16: { 1264 int32_t index = READ_INST_16_1(); 1265 info.inputs.emplace_back(Immediate(index)); 1266 break; 1267 } 1268 case EcmaOpcode::STCONSTTOGLOBALRECORD_IMM16_ID16: { 1269 uint16_t stringId = READ_INST_16_2(); 1270 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1271 break; 1272 } 1273 case EcmaOpcode::GETTEMPLATEOBJECT_IMM8: 1274 case EcmaOpcode::GETTEMPLATEOBJECT_IMM16: 1275 break; 1276 case EcmaOpcode::COPYDATAPROPERTIES_V8: { 1277 uint16_t v0 = READ_INST_8_0(); 1278 info.inputs.emplace_back(VirtualRegister(v0)); 1279 break; 1280 } 1281 case EcmaOpcode::STOWNBYINDEX_IMM8_V8_IMM16: { 1282 uint8_t v0 = READ_INST_8_1(); 1283 uint16_t index = READ_INST_16_2(); 1284 info.inputs.emplace_back(VirtualRegister(v0)); 1285 info.inputs.emplace_back(Immediate(index)); 1286 break; 1287 } 1288 case EcmaOpcode::STOWNBYINDEX_IMM16_V8_IMM16: { 1289 uint8_t v0 = READ_INST_8_2(); 1290 uint16_t index = READ_INST_16_3(); 1291 info.inputs.emplace_back(VirtualRegister(v0)); 1292 info.inputs.emplace_back(Immediate(index)); 1293 break; 1294 } 1295 case EcmaOpcode::WIDE_STOWNBYINDEX_PREF_V8_IMM32: { 1296 uint32_t v0 = READ_INST_8_1(); 1297 uint32_t index = READ_INST_32_2(); 1298 info.inputs.emplace_back(VirtualRegister(v0)); 1299 info.inputs.emplace_back(Immediate(index)); 1300 break; 1301 } 1302 case EcmaOpcode::STOWNBYVALUE_IMM8_V8_V8: { 1303 uint32_t v0 = READ_INST_8_1(); 1304 uint32_t v1 = READ_INST_8_2(); 1305 info.inputs.emplace_back(VirtualRegister(v0)); 1306 info.inputs.emplace_back(VirtualRegister(v1)); 1307 break; 1308 } 1309 case EcmaOpcode::STOWNBYVALUE_IMM16_V8_V8: { 1310 uint32_t v0 = READ_INST_8_2(); 1311 uint32_t v1 = READ_INST_8_3(); 1312 info.inputs.emplace_back(VirtualRegister(v0)); 1313 info.inputs.emplace_back(VirtualRegister(v1)); 1314 break; 1315 } 1316 case EcmaOpcode::CREATEOBJECTWITHEXCLUDEDKEYS_IMM8_V8_V8: { 1317 uint8_t numKeys = READ_INST_8_0(); 1318 uint16_t v0 = READ_INST_8_1(); 1319 uint16_t firstArgRegIdx = READ_INST_8_2(); 1320 info.inputs.emplace_back(VirtualRegister(v0)); 1321 for (int i = 0; i <= numKeys; i++) { 1322 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i)); 1323 } 1324 break; 1325 } 1326 case EcmaOpcode::WIDE_CREATEOBJECTWITHEXCLUDEDKEYS_PREF_IMM16_V8_V8: { 1327 uint16_t numKeys = READ_INST_16_1(); 1328 uint16_t v0 = READ_INST_8_3(); 1329 uint16_t firstArgRegIdx = READ_INST_8_4(); 1330 info.inputs.emplace_back(VirtualRegister(v0)); 1331 for (int i = 0; i <= numKeys; i++) { 1332 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i)); 1333 } 1334 break; 1335 } 1336 case EcmaOpcode::COPYRESTARGS_IMM8: { 1337 uint16_t restIdx = READ_INST_8_0(); 1338 info.inputs.emplace_back(Immediate(restIdx)); 1339 break; 1340 } 1341 case EcmaOpcode::WIDE_COPYRESTARGS_PREF_IMM16: { 1342 uint16_t restIdx = READ_INST_16_1(); 1343 info.inputs.emplace_back(Immediate(restIdx)); 1344 break; 1345 } 1346 case EcmaOpcode::DEFINEGETTERSETTERBYVALUE_V8_V8_V8_V8: { 1347 uint16_t v0 = READ_INST_8_0(); 1348 uint16_t v1 = READ_INST_8_1(); 1349 uint16_t v2 = READ_INST_8_2(); 1350 uint16_t v3 = READ_INST_8_3(); 1351 info.inputs.emplace_back(VirtualRegister(v0)); 1352 info.inputs.emplace_back(VirtualRegister(v1)); 1353 info.inputs.emplace_back(VirtualRegister(v2)); 1354 info.inputs.emplace_back(VirtualRegister(v3)); 1355 break; 1356 } 1357 case EcmaOpcode::LDOBJBYINDEX_IMM8_IMM16: { 1358 uint32_t idx = READ_INST_16_1(); 1359 info.inputs.emplace_back(Immediate(idx)); 1360 break; 1361 } 1362 case EcmaOpcode::LDOBJBYINDEX_IMM16_IMM16: { 1363 uint32_t idx = READ_INST_16_2(); 1364 info.inputs.emplace_back(Immediate(idx)); 1365 break; 1366 } 1367 case EcmaOpcode::WIDE_LDOBJBYINDEX_PREF_IMM32: { 1368 uint32_t idx = READ_INST_32_1(); 1369 info.inputs.emplace_back(Immediate(idx)); 1370 break; 1371 } 1372 case EcmaOpcode::STOBJBYINDEX_IMM8_V8_IMM16: { 1373 uint8_t v0 = READ_INST_8_1(); 1374 uint16_t index = READ_INST_16_2(); 1375 info.inputs.emplace_back(VirtualRegister(v0)); 1376 info.inputs.emplace_back(Immediate(index)); 1377 break; 1378 } 1379 case EcmaOpcode::STOBJBYINDEX_IMM16_V8_IMM16: { 1380 uint8_t v0 = READ_INST_8_2(); 1381 uint16_t index = READ_INST_16_3(); 1382 info.inputs.emplace_back(VirtualRegister(v0)); 1383 info.inputs.emplace_back(Immediate(index)); 1384 break; 1385 } 1386 case EcmaOpcode::WIDE_STOBJBYINDEX_PREF_V8_IMM32: { 1387 uint8_t v0 = READ_INST_8_1(); 1388 uint32_t index = READ_INST_32_2(); 1389 info.inputs.emplace_back(VirtualRegister(v0)); 1390 info.inputs.emplace_back(Immediate(index)); 1391 break; 1392 } 1393 case EcmaOpcode::LDOBJBYVALUE_IMM8_V8: { 1394 uint16_t slotId = READ_INST_8_0(); 1395 uint32_t v0 = READ_INST_8_1(); 1396 info.inputs.emplace_back(ICSlotId(slotId)); 1397 info.inputs.emplace_back(VirtualRegister(v0)); 1398 break; 1399 } 1400 case EcmaOpcode::LDOBJBYVALUE_IMM16_V8: { 1401 uint16_t slotId = READ_INST_16_0(); 1402 uint32_t v0 = READ_INST_8_2(); 1403 info.inputs.emplace_back(ICSlotId(slotId)); 1404 info.inputs.emplace_back(VirtualRegister(v0)); 1405 break; 1406 } 1407 case EcmaOpcode::STOBJBYVALUE_IMM8_V8_V8: { 1408 uint16_t slotId = READ_INST_8_0(); 1409 uint32_t v0 = READ_INST_8_1(); 1410 uint32_t v1 = READ_INST_8_2(); 1411 info.inputs.emplace_back(ICSlotId(slotId)); 1412 info.inputs.emplace_back(VirtualRegister(v0)); 1413 info.inputs.emplace_back(VirtualRegister(v1)); 1414 break; 1415 } 1416 case EcmaOpcode::STOBJBYVALUE_IMM16_V8_V8: { 1417 uint16_t slotId = READ_INST_16_0(); 1418 uint32_t v0 = READ_INST_8_2(); 1419 uint32_t v1 = READ_INST_8_3(); 1420 info.inputs.emplace_back(ICSlotId(slotId)); 1421 info.inputs.emplace_back(VirtualRegister(v0)); 1422 info.inputs.emplace_back(VirtualRegister(v1)); 1423 break; 1424 } 1425 case EcmaOpcode::LDSUPERBYVALUE_IMM8_V8: { 1426 uint32_t v0 = READ_INST_8_1(); 1427 info.inputs.emplace_back(VirtualRegister(v0)); 1428 break; 1429 } 1430 case EcmaOpcode::LDSUPERBYVALUE_IMM16_V8: { 1431 uint32_t v0 = READ_INST_8_2(); 1432 info.inputs.emplace_back(VirtualRegister(v0)); 1433 break; 1434 } 1435 case EcmaOpcode::STSUPERBYVALUE_IMM8_V8_V8: { 1436 uint32_t v0 = READ_INST_8_1(); 1437 uint32_t v1 = READ_INST_8_2(); 1438 info.inputs.emplace_back(VirtualRegister(v0)); 1439 info.inputs.emplace_back(VirtualRegister(v1)); 1440 break; 1441 } 1442 case EcmaOpcode::STSUPERBYVALUE_IMM16_V8_V8: { 1443 uint32_t v0 = READ_INST_8_2(); 1444 uint32_t v1 = READ_INST_8_3(); 1445 info.inputs.emplace_back(VirtualRegister(v0)); 1446 info.inputs.emplace_back(VirtualRegister(v1)); 1447 break; 1448 } 1449 case EcmaOpcode::TRYLDGLOBALBYNAME_IMM8_ID16: { 1450 uint16_t slotId = READ_INST_8_0(); 1451 uint16_t stringId = READ_INST_16_1(); 1452 info.inputs.emplace_back(ICSlotId(slotId)); 1453 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1454 break; 1455 } 1456 case EcmaOpcode::TRYLDGLOBALBYNAME_IMM16_ID16: { 1457 uint16_t slotId = READ_INST_16_0(); 1458 uint16_t stringId = READ_INST_16_2(); 1459 info.inputs.emplace_back(ICSlotId(slotId)); 1460 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1461 break; 1462 } 1463 case EcmaOpcode::TRYSTGLOBALBYNAME_IMM8_ID16: { 1464 uint16_t slotId = READ_INST_8_0(); 1465 uint16_t stringId = READ_INST_16_1(); 1466 info.inputs.emplace_back(ICSlotId(slotId)); 1467 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1468 break; 1469 } 1470 case EcmaOpcode::TRYSTGLOBALBYNAME_IMM16_ID16: { 1471 uint16_t slotId = READ_INST_16_0(); 1472 uint16_t stringId = READ_INST_16_2(); 1473 info.inputs.emplace_back(ICSlotId(slotId)); 1474 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1475 break; 1476 } 1477 case EcmaOpcode::STTOGLOBALRECORD_IMM16_ID16: { 1478 uint16_t stringId = READ_INST_16_2(); 1479 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1480 break; 1481 } 1482 case EcmaOpcode::STOWNBYVALUEWITHNAMESET_IMM8_V8_V8: { 1483 uint32_t v0 = READ_INST_8_1(); 1484 uint32_t v1 = READ_INST_8_2(); 1485 info.inputs.emplace_back(VirtualRegister(v0)); 1486 info.inputs.emplace_back(VirtualRegister(v1)); 1487 break; 1488 } 1489 case EcmaOpcode::STOWNBYVALUEWITHNAMESET_IMM16_V8_V8: { 1490 uint32_t v0 = READ_INST_8_2(); 1491 uint32_t v1 = READ_INST_8_3(); 1492 info.inputs.emplace_back(VirtualRegister(v0)); 1493 info.inputs.emplace_back(VirtualRegister(v1)); 1494 break; 1495 } 1496 case EcmaOpcode::STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8: { 1497 uint16_t stringId = READ_INST_16_1(); 1498 uint32_t v0 = READ_INST_8_3(); 1499 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1500 info.inputs.emplace_back(VirtualRegister(v0)); 1501 break; 1502 } 1503 case EcmaOpcode::STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8: { 1504 uint16_t stringId = READ_INST_16_2(); 1505 uint32_t v0 = READ_INST_8_4(); 1506 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1507 info.inputs.emplace_back(VirtualRegister(v0)); 1508 break; 1509 } 1510 case EcmaOpcode::STTHISBYVALUE_IMM8_V8: { 1511 uint16_t slotId = READ_INST_8_0(); 1512 uint32_t v0 = READ_INST_8_1(); 1513 info.inputs.emplace_back(ICSlotId(slotId)); 1514 info.inputs.emplace_back(VirtualRegister(v0)); 1515 break; 1516 } 1517 case EcmaOpcode::STTHISBYVALUE_IMM16_V8: { 1518 uint16_t slotId = READ_INST_16_0(); 1519 uint32_t v0 = READ_INST_8_2(); 1520 info.inputs.emplace_back(ICSlotId(slotId)); 1521 info.inputs.emplace_back(VirtualRegister(v0)); 1522 break; 1523 } 1524 // not implement 1525 case EcmaOpcode::JSTRICTEQZ_IMM8: 1526 case EcmaOpcode::JSTRICTEQZ_IMM16: 1527 case EcmaOpcode::JNSTRICTEQZ_IMM8: 1528 case EcmaOpcode::JNSTRICTEQZ_IMM16: 1529 case EcmaOpcode::JEQNULL_IMM8: 1530 case EcmaOpcode::JEQNULL_IMM16: 1531 case EcmaOpcode::JNENULL_IMM8: 1532 case EcmaOpcode::JNENULL_IMM16: 1533 case EcmaOpcode::JSTRICTEQNULL_IMM8: 1534 case EcmaOpcode::JSTRICTEQNULL_IMM16: 1535 case EcmaOpcode::JNSTRICTEQNULL_IMM8: 1536 case EcmaOpcode::JNSTRICTEQNULL_IMM16: 1537 case EcmaOpcode::JEQUNDEFINED_IMM8: 1538 case EcmaOpcode::JEQUNDEFINED_IMM16: 1539 case EcmaOpcode::JNEUNDEFINED_IMM8: 1540 case EcmaOpcode::JNEUNDEFINED_IMM16: 1541 case EcmaOpcode::JSTRICTEQUNDEFINED_IMM8: 1542 case EcmaOpcode::JSTRICTEQUNDEFINED_IMM16: 1543 case EcmaOpcode::JNSTRICTEQUNDEFINED_IMM8: 1544 case EcmaOpcode::JNSTRICTEQUNDEFINED_IMM16: 1545 case EcmaOpcode::JEQ_V8_IMM8: 1546 case EcmaOpcode::JEQ_V8_IMM16: 1547 case EcmaOpcode::JNE_V8_IMM8: 1548 case EcmaOpcode::JNE_V8_IMM16: 1549 case EcmaOpcode::JSTRICTEQ_V8_IMM8: 1550 case EcmaOpcode::JSTRICTEQ_V8_IMM16: 1551 case EcmaOpcode::JNSTRICTEQ_V8_IMM8: 1552 case EcmaOpcode::JNSTRICTEQ_V8_IMM16: 1553 case EcmaOpcode::LDTHIS: 1554 break; 1555 case EcmaOpcode::LDTHISBYNAME_IMM8_ID16: { 1556 uint16_t slotId = READ_INST_8_0(); 1557 uint16_t stringId = READ_INST_16_1(); 1558 info.inputs.emplace_back(ICSlotId(slotId)); 1559 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1560 break; 1561 } 1562 case EcmaOpcode::LDTHISBYNAME_IMM16_ID16: { 1563 uint16_t slotId = READ_INST_16_0(); 1564 uint16_t stringId = READ_INST_16_2(); 1565 info.inputs.emplace_back(ICSlotId(slotId)); 1566 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1567 break; 1568 } 1569 case EcmaOpcode::STTHISBYNAME_IMM8_ID16: { 1570 uint16_t slotId = READ_INST_8_0(); 1571 uint16_t stringId = READ_INST_16_1(); 1572 info.inputs.emplace_back(ICSlotId(slotId)); 1573 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1574 break; 1575 } 1576 case EcmaOpcode::STTHISBYNAME_IMM16_ID16: { 1577 uint16_t slotId = READ_INST_16_0(); 1578 uint16_t stringId = READ_INST_16_2(); 1579 info.inputs.emplace_back(ICSlotId(slotId)); 1580 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1581 break; 1582 } 1583 case EcmaOpcode::LDGLOBALVAR_IMM16_ID16: { 1584 uint16_t slotId = READ_INST_16_0(); 1585 uint16_t stringId = READ_INST_16_2(); 1586 info.inputs.emplace_back(ICSlotId(slotId)); 1587 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1588 break; 1589 } 1590 case EcmaOpcode::LDOBJBYNAME_IMM8_ID16: { 1591 uint16_t slotId = READ_INST_8_0(); 1592 uint16_t stringId = READ_INST_16_1(); 1593 info.inputs.emplace_back(ICSlotId(slotId)); 1594 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1595 break; 1596 } 1597 case EcmaOpcode::LDOBJBYNAME_IMM16_ID16: { 1598 uint16_t slotId = READ_INST_16_0(); 1599 uint16_t stringId = READ_INST_16_2(); 1600 info.inputs.emplace_back(ICSlotId(slotId)); 1601 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1602 break; 1603 } 1604 case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8: { 1605 uint16_t slotId = READ_INST_8_0(); 1606 uint16_t stringId = READ_INST_16_1(); 1607 uint32_t v0 = READ_INST_8_3(); 1608 info.inputs.emplace_back(ICSlotId(slotId)); 1609 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1610 info.inputs.emplace_back(VirtualRegister(v0)); 1611 break; 1612 } 1613 case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8: { 1614 uint16_t slotId = READ_INST_16_0(); 1615 uint16_t stringId = READ_INST_16_2(); 1616 uint32_t v0 = READ_INST_8_4(); 1617 info.inputs.emplace_back(ICSlotId(slotId)); 1618 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1619 info.inputs.emplace_back(VirtualRegister(v0)); 1620 break; 1621 } 1622 case EcmaOpcode::LDSUPERBYNAME_IMM8_ID16: { 1623 uint16_t stringId = READ_INST_16_1(); 1624 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1625 break; 1626 } 1627 case EcmaOpcode::LDSUPERBYNAME_IMM16_ID16: { 1628 uint16_t stringId = READ_INST_16_2(); 1629 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1630 break; 1631 } 1632 case EcmaOpcode::STSUPERBYNAME_IMM8_ID16_V8: { 1633 uint16_t stringId = READ_INST_16_1(); 1634 uint32_t v0 = READ_INST_8_3(); 1635 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1636 info.inputs.emplace_back(VirtualRegister(v0)); 1637 break; 1638 } 1639 case EcmaOpcode::STSUPERBYNAME_IMM16_ID16_V8: { 1640 uint16_t stringId = READ_INST_16_2(); 1641 uint32_t v0 = READ_INST_8_4(); 1642 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1643 info.inputs.emplace_back(VirtualRegister(v0)); 1644 break; 1645 } 1646 case EcmaOpcode::STGLOBALVAR_IMM16_ID16: { 1647 uint16_t slotId = READ_INST_16_0(); 1648 uint32_t stringId = READ_INST_16_2(); 1649 info.inputs.emplace_back(ICSlotId(slotId)); 1650 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1651 break; 1652 } 1653 case EcmaOpcode::CREATEGENERATOROBJ_V8: { 1654 uint16_t v0 = READ_INST_8_0(); 1655 info.inputs.emplace_back(VirtualRegister(v0)); 1656 break; 1657 } 1658 case EcmaOpcode::CREATEASYNCGENERATOROBJ_V8: { 1659 uint16_t v0 = READ_INST_8_0(); 1660 info.inputs.emplace_back(VirtualRegister(v0)); 1661 break; 1662 } 1663 case EcmaOpcode::ASYNCGENERATORRESOLVE_V8_V8_V8: { 1664 uint16_t v0 = READ_INST_8_0(); 1665 uint16_t v1 = READ_INST_8_1(); 1666 uint16_t v2 = READ_INST_8_2(); 1667 uint32_t offset = builder->GetPcOffset(pc); 1668 offset += BytecodeInstruction::Size(EcmaOpcode::ASYNCGENERATORRESOLVE_V8_V8_V8); // skip suspend bc 1669 info.inputs.emplace_back(Immediate(offset)); // Save the pc offset 1670 info.inputs.emplace_back(VirtualRegister(v0)); 1671 info.inputs.emplace_back(VirtualRegister(v1)); 1672 info.inputs.emplace_back(VirtualRegister(v2)); 1673 break; 1674 } 1675 case EcmaOpcode::ASYNCGENERATORREJECT_V8: { 1676 uint16_t v0 = READ_INST_8_0(); 1677 info.inputs.emplace_back(VirtualRegister(v0)); 1678 break; 1679 } 1680 case EcmaOpcode::STARRAYSPREAD_V8_V8: { 1681 uint16_t v0 = READ_INST_8_0(); 1682 uint16_t v1 = READ_INST_8_1(); 1683 info.inputs.emplace_back(VirtualRegister(v0)); 1684 info.inputs.emplace_back(VirtualRegister(v1)); 1685 break; 1686 } 1687 case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8: { 1688 uint16_t slotId = READ_INST_8_0(); 1689 uint16_t methodId = READ_INST_16_1(); 1690 uint16_t literaId = READ_INST_16_3(); 1691 uint16_t length = READ_INST_16_5(); 1692 uint16_t v0 = READ_INST_8_7(); 1693 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 1694 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ClassLiteralIDType, literaId)); 1695 info.inputs.emplace_back(Immediate(length)); 1696 info.inputs.emplace_back(VirtualRegister(v0)); 1697 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1698 info.inputs.emplace_back(ICSlotId(slotId)); 1699 break; 1700 } 1701 case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8: { 1702 uint16_t slotId = READ_INST_16_0(); 1703 uint16_t methodId = READ_INST_16_2(); 1704 uint16_t literaId = READ_INST_16_4(); 1705 uint16_t length = READ_INST_16_6(); 1706 uint16_t v0 = READ_INST_8_8(); 1707 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 1708 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ClassLiteralIDType, literaId)); 1709 info.inputs.emplace_back(Immediate(length)); 1710 info.inputs.emplace_back(VirtualRegister(v0)); 1711 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1712 info.inputs.emplace_back(ICSlotId(slotId)); 1713 break; 1714 } 1715 case EcmaOpcode::LDFUNCTION: { 1716 break; 1717 } 1718 case EcmaOpcode::LDBIGINT_ID16: { 1719 uint32_t stringId = READ_INST_16_0(); 1720 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1721 break; 1722 } 1723 case EcmaOpcode::DYNAMICIMPORT: { 1724 break; 1725 } 1726 case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8: 1727 case EcmaOpcode::SUPERCALLARROWRANGE_IMM8_IMM8_V8: { 1728 uint16_t range = READ_INST_8_1(); 1729 uint16_t v0 = READ_INST_8_2(); 1730 for (size_t i = 0; i < range; i++) { 1731 info.inputs.emplace_back(VirtualRegister(v0 + i)); 1732 } 1733 break; 1734 } 1735 case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8: 1736 case EcmaOpcode::WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8: { 1737 uint16_t range = READ_INST_16_1(); 1738 uint16_t v0 = READ_INST_8_3(); 1739 for (size_t i = 0; i < range; i++) { 1740 info.inputs.emplace_back(VirtualRegister(v0 + i)); 1741 } 1742 break; 1743 } 1744 case EcmaOpcode::SUPERCALLSPREAD_IMM8_V8: { 1745 uint16_t v0 = READ_INST_8_1(); 1746 info.inputs.emplace_back(VirtualRegister(v0)); 1747 break; 1748 } 1749 case EcmaOpcode::CALLRUNTIME_SUPERCALLFORWARDALLARGS_PREF_V8: { 1750 uint16_t v0 = READ_INST_8_1(); 1751 info.inputs.emplace_back(VirtualRegister(v0)); 1752 break; 1753 } 1754 case EcmaOpcode::POPLEXENV: { 1755 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1756 info.vregOut.emplace_back(builder->GetEnvVregIdx()); 1757 break; 1758 } 1759 case EcmaOpcode::LDPRIVATEPROPERTY_IMM8_IMM16_IMM16: { 1760 uint32_t slotId = READ_INST_8_0(); 1761 uint32_t levelIndex = READ_INST_16_1(); 1762 uint32_t slotIndex = READ_INST_16_3(); 1763 info.inputs.emplace_back(Immediate(slotId)); 1764 info.inputs.emplace_back(Immediate(levelIndex)); 1765 info.inputs.emplace_back(Immediate(slotIndex)); 1766 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1767 break; 1768 } 1769 case EcmaOpcode::STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8: { 1770 uint32_t slotId = READ_INST_8_0(); 1771 uint32_t levelIndex = READ_INST_16_1(); 1772 uint32_t slotIndex = READ_INST_16_3(); 1773 uint32_t v0 = READ_INST_8_5(); 1774 info.inputs.emplace_back(Immediate(slotId)); 1775 info.inputs.emplace_back(Immediate(levelIndex)); 1776 info.inputs.emplace_back(Immediate(slotIndex)); 1777 info.inputs.emplace_back(VirtualRegister(v0)); 1778 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1779 break; 1780 } 1781 case EcmaOpcode::TESTIN_IMM8_IMM16_IMM16: { 1782 uint32_t slotId = READ_INST_8_0(); 1783 uint32_t levelIndex = READ_INST_16_1(); 1784 uint32_t slotIndex = READ_INST_16_3(); 1785 info.inputs.emplace_back(Immediate(slotId)); 1786 info.inputs.emplace_back(Immediate(levelIndex)); 1787 info.inputs.emplace_back(Immediate(slotIndex)); 1788 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1789 break; 1790 } 1791 case EcmaOpcode::DEFINEPROPERTYBYNAME_IMM8_ID16_V8: 1792 case EcmaOpcode::DEFINEFIELDBYNAME_IMM8_ID16_V8: { 1793 uint16_t slotId = READ_INST_8_0(); 1794 uint16_t stringId = READ_INST_16_1(); 1795 uint32_t v0 = READ_INST_8_3(); 1796 info.inputs.emplace_back(ICSlotId(slotId)); 1797 info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId)); 1798 info.inputs.emplace_back(VirtualRegister(v0)); 1799 break; 1800 } 1801 case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8: { 1802 uint32_t v0 = READ_INST_8_2(); 1803 uint32_t v1 = READ_INST_8_3(); 1804 info.inputs.emplace_back(VirtualRegister(v0)); 1805 info.inputs.emplace_back(VirtualRegister(v1)); 1806 break; 1807 } 1808 case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYINDEX_PREF_IMM8_IMM32_V8: { 1809 uint32_t index = READ_INST_32_2(); 1810 uint32_t v0 = READ_INST_8_6(); 1811 info.inputs.emplace_back(Immediate(index)); 1812 info.inputs.emplace_back(VirtualRegister(v0)); 1813 break; 1814 } 1815 case EcmaOpcode::CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16: { 1816 uint32_t count = READ_INST_16_1(); 1817 uint32_t literalId = READ_INST_16_3(); 1818 info.inputs.emplace_back(Immediate(count)); 1819 info.inputs.emplace_back(Immediate(literalId)); 1820 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1821 break; 1822 } 1823 case EcmaOpcode::CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8: { 1824 uint32_t levelIndex = READ_INST_16_2(); 1825 uint32_t slotIndex = READ_INST_16_4(); 1826 uint32_t v0 = READ_INST_8_6(); 1827 info.inputs.emplace_back(Immediate(levelIndex)); 1828 info.inputs.emplace_back(Immediate(slotIndex)); 1829 info.inputs.emplace_back(VirtualRegister(v0)); 1830 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1831 break; 1832 } 1833 case EcmaOpcode::CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8: { 1834 uint16_t methodId = READ_INST_16_3(); 1835 uint16_t literaId = READ_INST_16_5(); 1836 uint16_t length = READ_INST_16_7(); 1837 uint16_t v0 = READ_INST_8_9(); 1838 info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId)); 1839 info.inputs.emplace_back(ConstDataId(ConstDataIDType::ClassLiteralIDType, literaId)); 1840 info.inputs.emplace_back(Immediate(length)); 1841 info.inputs.emplace_back(VirtualRegister(v0)); 1842 break; 1843 } 1844 case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16: { 1845 uint16_t level = READ_INST_16_1(); 1846 info.inputs.emplace_back(Immediate(level)); 1847 info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx())); 1848 break; 1849 } 1850 case EcmaOpcode::TONUMERIC_IMM8: 1851 case EcmaOpcode::INC_IMM8: 1852 case EcmaOpcode::DEC_IMM8: 1853 case EcmaOpcode::NOT_IMM8: 1854 case EcmaOpcode::NEG_IMM8: 1855 case EcmaOpcode::JMP_IMM8: 1856 case EcmaOpcode::JMP_IMM16: 1857 case EcmaOpcode::JMP_IMM32: 1858 case EcmaOpcode::JEQZ_IMM8: 1859 case EcmaOpcode::JEQZ_IMM16: 1860 case EcmaOpcode::JEQZ_IMM32: 1861 case EcmaOpcode::JNEZ_IMM8: 1862 case EcmaOpcode::JNEZ_IMM16: 1863 case EcmaOpcode::JNEZ_IMM32: 1864 case EcmaOpcode::RETURN: 1865 case EcmaOpcode::RETURNUNDEFINED: 1866 case EcmaOpcode::LDNAN: 1867 case EcmaOpcode::LDINFINITY: 1868 case EcmaOpcode::LDNEWTARGET: 1869 case EcmaOpcode::LDUNDEFINED: 1870 case EcmaOpcode::LDNULL: 1871 case EcmaOpcode::LDSYMBOL: 1872 case EcmaOpcode::LDGLOBAL: 1873 case EcmaOpcode::LDTRUE: 1874 case EcmaOpcode::LDFALSE: 1875 case EcmaOpcode::LDHOLE: 1876 case EcmaOpcode::CALLARG0_IMM8: 1877 case EcmaOpcode::GETUNMAPPEDARGS: 1878 case EcmaOpcode::ASYNCFUNCTIONENTER: 1879 case EcmaOpcode::TYPEOF_IMM8: 1880 case EcmaOpcode::TYPEOF_IMM16: 1881 case EcmaOpcode::TONUMBER_IMM8: 1882 case EcmaOpcode::THROW_PREF_NONE: 1883 case EcmaOpcode::GETPROPITERATOR: 1884 case EcmaOpcode::GETRESUMEMODE: 1885 case EcmaOpcode::CREATEEMPTYARRAY_IMM8: 1886 case EcmaOpcode::CREATEEMPTYARRAY_IMM16: 1887 case EcmaOpcode::CREATEEMPTYOBJECT: 1888 case EcmaOpcode::DEBUGGER: 1889 case EcmaOpcode::ISTRUE: 1890 case EcmaOpcode::ISFALSE: 1891 case EcmaOpcode::CALLRUNTIME_ISTRUE_PREF_IMM8: 1892 case EcmaOpcode::CALLRUNTIME_ISFALSE_PREF_IMM8: 1893 case EcmaOpcode::NOP: 1894 case EcmaOpcode::GETITERATOR_IMM8: 1895 case EcmaOpcode::GETITERATOR_IMM16: 1896 case EcmaOpcode::GETASYNCITERATOR_IMM8: 1897 case EcmaOpcode::THROW_NOTEXISTS_PREF_NONE: 1898 case EcmaOpcode::THROW_PATTERNNONCOERCIBLE_PREF_NONE: 1899 case EcmaOpcode::THROW_DELETESUPERPROPERTY_PREF_NONE: 1900 case EcmaOpcode::RESUMEGENERATOR: 1901 case EcmaOpcode::CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE: 1902 case EcmaOpcode::CALLRUNTIME_TOPROPERTYKEY_PREF_NONE: 1903 break; 1904 case EcmaOpcode::LDTHISBYVALUE_IMM8: { 1905 uint16_t slotId = READ_INST_8_0(); 1906 info.inputs.emplace_back(ICSlotId(slotId)); 1907 break; 1908 } 1909 case EcmaOpcode::LDTHISBYVALUE_IMM16: { 1910 uint16_t slotId = READ_INST_16_0(); 1911 info.inputs.emplace_back(ICSlotId(slotId)); 1912 break; 1913 } 1914 case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16: { 1915 uint16_t index = READ_INST_16_1(); 1916 info.inputs.emplace_back(Immediate(index)); 1917 break; 1918 } 1919 case EcmaOpcode::WIDE_STPATCHVAR_PREF_IMM16: { 1920 uint16_t index = READ_INST_16_1(); 1921 info.inputs.emplace_back(Immediate(index)); 1922 break; 1923 } 1924 default: { 1925 LOG_COMPILER(FATAL) << "Error bytecode: " << static_cast<uint16_t>(opcode); 1926 UNREACHABLE(); 1927 break; 1928 } 1929 } 1930} 1931 1932const BytecodeInfo &BytecodeIterator::GetBytecodeInfo() const 1933{ 1934 return builder_->GetBytecodeInfo(index_); 1935} 1936 1937const uint8_t *BytecodeIterator::PeekNextPc(size_t i) const 1938{ 1939 ASSERT(index_ + static_cast<int32_t>(i) <= end_); 1940 return builder_->GetPCByIndex(static_cast<uint32_t>(index_ + i)); 1941} 1942 1943const uint8_t *BytecodeIterator::PeekPrevPc(size_t i) const 1944{ 1945 ASSERT(index_ - static_cast<int32_t>(i) >= start_); 1946 return builder_->GetPCByIndex(static_cast<uint32_t>(index_ - i)); 1947} 1948} // panda::ecmascript::kungfu 1949