• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 namespace panda::ecmascript::kungfu {
InitBytecodeMetaData(const uint8_t * pc)20 BytecodeMetaData 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             flags |= BytecodeFlags::READ_NEWTARGET;
496             break;
497         case EcmaOpcode::GETUNMAPPEDARGS:
498         case EcmaOpcode::COPYRESTARGS_IMM8:
499         case EcmaOpcode::WIDE_COPYRESTARGS_PREF_IMM16:
500             flags |= BytecodeFlags::READ_ARGC;
501             [[fallthrough]];
502         default:
503             break;
504     }
505 
506     switch (inst.GetOpcode()) {
507         case EcmaOpcode::LDOBJBYNAME_IMM8_ID16:
508         case EcmaOpcode::LDOBJBYNAME_IMM16_ID16:
509         case EcmaOpcode::LDTHISBYNAME_IMM8_ID16:
510         case EcmaOpcode::LDTHISBYNAME_IMM16_ID16:
511         case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8:
512         case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8:
513         case EcmaOpcode::STTHISBYNAME_IMM8_ID16:
514         case EcmaOpcode::STTHISBYNAME_IMM16_ID16:
515         case EcmaOpcode::DEFINEFIELDBYNAME_IMM8_ID16_V8:
516         case EcmaOpcode::DEFINEPROPERTYBYNAME_IMM8_ID16_V8:
517             kind = BytecodeKind::ACCESSOR_BC;
518             break;
519         default:
520             break;
521     }
522 
523     if (kind == BytecodeKind::GENERAL ||
524         kind == BytecodeKind::THROW_BC ||
525         kind == BytecodeKind::RESUME ||
526         kind == BytecodeKind::SUSPEND ||
527         kind == BytecodeKind::GENERATOR_RESOLVE ||
528         kind == BytecodeKind::CALL_BC ||
529         kind == BytecodeKind::ACCESSOR_BC) {
530         flags |= BytecodeFlags::GENERAL_BC;
531     }
532     auto size = inst.GetSize();
533     auto vregCount = GetVRegCount(inst);
534     uint64_t value = SizeField::Encode(size) | KindField::Encode(kind) |
535                      FlagsField::Encode(static_cast<BytecodeFlags>(flags)) |
536                      OpcodeField::Encode(inst.GetOpcode()) | VRegCountField::Encode(vregCount);
537     return BytecodeMetaData(value);
538 }
539 
540 // static
GetVRegCount(const BytecodeInstruction & inst)541 size_t BytecodeMetaData::GetVRegCount(const BytecodeInstruction &inst)
542 {
543     size_t idx = 0;
544     BytecodeInstruction::Format format = inst.GetFormat();
545     while (inst.HasVReg(format, idx)) {
546         idx++;
547     }
548     return idx;
549 }
550 
Bytecodes()551 Bytecodes::Bytecodes()
552 {
553     for (uint8_t pc = 0; pc <= static_cast<uint8_t>(Bytecodes::LAST_OPCODE); pc++) {
554         auto info = BytecodeMetaData::InitBytecodeMetaData(&pc);
555         bytecodes_[pc] = info;
556     }
557     auto last = (static_cast<uint16_t>(Bytecodes::LAST_CALLRUNTIME_OPCODE) & OPCODE_MASK) >> BYTE_SIZE;
558     for (uint8_t pc = 0; pc <= last; pc++) {
559         std::array<uint8_t, 2> bytecode{CALLRUNTIME_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode
560         auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]);
561         callRuntimeBytecodes_[pc] = info;
562     }
563     last = (static_cast<uint16_t>(Bytecodes::LAST_DEPRECATED_OPCODE) & OPCODE_MASK) >> BYTE_SIZE;
564     for (uint8_t pc = 0; pc <= last; pc++) {
565         std::array<uint8_t, 2> bytecode{DEPRECATED_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode
566         auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]);
567         deprecatedBytecodes_[pc] = info;
568     }
569     last = (static_cast<uint16_t>(Bytecodes::LAST_WIDE_OPCODE) & OPCODE_MASK) >> BYTE_SIZE;
570     for (uint8_t pc = 0; pc <= last; pc++) {
571         std::array<uint8_t, 2> bytecode{WIDE_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode
572         auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]);
573         wideBytecodes_[pc] = info;
574     }
575     last = (static_cast<uint16_t>(Bytecodes::LAST_THROW_OPCODE) & OPCODE_MASK) >> BYTE_SIZE;
576     for (uint8_t pc = 0; pc <= last; pc++) {
577         std::array<uint8_t, 2> bytecode{THROW_PREFIX_OPCODE_INDEX, pc}; // 2: 2 opcode
578         auto info = BytecodeMetaData::InitBytecodeMetaData(&bytecode[0]);
579         throwBytecodes_[pc] = info;
580     }
581 }
582 
InitBytecodeInfo(BytecodeCircuitBuilder * builder,BytecodeInfo & info,const uint8_t * pc)583 void BytecodeInfo::InitBytecodeInfo(BytecodeCircuitBuilder *builder,
584                                     BytecodeInfo &info, const uint8_t *pc)
585 {
586     auto opcode = info.GetOpcode();
587     switch (opcode) {
588         case EcmaOpcode::MOV_V4_V4: {
589             uint16_t vdst = READ_INST_4_0();
590             uint16_t vsrc = READ_INST_4_1();
591             info.vregOut.emplace_back(vdst);
592             info.inputs.emplace_back(VirtualRegister(vsrc));
593             break;
594         }
595         case EcmaOpcode::MOV_V8_V8: {
596             uint16_t vdst = READ_INST_8_0();
597             uint16_t vsrc = READ_INST_8_1();
598             info.vregOut.emplace_back(vdst);
599             info.inputs.emplace_back(VirtualRegister(vsrc));
600             break;
601         }
602         case EcmaOpcode::MOV_V16_V16: {
603             uint16_t vdst = READ_INST_16_0();
604             uint16_t vsrc = READ_INST_16_2();
605             info.vregOut.emplace_back(vdst);
606             info.inputs.emplace_back(VirtualRegister(vsrc));
607             break;
608         }
609         case EcmaOpcode::LDA_STR_ID16: {
610             uint16_t stringId = READ_INST_16_0();
611             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
612             break;
613         }
614         case EcmaOpcode::LDA_V8: {
615             uint16_t vsrc = READ_INST_8_0();
616             info.inputs.emplace_back(VirtualRegister(vsrc));
617             break;
618         }
619         case EcmaOpcode::STA_V8: {
620             uint16_t vdst = READ_INST_8_0();
621             info.vregOut.emplace_back(vdst);
622             break;
623         }
624         case EcmaOpcode::LDAI_IMM32: {
625             info.inputs.emplace_back(Immediate(READ_INST_32_0()));
626             break;
627         }
628         case EcmaOpcode::FLDAI_IMM64: {
629             info.inputs.emplace_back(Immediate(READ_INST_64_0()));
630             break;
631         }
632         case EcmaOpcode::CALLARG1_IMM8_V8: {
633             uint32_t a0 = READ_INST_8_1();
634             info.inputs.emplace_back(VirtualRegister(a0));
635             break;
636         }
637         case EcmaOpcode::CALLTHIS1_IMM8_V8_V8: {
638             uint32_t startReg = READ_INST_8_1(); // this
639             uint32_t a0 = READ_INST_8_2();
640             info.inputs.emplace_back(VirtualRegister(startReg));
641             info.inputs.emplace_back(VirtualRegister(a0));
642             break;
643         }
644         case EcmaOpcode::CALLARGS2_IMM8_V8_V8: {
645             uint32_t a0 = READ_INST_8_1();
646             uint32_t a1 = READ_INST_8_2();
647             info.inputs.emplace_back(VirtualRegister(a0));
648             info.inputs.emplace_back(VirtualRegister(a1));
649             break;
650         }
651         case EcmaOpcode::CALLARGS3_IMM8_V8_V8_V8: {
652             uint32_t a0 = READ_INST_8_1();
653             uint32_t a1 = READ_INST_8_2();
654             uint32_t a2 = READ_INST_8_3();
655             info.inputs.emplace_back(VirtualRegister(a0));
656             info.inputs.emplace_back(VirtualRegister(a1));
657             info.inputs.emplace_back(VirtualRegister(a2));
658             break;
659         }
660         case EcmaOpcode::CALLTHISRANGE_IMM8_IMM8_V8: {
661             uint32_t actualNumArgs = READ_INST_8_1();
662             uint32_t startReg = READ_INST_8_2();
663             info.inputs.emplace_back(VirtualRegister(startReg));
664             for (size_t i = 1; i <= actualNumArgs; i++) {
665                 info.inputs.emplace_back(VirtualRegister(startReg + i));
666             }
667             break;
668         }
669         case EcmaOpcode::WIDE_CALLTHISRANGE_PREF_IMM16_V8: {
670             uint32_t actualNumArgs = READ_INST_16_1();
671             uint32_t startReg = READ_INST_8_3();
672             info.inputs.emplace_back(VirtualRegister(startReg));
673             for (size_t i = 1; i <= actualNumArgs; i++) {
674                 info.inputs.emplace_back(VirtualRegister(startReg + i));
675             }
676             break;
677         }
678         case EcmaOpcode::CALLTHIS0_IMM8_V8: {
679             int32_t startReg = READ_INST_8_1();
680             info.inputs.emplace_back(VirtualRegister(startReg));
681             break;
682         }
683         case EcmaOpcode::CALLTHIS2_IMM8_V8_V8_V8: {
684             int32_t startReg = READ_INST_8_1();
685             uint32_t a0 = READ_INST_8_2();
686             uint32_t a1 = READ_INST_8_3();
687             info.inputs.emplace_back(VirtualRegister(startReg));
688             info.inputs.emplace_back(VirtualRegister(a0));
689             info.inputs.emplace_back(VirtualRegister(a1));
690             break;
691         }
692         case EcmaOpcode::CALLTHIS3_IMM8_V8_V8_V8_V8: {
693             int32_t startReg = READ_INST_8_1();
694             uint32_t a0 = READ_INST_8_2();
695             uint32_t a1 = READ_INST_8_3();
696             uint32_t a2 = READ_INST_8_4();
697             info.inputs.emplace_back(VirtualRegister(startReg));
698             info.inputs.emplace_back(VirtualRegister(a0));
699             info.inputs.emplace_back(VirtualRegister(a1));
700             info.inputs.emplace_back(VirtualRegister(a2));
701             break;
702         }
703         case EcmaOpcode::CALLRUNTIME_CALLINIT_PREF_IMM8_V8: {
704             int32_t startReg = READ_INST_8_2();
705             info.inputs.emplace_back(VirtualRegister(startReg));
706             break;
707         }
708 
709         case EcmaOpcode::APPLY_IMM8_V8_V8: {
710             uint16_t v0 = READ_INST_8_1();
711             uint16_t v1 = READ_INST_8_2();
712             info.inputs.emplace_back(VirtualRegister(v0));
713             info.inputs.emplace_back(VirtualRegister(v1));
714             break;
715         }
716         case EcmaOpcode::CALLRANGE_IMM8_IMM8_V8: {
717             int32_t actualNumArgs = READ_INST_8_1();
718             int32_t startReg = READ_INST_8_2();
719             for (int i = 0; i < actualNumArgs; i++) {
720                 info.inputs.emplace_back(VirtualRegister(startReg + i));
721             }
722             break;
723         }
724         case EcmaOpcode::WIDE_CALLRANGE_PREF_IMM16_V8: {
725             int32_t actualNumArgs = READ_INST_16_1();
726             int32_t startReg = READ_INST_8_3();
727             for (int i = 0; i < actualNumArgs; i++) {
728                 info.inputs.emplace_back(VirtualRegister(startReg + i));
729             }
730             break;
731         }
732         case EcmaOpcode::THROW_CONSTASSIGNMENT_PREF_V8: {
733             uint16_t v0 = READ_INST_8_1();
734             info.inputs.emplace_back(VirtualRegister(v0));
735             break;
736         }
737         case EcmaOpcode::THROW_IFNOTOBJECT_PREF_V8: {
738             uint16_t v0 = READ_INST_8_1();
739             info.inputs.emplace_back(VirtualRegister(v0));
740             break;
741         }
742         case EcmaOpcode::THROW_UNDEFINEDIFHOLE_PREF_V8_V8: {
743             uint16_t v0 = READ_INST_8_1();
744             uint16_t v1 = READ_INST_8_2();
745             info.inputs.emplace_back(VirtualRegister(v0));
746             info.inputs.emplace_back(VirtualRegister(v1));
747             break;
748         }
749         case EcmaOpcode::THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16: {
750             uint16_t stringId = READ_INST_16_1();
751             info.inputs.emplace_back(ICSlotId(stringId));
752             break;
753         }
754         case EcmaOpcode::THROW_IFSUPERNOTCORRECTCALL_PREF_IMM8: {
755             uint8_t imm = READ_INST_8_1();
756             info.inputs.emplace_back(Immediate(imm));
757             break;
758         }
759         case EcmaOpcode::THROW_IFSUPERNOTCORRECTCALL_PREF_IMM16: {
760             uint16_t imm = READ_INST_16_1();
761             info.inputs.emplace_back(Immediate(imm));
762             break;
763         }
764         case EcmaOpcode::CLOSEITERATOR_IMM8_V8: {
765             uint16_t v0 = READ_INST_8_1();
766             info.inputs.emplace_back(VirtualRegister(v0));
767             break;
768         }
769         case EcmaOpcode::ADD2_IMM8_V8: {
770             uint16_t v0 = READ_INST_8_1();
771             info.inputs.emplace_back(VirtualRegister(v0));
772             break;
773         }
774         case EcmaOpcode::SUB2_IMM8_V8: {
775             uint16_t v0 = READ_INST_8_1();
776             info.inputs.emplace_back(VirtualRegister(v0));
777             break;
778         }
779         case EcmaOpcode::MUL2_IMM8_V8: {
780             uint16_t v0 = READ_INST_8_1();
781             info.inputs.emplace_back(VirtualRegister(v0));
782             break;
783         }
784         case EcmaOpcode::DIV2_IMM8_V8: {
785             uint16_t v0 = READ_INST_8_1();
786             info.inputs.emplace_back(VirtualRegister(v0));
787             break;
788         }
789         case EcmaOpcode::MOD2_IMM8_V8: {
790             uint16_t v0 = READ_INST_8_1();
791             info.inputs.emplace_back(VirtualRegister(v0));
792             break;
793         }
794         case EcmaOpcode::EQ_IMM8_V8: {
795             uint16_t v0 = READ_INST_8_1();
796             info.inputs.emplace_back(VirtualRegister(v0));
797             break;
798         }
799         case EcmaOpcode::NOTEQ_IMM8_V8: {
800             uint16_t v0 = READ_INST_8_1();
801             info.inputs.emplace_back(VirtualRegister(v0));
802             break;
803         }
804         case EcmaOpcode::LESS_IMM8_V8: {
805             uint16_t v0 = READ_INST_8_1();
806             info.inputs.emplace_back(VirtualRegister(v0));
807             break;
808         }
809         case EcmaOpcode::LESSEQ_IMM8_V8: {
810             uint16_t v0 = READ_INST_8_1();
811             info.inputs.emplace_back(VirtualRegister(v0));
812             break;
813         }
814         case EcmaOpcode::GREATER_IMM8_V8: {
815             uint16_t v0 = READ_INST_8_1();
816             info.inputs.emplace_back(VirtualRegister(v0));
817             break;
818         }
819         case EcmaOpcode::GREATEREQ_IMM8_V8: {
820             uint16_t vs = READ_INST_8_1();
821             info.inputs.emplace_back(VirtualRegister(vs));
822             break;
823         }
824         case EcmaOpcode::SHL2_IMM8_V8: {
825             uint16_t v0 = READ_INST_8_1();
826             info.inputs.emplace_back(VirtualRegister(v0));
827             break;
828         }
829         case EcmaOpcode::SHR2_IMM8_V8: {
830             uint16_t v0 = READ_INST_8_1();
831             info.inputs.emplace_back(VirtualRegister(v0));
832             break;
833         }
834         case EcmaOpcode::ASHR2_IMM8_V8: {
835             uint16_t v0 = READ_INST_8_1();
836             info.inputs.emplace_back(VirtualRegister(v0));
837             break;
838         }
839         case EcmaOpcode::AND2_IMM8_V8: {
840             uint16_t v0 = READ_INST_8_1();
841             info.inputs.emplace_back(VirtualRegister(v0));
842             break;
843         }
844         case EcmaOpcode::OR2_IMM8_V8: {
845             uint16_t v0 = READ_INST_8_1();
846             info.inputs.emplace_back(VirtualRegister(v0));
847             break;
848         }
849         case EcmaOpcode::XOR2_IMM8_V8: {
850             uint16_t v0 = READ_INST_8_1();
851             info.inputs.emplace_back(VirtualRegister(v0));
852             break;
853         }
854         case EcmaOpcode::EXP_IMM8_V8: {
855             uint16_t v0 = READ_INST_8_1();
856             info.inputs.emplace_back(VirtualRegister(v0));
857             break;
858         }
859         case EcmaOpcode::ISIN_IMM8_V8: {
860             uint16_t v0 = READ_INST_8_1();
861             info.inputs.emplace_back(VirtualRegister(v0));
862             break;
863         }
864         case EcmaOpcode::INSTANCEOF_IMM8_V8: {
865             uint16_t slotId = READ_INST_8_0();
866             uint16_t v0 = READ_INST_8_1();
867             info.inputs.emplace_back(ICSlotId(slotId));
868             info.inputs.emplace_back(VirtualRegister(v0));
869             break;
870         }
871         case EcmaOpcode::STRICTNOTEQ_IMM8_V8: {
872             uint16_t v0 = READ_INST_8_1();
873             info.inputs.emplace_back(VirtualRegister(v0));
874             break;
875         }
876         case EcmaOpcode::STRICTEQ_IMM8_V8: {
877             uint16_t v0 = READ_INST_8_1();
878             info.inputs.emplace_back(VirtualRegister(v0));
879             break;
880         }
881         case EcmaOpcode::DELOBJPROP_V8: {
882             uint16_t v0 = READ_INST_8_0();
883             info.inputs.emplace_back(VirtualRegister(v0));
884             break;
885         }
886         case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8: {
887             uint16_t slotId = READ_INST_8_0();
888             uint16_t methodId = READ_INST_16_1();
889             uint16_t length = READ_INST_8_3();
890             info.inputs.emplace_back(ICSlotId(slotId));
891             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
892             info.inputs.emplace_back(Immediate(length));
893             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
894             break;
895         }
896         case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8: {
897             uint16_t slotId = READ_INST_16_0();
898             uint16_t methodId = READ_INST_16_2();
899             uint16_t length = READ_INST_8_4();
900             info.inputs.emplace_back(ICSlotId(slotId));
901             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
902             info.inputs.emplace_back(Immediate(length));
903             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
904             break;
905         }
906         case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8: {
907             uint16_t slotId = READ_INST_8_0();
908             uint16_t methodId = READ_INST_16_1();
909             uint16_t length = READ_INST_8_3();
910             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
911             info.inputs.emplace_back(Immediate(length));
912             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
913             info.inputs.emplace_back(ICSlotId(slotId));
914             break;
915         }
916         case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8: {
917             uint16_t slotId = READ_INST_16_0();
918             uint16_t methodId = READ_INST_16_2();
919             uint16_t length = READ_INST_8_4();
920             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
921             info.inputs.emplace_back(Immediate(length));
922             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
923             info.inputs.emplace_back(ICSlotId(slotId));
924             break;
925         }
926         case EcmaOpcode::NEWOBJRANGE_IMM8_IMM8_V8: {
927             uint16_t numArgs = READ_INST_8_1();
928             uint16_t firstArgRegIdx = READ_INST_8_2();
929             for (uint16_t i = 0; i < numArgs; ++i) {
930                 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i));
931             }
932             break;
933         }
934         case EcmaOpcode::NEWOBJRANGE_IMM16_IMM8_V8: {
935             uint16_t numArgs = READ_INST_8_2();
936             uint16_t firstArgRegIdx = READ_INST_8_3();
937             for (uint16_t i = 0; i < numArgs; ++i) {
938                 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i));
939             }
940             break;
941         }
942         case EcmaOpcode::WIDE_NEWOBJRANGE_PREF_IMM16_V8: {
943             uint16_t numArgs = READ_INST_16_1();
944             uint16_t firstArgRegIdx = READ_INST_8_3();
945             for (uint16_t i = 0; i < numArgs; ++i) {
946                 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i));
947             }
948             break;
949         }
950         case EcmaOpcode::LDLEXVAR_IMM4_IMM4: {
951             uint16_t level = READ_INST_4_0();
952             uint16_t slot = READ_INST_4_1();
953             info.inputs.emplace_back(Immediate(level));
954             info.inputs.emplace_back(Immediate(slot));
955             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
956             break;
957         }
958         case EcmaOpcode::LDLEXVAR_IMM8_IMM8: {
959             uint16_t level = READ_INST_8_0();
960             uint16_t slot = READ_INST_8_1();
961             info.inputs.emplace_back(Immediate(level));
962             info.inputs.emplace_back(Immediate(slot));
963             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
964             break;
965         }
966         case EcmaOpcode::WIDE_LDLEXVAR_PREF_IMM16_IMM16: {
967             uint16_t level = READ_INST_16_1();
968             uint16_t slot = READ_INST_16_3();
969             info.inputs.emplace_back(Immediate(level));
970             info.inputs.emplace_back(Immediate(slot));
971             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
972             break;
973         }
974         case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4: {
975             uint16_t level = READ_INST_4_2();
976             uint16_t slot = READ_INST_4_3();
977             info.inputs.emplace_back(Immediate(level));
978             info.inputs.emplace_back(Immediate(slot));
979             break;
980         }
981         case EcmaOpcode::CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8: {
982             uint16_t level = READ_INST_8_1();
983             uint16_t slot = READ_INST_8_2();
984             info.inputs.emplace_back(Immediate(level));
985             info.inputs.emplace_back(Immediate(slot));
986             break;
987         }
988         case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16: {
989             uint16_t level = READ_INST_16_1();
990             uint16_t slot = READ_INST_16_3();
991             info.inputs.emplace_back(Immediate(level));
992             info.inputs.emplace_back(Immediate(slot));
993             break;
994         }
995         case EcmaOpcode::STLEXVAR_IMM4_IMM4: {
996             uint16_t level = READ_INST_4_0();
997             uint16_t slot = READ_INST_4_1();
998             info.inputs.emplace_back(Immediate(level));
999             info.inputs.emplace_back(Immediate(slot));
1000             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1001             break;
1002         }
1003         case EcmaOpcode::STLEXVAR_IMM8_IMM8: {
1004             uint16_t level = READ_INST_8_0();
1005             uint16_t slot = READ_INST_8_1();
1006             info.inputs.emplace_back(Immediate(level));
1007             info.inputs.emplace_back(Immediate(slot));
1008             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1009             break;
1010         }
1011         case EcmaOpcode::WIDE_STLEXVAR_PREF_IMM16_IMM16: {
1012             uint16_t level = READ_INST_16_1();
1013             uint16_t slot = READ_INST_16_3();
1014             info.inputs.emplace_back(Immediate(level));
1015             info.inputs.emplace_back(Immediate(slot));
1016             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1017             break;
1018         }
1019         case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4: {
1020             uint16_t level = READ_INST_4_2();
1021             uint16_t slot = READ_INST_4_3();
1022             info.inputs.emplace_back(Immediate(level));
1023             info.inputs.emplace_back(Immediate(slot));
1024             break;
1025         }
1026         case EcmaOpcode::CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8: {
1027             uint16_t level = READ_INST_8_1();
1028             uint16_t slot = READ_INST_8_2();
1029             info.inputs.emplace_back(Immediate(level));
1030             info.inputs.emplace_back(Immediate(slot));
1031             break;
1032         }
1033         case EcmaOpcode::CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16: {
1034             uint16_t level = READ_INST_16_1();
1035             uint16_t slot = READ_INST_16_3();
1036             info.inputs.emplace_back(Immediate(level));
1037             info.inputs.emplace_back(Immediate(slot));
1038             break;
1039         }
1040         case EcmaOpcode::NEWLEXENV_IMM8: {
1041             uint8_t numVars = READ_INST_8_0();
1042             info.inputs.emplace_back(Immediate(numVars));
1043             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1044             info.vregOut.emplace_back(builder->GetEnvVregIdx());
1045             break;
1046         }
1047         case EcmaOpcode::WIDE_NEWLEXENV_PREF_IMM16: {
1048             uint16_t numVars = READ_INST_16_1();
1049             info.inputs.emplace_back(Immediate(numVars));
1050             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1051             info.vregOut.emplace_back(builder->GetEnvVregIdx());
1052             break;
1053         }
1054         case EcmaOpcode::CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8: {
1055             uint8_t numVars = READ_INST_8_1();
1056             info.inputs.emplace_back(Immediate(numVars));
1057             break;
1058         }
1059         case EcmaOpcode::CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16: {
1060             uint16_t numVars = READ_INST_16_1();
1061             info.inputs.emplace_back(Immediate(numVars));
1062             break;
1063         }
1064         case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16: {
1065             uint16_t numVars = READ_INST_8_0();
1066             uint16_t scopeId = READ_INST_16_1();
1067             info.inputs.emplace_back(Immediate(numVars));
1068             info.inputs.emplace_back(Immediate(scopeId));
1069             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1070             info.vregOut.emplace_back(builder->GetEnvVregIdx());
1071             break;
1072         }
1073         case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16: {
1074             uint16_t numVars = READ_INST_16_1();
1075             uint16_t scopeId = READ_INST_16_3();
1076             info.inputs.emplace_back(Immediate(numVars));
1077             info.inputs.emplace_back(Immediate(scopeId));
1078             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1079             info.vregOut.emplace_back(builder->GetEnvVregIdx());
1080             break;
1081         }
1082         case EcmaOpcode::CREATEITERRESULTOBJ_V8_V8: {
1083             uint16_t v0 = READ_INST_8_0();
1084             uint16_t v1 = READ_INST_8_1();
1085             info.inputs.emplace_back(VirtualRegister(v0));
1086             info.inputs.emplace_back(VirtualRegister(v1));
1087             break;
1088         }
1089         case EcmaOpcode::SUSPENDGENERATOR_V8: {
1090             uint16_t v0 = READ_INST_8_0();
1091             uint32_t offset = builder->GetPcOffset(pc);
1092             offset += BytecodeInstruction::Size(EcmaOpcode::SUSPENDGENERATOR_V8); // skip suspend bc
1093             info.inputs.emplace_back(Immediate(offset)); // Save the pc offset when suspend
1094             info.inputs.emplace_back(VirtualRegister(v0));
1095             break;
1096         }
1097         case EcmaOpcode::ASYNCFUNCTIONAWAITUNCAUGHT_V8: {
1098             uint16_t v0 = READ_INST_8_0();
1099             info.inputs.emplace_back(VirtualRegister(v0));
1100             break;
1101         }
1102         case EcmaOpcode::ASYNCFUNCTIONRESOLVE_V8: {
1103             uint16_t v0 = READ_INST_8_0();
1104             info.inputs.emplace_back(VirtualRegister(v0));
1105             break;
1106         }
1107         case EcmaOpcode::ASYNCFUNCTIONREJECT_V8: {
1108             uint16_t v0 = READ_INST_8_0();
1109             info.inputs.emplace_back(VirtualRegister(v0));
1110             break;
1111         }
1112         case EcmaOpcode::CLOSEITERATOR_IMM16_V8: {
1113             uint16_t v0 = READ_INST_8_2();
1114             info.inputs.emplace_back(VirtualRegister(v0));
1115             break;
1116         }
1117         case EcmaOpcode::NEWOBJAPPLY_IMM8_V8: {
1118             uint16_t v0 = READ_INST_8_1();
1119             info.inputs.emplace_back(VirtualRegister(v0));
1120             break;
1121         }
1122         case EcmaOpcode::NEWOBJAPPLY_IMM16_V8: {
1123             uint16_t v0 = READ_INST_8_2();
1124             info.inputs.emplace_back(VirtualRegister(v0));
1125             break;
1126         }
1127         case EcmaOpcode::STOWNBYNAME_IMM8_ID16_V8: {
1128             uint16_t stringId = READ_INST_16_1();
1129             uint32_t v0 = READ_INST_8_3();
1130             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1131             info.inputs.emplace_back(VirtualRegister(v0));
1132             break;
1133         }
1134         case EcmaOpcode::STOWNBYNAME_IMM16_ID16_V8: {
1135             uint16_t stringId = READ_INST_16_2();
1136             uint32_t v0 = READ_INST_8_4();
1137             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1138             info.inputs.emplace_back(VirtualRegister(v0));
1139             break;
1140         }
1141         case EcmaOpcode::CREATEREGEXPWITHLITERAL_IMM8_ID16_IMM8: {
1142             uint16_t stringId = READ_INST_16_1();
1143             uint8_t flags = READ_INST_8_3();
1144             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1145             info.inputs.emplace_back(Immediate(flags));
1146             break;
1147         }
1148         case EcmaOpcode::CREATEREGEXPWITHLITERAL_IMM16_ID16_IMM8: {
1149             uint16_t stringId = READ_INST_16_2();
1150             uint8_t flags = READ_INST_8_4();
1151             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1152             info.inputs.emplace_back(Immediate(flags));
1153             break;
1154         }
1155         case EcmaOpcode::GETNEXTPROPNAME_V8: {
1156             uint16_t v0 = READ_INST_8_0();
1157             info.inputs.emplace_back(VirtualRegister(v0));
1158             break;
1159         }
1160         case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16: {
1161             uint16_t imm = READ_INST_16_1();
1162             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ObjectLiteralIDType, imm));
1163             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1164             break;
1165         }
1166         case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16: {
1167             uint16_t imm = READ_INST_16_2();
1168             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ObjectLiteralIDType, imm));
1169             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1170             break;
1171         }
1172         case EcmaOpcode::SETOBJECTWITHPROTO_IMM8_V8: {
1173             uint16_t v0 = READ_INST_8_1();
1174             info.inputs.emplace_back(VirtualRegister(v0));
1175             break;
1176         }
1177         case EcmaOpcode::SETOBJECTWITHPROTO_IMM16_V8: {
1178             uint16_t v0 = READ_INST_8_2();
1179             info.inputs.emplace_back(VirtualRegister(v0));
1180             break;
1181         }
1182         case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16: {
1183             uint16_t imm = READ_INST_16_1();
1184             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ArrayLiteralIDType, imm));
1185             break;
1186         }
1187         case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16: {
1188             uint16_t imm = READ_INST_16_2();
1189             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ArrayLiteralIDType, imm));
1190             break;
1191         }
1192         case EcmaOpcode::GETMODULENAMESPACE_IMM8: {
1193             int32_t index = READ_INST_8_0();
1194             info.inputs.emplace_back(Immediate(index));
1195             break;
1196         }
1197         case EcmaOpcode::WIDE_GETMODULENAMESPACE_PREF_IMM16: {
1198             int32_t index = READ_INST_16_1();
1199             info.inputs.emplace_back(Immediate(index));
1200             break;
1201         }
1202         case EcmaOpcode::STMODULEVAR_IMM8: {
1203             int32_t index = READ_INST_8_0();
1204             info.inputs.emplace_back(Immediate(index));
1205             break;
1206         }
1207         case EcmaOpcode::SETGENERATORSTATE_IMM8: {
1208             int32_t index = READ_INST_8_0();
1209             info.inputs.emplace_back(Immediate(index));
1210             break;
1211         }
1212         case EcmaOpcode::WIDE_STMODULEVAR_PREF_IMM16: {
1213             int32_t index = READ_INST_16_1();
1214             info.inputs.emplace_back(Immediate(index));
1215             break;
1216         }
1217         case EcmaOpcode::LDLOCALMODULEVAR_IMM8: {
1218             int32_t index = READ_INST_8_0();
1219             info.inputs.emplace_back(Immediate(index));
1220             break;
1221         }
1222         case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16: {
1223             int32_t index = READ_INST_16_1();
1224             info.inputs.emplace_back(Immediate(index));
1225             break;
1226         }
1227         case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8: {
1228             int32_t index = READ_INST_8_0();
1229             info.inputs.emplace_back(Immediate(index));
1230             break;
1231         }
1232         case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16: {
1233             int32_t index = READ_INST_16_1();
1234             info.inputs.emplace_back(Immediate(index));
1235             break;
1236         }
1237         case EcmaOpcode::CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8: {
1238             int32_t index = READ_INST_8_1();
1239             info.inputs.emplace_back(Immediate(index));
1240             break;
1241         }
1242         case EcmaOpcode::CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16: {
1243             int32_t index = READ_INST_16_1();
1244             info.inputs.emplace_back(Immediate(index));
1245             break;
1246         }
1247         case EcmaOpcode::CALLRUNTIME_LDLAZYMODULEVAR_PREF_IMM8: {
1248             int32_t index = READ_INST_8_1();
1249             info.inputs.emplace_back(Immediate(index));
1250             break;
1251         }
1252         case EcmaOpcode::CALLRUNTIME_WIDELDLAZYMODULEVAR_PREF_IMM16: {
1253             int32_t index = READ_INST_16_1();
1254             info.inputs.emplace_back(Immediate(index));
1255             break;
1256         }
1257         case EcmaOpcode::CALLRUNTIME_LDLAZYSENDABLEMODULEVAR_PREF_IMM8: {
1258             int32_t index = READ_INST_8_1();
1259             info.inputs.emplace_back(Immediate(index));
1260             break;
1261         }
1262         case EcmaOpcode::CALLRUNTIME_WIDELDLAZYSENDABLEMODULEVAR_PREF_IMM16: {
1263             int32_t index = READ_INST_16_1();
1264             info.inputs.emplace_back(Immediate(index));
1265             break;
1266         }
1267         case EcmaOpcode::STCONSTTOGLOBALRECORD_IMM16_ID16: {
1268             uint16_t stringId = READ_INST_16_2();
1269             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1270             break;
1271         }
1272         case EcmaOpcode::GETTEMPLATEOBJECT_IMM8:
1273         case EcmaOpcode::GETTEMPLATEOBJECT_IMM16:
1274             break;
1275         case EcmaOpcode::COPYDATAPROPERTIES_V8: {
1276             uint16_t v0 = READ_INST_8_0();
1277             info.inputs.emplace_back(VirtualRegister(v0));
1278             break;
1279         }
1280         case EcmaOpcode::STOWNBYINDEX_IMM8_V8_IMM16: {
1281             uint8_t v0 = READ_INST_8_1();
1282             uint16_t index = READ_INST_16_2();
1283             info.inputs.emplace_back(VirtualRegister(v0));
1284             info.inputs.emplace_back(Immediate(index));
1285             break;
1286         }
1287         case EcmaOpcode::STOWNBYINDEX_IMM16_V8_IMM16: {
1288             uint8_t v0 = READ_INST_8_2();
1289             uint16_t index = READ_INST_16_3();
1290             info.inputs.emplace_back(VirtualRegister(v0));
1291             info.inputs.emplace_back(Immediate(index));
1292             break;
1293         }
1294         case EcmaOpcode::WIDE_STOWNBYINDEX_PREF_V8_IMM32: {
1295             uint32_t v0 = READ_INST_8_1();
1296             uint32_t index = READ_INST_32_2();
1297             info.inputs.emplace_back(VirtualRegister(v0));
1298             info.inputs.emplace_back(Immediate(index));
1299             break;
1300         }
1301         case EcmaOpcode::STOWNBYVALUE_IMM8_V8_V8: {
1302             uint32_t v0 = READ_INST_8_1();
1303             uint32_t v1 = READ_INST_8_2();
1304             info.inputs.emplace_back(VirtualRegister(v0));
1305             info.inputs.emplace_back(VirtualRegister(v1));
1306             break;
1307         }
1308         case EcmaOpcode::STOWNBYVALUE_IMM16_V8_V8: {
1309             uint32_t v0 = READ_INST_8_2();
1310             uint32_t v1 = READ_INST_8_3();
1311             info.inputs.emplace_back(VirtualRegister(v0));
1312             info.inputs.emplace_back(VirtualRegister(v1));
1313             break;
1314         }
1315         case EcmaOpcode::CREATEOBJECTWITHEXCLUDEDKEYS_IMM8_V8_V8: {
1316             uint8_t numKeys = READ_INST_8_0();
1317             uint16_t v0 = READ_INST_8_1();
1318             uint16_t firstArgRegIdx = READ_INST_8_2();
1319             info.inputs.emplace_back(VirtualRegister(v0));
1320             for (int i = 0; i <= numKeys; i++) {
1321                 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i));
1322             }
1323             break;
1324         }
1325         case EcmaOpcode::WIDE_CREATEOBJECTWITHEXCLUDEDKEYS_PREF_IMM16_V8_V8: {
1326             uint16_t numKeys = READ_INST_16_1();
1327             uint16_t v0 = READ_INST_8_3();
1328             uint16_t firstArgRegIdx = READ_INST_8_4();
1329             info.inputs.emplace_back(VirtualRegister(v0));
1330             for (int i = 0; i <= numKeys; i++) {
1331                 info.inputs.emplace_back(VirtualRegister(firstArgRegIdx + i));
1332             }
1333             break;
1334         }
1335         case EcmaOpcode::COPYRESTARGS_IMM8: {
1336             uint16_t restIdx = READ_INST_8_0();
1337             info.inputs.emplace_back(Immediate(restIdx));
1338             break;
1339         }
1340         case EcmaOpcode::WIDE_COPYRESTARGS_PREF_IMM16: {
1341             uint16_t restIdx = READ_INST_16_1();
1342             info.inputs.emplace_back(Immediate(restIdx));
1343             break;
1344         }
1345         case EcmaOpcode::DEFINEGETTERSETTERBYVALUE_V8_V8_V8_V8: {
1346             uint16_t v0 = READ_INST_8_0();
1347             uint16_t v1 = READ_INST_8_1();
1348             uint16_t v2 = READ_INST_8_2();
1349             uint16_t v3 = READ_INST_8_3();
1350             info.inputs.emplace_back(VirtualRegister(v0));
1351             info.inputs.emplace_back(VirtualRegister(v1));
1352             info.inputs.emplace_back(VirtualRegister(v2));
1353             info.inputs.emplace_back(VirtualRegister(v3));
1354             break;
1355         }
1356         case EcmaOpcode::LDOBJBYINDEX_IMM8_IMM16: {
1357             uint32_t idx = READ_INST_16_1();
1358             info.inputs.emplace_back(Immediate(idx));
1359             break;
1360         }
1361         case EcmaOpcode::LDOBJBYINDEX_IMM16_IMM16: {
1362             uint32_t idx = READ_INST_16_2();
1363             info.inputs.emplace_back(Immediate(idx));
1364             break;
1365         }
1366         case EcmaOpcode::WIDE_LDOBJBYINDEX_PREF_IMM32: {
1367             uint32_t idx = READ_INST_32_1();
1368             info.inputs.emplace_back(Immediate(idx));
1369             break;
1370         }
1371         case EcmaOpcode::STOBJBYINDEX_IMM8_V8_IMM16: {
1372             uint8_t v0 = READ_INST_8_1();
1373             uint16_t index = READ_INST_16_2();
1374             info.inputs.emplace_back(VirtualRegister(v0));
1375             info.inputs.emplace_back(Immediate(index));
1376             break;
1377         }
1378         case EcmaOpcode::STOBJBYINDEX_IMM16_V8_IMM16: {
1379             uint8_t v0 = READ_INST_8_2();
1380             uint16_t index = READ_INST_16_3();
1381             info.inputs.emplace_back(VirtualRegister(v0));
1382             info.inputs.emplace_back(Immediate(index));
1383             break;
1384         }
1385         case EcmaOpcode::WIDE_STOBJBYINDEX_PREF_V8_IMM32: {
1386             uint8_t v0 = READ_INST_8_1();
1387             uint32_t index = READ_INST_32_2();
1388             info.inputs.emplace_back(VirtualRegister(v0));
1389             info.inputs.emplace_back(Immediate(index));
1390             break;
1391         }
1392         case EcmaOpcode::LDOBJBYVALUE_IMM8_V8: {
1393             uint16_t slotId = READ_INST_8_0();
1394             uint32_t v0 = READ_INST_8_1();
1395             info.inputs.emplace_back(ICSlotId(slotId));
1396             info.inputs.emplace_back(VirtualRegister(v0));
1397             break;
1398         }
1399         case EcmaOpcode::LDOBJBYVALUE_IMM16_V8: {
1400             uint16_t slotId = READ_INST_16_0();
1401             uint32_t v0 = READ_INST_8_2();
1402             info.inputs.emplace_back(ICSlotId(slotId));
1403             info.inputs.emplace_back(VirtualRegister(v0));
1404             break;
1405         }
1406         case EcmaOpcode::STOBJBYVALUE_IMM8_V8_V8: {
1407             uint16_t slotId = READ_INST_8_0();
1408             uint32_t v0 = READ_INST_8_1();
1409             uint32_t v1 = READ_INST_8_2();
1410             info.inputs.emplace_back(ICSlotId(slotId));
1411             info.inputs.emplace_back(VirtualRegister(v0));
1412             info.inputs.emplace_back(VirtualRegister(v1));
1413             break;
1414         }
1415         case EcmaOpcode::STOBJBYVALUE_IMM16_V8_V8: {
1416             uint16_t slotId = READ_INST_16_0();
1417             uint32_t v0 = READ_INST_8_2();
1418             uint32_t v1 = READ_INST_8_3();
1419             info.inputs.emplace_back(ICSlotId(slotId));
1420             info.inputs.emplace_back(VirtualRegister(v0));
1421             info.inputs.emplace_back(VirtualRegister(v1));
1422             break;
1423         }
1424         case EcmaOpcode::LDSUPERBYVALUE_IMM8_V8: {
1425             uint32_t v0 = READ_INST_8_1();
1426             info.inputs.emplace_back(VirtualRegister(v0));
1427             break;
1428         }
1429         case EcmaOpcode::LDSUPERBYVALUE_IMM16_V8: {
1430             uint32_t v0 = READ_INST_8_2();
1431             info.inputs.emplace_back(VirtualRegister(v0));
1432             break;
1433         }
1434         case EcmaOpcode::STSUPERBYVALUE_IMM8_V8_V8: {
1435             uint32_t v0 = READ_INST_8_1();
1436             uint32_t v1 = READ_INST_8_2();
1437             info.inputs.emplace_back(VirtualRegister(v0));
1438             info.inputs.emplace_back(VirtualRegister(v1));
1439             break;
1440         }
1441         case EcmaOpcode::STSUPERBYVALUE_IMM16_V8_V8: {
1442             uint32_t v0 = READ_INST_8_2();
1443             uint32_t v1 = READ_INST_8_3();
1444             info.inputs.emplace_back(VirtualRegister(v0));
1445             info.inputs.emplace_back(VirtualRegister(v1));
1446             break;
1447         }
1448         case EcmaOpcode::TRYLDGLOBALBYNAME_IMM8_ID16: {
1449             uint16_t slotId = READ_INST_8_0();
1450             uint16_t stringId = READ_INST_16_1();
1451             info.inputs.emplace_back(ICSlotId(slotId));
1452             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1453             break;
1454         }
1455         case EcmaOpcode::TRYLDGLOBALBYNAME_IMM16_ID16: {
1456             uint16_t slotId = READ_INST_16_0();
1457             uint16_t stringId = READ_INST_16_2();
1458             info.inputs.emplace_back(ICSlotId(slotId));
1459             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1460             break;
1461         }
1462         case EcmaOpcode::TRYSTGLOBALBYNAME_IMM8_ID16: {
1463             uint16_t slotId = READ_INST_8_0();
1464             uint16_t stringId = READ_INST_16_1();
1465             info.inputs.emplace_back(ICSlotId(slotId));
1466             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1467             break;
1468         }
1469         case EcmaOpcode::TRYSTGLOBALBYNAME_IMM16_ID16: {
1470             uint16_t slotId = READ_INST_16_0();
1471             uint16_t stringId = READ_INST_16_2();
1472             info.inputs.emplace_back(ICSlotId(slotId));
1473             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1474             break;
1475         }
1476         case EcmaOpcode::STTOGLOBALRECORD_IMM16_ID16: {
1477             uint16_t stringId = READ_INST_16_2();
1478             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1479             break;
1480         }
1481         case EcmaOpcode::STOWNBYVALUEWITHNAMESET_IMM8_V8_V8: {
1482             uint32_t v0 = READ_INST_8_1();
1483             uint32_t v1 = READ_INST_8_2();
1484             info.inputs.emplace_back(VirtualRegister(v0));
1485             info.inputs.emplace_back(VirtualRegister(v1));
1486             break;
1487         }
1488         case EcmaOpcode::STOWNBYVALUEWITHNAMESET_IMM16_V8_V8: {
1489             uint32_t v0 = READ_INST_8_2();
1490             uint32_t v1 = READ_INST_8_3();
1491             info.inputs.emplace_back(VirtualRegister(v0));
1492             info.inputs.emplace_back(VirtualRegister(v1));
1493             break;
1494         }
1495         case EcmaOpcode::STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8: {
1496             uint16_t stringId = READ_INST_16_1();
1497             uint32_t v0 = READ_INST_8_3();
1498             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1499             info.inputs.emplace_back(VirtualRegister(v0));
1500             break;
1501         }
1502         case EcmaOpcode::STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8: {
1503             uint16_t stringId = READ_INST_16_2();
1504             uint32_t v0 = READ_INST_8_4();
1505             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1506             info.inputs.emplace_back(VirtualRegister(v0));
1507             break;
1508         }
1509         case EcmaOpcode::STTHISBYVALUE_IMM8_V8: {
1510             uint16_t slotId = READ_INST_8_0();
1511             uint32_t v0 = READ_INST_8_1();
1512             info.inputs.emplace_back(ICSlotId(slotId));
1513             info.inputs.emplace_back(VirtualRegister(v0));
1514             break;
1515         }
1516         case EcmaOpcode::STTHISBYVALUE_IMM16_V8: {
1517             uint16_t slotId = READ_INST_16_0();
1518             uint32_t v0 = READ_INST_8_2();
1519             info.inputs.emplace_back(ICSlotId(slotId));
1520             info.inputs.emplace_back(VirtualRegister(v0));
1521             break;
1522         }
1523         // not implement
1524         case EcmaOpcode::JSTRICTEQZ_IMM8:
1525         case EcmaOpcode::JSTRICTEQZ_IMM16:
1526         case EcmaOpcode::JNSTRICTEQZ_IMM8:
1527         case EcmaOpcode::JNSTRICTEQZ_IMM16:
1528         case EcmaOpcode::JEQNULL_IMM8:
1529         case EcmaOpcode::JEQNULL_IMM16:
1530         case EcmaOpcode::JNENULL_IMM8:
1531         case EcmaOpcode::JNENULL_IMM16:
1532         case EcmaOpcode::JSTRICTEQNULL_IMM8:
1533         case EcmaOpcode::JSTRICTEQNULL_IMM16:
1534         case EcmaOpcode::JNSTRICTEQNULL_IMM8:
1535         case EcmaOpcode::JNSTRICTEQNULL_IMM16:
1536         case EcmaOpcode::JEQUNDEFINED_IMM8:
1537         case EcmaOpcode::JEQUNDEFINED_IMM16:
1538         case EcmaOpcode::JNEUNDEFINED_IMM8:
1539         case EcmaOpcode::JNEUNDEFINED_IMM16:
1540         case EcmaOpcode::JSTRICTEQUNDEFINED_IMM8:
1541         case EcmaOpcode::JSTRICTEQUNDEFINED_IMM16:
1542         case EcmaOpcode::JNSTRICTEQUNDEFINED_IMM8:
1543         case EcmaOpcode::JNSTRICTEQUNDEFINED_IMM16:
1544         case EcmaOpcode::JEQ_V8_IMM8:
1545         case EcmaOpcode::JEQ_V8_IMM16:
1546         case EcmaOpcode::JNE_V8_IMM8:
1547         case EcmaOpcode::JNE_V8_IMM16:
1548         case EcmaOpcode::JSTRICTEQ_V8_IMM8:
1549         case EcmaOpcode::JSTRICTEQ_V8_IMM16:
1550         case EcmaOpcode::JNSTRICTEQ_V8_IMM8:
1551         case EcmaOpcode::JNSTRICTEQ_V8_IMM16:
1552         case EcmaOpcode::LDTHIS:
1553             break;
1554         case EcmaOpcode::LDTHISBYNAME_IMM8_ID16: {
1555             uint16_t slotId = READ_INST_8_0();
1556             uint16_t stringId = READ_INST_16_1();
1557             info.inputs.emplace_back(ICSlotId(slotId));
1558             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1559             break;
1560         }
1561         case EcmaOpcode::LDTHISBYNAME_IMM16_ID16: {
1562             uint16_t slotId = READ_INST_16_0();
1563             uint16_t stringId = READ_INST_16_2();
1564             info.inputs.emplace_back(ICSlotId(slotId));
1565             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1566             break;
1567         }
1568         case EcmaOpcode::STTHISBYNAME_IMM8_ID16: {
1569             uint16_t slotId = READ_INST_8_0();
1570             uint16_t stringId = READ_INST_16_1();
1571             info.inputs.emplace_back(ICSlotId(slotId));
1572             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1573             break;
1574         }
1575         case EcmaOpcode::STTHISBYNAME_IMM16_ID16: {
1576             uint16_t slotId = READ_INST_16_0();
1577             uint16_t stringId = READ_INST_16_2();
1578             info.inputs.emplace_back(ICSlotId(slotId));
1579             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1580             break;
1581         }
1582         case EcmaOpcode::LDGLOBALVAR_IMM16_ID16: {
1583             uint16_t slotId = READ_INST_16_0();
1584             uint16_t stringId = READ_INST_16_2();
1585             info.inputs.emplace_back(ICSlotId(slotId));
1586             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1587             break;
1588         }
1589         case EcmaOpcode::LDOBJBYNAME_IMM8_ID16: {
1590             uint16_t slotId = READ_INST_8_0();
1591             uint16_t stringId = READ_INST_16_1();
1592             info.inputs.emplace_back(ICSlotId(slotId));
1593             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1594             break;
1595         }
1596         case EcmaOpcode::LDOBJBYNAME_IMM16_ID16: {
1597             uint16_t slotId = READ_INST_16_0();
1598             uint16_t stringId = READ_INST_16_2();
1599             info.inputs.emplace_back(ICSlotId(slotId));
1600             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1601             break;
1602         }
1603         case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8: {
1604             uint16_t slotId = READ_INST_8_0();
1605             uint16_t stringId = READ_INST_16_1();
1606             uint32_t v0 = READ_INST_8_3();
1607             info.inputs.emplace_back(ICSlotId(slotId));
1608             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1609             info.inputs.emplace_back(VirtualRegister(v0));
1610             break;
1611         }
1612         case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8: {
1613             uint16_t slotId = READ_INST_16_0();
1614             uint16_t stringId = READ_INST_16_2();
1615             uint32_t v0 = READ_INST_8_4();
1616             info.inputs.emplace_back(ICSlotId(slotId));
1617             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1618             info.inputs.emplace_back(VirtualRegister(v0));
1619             break;
1620         }
1621         case EcmaOpcode::LDSUPERBYNAME_IMM8_ID16: {
1622             uint16_t stringId = READ_INST_16_1();
1623             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1624             break;
1625         }
1626         case EcmaOpcode::LDSUPERBYNAME_IMM16_ID16: {
1627             uint16_t stringId = READ_INST_16_2();
1628             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1629             break;
1630         }
1631         case EcmaOpcode::STSUPERBYNAME_IMM8_ID16_V8: {
1632             uint16_t stringId = READ_INST_16_1();
1633             uint32_t v0 = READ_INST_8_3();
1634             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1635             info.inputs.emplace_back(VirtualRegister(v0));
1636             break;
1637         }
1638         case EcmaOpcode::STSUPERBYNAME_IMM16_ID16_V8: {
1639             uint16_t stringId = READ_INST_16_2();
1640             uint32_t v0 = READ_INST_8_4();
1641             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1642             info.inputs.emplace_back(VirtualRegister(v0));
1643             break;
1644         }
1645         case EcmaOpcode::STGLOBALVAR_IMM16_ID16: {
1646             uint16_t slotId = READ_INST_16_0();
1647             uint32_t stringId = READ_INST_16_2();
1648             info.inputs.emplace_back(ICSlotId(slotId));
1649             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1650             break;
1651         }
1652         case EcmaOpcode::CREATEGENERATOROBJ_V8: {
1653             uint16_t v0 = READ_INST_8_0();
1654             info.inputs.emplace_back(VirtualRegister(v0));
1655             break;
1656         }
1657         case EcmaOpcode::CREATEASYNCGENERATOROBJ_V8: {
1658             uint16_t v0 = READ_INST_8_0();
1659             info.inputs.emplace_back(VirtualRegister(v0));
1660             break;
1661         }
1662         case EcmaOpcode::ASYNCGENERATORRESOLVE_V8_V8_V8: {
1663             uint16_t v0 = READ_INST_8_0();
1664             uint16_t v1 = READ_INST_8_1();
1665             uint16_t v2 = READ_INST_8_2();
1666             uint32_t offset = builder->GetPcOffset(pc);
1667             offset += BytecodeInstruction::Size(EcmaOpcode::ASYNCGENERATORRESOLVE_V8_V8_V8); // skip suspend bc
1668             info.inputs.emplace_back(Immediate(offset)); // Save the pc offset
1669             info.inputs.emplace_back(VirtualRegister(v0));
1670             info.inputs.emplace_back(VirtualRegister(v1));
1671             info.inputs.emplace_back(VirtualRegister(v2));
1672             break;
1673         }
1674         case EcmaOpcode::ASYNCGENERATORREJECT_V8: {
1675             uint16_t v0 = READ_INST_8_0();
1676             info.inputs.emplace_back(VirtualRegister(v0));
1677             break;
1678         }
1679         case EcmaOpcode::STARRAYSPREAD_V8_V8: {
1680             uint16_t v0 = READ_INST_8_0();
1681             uint16_t v1 = READ_INST_8_1();
1682             info.inputs.emplace_back(VirtualRegister(v0));
1683             info.inputs.emplace_back(VirtualRegister(v1));
1684             break;
1685         }
1686         case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8: {
1687             uint16_t slotId = READ_INST_8_0();
1688             uint16_t methodId = READ_INST_16_1();
1689             uint16_t literaId = READ_INST_16_3();
1690             uint16_t length = READ_INST_16_5();
1691             uint16_t v0 = READ_INST_8_7();
1692             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
1693             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ClassLiteralIDType, literaId));
1694             info.inputs.emplace_back(Immediate(length));
1695             info.inputs.emplace_back(VirtualRegister(v0));
1696             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1697             info.inputs.emplace_back(ICSlotId(slotId));
1698             break;
1699         }
1700         case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8: {
1701             uint16_t slotId = READ_INST_16_0();
1702             uint16_t methodId = READ_INST_16_2();
1703             uint16_t literaId = READ_INST_16_4();
1704             uint16_t length = READ_INST_16_6();
1705             uint16_t v0 = READ_INST_8_8();
1706             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
1707             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ClassLiteralIDType, literaId));
1708             info.inputs.emplace_back(Immediate(length));
1709             info.inputs.emplace_back(VirtualRegister(v0));
1710             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1711             info.inputs.emplace_back(ICSlotId(slotId));
1712             break;
1713         }
1714         case EcmaOpcode::LDFUNCTION: {
1715             break;
1716         }
1717         case EcmaOpcode::LDBIGINT_ID16: {
1718             uint32_t stringId = READ_INST_16_0();
1719             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1720             break;
1721         }
1722         case EcmaOpcode::DYNAMICIMPORT: {
1723             break;
1724         }
1725         case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8:
1726         case EcmaOpcode::SUPERCALLARROWRANGE_IMM8_IMM8_V8: {
1727             uint16_t range = READ_INST_8_1();
1728             uint16_t v0 = READ_INST_8_2();
1729             for (size_t i = 0; i < range; i++) {
1730                 info.inputs.emplace_back(VirtualRegister(v0 + i));
1731             }
1732             break;
1733         }
1734         case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8:
1735         case EcmaOpcode::WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8: {
1736             uint16_t range = READ_INST_16_1();
1737             uint16_t v0 = READ_INST_8_3();
1738             for (size_t i = 0; i < range; i++) {
1739                 info.inputs.emplace_back(VirtualRegister(v0 + i));
1740             }
1741             break;
1742         }
1743         case EcmaOpcode::SUPERCALLSPREAD_IMM8_V8: {
1744             uint16_t v0 = READ_INST_8_1();
1745             info.inputs.emplace_back(VirtualRegister(v0));
1746             break;
1747         }
1748         case EcmaOpcode::POPLEXENV: {
1749             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1750             info.vregOut.emplace_back(builder->GetEnvVregIdx());
1751             break;
1752         }
1753         case EcmaOpcode::LDPRIVATEPROPERTY_IMM8_IMM16_IMM16: {
1754             uint32_t slotId = READ_INST_8_0();
1755             uint32_t levelIndex = READ_INST_16_1();
1756             uint32_t slotIndex = READ_INST_16_3();
1757             info.inputs.emplace_back(Immediate(slotId));
1758             info.inputs.emplace_back(Immediate(levelIndex));
1759             info.inputs.emplace_back(Immediate(slotIndex));
1760             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1761             break;
1762         }
1763         case EcmaOpcode::STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8: {
1764             uint32_t slotId = READ_INST_8_0();
1765             uint32_t levelIndex = READ_INST_16_1();
1766             uint32_t slotIndex = READ_INST_16_3();
1767             uint32_t v0 = READ_INST_8_5();
1768             info.inputs.emplace_back(Immediate(slotId));
1769             info.inputs.emplace_back(Immediate(levelIndex));
1770             info.inputs.emplace_back(Immediate(slotIndex));
1771             info.inputs.emplace_back(VirtualRegister(v0));
1772             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1773             break;
1774         }
1775         case EcmaOpcode::TESTIN_IMM8_IMM16_IMM16: {
1776             uint32_t slotId = READ_INST_8_0();
1777             uint32_t levelIndex = READ_INST_16_1();
1778             uint32_t slotIndex = READ_INST_16_3();
1779             info.inputs.emplace_back(Immediate(slotId));
1780             info.inputs.emplace_back(Immediate(levelIndex));
1781             info.inputs.emplace_back(Immediate(slotIndex));
1782             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1783             break;
1784         }
1785         case EcmaOpcode::DEFINEPROPERTYBYNAME_IMM8_ID16_V8:
1786         case EcmaOpcode::DEFINEFIELDBYNAME_IMM8_ID16_V8: {
1787             uint16_t slotId = READ_INST_8_0();
1788             uint16_t stringId = READ_INST_16_1();
1789             uint32_t v0 = READ_INST_8_3();
1790             info.inputs.emplace_back(ICSlotId(slotId));
1791             info.inputs.emplace_back(ConstDataId(ConstDataIDType::StringIDType, stringId));
1792             info.inputs.emplace_back(VirtualRegister(v0));
1793             break;
1794         }
1795         case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8: {
1796             uint32_t v0 = READ_INST_8_2();
1797             uint32_t v1 = READ_INST_8_3();
1798             info.inputs.emplace_back(VirtualRegister(v0));
1799             info.inputs.emplace_back(VirtualRegister(v1));
1800             break;
1801         }
1802         case EcmaOpcode::CALLRUNTIME_DEFINEFIELDBYINDEX_PREF_IMM8_IMM32_V8: {
1803             uint32_t index = READ_INST_32_2();
1804             uint32_t v0 = READ_INST_8_6();
1805             info.inputs.emplace_back(Immediate(index));
1806             info.inputs.emplace_back(VirtualRegister(v0));
1807             break;
1808         }
1809         case EcmaOpcode::CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16: {
1810             uint32_t count = READ_INST_16_1();
1811             uint32_t literalId = READ_INST_16_3();
1812             info.inputs.emplace_back(Immediate(count));
1813             info.inputs.emplace_back(Immediate(literalId));
1814             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1815             break;
1816         }
1817         case EcmaOpcode::CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8: {
1818             uint32_t levelIndex = READ_INST_16_2();
1819             uint32_t slotIndex = READ_INST_16_4();
1820             uint32_t v0 = READ_INST_8_6();
1821             info.inputs.emplace_back(Immediate(levelIndex));
1822             info.inputs.emplace_back(Immediate(slotIndex));
1823             info.inputs.emplace_back(VirtualRegister(v0));
1824             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1825             break;
1826         }
1827         case EcmaOpcode::CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8: {
1828             uint16_t methodId = READ_INST_16_3();
1829             uint16_t literaId = READ_INST_16_5();
1830             uint16_t length = READ_INST_16_7();
1831             uint16_t v0 = READ_INST_8_9();
1832             info.inputs.emplace_back(ConstDataId(ConstDataIDType::MethodIDType, methodId));
1833             info.inputs.emplace_back(ConstDataId(ConstDataIDType::ClassLiteralIDType, literaId));
1834             info.inputs.emplace_back(Immediate(length));
1835             info.inputs.emplace_back(VirtualRegister(v0));
1836             break;
1837         }
1838         case EcmaOpcode::CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16: {
1839             uint16_t level = READ_INST_16_1();
1840             info.inputs.emplace_back(Immediate(level));
1841             info.inputs.emplace_back(VirtualRegister(builder->GetEnvVregIdx()));
1842             break;
1843         }
1844         case EcmaOpcode::TONUMERIC_IMM8:
1845         case EcmaOpcode::INC_IMM8:
1846         case EcmaOpcode::DEC_IMM8:
1847         case EcmaOpcode::NOT_IMM8:
1848         case EcmaOpcode::NEG_IMM8:
1849         case EcmaOpcode::JMP_IMM8:
1850         case EcmaOpcode::JMP_IMM16:
1851         case EcmaOpcode::JMP_IMM32:
1852         case EcmaOpcode::JEQZ_IMM8:
1853         case EcmaOpcode::JEQZ_IMM16:
1854         case EcmaOpcode::JEQZ_IMM32:
1855         case EcmaOpcode::JNEZ_IMM8:
1856         case EcmaOpcode::JNEZ_IMM16:
1857         case EcmaOpcode::JNEZ_IMM32:
1858         case EcmaOpcode::RETURN:
1859         case EcmaOpcode::RETURNUNDEFINED:
1860         case EcmaOpcode::LDNAN:
1861         case EcmaOpcode::LDINFINITY:
1862         case EcmaOpcode::LDNEWTARGET:
1863         case EcmaOpcode::LDUNDEFINED:
1864         case EcmaOpcode::LDNULL:
1865         case EcmaOpcode::LDSYMBOL:
1866         case EcmaOpcode::LDGLOBAL:
1867         case EcmaOpcode::LDTRUE:
1868         case EcmaOpcode::LDFALSE:
1869         case EcmaOpcode::LDHOLE:
1870         case EcmaOpcode::CALLARG0_IMM8:
1871         case EcmaOpcode::GETUNMAPPEDARGS:
1872         case EcmaOpcode::ASYNCFUNCTIONENTER:
1873         case EcmaOpcode::TYPEOF_IMM8:
1874         case EcmaOpcode::TYPEOF_IMM16:
1875         case EcmaOpcode::TONUMBER_IMM8:
1876         case EcmaOpcode::THROW_PREF_NONE:
1877         case EcmaOpcode::GETPROPITERATOR:
1878         case EcmaOpcode::GETRESUMEMODE:
1879         case EcmaOpcode::CREATEEMPTYARRAY_IMM8:
1880         case EcmaOpcode::CREATEEMPTYARRAY_IMM16:
1881         case EcmaOpcode::CREATEEMPTYOBJECT:
1882         case EcmaOpcode::DEBUGGER:
1883         case EcmaOpcode::ISTRUE:
1884         case EcmaOpcode::ISFALSE:
1885         case EcmaOpcode::CALLRUNTIME_ISTRUE_PREF_IMM8:
1886         case EcmaOpcode::CALLRUNTIME_ISFALSE_PREF_IMM8:
1887         case EcmaOpcode::NOP:
1888         case EcmaOpcode::GETITERATOR_IMM8:
1889         case EcmaOpcode::GETITERATOR_IMM16:
1890         case EcmaOpcode::GETASYNCITERATOR_IMM8:
1891         case EcmaOpcode::THROW_NOTEXISTS_PREF_NONE:
1892         case EcmaOpcode::THROW_PATTERNNONCOERCIBLE_PREF_NONE:
1893         case EcmaOpcode::THROW_DELETESUPERPROPERTY_PREF_NONE:
1894         case EcmaOpcode::RESUMEGENERATOR:
1895         case EcmaOpcode::CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE:
1896         case EcmaOpcode::CALLRUNTIME_TOPROPERTYKEY_PREF_NONE:
1897             break;
1898         case EcmaOpcode::LDTHISBYVALUE_IMM8: {
1899             uint16_t slotId = READ_INST_8_0();
1900             info.inputs.emplace_back(ICSlotId(slotId));
1901             break;
1902         }
1903         case EcmaOpcode::LDTHISBYVALUE_IMM16: {
1904             uint16_t slotId = READ_INST_16_0();
1905             info.inputs.emplace_back(ICSlotId(slotId));
1906             break;
1907         }
1908         case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16: {
1909             uint16_t index = READ_INST_16_1();
1910             info.inputs.emplace_back(Immediate(index));
1911             break;
1912         }
1913         case EcmaOpcode::WIDE_STPATCHVAR_PREF_IMM16: {
1914             uint16_t index = READ_INST_16_1();
1915             info.inputs.emplace_back(Immediate(index));
1916             break;
1917         }
1918         default: {
1919             LOG_COMPILER(FATAL) << "Error bytecode: " << static_cast<uint16_t>(opcode);
1920             UNREACHABLE();
1921             break;
1922         }
1923     }
1924 }
1925 
GetBytecodeInfo() const1926 const BytecodeInfo &BytecodeIterator::GetBytecodeInfo() const
1927 {
1928     return builder_->GetBytecodeInfo(index_);
1929 }
1930 
PeekNextPc(size_t i) const1931 const uint8_t *BytecodeIterator::PeekNextPc(size_t i) const
1932 {
1933     ASSERT(index_ + static_cast<int32_t>(i) <= end_);
1934     return builder_->GetPCByIndex(static_cast<uint32_t>(index_ + i));
1935 }
1936 
PeekPrevPc(size_t i) const1937 const uint8_t *BytecodeIterator::PeekPrevPc(size_t i) const
1938 {
1939     ASSERT(index_ - static_cast<int32_t>(i) >= start_);
1940     return builder_->GetPCByIndex(static_cast<uint32_t>(index_ - i));
1941 }
1942 } // panda::ecmascript::kungfu
1943