1 /*
2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ecmascript/compiler/access_object_stub_builder.h"
17 #include "ecmascript/compiler/call_stub_builder.h"
18 #include "ecmascript/compiler/interpreter_stub-inl.h"
19 #include "ecmascript/compiler/operations_stub_builder.h"
20 #include "ecmascript/compiler/profiler_stub_builder.h"
21 #include "ecmascript/dfx/vm_thread_control.h"
22 #include "ecmascript/interpreter/interpreter.h"
23 #include "ecmascript/interpreter/interpreter_assembly.h"
24
25 namespace panda::ecmascript::kungfu {
26 #define DECLARE_ASM_HANDLER_BASE(name, needPrint, V, format) \
27 void name##StubBuilder::GenerateCircuit() \
28 { \
29 GateRef glue = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::GLUE)); \
30 GateRef sp = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::SP)); \
31 GateRef pc = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::PC)); \
32 GateRef constpool = TaggedPointerArgument( \
33 static_cast<size_t>(InterpreterHandlerInputs::CONSTPOOL)); \
34 GateRef profileTypeInfo = TaggedPointerArgument( \
35 static_cast<size_t>(InterpreterHandlerInputs::PROFILE_TYPE_INFO)); \
36 GateRef acc = TaggedArgument(static_cast<size_t>(InterpreterHandlerInputs::ACC)); \
37 GateRef hotnessCounter = Int32Argument( \
38 static_cast<size_t>(InterpreterHandlerInputs::HOTNESS_COUNTER)); \
39 DebugPrintInstruction<needPrint>(); \
40 V(format) \
41 GenerateCircuitImpl(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, callback); \
42 }
43
44 #define DECLARE_ASM_HANDLE_IMPLEMENT(name) \
45 void name##StubBuilder::GenerateCircuitImpl(GateRef glue, GateRef sp, GateRef pc, \
46 GateRef constpool, GateRef profileTypeInfo, \
47 GateRef acc, GateRef hotnessCounter, \
48 [[maybe_unused]] ProfileOperation callback)
49
50 #define REGISTER_PROFILE_CALL_BACK(format) \
51 ProfileOperation callback( \
52 [this, glue, sp, pc, profileTypeInfo](const std::initializer_list<GateRef> &values, OperationType type) { \
53 GateRef state = GetFrame(sp); \
54 GateRef currentEnv = GetEnvFromFrame(glue, state); \
55 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv); \
56 ProfilerStubBuilder profiler(this, globalEnv); \
57 profiler.PGOProfiler(glue, pc, GetFunctionFromFrame(glue, state), \
58 profileTypeInfo, values, format, type); \
59 }, nullptr);
60
61 #define REGISTER_JIT_PROFILE_CALL_BACK(format) \
62 ProfileOperation callback( \
63 nullptr, \
64 [this, glue, sp, pc, profileTypeInfo](const std::initializer_list<GateRef> &values, OperationType type) { \
65 GateRef state = GetFrame(sp); \
66 GateRef currentEnv = GetEnvFromFrame(glue, state); \
67 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv); \
68 ProfilerStubBuilder profiler(this, globalEnv); \
69 profiler.PGOProfiler(glue, pc, GetFunctionFromFrame(glue, state), \
70 profileTypeInfo, values, format, type); \
71 });
72
73 #define REGISTER_NULL_CALL_BACK(format) ProfileOperation callback;
74
75 #define DECLARE_ASM_HANDLER(name) \
76 DECLARE_ASM_HANDLER_BASE(name, true, REGISTER_NULL_CALL_BACK, SlotIDFormat::IMM8) \
77 DECLARE_ASM_HANDLE_IMPLEMENT(name)
78
79 #define DECLARE_ASM_HANDLER_NOPRINT(name) \
80 DECLARE_ASM_HANDLER_BASE(name, false, REGISTER_NULL_CALL_BACK, SlotIDFormat::IMM8) \
81 DECLARE_ASM_HANDLE_IMPLEMENT(name)
82
83 #define DECLARE_ASM_HANDLER_PROFILE(name, base, format) \
84 DECLARE_ASM_HANDLER_BASE(name, true, REGISTER_PROFILE_CALL_BACK, format)
85
86 #define DECLARE_ASM_HANDLER_JIT_PROFILE(name, base, format) \
87 DECLARE_ASM_HANDLER_BASE(name, true, REGISTER_JIT_PROFILE_CALL_BACK, format)
88
89 #define DECLARE_ASM_HANDLER_STW_COPY(name) \
90 DECLARE_ASM_HANDLER_BASE(name##StwCopy, true, REGISTER_NULL_CALL_BACK, SlotIDFormat::IMM8)
91
92 // TYPE:{OFFSET, ACC_VARACC, JUMP, SSD}
93 #define DISPATCH_BAK(TYPE, ...) DISPATCH_##TYPE(__VA_ARGS__)
94
95 // Dispatch(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, offset)
96 #define DISPATCH_OFFSET(offset) \
97 DISPATCH_BASE(profileTypeInfo, acc, hotnessCounter, offset)
98
99 // Dispatch(glue, sp, pc, constpool, profileTypeInfo, *varAcc, hotnessCounter, offset)
100 #define DISPATCH_VARACC(offset) \
101 DISPATCH_BASE(profileTypeInfo, *varAcc, hotnessCounter, offset)
102
103 // Dispatch(glue, sp, pc, constpool, *varProfileTypeInfo, acc, *varHotnessCounter, offset)
104 #define DISPATCH_JUMP(offset) \
105 DISPATCH_BASE(*varProfileTypeInfo, acc, *varHotnessCounter, offset)
106
107 #define DISPATCH_SSD(offset) \
108 Dispatch(glue, *varSp, *varPc, *varConstpool, *varProfileTypeInfo, *varAcc, \
109 *varHotnessCounter, offset)
110
111 #define DISPATCH_BASE(...) \
112 Dispatch(glue, sp, pc, constpool, __VA_ARGS__)
113
114 #define INT_PTR(opcode) \
115 IntPtr(BytecodeInstruction::Size(BytecodeInstruction::Opcode::opcode))
116
117 #define DISPATCH_WITH_ACC(opcode) DISPATCH_BAK(VARACC, INT_PTR(opcode))
118
119 #define DISPATCH(opcode) DISPATCH_BAK(OFFSET, INT_PTR(opcode))
120
121 #define DISPATCH_LAST() \
122 DispatchLast(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter) \
123
124 #define DISPATCH_LAST_WITH_ACC() \
125 DispatchLast(glue, sp, pc, constpool, profileTypeInfo, *varAcc, hotnessCounter) \
126
127 #define UPDATE_HOTNESS(_sp, callback) \
128 varHotnessCounter = Int32Add(offset, *varHotnessCounter); \
129 BRANCH(Int32LessThan(*varHotnessCounter, Int32(0)), &slowPath, &dispatch); \
130 Bind(&slowPath); \
131 { \
132 GateRef func = GetFunctionFromFrame(glue, GetFrame(_sp)); \
133 GateRef iVecOffset = IntPtr(JSThread::GlueData::GetInterruptVectorOffset(env->IsArch32Bit())); \
134 GateRef interruptsFlag = LoadPrimitive(VariableType::INT8(), glue, iVecOffset); \
135 varHotnessCounter = Int32(EcmaInterpreter::METHOD_HOTNESS_THRESHOLD); \
136 Label initialized(env); \
137 Label callRuntime(env); \
138 BRANCH(BitOr(TaggedIsUndefined(*varProfileTypeInfo), \
139 Int8Equal(interruptsFlag, Int8(VmThreadControl::VM_NEED_SUSPENSION))), \
140 &callRuntime, &initialized); \
141 Bind(&callRuntime); \
142 if (!(callback).IsEmpty()) { \
143 varProfileTypeInfo = CallRuntime(glue, RTSTUB_ID(UpdateHotnessCounterWithProf), {func}); \
144 } else { \
145 varProfileTypeInfo = CallRuntime(glue, RTSTUB_ID(UpdateHotnessCounter), {func}); \
146 } \
147 Label handleException(env); \
148 Label noException(env); \
149 BRANCH(HasPendingException(glue), &handleException, &noException); \
150 Bind(&handleException); \
151 { \
152 DISPATCH_LAST(); \
153 } \
154 Bind(&noException); \
155 { \
156 Jump(&dispatch); \
157 } \
158 Bind(&initialized); \
159 Label callCheckSafePoint(env); \
160 Label afterCheckSafePoint(env); \
161 BRANCH_UNLIKELY(LoadPrimitive(VariableType::BOOL(), glue, IntPtr( \
162 JSThread::GlueData::GetIsEnableCMCGCOffset(env->Is32Bit()))), \
163 &callCheckSafePoint, &afterCheckSafePoint); \
164 Bind(&callCheckSafePoint); \
165 { \
166 CallRuntime(glue, RTSTUB_ID(CheckSafePoint), {}); \
167 Jump(&afterCheckSafePoint); \
168 } \
169 Bind(&afterCheckSafePoint); \
170 (callback).TryDump(); \
171 (callback).TryJitCompile(); \
172 Jump(&dispatch); \
173 } \
174 Bind(&dispatch);
175
176 #define CHECK_EXCEPTION(res, offset) \
177 CheckException(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, \
178 res, offset)
179
180 #define CHECK_EXCEPTION_VARACC(res, offset) \
181 CheckException(glue, sp, pc, constpool, profileTypeInfo, *varAcc, hotnessCounter, \
182 res, offset)
183
184 #define CHECK_EXCEPTION_WITH_JUMP(res, jump) \
185 CheckExceptionWithJump(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, \
186 res, jump)
187
188 #define CHECK_EXCEPTION_WITH_ACC(res, offset) \
189 CheckExceptionWithVar(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, \
190 res, offset)
191
192 #define CHECK_EXCEPTION_WITH_VARACC(res, offset) \
193 CheckExceptionWithVar(glue, sp, pc, constpool, profileTypeInfo, *varAcc, hotnessCounter, \
194 res, offset)
195
196 #define CHECK_PENDING_EXCEPTION(res, offset) \
197 CheckPendingException(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, \
198 res, offset)
199
200 #define METHOD_ENTRY(func) \
201 auto env = GetEnvironment(); \
202 METHOD_ENTRY_ENV_DEFINED(func)
203
204 #define METHOD_ENTRY_ENV_DEFINED(func) \
205 GateRef isDebugModeOffset = IntPtr(JSThread::GlueData::GetIsDebugModeOffset(env->Is32Bit())); \
206 GateRef isDebugMode = LoadPrimitive(VariableType::BOOL(), glue, isDebugModeOffset); \
207 Label isDebugModeTrue(env); \
208 Label isDebugModeFalse(env); \
209 BRANCH(isDebugMode, &isDebugModeTrue, &isDebugModeFalse); \
210 Bind(&isDebugModeTrue); \
211 { \
212 CallRuntime(glue, RTSTUB_ID(MethodEntry), { func }); \
213 Jump(&isDebugModeFalse); \
214 } \
215 Bind(&isDebugModeFalse)
216
217 #define METHOD_EXIT() \
218 Label NeedCallRuntimeTrue(env); \
219 Label NeedCallRuntimeFalse(env); \
220 GateRef isDebugModeOrTracing = LogicOrBuilder(env) \
221 .Or(LoadPrimitive(VariableType::BOOL(), glue, \
222 IntPtr(JSThread::GlueData::GetIsDebugModeOffset(env->Is32Bit())))) \
223 .Or(LoadPrimitive(VariableType::BOOL(), glue, \
224 IntPtr(JSThread::GlueData::GetIsTracingOffset(env->Is32Bit())))) \
225 .Done(); \
226 BRANCH(isDebugModeOrTracing, &NeedCallRuntimeTrue, &NeedCallRuntimeFalse); \
227 Bind(&NeedCallRuntimeTrue); \
228 { \
229 CallRuntime(glue, RTSTUB_ID(MethodExit), {}); \
230 Jump(&NeedCallRuntimeFalse); \
231 } \
232 Bind(&NeedCallRuntimeFalse)
233
234 #define TRY_OSR() \
235 DEFVARIABLE(varOsrCache, VariableType::NATIVE_POINTER(), Undefined()); \
236 DEFVARIABLE(varMachineCodeOffset, VariableType::JS_ANY(), Undefined()); \
237 DEFVARIABLE(varMachineCode, VariableType::NATIVE_POINTER(), Undefined()); \
238 Label getOsrCache(env); \
239 Label getMachineCode(env); \
240 Label checkDeOptFlag(env); \
241 Label checkExecCount(env); \
242 Label clearMachineCode(env); \
243 Label executeBCByAOT(env); \
244 Label executeBCByInterpreter(env); \
245 GateRef curFrame = GetFrame(sp); \
246 GateRef curFunction = GetFunctionFromFrame(glue, curFrame); \
247 GateRef curMethod = Load(VariableType::JS_ANY(), glue, curFunction, IntPtr(JSFunctionBase::METHOD_OFFSET)); \
248 Branch(TaggedIsUndefined(profileTypeInfo), &executeBCByInterpreter, &getOsrCache); \
249 Bind(&getOsrCache); \
250 { \
251 GateRef profileTypeInfoLength = GetLengthOfTaggedArray(profileTypeInfo); \
252 GateRef typeInfoNum = Int32Sub(profileTypeInfoLength, Int32(ProfileTypeInfo::JIT_OSR_INDEX)); \
253 GateRef relativeOffset = PtrMul(ZExtInt32ToPtr(typeInfoNum), IntPtr(JSTaggedValue::TaggedTypeSize())); \
254 GateRef osrCacheOffset = PtrAdd(relativeOffset, IntPtr(TaggedArray::DATA_OFFSET)); \
255 varOsrCache = LoadPrimitive(VariableType::NATIVE_POINTER(), profileTypeInfo, osrCacheOffset); \
256 Branch(TaggedIsUndefinedOrNull(*varOsrCache), &executeBCByInterpreter, &getMachineCode); \
257 } \
258 Bind(&getMachineCode); \
259 { \
260 DEFVARIABLE(varIndex, VariableType::INT32(), Int32(0)); \
261 Label traverseOsrCache(env); \
262 Label compareOffset(env); \
263 Label addIndex(env); \
264 Label traverseOsrCacheAgain(env); \
265 GateRef fistPC = LoadPrimitive(VariableType::NATIVE_POINTER(), curMethod, \
266 IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET)); \
267 GateRef jmpOffsetInFunc = TruncPtrToInt32(PtrSub(pc, fistPC)); \
268 GateRef length = GetLengthOfTaggedArray(*varOsrCache); \
269 Branch(Int32LessThan(*varIndex, length), &traverseOsrCache, &executeBCByInterpreter); \
270 LoopBegin(&traverseOsrCache); \
271 { \
272 GateRef relativeOffset = PtrMul(ZExtInt32ToPtr(*varIndex), IntPtr(JSTaggedValue::TaggedTypeSize())); \
273 varMachineCodeOffset = PtrAdd(relativeOffset, IntPtr(TaggedArray::DATA_OFFSET)); \
274 varMachineCode = LoadPrimitive(VariableType::NATIVE_POINTER(), *varOsrCache, *varMachineCodeOffset); \
275 Branch(TaggedIsUndefinedOrNull(*varMachineCode), &addIndex, &compareOffset); \
276 Bind(&compareOffset); \
277 { \
278 GateRef offsetField = LoadPrimitive(VariableType::INT32(), *varMachineCode, \
279 IntPtr(MachineCode::INS_SIZE_OFFSET)); \
280 Branch(Int32Equal(jmpOffsetInFunc, offsetField), &checkExecCount, &addIndex); \
281 } \
282 Bind(&addIndex); \
283 { \
284 varIndex = Int32Add(*varIndex, Int32(1)); \
285 varMachineCode = NullPtr(); \
286 Branch(Int32LessThan(*varIndex, length), &traverseOsrCacheAgain, &executeBCByInterpreter); \
287 } \
288 Bind(&traverseOsrCacheAgain); \
289 } \
290 LoopEnd(&traverseOsrCache); \
291 } \
292 Bind(&checkExecCount); \
293 { \
294 GateRef execCnt = \
295 LoadPrimitive(VariableType::INT16(), *varMachineCode, IntPtr(MachineCode::OSR_EXECUTE_CNT_OFFSET)); \
296 Branch(Int32LessThan(ZExtInt16ToInt32(execCnt), Int32(5)), &checkDeOptFlag, &dispatch); \
297 } \
298 Bind(&checkDeOptFlag); \
299 { \
300 GateRef deOptField = \
301 LoadPrimitive(VariableType::INT16(), *varMachineCode, IntPtr(MachineCode::OSRMASK_OFFSET)); \
302 Branch(Equal(deOptField, Int16(MachineCode::OSR_DEOPT_FLAG)), &clearMachineCode, &executeBCByAOT); \
303 } \
304 Bind(&clearMachineCode); \
305 { \
306 Store(VariableType::NATIVE_POINTER(), glue, *varOsrCache, *varMachineCodeOffset, Undefined()); \
307 Jump(&executeBCByInterpreter); \
308 } \
309 Bind(&executeBCByAOT); \
310 { \
311 DEFVARIABLE(varRetVal, VariableType::JS_ANY(), Undefined()); \
312 Label fastCallOptimized(env); \
313 Label callOptimized(env); \
314 Label handleReturn(env); \
315 Label resumeRspAndReturn(env); \
316 Label resumeRspAndDispatch(env); \
317 Store(VariableType::NATIVE_POINTER(), glue, curFunction, IntPtr(JSFunction::MACHINECODE_OFFSET), \
318 *varMachineCode); \
319 GateRef execCnt = \
320 LoadPrimitive(VariableType::INT16(), *varMachineCode, IntPtr(MachineCode::OSR_EXECUTE_CNT_OFFSET)); \
321 GateRef newExecCnt = Int16Add(execCnt, Int16(1)); \
322 Store(VariableType::INT16(), glue, *varMachineCode, IntPtr(MachineCode::OSR_EXECUTE_CNT_OFFSET), \
323 newExecCnt); \
324 GateRef codeAddr = LoadPrimitive(VariableType::NATIVE_POINTER(), *varMachineCode, \
325 IntPtr(MachineCode::FUNCADDR_OFFSET)); \
326 varRetVal = FastCallOptimized(glue, codeAddr, { glue, sp }); \
327 Jump(&handleReturn); \
328 Bind(&handleReturn); \
329 { \
330 GateRef prevSp = LoadPrimitive(VariableType::NATIVE_POINTER(), curFrame, \
331 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit()))); \
332 GateRef prevFrame = GetFrame(prevSp); \
333 GateRef prevPc = GetPcFromFrame(prevFrame); \
334 Branch(IntPtrEqual(prevPc, IntPtr(0)), &resumeRspAndReturn, &resumeRspAndDispatch); \
335 Bind(&resumeRspAndReturn); \
336 { \
337 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varRetVal, prevSp, sp}); \
338 Return(); \
339 } \
340 Bind(&resumeRspAndDispatch); \
341 { \
342 GateRef prevFunction = GetFunctionFromFrame(glue, prevFrame); \
343 GateRef prevMethod = Load(VariableType::JS_ANY(), glue, prevFunction, \
344 IntPtr(JSFunctionBase::METHOD_OFFSET)); \
345 GateRef prevConstpool = GetConstpoolFromMethod(glue, prevMethod); \
346 GateRef prevProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, prevFunction); \
347 GateRef prevHotnessCounter = GetHotnessCounterFromMethod(prevMethod); \
348 GateRef jumpSize = GetCallSizeFromFrame(prevFrame); \
349 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch), \
350 {glue, sp, prevPc, prevConstpool, prevProfileTypeInfo, *varRetVal, \
351 prevHotnessCounter, jumpSize}); \
352 Return(); \
353 } \
354 } \
355 } \
356 Bind(&executeBCByInterpreter)
357
358 #define DEFINE_BY_NAME(newIc) \
359 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc)); \
360 GateRef stringId = ReadInst16_1(pc); \
361 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId)); \
362 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc))); \
363 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp)); \
364 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv); \
365 DEFVARIABLE(holder, VariableType::JS_ANY(), receiver); \
366 Label icPath(env); \
367 Label whichPath(env); \
368 Label slowPath(env); \
369 Label exit(env); \
370 Label isEcmaObj(env); \
371 /*hclass hit -> ic path*/ \
372 Label tryGetHclass(env); \
373 Label firstValueHeapObject(env); \
374 Label hclassNotHit(env); \
375 BRANCH(IsEcmaObject(glue, receiver), &isEcmaObj, &slowPath); \
376 Bind(&isEcmaObj); \
377 BRANCH(TaggedIsUndefined(profileTypeInfo), &hclassNotHit, &tryGetHclass); \
378 Bind(&tryGetHclass); \
379 { \
380 GateRef firstValue = GetValueFromTaggedArray(glue, profileTypeInfo, slotId); \
381 BRANCH(TaggedIsHeapObject(firstValue), &firstValueHeapObject, &hclassNotHit); \
382 Bind(&firstValueHeapObject); \
383 GateRef hclass = LoadHClass(glue, *holder); \
384 BRANCH(Equal(LoadObjectFromWeakRef(firstValue), hclass), &whichPath, &hclassNotHit); \
385 } \
386 Bind(&hclassNotHit); \
387 /* found entry -> slow path*/ \
388 Label loopHead(env); \
389 Label loopEnd(env); \
390 Label loopExit(env); \
391 Jump(&loopHead); \
392 LoopBegin(&loopHead); \
393 { \
394 GateRef hclass = LoadHClass(glue, *holder); \
395 GateRef jsType = GetObjectType(hclass); \
396 Label findProperty(env); \
397 BRANCH(IsSpecialIndexedObj(jsType), &slowPath, &findProperty); \
398 Bind(&findProperty); \
399 Label isDicMode(env); \
400 Label notDicMode(env); \
401 BRANCH(IsDictionaryModeByHClass(hclass), &isDicMode, ¬DicMode); \
402 Bind(&isDicMode); \
403 { \
404 GateRef array = GetPropertiesArray(glue, *holder); \
405 GateRef entry = FindEntryFromHashTable<NameDictionary>(glue, array, propKey); \
406 BRANCH(Int32NotEqual(entry, Int32(-1)), &slowPath, &loopExit); \
407 } \
408 Bind(¬DicMode); \
409 { \
410 GateRef layOutInfo = GetLayoutFromHClass(glue, hclass); \
411 GateRef propsNum = GetNumberOfPropsFromHClass(hclass); \
412 GateRef entry = FindElementWithCache(glue, layOutInfo, hclass, propKey, propsNum); \
413 BRANCH(Int32NotEqual(entry, Int32(-1)), &slowPath, &loopExit); \
414 } \
415 Bind(&loopExit); \
416 { \
417 holder = GetPrototypeFromHClass(glue, LoadHClass(glue, *holder)); \
418 BRANCH(TaggedIsHeapObject(*holder), &loopEnd, &whichPath); \
419 } \
420 Bind(&loopEnd); \
421 LoopEndWithCheckSafePoint(&loopHead, env, glue); \
422 } \
423 Bind(&whichPath); \
424 { \
425 BRANCH(newIc, &icPath, &slowPath); \
426 } \
427 Bind(&icPath); \
428 { \
429 /* IC do the same thing as stobjbyname */ \
430 AccessObjectStubBuilder builder(this, globalEnv); \
431 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16); \
432 result = builder.StOwnICByName(glue, receiver, 0, info, acc, profileTypeInfo, slotId, callback); \
433 Jump(&exit); \
434 } \
435 Bind(&slowPath); \
436 { \
437 SetCurrentGlobalEnv(globalEnv); \
438 result = DefineField(glue, receiver, propKey, acc); \
439 Jump(&exit); \
440 } \
441 Bind(&exit)
442
443 template <bool needPrint>
DebugPrintInstruction()444 void InterpreterStubBuilder::DebugPrintInstruction()
445 {
446 #if ECMASCRIPT_ENABLE_INTERPRETER_LOG
447 if constexpr (!needPrint) {
448 return;
449 }
450 GateRef glue = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::GLUE));
451 GateRef pc = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::PC));
452 CallNGCRuntime(glue, RTSTUB_ID(DebugPrintInstruction), { glue, pc });
453 #endif
454 #if ECMASCRIPT_ENABLE_COLLECTING_OPCODES
455 GateRef opcodeGlue = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::GLUE));
456 GateRef opcodePc = PtrArgument(static_cast<size_t>(InterpreterHandlerInputs::PC));
457 CallNGCRuntime(opcodeGlue, RTSTUB_ID(CollectingOpcodes), { opcodeGlue, opcodePc });
458 #endif
459 }
460
DECLARE_ASM_HANDLER(HandleLdnan)461 DECLARE_ASM_HANDLER(HandleLdnan)
462 {
463 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
464 varAcc = DoubleToTaggedDoublePtr(Double(base::NAN_VALUE));
465 DISPATCH_WITH_ACC(LDNAN);
466 }
467
DECLARE_ASM_HANDLER(HandleLdinfinity)468 DECLARE_ASM_HANDLER(HandleLdinfinity)
469 {
470 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
471 varAcc = DoubleToTaggedDoublePtr(Double(base::POSITIVE_INFINITY));
472 DISPATCH_WITH_ACC(LDINFINITY);
473 }
474
DECLARE_ASM_HANDLER(HandleLdundefined)475 DECLARE_ASM_HANDLER(HandleLdundefined)
476 {
477 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
478 varAcc = Undefined();
479 DISPATCH_WITH_ACC(LDUNDEFINED);
480 }
481
DECLARE_ASM_HANDLER(HandleLdnull)482 DECLARE_ASM_HANDLER(HandleLdnull)
483 {
484 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
485 varAcc = Null();
486 DISPATCH_WITH_ACC(LDNULL);
487 }
488
DECLARE_ASM_HANDLER(HandleLdsymbol)489 DECLARE_ASM_HANDLER(HandleLdsymbol)
490 {
491 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
492 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
493 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
494 varAcc = GetGlobalEnvValue(VariableType::JS_POINTER(), glue, globalEnv, GlobalEnv::SYMBOL_FUNCTION_INDEX);
495 DISPATCH_WITH_ACC(LDSYMBOL);
496 }
497
DECLARE_ASM_HANDLER(HandleLdglobal)498 DECLARE_ASM_HANDLER(HandleLdglobal)
499 {
500 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
501 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
502 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
503 varAcc = GetGlobalObject(glue, globalEnv);
504 DISPATCH_WITH_ACC(LDGLOBAL);
505 }
506
DECLARE_ASM_HANDLER(HandleLdtrue)507 DECLARE_ASM_HANDLER(HandleLdtrue)
508 {
509 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
510 varAcc = TaggedTrue();
511 DISPATCH_WITH_ACC(LDTRUE);
512 }
513
DECLARE_ASM_HANDLER(HandleLdfalse)514 DECLARE_ASM_HANDLER(HandleLdfalse)
515 {
516 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
517 varAcc = TaggedFalse();
518 DISPATCH_WITH_ACC(LDFALSE);
519 }
520
DECLARE_ASM_HANDLER(HandleTypeofImm8)521 DECLARE_ASM_HANDLER(HandleTypeofImm8)
522 {
523 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
524 varAcc = FastTypeOf(glue, acc);
525 DISPATCH_WITH_ACC(TYPEOF_IMM8);
526 }
527
DECLARE_ASM_HANDLER(HandleTypeofImm16)528 DECLARE_ASM_HANDLER(HandleTypeofImm16)
529 {
530 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
531 varAcc = FastTypeOf(glue, acc);
532 DISPATCH_WITH_ACC(TYPEOF_IMM16);
533 }
534
DECLARE_ASM_HANDLER(HandlePoplexenv)535 DECLARE_ASM_HANDLER(HandlePoplexenv)
536 {
537 GateRef state = GetFrame(sp);
538 GateRef currentLexEnv = GetEnvFromFrame(glue, state);
539 GateRef parentLexEnv = GetParentEnv(glue, currentLexEnv);
540 SetEnvToFrame(glue, state, parentLexEnv);
541 DISPATCH(POPLEXENV);
542 }
543
DECLARE_ASM_HANDLER(HandleDeprecatedPoplexenvPrefNone)544 DECLARE_ASM_HANDLER(HandleDeprecatedPoplexenvPrefNone)
545 {
546 GateRef state = GetFrame(sp);
547 GateRef currentLexEnv = GetEnvFromFrame(glue, state);
548 GateRef parentLexEnv = GetParentEnv(glue, currentLexEnv);
549 SetEnvToFrame(glue, state, parentLexEnv);
550 DISPATCH(DEPRECATED_POPLEXENV_PREF_NONE);
551 }
552
DECLARE_ASM_HANDLER(HandleGetunmappedargs)553 DECLARE_ASM_HANDLER(HandleGetunmappedargs)
554 {
555 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
556 DEFVARIABLE(argumentsList, VariableType::JS_ANY(), Hole());
557 DEFVARIABLE(argumentsObj, VariableType::JS_ANY(), Hole());
558 auto env = GetEnvironment();
559 GateRef startIdxAndNumArgs = GetStartIdxAndNumArgs(glue, sp, Int32(0));
560 // 32: high 32 bits = startIdx, low 32 bits = numArgs
561 GateRef startIdx = TruncInt64ToInt32(Int64LSR(startIdxAndNumArgs, Int64(32)));
562 GateRef numArgs = TruncInt64ToInt32(startIdxAndNumArgs);
563 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
564 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
565
566 Label newArgumentsObj(env);
567 Label checkException(env);
568 Label dispatch(env);
569 Label slowPath(env);
570 NewObjectStubBuilder newBuilder(this, globalEnv);
571 newBuilder.SetParameters(glue, 0);
572 Label afterArgumentsList(env);
573 newBuilder.NewArgumentsList(&argumentsList, &afterArgumentsList, sp, startIdx, numArgs);
574 Bind(&afterArgumentsList);
575 BRANCH(TaggedIsException(*argumentsList), &slowPath, &newArgumentsObj);
576 Bind(&newArgumentsObj);
577 Label afterArgumentsObj(env);
578 newBuilder.NewArgumentsObj(&argumentsObj, &afterArgumentsObj, *argumentsList, numArgs);
579 Bind(&afterArgumentsObj);
580 BRANCH(TaggedIsException(*argumentsObj), &slowPath, &checkException);
581 Bind(&checkException);
582 BRANCH(HasPendingException(glue), &slowPath, &dispatch);
583 Bind(&dispatch);
584 {
585 varAcc = *argumentsObj;
586 DISPATCH_WITH_ACC(GETUNMAPPEDARGS);
587 }
588
589 Bind(&slowPath);
590 {
591 GateRef res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(GetUnmapedArgs), {});
592 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(GETUNMAPPEDARGS));
593 }
594 }
595
DECLARE_ASM_HANDLER(HandleCopyrestargsImm8)596 DECLARE_ASM_HANDLER(HandleCopyrestargsImm8)
597 {
598 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
599 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
600 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
601 auto env = GetEnvironment();
602 GateRef restIdx = ZExtInt8ToInt32(ReadInst8_0(pc));
603 GateRef startIdxAndNumArgs = GetStartIdxAndNumArgs(glue, sp, restIdx);
604 GateRef startIdx = TruncInt64ToInt32(Int64LSR(startIdxAndNumArgs, Int64(32)));
605 GateRef numArgs = TruncInt64ToInt32(startIdxAndNumArgs);
606 Label dispatch(env);
607 Label slowPath(env);
608 // For the args, we use ElementsKind::GENERIC as the kind
609 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
610 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
611 GateRef intialHClass = GetGlobalEnvValue(VariableType::JS_ANY(), glue, globalEnv,
612 static_cast<size_t>(GlobalEnvField::ELEMENT_HOLE_TAGGED_HCLASS_INDEX));
613 NewObjectStubBuilder newBuilder(this, globalEnv);
614 newBuilder.SetParameters(glue, 0);
615 res = newBuilder.NewJSArrayWithSize(intialHClass, numArgs);
616 GateRef lengthOffset = IntPtr(JSArray::LENGTH_OFFSET);
617 Store(VariableType::INT32(), glue, *res, lengthOffset, TruncInt64ToInt32(numArgs));
618 GateRef accessor = GetGlobalConstantValue(VariableType::JS_ANY(), glue, ConstantIndex::ARRAY_LENGTH_ACCESSOR);
619 Store(VariableType::JS_ANY(), glue, *res,
620 IntPtr(JSArray::GetInlinedPropertyOffset(JSArray::LENGTH_INLINE_PROPERTY_INDEX)), accessor);
621 SetExtensibleToBitfield(glue, *res, true);
622 Label setArgumentsBegin(env);
623 Label setArgumentsAgain(env);
624 Label setArgumentsEnd(env);
625 GateRef elements = GetElementsArray(glue, *res);
626 BRANCH(Int32UnsignedLessThan(*i, numArgs), &setArgumentsBegin, &setArgumentsEnd);
627 LoopBegin(&setArgumentsBegin);
628 {
629 GateRef idx = ZExtInt32ToPtr(Int32Add(startIdx, *i));
630 GateRef receiver = LoadPrimitive(VariableType::JS_ANY(), sp, PtrMul(IntPtr(sizeof(JSTaggedType)), idx));
631 SetValueToTaggedArray(VariableType::JS_ANY(), glue, elements, *i, receiver);
632 i = Int32Add(*i, Int32(1));
633 BRANCH(Int32UnsignedLessThan(*i, numArgs), &setArgumentsAgain, &setArgumentsEnd);
634 Bind(&setArgumentsAgain);
635 }
636 LoopEnd(&setArgumentsBegin);
637 Bind(&setArgumentsEnd);
638 BRANCH(HasPendingException(glue), &slowPath, &dispatch);
639 Bind(&dispatch);
640 {
641 varAcc = *res;
642 DISPATCH_WITH_ACC(COPYRESTARGS_IMM8);
643 }
644
645 Bind(&slowPath);
646 {
647 GateRef result2 = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(CopyRestArgs),
648 { IntToTaggedInt(restIdx) });
649 CHECK_EXCEPTION_WITH_ACC(result2, INT_PTR(COPYRESTARGS_IMM8));
650 }
651 }
652
DECLARE_ASM_HANDLER(HandleWideCopyrestargsPrefImm16)653 DECLARE_ASM_HANDLER(HandleWideCopyrestargsPrefImm16)
654 {
655 GateRef restIdx = ZExtInt16ToInt32(ReadInst16_1(pc));
656 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
657 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CopyRestArgs), { IntToTaggedInt(restIdx) });
658 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_COPYRESTARGS_PREF_IMM16));
659 }
660
DECLARE_ASM_HANDLER(HandleCreateobjectwithexcludedkeysImm8V8V8)661 DECLARE_ASM_HANDLER(HandleCreateobjectwithexcludedkeysImm8V8V8)
662 {
663 GateRef numKeys = ReadInst8_0(pc);
664 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
665 GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_2(pc));
666 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
667 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateObjectWithExcludedKeys),
668 { Int16ToTaggedInt(numKeys), obj, Int16ToTaggedInt(firstArgRegIdx) });
669 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEOBJECTWITHEXCLUDEDKEYS_IMM8_V8_V8));
670 }
671
DECLARE_ASM_HANDLER(HandleWideCreateobjectwithexcludedkeysPrefImm16V8V8)672 DECLARE_ASM_HANDLER(HandleWideCreateobjectwithexcludedkeysPrefImm16V8V8)
673 {
674 GateRef numKeys = ReadInst16_1(pc);
675 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
676 GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_4(pc));
677 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
678 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateObjectWithExcludedKeys),
679 { Int16ToTaggedInt(numKeys), obj, Int16ToTaggedInt(firstArgRegIdx) });
680 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_CREATEOBJECTWITHEXCLUDEDKEYS_PREF_IMM16_V8_V8));
681 }
682
DECLARE_ASM_HANDLER(HandleThrowIfsupernotcorrectcallPrefImm16)683 DECLARE_ASM_HANDLER(HandleThrowIfsupernotcorrectcallPrefImm16)
684 {
685 GateRef imm = ReadInst16_1(pc);
686 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
687 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowIfSuperNotCorrectCall),
688 { Int16ToTaggedInt(imm), acc }); // acc is thisValue
689 CHECK_EXCEPTION(res, INT_PTR(THROW_IFSUPERNOTCORRECTCALL_PREF_IMM16));
690 }
691
DECLARE_ASM_HANDLER(HandleThrowIfsupernotcorrectcallPrefImm8)692 DECLARE_ASM_HANDLER(HandleThrowIfsupernotcorrectcallPrefImm8)
693 {
694 GateRef imm = ReadInst8_1(pc);
695 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
696 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowIfSuperNotCorrectCall),
697 { Int8ToTaggedInt(imm), acc }); // acc is thisValue
698 CHECK_EXCEPTION(res, INT_PTR(THROW_IFSUPERNOTCORRECTCALL_PREF_IMM8));
699 }
700
DECLARE_ASM_HANDLER(HandleAsyncfunctionresolveV8)701 DECLARE_ASM_HANDLER(HandleAsyncfunctionresolveV8)
702 {
703 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc)));
704 GateRef value = acc;
705 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
706 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject),
707 { asyncFuncObj, value, TaggedTrue() });
708 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(ASYNCFUNCTIONRESOLVE_V8));
709 }
710
DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionresolvePrefV8V8V8)711 DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionresolvePrefV8V8V8)
712 {
713 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
714 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
715 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
716 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject),
717 { asyncFuncObj, value, TaggedTrue() });
718 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_ASYNCFUNCTIONRESOLVE_PREF_V8_V8_V8));
719 }
720
DECLARE_ASM_HANDLER(HandleAsyncfunctionrejectV8)721 DECLARE_ASM_HANDLER(HandleAsyncfunctionrejectV8)
722 {
723 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc)));
724 GateRef value = acc;
725 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
726 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject),
727 { asyncFuncObj, value, TaggedFalse() });
728 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(ASYNCFUNCTIONREJECT_V8));
729 }
730
DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionrejectPrefV8V8V8)731 DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionrejectPrefV8V8V8)
732 {
733 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
734 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
735 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
736 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionResolveOrReject),
737 { asyncFuncObj, value, TaggedFalse() });
738 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_ASYNCFUNCTIONREJECT_PREF_V8_V8_V8));
739 }
740
DECLARE_ASM_HANDLER(HandleDefinegettersetterbyvalueV8V8V8V8)741 DECLARE_ASM_HANDLER(HandleDefinegettersetterbyvalueV8V8V8V8)
742 {
743 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc)));
744 GateRef prop = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
745 GateRef getter = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
746 GateRef setter = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
747 GateRef frame = GetFrame(sp);
748 GateRef func = GetFunctionFromFrame(glue, frame);
749
750 GateRef method = Load(VariableType::JS_ANY(), glue, func, IntPtr(JSFunctionBase::METHOD_OFFSET));
751 GateRef firstPC =
752 LoadPrimitive(VariableType::NATIVE_POINTER(), method, IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
753 GateRef offset = TaggedPtrToTaggedIntPtr(PtrSub(pc, firstPC));
754 GateRef currentEnv = GetEnvFromFrame(glue, frame);
755 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DefineGetterSetterByValue),
756 { obj, prop, getter, setter, acc, func, offset }); // acc is flag
757 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEFINEGETTERSETTERBYVALUE_V8_V8_V8_V8));
758 }
759
DECLARE_ASM_HANDLER(HandleGetpropiterator)760 DECLARE_ASM_HANDLER(HandleGetpropiterator)
761 {
762 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
763 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
764 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
765 NewObjectStubBuilder newBuilder(this, globalEnv);
766 GateRef res = newBuilder.EnumerateObjectProperties(glue, *varAcc);
767 CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(GETPROPITERATOR));
768 }
769
DECLARE_ASM_HANDLER(HandleAsyncfunctionenter)770 DECLARE_ASM_HANDLER(HandleAsyncfunctionenter)
771 {
772 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
773 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
774 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionEnter), {});
775 CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(ASYNCFUNCTIONENTER));
776 }
777
DECLARE_ASM_HANDLER(HandleLdhole)778 DECLARE_ASM_HANDLER(HandleLdhole)
779 {
780 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
781 varAcc = Hole();
782 DISPATCH_WITH_ACC(LDHOLE);
783 }
784
DECLARE_ASM_HANDLER(HandleCreateemptyobject)785 DECLARE_ASM_HANDLER(HandleCreateemptyobject)
786 {
787 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
788 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
789 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
790 NewObjectStubBuilder newBuilder(this, globalEnv);
791 varAcc = newBuilder.CreateEmptyObject(glue);
792 DISPATCH_WITH_ACC(CREATEEMPTYOBJECT);
793 }
794
DECLARE_ASM_HANDLER(HandleCreateemptyarrayImm8)795 DECLARE_ASM_HANDLER(HandleCreateemptyarrayImm8)
796 {
797 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
798 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
799 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
800 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
801 NewObjectStubBuilder newBuilder(this, globalEnv);
802 GateRef frame = GetFrame(*varSp);
803 GateRef func = GetFunctionFromFrame(glue, frame);
804 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
805 varAcc = newBuilder.CreateEmptyArray(glue, func, { pc, 0, true }, profileTypeInfo, slotId, callback);
806 DISPATCH_WITH_ACC(CREATEEMPTYARRAY_IMM8);
807 }
808
DECLARE_ASM_HANDLER(HandleCreateemptyarrayImm16)809 DECLARE_ASM_HANDLER(HandleCreateemptyarrayImm16)
810 {
811 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
812 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
813 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
814 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
815 NewObjectStubBuilder newBuilder(this, globalEnv);
816 GateRef frame = GetFrame(*varSp);
817 GateRef func = GetFunctionFromFrame(glue, frame);
818 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
819 varAcc = newBuilder.CreateEmptyArray(glue, func, { pc, 0 , true }, profileTypeInfo, slotId, callback);
820 DISPATCH_WITH_ACC(CREATEEMPTYARRAY_IMM16);
821 }
822
DECLARE_ASM_HANDLER(HandleGetiteratorImm8)823 DECLARE_ASM_HANDLER(HandleGetiteratorImm8)
824 {
825 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
826 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
827 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
828 SetCurrentGlobalEnv(globalEnv);
829 GateRef res = GetIterator(glue, *varAcc, callback);
830 CHECK_PENDING_EXCEPTION(res, INT_PTR(GETITERATOR_IMM8));
831 }
832
DECLARE_ASM_HANDLER(HandleGetiteratorImm16)833 DECLARE_ASM_HANDLER(HandleGetiteratorImm16)
834 {
835 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
836 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
837 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
838 SetCurrentGlobalEnv(globalEnv);
839 GateRef res = GetIterator(glue, *varAcc, callback);
840 CHECK_PENDING_EXCEPTION(res, INT_PTR(GETITERATOR_IMM16));
841 }
842
DECLARE_ASM_HANDLER(HandleGetasynciteratorImm8)843 DECLARE_ASM_HANDLER(HandleGetasynciteratorImm8)
844 {
845 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
846 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
847 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetAsyncIterator), { *varAcc });
848 CHECK_PENDING_EXCEPTION(res, INT_PTR(GETASYNCITERATOR_IMM8));
849 }
850
DECLARE_ASM_HANDLER(HandleLdPrivatePropertyImm8Imm16Imm16)851 DECLARE_ASM_HANDLER(HandleLdPrivatePropertyImm8Imm16Imm16)
852 {
853 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
854 GateRef levelIndex = ReadInst16_1(pc);
855 GateRef slotIndex = ReadInst16_3(pc);
856
857 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
858 result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdPrivateProperty),
859 {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj
860 CHECK_EXCEPTION_WITH_ACC(*result, INT_PTR(LDPRIVATEPROPERTY_IMM8_IMM16_IMM16));
861 }
862
DECLARE_ASM_HANDLER(HandleStPrivatePropertyImm8Imm16Imm16V8)863 DECLARE_ASM_HANDLER(HandleStPrivatePropertyImm8Imm16Imm16V8)
864 {
865 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
866 GateRef levelIndex = ReadInst16_1(pc);
867 GateRef slotIndex = ReadInst16_3(pc);
868 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_5(pc)));
869 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
870 result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StPrivateProperty),
871 {currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc}); // acc as value
872 CHECK_EXCEPTION_WITH_ACC(*result, INT_PTR(STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8));
873 }
874
DECLARE_ASM_HANDLER(HandleTestInImm8Imm16Imm16)875 DECLARE_ASM_HANDLER(HandleTestInImm8Imm16Imm16)
876 {
877 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
878 [[maybe_unused]] GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
879 GateRef levelIndex = ReadInst16_1(pc);
880 GateRef slotIndex = ReadInst16_3(pc);
881 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(TestIn), {currentEnv,
882 IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), acc}); // acc as obj
883 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(TESTIN_IMM8_IMM16_IMM16));
884 }
885
DECLARE_ASM_HANDLER(HandleThrowPatternnoncoerciblePrefNone)886 DECLARE_ASM_HANDLER(HandleThrowPatternnoncoerciblePrefNone)
887 {
888 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
889 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowPatternNonCoercible), {});
890 DISPATCH_LAST();
891 }
892
DECLARE_ASM_HANDLER(HandleThrowDeletesuperpropertyPrefNone)893 DECLARE_ASM_HANDLER(HandleThrowDeletesuperpropertyPrefNone)
894 {
895 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
896 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowDeleteSuperProperty), {});
897 DISPATCH_LAST();
898 }
899
DECLARE_ASM_HANDLER(HandleDebugger)900 DECLARE_ASM_HANDLER(HandleDebugger)
901 {
902 CallRuntime(glue, RTSTUB_ID(NotifyDebuggerStatement), {});
903 DISPATCH(DEBUGGER);
904 }
905
DECLARE_ASM_HANDLER(HandleMul2Imm8V8)906 DECLARE_ASM_HANDLER(HandleMul2Imm8V8)
907 {
908 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
909 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
910 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
911 OperationsStubBuilder builder(this, globalEnv);
912 GateRef result = builder.Mul(glue, left, acc, callback);
913 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(MUL2_IMM8_V8));
914 }
915
DECLARE_ASM_HANDLER(HandleDiv2Imm8V8)916 DECLARE_ASM_HANDLER(HandleDiv2Imm8V8)
917 {
918 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
919 OperationsStubBuilder builder(this);
920 GateRef result = builder.Div(glue, left, acc, callback);
921 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DIV2_IMM8_V8));
922 }
923
DECLARE_ASM_HANDLER(HandleMod2Imm8V8)924 DECLARE_ASM_HANDLER(HandleMod2Imm8V8)
925 {
926 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
927 OperationsStubBuilder builder(this);
928 GateRef result = builder.Mod(glue, left, acc, callback);
929 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(MOD2_IMM8_V8));
930 }
931
DECLARE_ASM_HANDLER(HandleEqImm8V8)932 DECLARE_ASM_HANDLER(HandleEqImm8V8)
933 {
934 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
935 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
936 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
937 OperationsStubBuilder builder(this, globalEnv);
938 GateRef result = builder.Equal(glue, left, acc, callback);
939 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(EQ_IMM8_V8));
940 }
941
DECLARE_ASM_HANDLER(HandleJequndefinedImm16)942 DECLARE_ASM_HANDLER(HandleJequndefinedImm16)
943 {
944 DISPATCH(NOP);
945 }
946
DECLARE_ASM_HANDLER(HandleJequndefinedImm8)947 DECLARE_ASM_HANDLER(HandleJequndefinedImm8)
948 {
949 DISPATCH(NOP);
950 }
951
DECLARE_ASM_HANDLER(HandleNoteqImm8V8)952 DECLARE_ASM_HANDLER(HandleNoteqImm8V8)
953 {
954 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
955 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
956 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
957 OperationsStubBuilder builder(this, globalEnv);
958 GateRef result = builder.NotEqual(glue, left, acc, callback);
959 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NOTEQ_IMM8_V8));
960 }
961
DECLARE_ASM_HANDLER(HandleLessImm8V8)962 DECLARE_ASM_HANDLER(HandleLessImm8V8)
963 {
964 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
965 OperationsStubBuilder builder(this);
966 GateRef result = builder.Less(glue, left, acc, callback);
967 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LESS_IMM8_V8));
968 }
969
DECLARE_ASM_HANDLER(HandleLesseqImm8V8)970 DECLARE_ASM_HANDLER(HandleLesseqImm8V8)
971 {
972 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
973 OperationsStubBuilder builder(this);
974 GateRef result = builder.LessEq(glue, left, acc, callback);
975 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LESSEQ_IMM8_V8));
976 }
977
DECLARE_ASM_HANDLER(HandleGreaterImm8V8)978 DECLARE_ASM_HANDLER(HandleGreaterImm8V8)
979 {
980 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
981 OperationsStubBuilder builder(this);
982 GateRef result = builder.Greater(glue, left, acc, callback);
983 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GREATER_IMM8_V8));
984 }
985
DECLARE_ASM_HANDLER(HandleGreatereqImm8V8)986 DECLARE_ASM_HANDLER(HandleGreatereqImm8V8)
987 {
988 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
989 OperationsStubBuilder builder(this);
990 GateRef result = builder.GreaterEq(glue, left, acc, callback);
991 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GREATEREQ_IMM8_V8));
992 }
993
DECLARE_ASM_HANDLER(HandleNop)994 DECLARE_ASM_HANDLER(HandleNop)
995 {
996 DISPATCH(NOP);
997 }
998
DECLARE_ASM_HANDLER(HandleLdaV8)999 DECLARE_ASM_HANDLER(HandleLdaV8)
1000 {
1001 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1002 GateRef vsrc = ReadInst8_0(pc);
1003 varAcc = GetVregValue(glue, sp, ZExtInt8ToPtr(vsrc));
1004 DISPATCH_WITH_ACC(LDA_V8);
1005 }
1006
DECLARE_ASM_HANDLER(HandleStaV8)1007 DECLARE_ASM_HANDLER(HandleStaV8)
1008 {
1009 GateRef vdst = ReadInst8_0(pc);
1010 SetVregValue(glue, sp, ZExtInt8ToPtr(vdst), acc);
1011 DISPATCH(STA_V8);
1012 }
1013
DECLARE_ASM_HANDLER(HandleJmpImm8)1014 DECLARE_ASM_HANDLER(HandleJmpImm8)
1015 {
1016 auto env = GetEnvironment();
1017 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
1018 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
1019
1020 GateRef offset = ReadInstSigned8_0(pc);
1021 Label dispatch(env);
1022 Label slowPath(env);
1023
1024 TRY_OSR();
1025
1026 UPDATE_HOTNESS(sp, callback);
1027 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
1028 }
1029
DECLARE_ASM_HANDLER(HandleJmpImm16)1030 DECLARE_ASM_HANDLER(HandleJmpImm16)
1031 {
1032 auto env = GetEnvironment();
1033 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
1034 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
1035
1036 GateRef offset = ReadInstSigned16_0(pc);
1037 Label dispatch(env);
1038 Label slowPath(env);
1039
1040 TRY_OSR();
1041
1042 UPDATE_HOTNESS(sp, callback);
1043 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
1044 }
1045
DECLARE_ASM_HANDLER(HandleJmpImm32)1046 DECLARE_ASM_HANDLER(HandleJmpImm32)
1047 {
1048 auto env = GetEnvironment();
1049 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
1050 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
1051
1052 GateRef offset = ReadInstSigned32_0(pc);
1053 Label dispatch(env);
1054 Label slowPath(env);
1055
1056 TRY_OSR();
1057
1058 UPDATE_HOTNESS(sp, callback);
1059 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
1060 }
1061
DECLARE_ASM_HANDLER(HandleLdlexvarImm4Imm4)1062 DECLARE_ASM_HANDLER(HandleLdlexvarImm4Imm4)
1063 {
1064 auto env = GetEnvironment();
1065 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1066
1067 GateRef level = ZExtInt8ToInt32(ReadInst4_0(pc));
1068 GateRef slot = ZExtInt8ToInt32(ReadInst4_1(pc));
1069 GateRef state = GetFrame(sp);
1070 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1071 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1072
1073 Label loopHead(env);
1074 Label loopEnd(env);
1075 Label afterLoop(env);
1076 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1077 LoopBegin(&loopHead);
1078 currentEnv = GetParentEnv(glue, *currentEnv);
1079 i = Int32Add(*i, Int32(1));
1080 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1081 Bind(&loopEnd);
1082 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1083 Bind(&afterLoop);
1084 GateRef variable = GetPropertiesFromLexicalEnv(glue, *currentEnv, slot);
1085 varAcc = variable;
1086
1087 DISPATCH_WITH_ACC(LDLEXVAR_IMM4_IMM4);
1088 }
1089
DECLARE_ASM_HANDLER(HandleLdlexvarImm8Imm8)1090 DECLARE_ASM_HANDLER(HandleLdlexvarImm8Imm8)
1091 {
1092 auto env = GetEnvironment();
1093 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1094
1095 GateRef level = ZExtInt8ToInt32(ReadInst8_0(pc));
1096 GateRef slot = ZExtInt8ToInt32(ReadInst8_1(pc));
1097
1098 GateRef state = GetFrame(sp);
1099 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1100 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1101
1102 Label loopHead(env);
1103 Label loopEnd(env);
1104 Label afterLoop(env);
1105 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1106 LoopBegin(&loopHead);
1107 currentEnv = GetParentEnv(glue, *currentEnv);
1108 i = Int32Add(*i, Int32(1));
1109 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1110 Bind(&loopEnd);
1111 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1112 Bind(&afterLoop);
1113 GateRef variable = GetPropertiesFromLexicalEnv(glue, *currentEnv, slot);
1114 varAcc = variable;
1115 DISPATCH_WITH_ACC(LDLEXVAR_IMM8_IMM8);
1116 }
1117
DECLARE_ASM_HANDLER(HandleWideLdlexvarPrefImm16Imm16)1118 DECLARE_ASM_HANDLER(HandleWideLdlexvarPrefImm16Imm16)
1119 {
1120 auto env = GetEnvironment();
1121 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1122
1123 GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
1124 GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
1125
1126 GateRef state = GetFrame(sp);
1127 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1128 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1129
1130 Label loopHead(env);
1131 Label loopEnd(env);
1132 Label afterLoop(env);
1133 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1134 LoopBegin(&loopHead);
1135 currentEnv = GetParentEnv(glue, *currentEnv);
1136 i = Int32Add(*i, Int32(1));
1137 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1138 Bind(&loopEnd);
1139 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1140 Bind(&afterLoop);
1141 GateRef variable = GetPropertiesFromLexicalEnv(glue, *currentEnv, slot);
1142 varAcc = variable;
1143 DISPATCH_WITH_ACC(WIDE_LDLEXVAR_PREF_IMM16_IMM16);
1144 }
1145
DECLARE_ASM_HANDLER(HandleStlexvarImm4Imm4)1146 DECLARE_ASM_HANDLER(HandleStlexvarImm4Imm4)
1147 {
1148 auto env = GetEnvironment();
1149 GateRef level = ZExtInt8ToInt32(ReadInst4_0(pc));
1150 GateRef slot = ZExtInt8ToInt32(ReadInst4_1(pc));
1151
1152 GateRef value = acc;
1153 GateRef state = GetFrame(sp);
1154 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1155 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1156
1157 Label loopHead(env);
1158 Label loopEnd(env);
1159 Label afterLoop(env);
1160 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1161 LoopBegin(&loopHead);
1162 currentEnv = GetParentEnv(glue, *currentEnv);
1163 i = Int32Add(*i, Int32(1));
1164 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1165 Bind(&loopEnd);
1166 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1167 Bind(&afterLoop);
1168 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
1169 DISPATCH(STLEXVAR_IMM4_IMM4);
1170 }
1171
DECLARE_ASM_HANDLER(HandleStlexvarImm8Imm8)1172 DECLARE_ASM_HANDLER(HandleStlexvarImm8Imm8)
1173 {
1174 auto env = GetEnvironment();
1175 GateRef level = ZExtInt8ToInt32(ReadInst8_0(pc));
1176 GateRef slot = ZExtInt8ToInt32(ReadInst8_1(pc));
1177
1178 GateRef value = acc;
1179 GateRef state = GetFrame(sp);
1180 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1181 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1182
1183 Label loopHead(env);
1184 Label loopEnd(env);
1185 Label afterLoop(env);
1186 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1187 LoopBegin(&loopHead);
1188 currentEnv = GetParentEnv(glue, *currentEnv);
1189 i = Int32Add(*i, Int32(1));
1190 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1191 Bind(&loopEnd);
1192 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1193 Bind(&afterLoop);
1194 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
1195 DISPATCH(STLEXVAR_IMM8_IMM8);
1196 }
1197
DECLARE_ASM_HANDLER(HandleWideStlexvarPrefImm16Imm16)1198 DECLARE_ASM_HANDLER(HandleWideStlexvarPrefImm16Imm16)
1199 {
1200 auto env = GetEnvironment();
1201 GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
1202 GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
1203
1204 GateRef value = acc;
1205 GateRef state = GetFrame(sp);
1206 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1207 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1208
1209 Label loopHead(env);
1210 Label loopEnd(env);
1211 Label afterLoop(env);
1212 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1213 LoopBegin(&loopHead);
1214 currentEnv = GetParentEnv(glue, *currentEnv);
1215 i = Int32Add(*i, Int32(1));
1216 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1217 Bind(&loopEnd);
1218 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1219 Bind(&afterLoop);
1220 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
1221 DISPATCH(WIDE_STLEXVAR_PREF_IMM16_IMM16);
1222 }
1223
DECLARE_ASM_HANDLER(HandleDeprecatedStlexvarPrefImm16Imm16V8)1224 DECLARE_ASM_HANDLER(HandleDeprecatedStlexvarPrefImm16Imm16V8)
1225 {
1226 auto env = GetEnvironment();
1227 GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
1228 GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
1229
1230 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_5(pc)));
1231 GateRef state = GetFrame(sp);
1232 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1233 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1234
1235 Label loopHead(env);
1236 Label loopEnd(env);
1237 Label afterLoop(env);
1238 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1239 LoopBegin(&loopHead);
1240 currentEnv = GetParentEnv(glue, *currentEnv);
1241 i = Int32Add(*i, Int32(1));
1242 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1243 Bind(&loopEnd);
1244 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1245 Bind(&afterLoop);
1246 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
1247 DISPATCH(DEPRECATED_STLEXVAR_PREF_IMM16_IMM16_V8);
1248 }
1249
DECLARE_ASM_HANDLER(HandleDeprecatedStlexvarPrefImm8Imm8V8)1250 DECLARE_ASM_HANDLER(HandleDeprecatedStlexvarPrefImm8Imm8V8)
1251 {
1252 auto env = GetEnvironment();
1253 GateRef level = ZExtInt8ToInt32(ReadInst8_1(pc));
1254 GateRef slot = ZExtInt8ToInt32(ReadInst8_2(pc));
1255
1256 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
1257 GateRef state = GetFrame(sp);
1258 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1259 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1260
1261 Label loopHead(env);
1262 Label loopEnd(env);
1263 Label afterLoop(env);
1264 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1265 LoopBegin(&loopHead);
1266 currentEnv = GetParentEnv(glue, *currentEnv);
1267 i = Int32Add(*i, Int32(1));
1268 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1269 Bind(&loopEnd);
1270 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1271 Bind(&afterLoop);
1272 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
1273 DISPATCH(DEPRECATED_STLEXVAR_PREF_IMM8_IMM8_V8);
1274 }
1275
DECLARE_ASM_HANDLER(HandleDeprecatedStlexvarPrefImm4Imm4V8)1276 DECLARE_ASM_HANDLER(HandleDeprecatedStlexvarPrefImm4Imm4V8)
1277 {
1278 auto env = GetEnvironment();
1279 GateRef level = ZExtInt8ToInt32(ReadInst4_2(pc));
1280 GateRef slot = ZExtInt8ToInt32(ReadInst4_3(pc));
1281
1282 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
1283 GateRef state = GetFrame(sp);
1284 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetEnvFromFrame(glue, state));
1285 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
1286
1287 Label loopHead(env);
1288 Label loopEnd(env);
1289 Label afterLoop(env);
1290 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
1291 LoopBegin(&loopHead);
1292 currentEnv = GetParentEnv(glue, *currentEnv);
1293 i = Int32Add(*i, Int32(1));
1294 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
1295 Bind(&loopEnd);
1296 LoopEndWithCheckSafePoint(&loopHead, env, glue);
1297 Bind(&afterLoop);
1298 SetPropertiesToLexicalEnv(glue, *currentEnv, slot, value);
1299 DISPATCH(DEPRECATED_STLEXVAR_PREF_IMM4_IMM4_V8);
1300 }
1301
DECLARE_ASM_HANDLER(HandleIncImm8)1302 DECLARE_ASM_HANDLER(HandleIncImm8)
1303 {
1304 OperationsStubBuilder builder(this);
1305 GateRef result = builder.Inc(glue, acc, callback);
1306 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(INC_IMM8));
1307 }
1308
DECLARE_ASM_HANDLER(HandleDeprecatedIncPrefV8)1309 DECLARE_ASM_HANDLER(HandleDeprecatedIncPrefV8)
1310 {
1311 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1312 OperationsStubBuilder builder(this);
1313 GateRef result = builder.Inc(glue, value);
1314 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_INC_PREF_V8));
1315 }
1316
DECLARE_ASM_HANDLER(HandleDecImm8)1317 DECLARE_ASM_HANDLER(HandleDecImm8)
1318 {
1319 OperationsStubBuilder builder(this);
1320 GateRef result = builder.Dec(glue, acc, callback);
1321 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEC_IMM8));
1322 }
1323
DECLARE_ASM_HANDLER(HandleDeprecatedDecPrefV8)1324 DECLARE_ASM_HANDLER(HandleDeprecatedDecPrefV8)
1325 {
1326 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1327 OperationsStubBuilder builder(this);
1328 GateRef result = builder.Dec(glue, value);
1329 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_DEC_PREF_V8));
1330 }
1331
DECLARE_ASM_HANDLER(HandleExpImm8V8)1332 DECLARE_ASM_HANDLER(HandleExpImm8V8)
1333 {
1334 GateRef v0 = ReadInst8_1(pc);
1335 GateRef base = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1336 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1337 GateRef result = CallRuntime(glue, RTSTUB_ID(Exp), { base, acc });
1338 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(EXP_IMM8_V8));
1339 }
1340
DECLARE_ASM_HANDLER(HandleIsinImm8V8)1341 DECLARE_ASM_HANDLER(HandleIsinImm8V8)
1342 {
1343 GateRef v0 = ReadInst8_1(pc);
1344 GateRef prop = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1345 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1346 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1347 SetCurrentGlobalEnv(globalEnv);
1348 #if ENABLE_NEXT_OPTIMIZATION
1349 GateRef result = IsIn(glue, prop, acc); // acc is obj
1350 #else
1351 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(IsIn), {prop, acc}); // acc is obj
1352 #endif
1353 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(ISIN_IMM8_V8));
1354 }
1355
DECLARE_ASM_HANDLER(HandleInstanceofImm8V8)1356 DECLARE_ASM_HANDLER(HandleInstanceofImm8V8)
1357 {
1358 GateRef v0 = ReadInst8_1(pc);
1359 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1360 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
1361 GateRef target = acc;
1362 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1363 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1364 SetCurrentGlobalEnv(globalEnv);
1365 GateRef result = InstanceOf(glue, obj, target, profileTypeInfo, slotId, callback);
1366 CHECK_PENDING_EXCEPTION(result, INT_PTR(INSTANCEOF_IMM8_V8));
1367 }
1368
DECLARE_ASM_HANDLER(HandleStrictnoteqImm8V8)1369 DECLARE_ASM_HANDLER(HandleStrictnoteqImm8V8)
1370 {
1371 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1372
1373 GateRef v0 = ReadInst8_1(pc);
1374 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1375 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1376 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1377
1378 OperationsStubBuilder builder(this, globalEnv);
1379 varAcc = builder.StrictNotEqual(glue, left, acc, callback);
1380 DISPATCH_WITH_ACC(STRICTNOTEQ_IMM8_V8);
1381 }
1382
DECLARE_ASM_HANDLER(HandleStricteqImm8V8)1383 DECLARE_ASM_HANDLER(HandleStricteqImm8V8)
1384 {
1385 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1386
1387 GateRef v0 = ReadInst8_1(pc);
1388 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1389 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1390 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1391
1392 OperationsStubBuilder builder(this, globalEnv);
1393 varAcc = builder.StrictEqual(glue, left, acc, callback);
1394 DISPATCH_WITH_ACC(STRICTEQ_IMM8_V8);
1395 }
1396
DECLARE_ASM_HANDLER(HandleResumegenerator)1397 DECLARE_ASM_HANDLER(HandleResumegenerator)
1398 {
1399 auto env = GetEnvironment();
1400 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1401 GateRef obj = *varAcc;
1402
1403 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
1404 GateRef frame = GetFrame(sp);
1405 GateRef curFunc = GetFunctionFromFrame(glue, frame);
1406 CallNGCRuntime(glue, RTSTUB_ID(StartCallTimer), { glue, curFunc, False() });
1407 #endif
1408 Label isAsyncGeneratorObj(env);
1409 Label notAsyncGeneratorObj(env);
1410 Label dispatch(env);
1411 BRANCH(TaggedIsAsyncGeneratorObject(glue, obj), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
1412 Bind(&isAsyncGeneratorObj);
1413 {
1414 GateRef resumeResultOffset = IntPtr(JSAsyncGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
1415 varAcc = Load(VariableType::JS_ANY(), glue, obj, resumeResultOffset);
1416 Jump(&dispatch);
1417 }
1418 Bind(¬AsyncGeneratorObj);
1419 {
1420 GateRef resumeResultOffset = IntPtr(JSGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
1421 varAcc = Load(VariableType::JS_ANY(), glue, obj, resumeResultOffset);
1422 GateRef taskInfoOffset = IntPtr(JSGeneratorObject::TASK_INFO_OFFSET);
1423 GateRef taskInfo = LoadPrimitive(VariableType::NATIVE_POINTER(), obj, taskInfoOffset);
1424 Store(VariableType::NATIVE_POINTER(), glue, glue,
1425 IntPtr(JSThread::GlueData::GetTaskInfoOffset(env->Is32Bit())), taskInfo);
1426 Store(VariableType::NATIVE_POINTER(), glue, obj,
1427 IntPtr(JSGeneratorObject::TASK_INFO_OFFSET), IntPtr(0));
1428 Jump(&dispatch);
1429 }
1430 Bind(&dispatch);
1431 DISPATCH_WITH_ACC(RESUMEGENERATOR);
1432 }
1433
DECLARE_ASM_HANDLER(HandleDeprecatedResumegeneratorPrefV8)1434 DECLARE_ASM_HANDLER(HandleDeprecatedResumegeneratorPrefV8)
1435 {
1436 auto env = GetEnvironment();
1437 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1438 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1439 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
1440 GateRef frame = GetFrame(sp);
1441 GateRef curFunc = GetFunctionFromFrame(glue, frame);
1442 CallNGCRuntime(glue, RTSTUB_ID(StartCallTimer), { glue, curFunc, False() });
1443 #endif
1444
1445 Label isAsyncGeneratorObj(env);
1446 Label notAsyncGeneratorObj(env);
1447 Label dispatch(env);
1448 BRANCH(TaggedIsAsyncGeneratorObject(glue, obj), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
1449 Bind(&isAsyncGeneratorObj);
1450 {
1451 GateRef resumeResultOffset = IntPtr(JSAsyncGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
1452 varAcc = Load(VariableType::JS_ANY(), glue, obj, resumeResultOffset);
1453 Jump(&dispatch);
1454 }
1455 Bind(¬AsyncGeneratorObj);
1456 {
1457 GateRef resumeResultOffset = IntPtr(JSGeneratorObject::GENERATOR_RESUME_RESULT_OFFSET);
1458 varAcc = Load(VariableType::JS_ANY(), glue, obj, resumeResultOffset);
1459 Jump(&dispatch);
1460 }
1461 Bind(&dispatch);
1462 DISPATCH_WITH_ACC(DEPRECATED_RESUMEGENERATOR_PREF_V8);
1463 }
1464
DECLARE_ASM_HANDLER(HandleGetresumemode)1465 DECLARE_ASM_HANDLER(HandleGetresumemode)
1466 {
1467 auto env = GetEnvironment();
1468 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1469 GateRef obj = *varAcc;
1470
1471 Label isAsyncGeneratorObj(env);
1472 Label notAsyncGeneratorObj(env);
1473 Label dispatch(env);
1474 BRANCH(TaggedIsAsyncGeneratorObject(glue, obj), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
1475 Bind(&isAsyncGeneratorObj);
1476 {
1477 varAcc = IntToTaggedPtr(GetResumeModeFromAsyncGeneratorObject(obj));
1478 Jump(&dispatch);
1479 }
1480 Bind(¬AsyncGeneratorObj);
1481 {
1482 varAcc = IntToTaggedPtr(GetResumeModeFromGeneratorObject(obj));
1483 Jump(&dispatch);
1484 }
1485 Bind(&dispatch);
1486 DISPATCH_WITH_ACC(GETRESUMEMODE);
1487 }
1488
DECLARE_ASM_HANDLER(HandleDeprecatedGetresumemodePrefV8)1489 DECLARE_ASM_HANDLER(HandleDeprecatedGetresumemodePrefV8)
1490 {
1491 auto env = GetEnvironment();
1492 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1493 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1494
1495 Label isAsyncGeneratorObj(env);
1496 Label notAsyncGeneratorObj(env);
1497 Label dispatch(env);
1498 BRANCH(TaggedIsAsyncGeneratorObject(glue, obj), &isAsyncGeneratorObj, ¬AsyncGeneratorObj);
1499 Bind(&isAsyncGeneratorObj);
1500 {
1501 varAcc = IntToTaggedPtr(GetResumeModeFromAsyncGeneratorObject(obj));
1502 Jump(&dispatch);
1503 }
1504 Bind(¬AsyncGeneratorObj);
1505 {
1506 varAcc = IntToTaggedPtr(GetResumeModeFromGeneratorObject(obj));
1507 Jump(&dispatch);
1508 }
1509 Bind(&dispatch);
1510 DISPATCH_WITH_ACC(DEPRECATED_GETRESUMEMODE_PREF_V8);
1511 }
1512
DECLARE_ASM_HANDLER(HandleCreategeneratorobjV8)1513 DECLARE_ASM_HANDLER(HandleCreategeneratorobjV8)
1514 {
1515 GateRef v0 = ReadInst8_0(pc);
1516 GateRef genFunc = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1517 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1518 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateGeneratorObj), { genFunc });
1519 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CREATEGENERATOROBJ_V8));
1520 }
1521
DECLARE_ASM_HANDLER(HandleThrowConstassignmentPrefV8)1522 DECLARE_ASM_HANDLER(HandleThrowConstassignmentPrefV8)
1523 {
1524 GateRef v0 = ReadInst8_1(pc);
1525 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1526 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1527 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowConstAssignment), { value });
1528 DISPATCH_LAST();
1529 }
1530
DECLARE_ASM_HANDLER(HandleGettemplateobjectImm8)1531 DECLARE_ASM_HANDLER(HandleGettemplateobjectImm8)
1532 {
1533 GateRef literal = acc;
1534 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1535 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetTemplateObject), { literal });
1536 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GETTEMPLATEOBJECT_IMM8));
1537 }
1538
DECLARE_ASM_HANDLER(HandleGettemplateobjectImm16)1539 DECLARE_ASM_HANDLER(HandleGettemplateobjectImm16)
1540 {
1541 GateRef literal = acc;
1542 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1543 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetTemplateObject), { literal });
1544 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GETTEMPLATEOBJECT_IMM16));
1545 }
1546
DECLARE_ASM_HANDLER(HandleDeprecatedGettemplateobjectPrefV8)1547 DECLARE_ASM_HANDLER(HandleDeprecatedGettemplateobjectPrefV8)
1548 {
1549 GateRef literal = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1550 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1551 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetTemplateObject), { literal });
1552 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_GETTEMPLATEOBJECT_PREF_V8));
1553 }
1554
DECLARE_ASM_HANDLER(HandleGetnextpropnameV8)1555 DECLARE_ASM_HANDLER(HandleGetnextpropnameV8)
1556 {
1557 GateRef v0 = ReadInst8_0(pc);
1558 GateRef iter = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1559 GateRef result = NextInternal(glue, iter);
1560 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(GETNEXTPROPNAME_V8));
1561 }
1562
DECLARE_ASM_HANDLER(HandleThrowIfnotobjectPrefV8)1563 DECLARE_ASM_HANDLER(HandleThrowIfnotobjectPrefV8)
1564 {
1565 auto env = GetEnvironment();
1566
1567 GateRef v0 = ReadInst8_1(pc);
1568 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1569 Label isEcmaObject(env);
1570 Label notEcmaObject(env);
1571 Label isHeapObject(env);
1572 BRANCH(TaggedIsHeapObject(value), &isHeapObject, ¬EcmaObject);
1573 Bind(&isHeapObject);
1574 BRANCH(TaggedObjectIsEcmaObject(glue, value), &isEcmaObject, ¬EcmaObject);
1575 Bind(&isEcmaObject);
1576 {
1577 DISPATCH(THROW_IFNOTOBJECT_PREF_V8);
1578 }
1579 Bind(¬EcmaObject);
1580 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1581 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowIfNotObject), {});
1582 DISPATCH_LAST();
1583 }
1584
DECLARE_ASM_HANDLER(HandleCloseiteratorImm8V8)1585 DECLARE_ASM_HANDLER(HandleCloseiteratorImm8V8)
1586 {
1587 GateRef v0 = ReadInst8_1(pc);
1588 GateRef iter = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1589 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1590 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CloseIterator), { iter });
1591 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CLOSEITERATOR_IMM8_V8));
1592 }
1593
DECLARE_ASM_HANDLER(HandleCloseiteratorImm16V8)1594 DECLARE_ASM_HANDLER(HandleCloseiteratorImm16V8)
1595 {
1596 GateRef v0 = ReadInst8_2(pc);
1597 GateRef iter = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1598 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1599 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CloseIterator), { iter });
1600 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CLOSEITERATOR_IMM16_V8));
1601 }
1602
DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8)1603 DECLARE_ASM_HANDLER(HandleSupercallspreadImm8V8)
1604 {
1605 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1606 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
1607 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
1608 auto env = GetEnvironment();
1609 GateRef v0 = ReadInst8_1(pc);
1610 GateRef array = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1611 GateRef thisFunc = acc;
1612 GateRef newTarget = GetNewTarget(glue, sp);
1613 GateRef superCtor = GetPrototype(glue, thisFunc);
1614 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1615 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1616
1617 Label dispatch(env);
1618 Label normalPath(env);
1619 Label slowPath(env);
1620 Label ctorIsJSFunction(env);
1621 Label ctorIsBase(env);
1622 Label ctorNotBase(env);
1623 Label ctorIsHeapObject(env);
1624 Label ctorIsConstructor(env);
1625 Label threadCheck(env);
1626 Label isException(env);
1627 Label noException(env);
1628
1629 BRANCH(TaggedIsHeapObject(superCtor), &ctorIsHeapObject, &slowPath);
1630 Bind(&ctorIsHeapObject);
1631 BRANCH(IsJSFunction(glue, superCtor), &ctorIsJSFunction, &slowPath);
1632 Bind(&ctorIsJSFunction);
1633 BRANCH(IsConstructor(glue, superCtor), &ctorIsConstructor, &slowPath);
1634 Bind(&ctorIsConstructor);
1635 BRANCH(TaggedIsUndefined(newTarget), &slowPath, &normalPath);
1636 Bind(&normalPath);
1637 {
1638 BRANCH(IsBase(glue, superCtor), &ctorIsBase, &ctorNotBase);
1639 Bind(&ctorIsBase);
1640 NewObjectStubBuilder objBuilder(this);
1641 thisObj = objBuilder.FastSuperAllocateThis(glue, superCtor, newTarget);
1642 BRANCH(HasPendingException(glue), &isException, &ctorNotBase);
1643 Bind(&ctorNotBase);
1644 GateRef argvLen = LoadPrimitive(VariableType::INT32(), array, IntPtr(JSArray::LENGTH_OFFSET));
1645 SetCurrentGlobalEnv(globalEnv);
1646 GateRef srcElements = GetCallSpreadArgs(glue, array, callback);
1647 BRANCH(TaggedIsException(srcElements), &isException, &noException);
1648 Bind(&noException);
1649 GateRef jumpSize = IntPtr(InterpreterAssembly::GetCallSize(EcmaOpcode::SUPERCALLSPREAD_IMM8_V8));
1650 METHOD_ENTRY_ENV_DEFINED(superCtor);
1651 GateRef elementsPtr = PtrAdd(srcElements, IntPtr(TaggedArray::DATA_OFFSET));
1652 JSCallArgs callArgs(JSCallMode::SUPER_CALL_SPREAD_WITH_ARGV);
1653 callArgs.superCallArgs = { thisFunc, array, ZExtInt32ToPtr(argvLen), elementsPtr, *thisObj, newTarget };
1654 CallStubBuilder callBuilder(this, glue, superCtor, argvLen, jumpSize, nullptr, hotnessCounter, callArgs,
1655 callback);
1656 res = callBuilder.JSCallDispatch();
1657 Jump(&threadCheck);
1658 }
1659 Bind(&slowPath);
1660 {
1661 res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(SuperCallSpread), { thisFunc, array });
1662 Jump(&threadCheck);
1663 }
1664 Bind(&threadCheck);
1665 {
1666 GateRef resVal = *res;
1667 GateRef isError = LogicAndBuilder(env).And(TaggedIsException(resVal)).And(HasPendingException(glue)).Done();
1668 BRANCH(isError, &isException, &dispatch);
1669 }
1670 Bind(&isException);
1671 {
1672 DISPATCH_LAST();
1673 }
1674 Bind(&dispatch);
1675 {
1676 varAcc = *res;
1677 DISPATCH_WITH_ACC(SUPERCALLSPREAD_IMM8_V8);
1678 }
1679 }
1680
DECLARE_ASM_HANDLER(HandleDelobjpropV8)1681 DECLARE_ASM_HANDLER(HandleDelobjpropV8)
1682 {
1683 GateRef v0 = ReadInst8_0(pc);
1684 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1685 GateRef prop = acc;
1686 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1687 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1688 SetCurrentGlobalEnv(globalEnv);
1689 GateRef result = DeletePropertyOrThrow(glue, obj, prop);
1690 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DELOBJPROP_V8));
1691 }
1692
DECLARE_ASM_HANDLER(HandleDeprecatedDelobjpropPrefV8V8)1693 DECLARE_ASM_HANDLER(HandleDeprecatedDelobjpropPrefV8V8)
1694 {
1695 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1696 GateRef prop = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
1697 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1698 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DelObjProp), { obj, prop });
1699 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_DELOBJPROP_PREF_V8_V8));
1700 }
1701
DECLARE_ASM_HANDLER(HandleNewobjapplyImm8V8)1702 DECLARE_ASM_HANDLER(HandleNewobjapplyImm8V8)
1703 {
1704 GateRef v0 = ReadInst8_1(pc);
1705 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1706 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1707 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array
1708 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NEWOBJAPPLY_IMM8_V8));
1709 }
1710
DECLARE_ASM_HANDLER(HandleNewobjapplyImm16V8)1711 DECLARE_ASM_HANDLER(HandleNewobjapplyImm16V8)
1712 {
1713 GateRef v0 = ReadInst8_2(pc);
1714 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1715 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1716 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjApply), { func, acc }); // acc is array
1717 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NEWOBJAPPLY_IMM16_V8));
1718 }
1719
DECLARE_ASM_HANDLER(HandleCreateiterresultobjV8V8)1720 DECLARE_ASM_HANDLER(HandleCreateiterresultobjV8V8)
1721 {
1722 GateRef v0 = ReadInst8_0(pc);
1723 GateRef v1 = ReadInst8_1(pc);
1724 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1725 GateRef flag = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1726 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1727 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateIterResultObj), { value, flag });
1728 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(CREATEITERRESULTOBJ_V8_V8));
1729 }
1730
DECLARE_ASM_HANDLER(HandleAsyncfunctionawaituncaughtV8)1731 DECLARE_ASM_HANDLER(HandleAsyncfunctionawaituncaughtV8)
1732 {
1733 GateRef v0 = ReadInst8_0(pc);
1734 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1735 GateRef value = acc;
1736 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1737 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionAwaitUncaught),
1738 { asyncFuncObj, value });
1739 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(ASYNCFUNCTIONAWAITUNCAUGHT_V8));
1740 }
1741
DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionawaituncaughtPrefV8V8)1742 DECLARE_ASM_HANDLER(HandleDeprecatedAsyncfunctionawaituncaughtPrefV8V8)
1743 {
1744 GateRef asyncFuncObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1745 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
1746 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1747 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncFunctionAwaitUncaught),
1748 { asyncFuncObj, value });
1749 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_ASYNCFUNCTIONAWAITUNCAUGHT_PREF_V8_V8));
1750 }
1751
DECLARE_ASM_HANDLER(HandleThrowUndefinedifholePrefV8V8)1752 DECLARE_ASM_HANDLER(HandleThrowUndefinedifholePrefV8V8)
1753 {
1754 auto env = GetEnvironment();
1755
1756 GateRef v0 = ReadInst8_1(pc);
1757 GateRef v1 = ReadInst8_2(pc);
1758 GateRef hole = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1759 Label isHole(env);
1760 Label notHole(env);
1761 BRANCH(TaggedIsHole(hole), &isHole, ¬Hole);
1762 Bind(¬Hole);
1763 {
1764 DISPATCH(THROW_UNDEFINEDIFHOLE_PREF_V8_V8);
1765 }
1766 Bind(&isHole);
1767 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1768 // assert obj.IsString()
1769 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1770 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowUndefinedIfHole), { obj });
1771 DISPATCH_LAST();
1772 }
1773
DECLARE_ASM_HANDLER(HandleThrowUndefinedifholewithnamePrefId16)1774 DECLARE_ASM_HANDLER(HandleThrowUndefinedifholewithnamePrefId16)
1775 {
1776 auto env = GetEnvironment();
1777
1778 GateRef hole = acc;
1779 Label isHole(env);
1780 Label notHole(env);
1781 BRANCH(TaggedIsHole(hole), &isHole, ¬Hole);
1782 Bind(¬Hole);
1783 {
1784 DISPATCH(THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16);
1785 }
1786 Bind(&isHole);
1787 GateRef stringId = ReadInst16_1(pc);
1788 GateRef str = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
1789 // assert obj.IsString()
1790 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1791 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowUndefinedIfHole), { str });
1792 DISPATCH_LAST();
1793 }
1794
DECLARE_ASM_HANDLER(HandleCopydatapropertiesV8)1795 DECLARE_ASM_HANDLER(HandleCopydatapropertiesV8)
1796 {
1797 GateRef v0 = ReadInst8_0(pc);
1798 GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1799 GateRef src = acc;
1800 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1801 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CopyDataProperties), { dst, src });
1802 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(COPYDATAPROPERTIES_V8));
1803 }
1804
DECLARE_ASM_HANDLER(HandleDeprecatedCopydatapropertiesPrefV8V8)1805 DECLARE_ASM_HANDLER(HandleDeprecatedCopydatapropertiesPrefV8V8)
1806 {
1807 GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1808 GateRef src = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
1809 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1810 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CopyDataProperties), { dst, src });
1811 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_COPYDATAPROPERTIES_PREF_V8_V8));
1812 }
1813
DECLARE_ASM_HANDLER(HandleStarrayspreadV8V8)1814 DECLARE_ASM_HANDLER(HandleStarrayspreadV8V8)
1815 {
1816 GateRef v0 = ReadInst8_0(pc);
1817 GateRef v1 = ReadInst8_1(pc);
1818 GateRef dst = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1819 GateRef index = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1820 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1821 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StArraySpread),
1822 { dst, index, acc }); // acc is res
1823 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(STARRAYSPREAD_V8_V8));
1824 }
1825
DECLARE_ASM_HANDLER(HandleSetobjectwithprotoImm8V8)1826 DECLARE_ASM_HANDLER(HandleSetobjectwithprotoImm8V8)
1827 {
1828 auto env = GetEnvironment();
1829 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1830
1831 GateRef v0 = ReadInst8_1(pc);
1832 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1833 GateRef obj = *varAcc;
1834 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1835 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetObjectWithProto), { proto, obj });
1836 Label notException(env);
1837 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
1838 Bind(¬Exception);
1839 DISPATCH_WITH_ACC(SETOBJECTWITHPROTO_IMM8_V8);
1840 }
1841
DECLARE_ASM_HANDLER(HandleSetobjectwithprotoImm16V8)1842 DECLARE_ASM_HANDLER(HandleSetobjectwithprotoImm16V8)
1843 {
1844 auto env = GetEnvironment();
1845 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1846
1847 GateRef v0 = ReadInst8_2(pc);
1848 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1849 GateRef obj = *varAcc;
1850 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1851 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetObjectWithProto), { proto, obj });
1852 Label notException(env);
1853 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
1854 Bind(¬Exception);
1855 DISPATCH_WITH_ACC(SETOBJECTWITHPROTO_IMM16_V8);
1856 }
1857
DECLARE_ASM_HANDLER(HandleDeprecatedSetobjectwithprotoPrefV8V8)1858 DECLARE_ASM_HANDLER(HandleDeprecatedSetobjectwithprotoPrefV8V8)
1859 {
1860 auto env = GetEnvironment();
1861 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
1862
1863 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
1864 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
1865 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1866 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetObjectWithProto), { proto, obj });
1867 Label notException(env);
1868 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
1869 Bind(¬Exception);
1870 DISPATCH_WITH_ACC(DEPRECATED_SETOBJECTWITHPROTO_PREF_V8_V8);
1871 }
1872
DECLARE_ASM_HANDLER(HandleStobjbyvalueImm8V8V8)1873 DECLARE_ASM_HANDLER(HandleStobjbyvalueImm8V8V8)
1874 {
1875 GateRef v0 = ReadInst8_1(pc);
1876 GateRef v1 = ReadInst8_2(pc);
1877 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1878 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1879 GateRef value = acc;
1880 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
1881 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1882 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1883
1884 AccessObjectStubBuilder builder(this, globalEnv);
1885 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, value, profileTypeInfo, slotId, callback);
1886 CHECK_EXCEPTION(result, INT_PTR(STOBJBYVALUE_IMM8_V8_V8));
1887 }
1888
DECLARE_ASM_HANDLER(HandleStobjbyvalueImm16V8V8)1889 DECLARE_ASM_HANDLER(HandleStobjbyvalueImm16V8V8)
1890 {
1891 GateRef v0 = ReadInst8_2(pc);
1892 GateRef v1 = ReadInst8_3(pc);
1893 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1894 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1895 GateRef value = acc;
1896 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
1897 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1898 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1899
1900 AccessObjectStubBuilder builder(this, globalEnv);
1901 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, value, profileTypeInfo, slotId, callback);
1902 CHECK_EXCEPTION(result, INT_PTR(STOBJBYVALUE_IMM16_V8_V8));
1903 }
1904
DECLARE_ASM_HANDLER(HandleStownbyvalueImm8V8V8)1905 DECLARE_ASM_HANDLER(HandleStownbyvalueImm8V8V8)
1906 {
1907 auto env = GetEnvironment();
1908
1909 GateRef v0 = ReadInst8_1(pc);
1910 GateRef v1 = ReadInst8_2(pc);
1911 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1912 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1913 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1914 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1915 Label isHeapObject(env);
1916 Label slowPath(env);
1917 BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
1918 Bind(&isHeapObject);
1919 Label notClassConstructor(env);
1920 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
1921 Bind(¬ClassConstructor);
1922 Label notClassPrototype(env);
1923 BRANCH(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
1924 Bind(¬ClassPrototype);
1925 {
1926 // fast path
1927 SetCurrentGlobalEnv(globalEnv);
1928 GateRef result = SetPropertyByValue(glue, receiver, propKey, acc, true, callback); // acc is value
1929 Label notHole(env);
1930 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
1931 Bind(¬Hole);
1932 CHECK_EXCEPTION(result, INT_PTR(STOWNBYVALUE_IMM8_V8_V8));
1933 }
1934 Bind(&slowPath);
1935 {
1936 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc });
1937 CHECK_EXCEPTION(result, INT_PTR(STOWNBYVALUE_IMM8_V8_V8));
1938 }
1939 }
1940
DECLARE_ASM_HANDLER(HandleStownbyvalueImm16V8V8)1941 DECLARE_ASM_HANDLER(HandleStownbyvalueImm16V8V8)
1942 {
1943 auto env = GetEnvironment();
1944
1945 GateRef v0 = ReadInst8_2(pc);
1946 GateRef v1 = ReadInst8_3(pc);
1947 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1948 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1949 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1950 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
1951 Label isHeapObject(env);
1952 Label slowPath(env);
1953 BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
1954 Bind(&isHeapObject);
1955 Label notClassConstructor(env);
1956 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
1957 Bind(¬ClassConstructor);
1958 Label notClassPrototype(env);
1959 BRANCH(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
1960 Bind(¬ClassPrototype);
1961 {
1962 // fast path
1963 SetCurrentGlobalEnv(globalEnv);
1964 GateRef result = SetPropertyByValue(glue, receiver, propKey, acc, true, callback); // acc is value
1965 Label notHole(env);
1966 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
1967 Bind(¬Hole);
1968 CHECK_EXCEPTION(result, INT_PTR(STOWNBYVALUE_IMM16_V8_V8));
1969 }
1970 Bind(&slowPath);
1971 {
1972 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValue), { receiver, propKey, acc });
1973 CHECK_EXCEPTION(result, INT_PTR(STOWNBYVALUE_IMM16_V8_V8));
1974 }
1975 }
1976
DECLARE_ASM_HANDLER(HandleStsuperbyvalueImm8V8V8)1977 DECLARE_ASM_HANDLER(HandleStsuperbyvalueImm8V8V8)
1978 {
1979 GateRef v0 = ReadInst8_1(pc);
1980 GateRef v1 = ReadInst8_2(pc);
1981 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1982 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1983 // acc is value, sp for thisFunc
1984 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1985 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
1986 CHECK_EXCEPTION(result, INT_PTR(STSUPERBYVALUE_IMM8_V8_V8));
1987 }
1988
DECLARE_ASM_HANDLER(HandleStsuperbyvalueImm16V8V8)1989 DECLARE_ASM_HANDLER(HandleStsuperbyvalueImm16V8V8)
1990 {
1991 GateRef v0 = ReadInst8_2(pc);
1992 GateRef v1 = ReadInst8_3(pc);
1993 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
1994 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
1995 // acc is value, sp for thisFunc
1996 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
1997 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
1998 CHECK_EXCEPTION(result, INT_PTR(STSUPERBYVALUE_IMM16_V8_V8));
1999 }
2000
DECLARE_ASM_HANDLER(HandleStsuperbynameImm8Id16V8)2001 DECLARE_ASM_HANDLER(HandleStsuperbynameImm8Id16V8)
2002 {
2003 GateRef stringId = ReadInst16_1(pc);
2004 GateRef v0 = ReadInst8_3(pc);
2005 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2006 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2007 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2008 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
2009 CHECK_EXCEPTION(result, INT_PTR(STSUPERBYNAME_IMM8_ID16_V8));
2010 }
2011
DECLARE_ASM_HANDLER(HandleStsuperbynameImm16Id16V8)2012 DECLARE_ASM_HANDLER(HandleStsuperbynameImm16Id16V8)
2013 {
2014 GateRef stringId = ReadInst16_2(pc);
2015 GateRef v0 = ReadInst8_4(pc);
2016 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2017 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2018 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2019 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StSuperByValue), { receiver, propKey, acc });
2020 CHECK_EXCEPTION(result, INT_PTR(STSUPERBYNAME_IMM16_ID16_V8));
2021 }
2022
DECLARE_ASM_HANDLER(HandleStobjbyindexImm8V8Imm16)2023 DECLARE_ASM_HANDLER(HandleStobjbyindexImm8V8Imm16)
2024 {
2025 auto env = GetEnvironment();
2026
2027 GateRef v0 = ReadInst8_1(pc);
2028 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2029 GateRef index = ZExtInt16ToInt32(ReadInst16_2(pc));
2030 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2031 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2032 Label fastPath(env);
2033 Label slowPath(env);
2034 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
2035 Bind(&fastPath);
2036 {
2037 SetCurrentGlobalEnv(globalEnv);
2038 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, false);
2039 Label notHole(env);
2040 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
2041 Bind(¬Hole);
2042 CHECK_EXCEPTION(result, INT_PTR(STOBJBYINDEX_IMM8_V8_IMM16));
2043 }
2044 Bind(&slowPath);
2045 {
2046 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StObjByIndex),
2047 { receiver, IntToTaggedInt(index), acc });
2048 CHECK_EXCEPTION(result, INT_PTR(STOBJBYINDEX_IMM8_V8_IMM16));
2049 }
2050 }
2051
DECLARE_ASM_HANDLER(HandleStobjbyindexImm16V8Imm16)2052 DECLARE_ASM_HANDLER(HandleStobjbyindexImm16V8Imm16)
2053 {
2054 auto env = GetEnvironment();
2055
2056 GateRef v0 = ReadInst8_2(pc);
2057 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2058 GateRef index = ZExtInt16ToInt32(ReadInst16_3(pc));
2059 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2060 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2061 Label fastPath(env);
2062 Label slowPath(env);
2063 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
2064 Bind(&fastPath);
2065 {
2066 SetCurrentGlobalEnv(globalEnv);
2067 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, false);
2068 Label notHole(env);
2069 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
2070 Bind(¬Hole);
2071 CHECK_EXCEPTION(result, INT_PTR(STOBJBYINDEX_IMM16_V8_IMM16));
2072 }
2073 Bind(&slowPath);
2074 {
2075 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StObjByIndex),
2076 { receiver, IntToTaggedInt(index), acc });
2077 CHECK_EXCEPTION(result, INT_PTR(STOBJBYINDEX_IMM16_V8_IMM16));
2078 }
2079 }
2080
DECLARE_ASM_HANDLER(HandleWideStobjbyindexPrefV8Imm32)2081 DECLARE_ASM_HANDLER(HandleWideStobjbyindexPrefV8Imm32)
2082 {
2083 auto env = GetEnvironment();
2084
2085 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
2086 GateRef index = ReadInst32_2(pc);
2087 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2088 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2089 Label fastPath(env);
2090 Label slowPath(env);
2091 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
2092 Bind(&fastPath);
2093 {
2094 SetCurrentGlobalEnv(globalEnv);
2095 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, false);
2096 Label notHole(env);
2097 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
2098 Bind(¬Hole);
2099 CHECK_EXCEPTION(result, INT_PTR(WIDE_STOBJBYINDEX_PREF_V8_IMM32));
2100 }
2101 Bind(&slowPath);
2102 {
2103 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StObjByIndex),
2104 { receiver, IntToTaggedInt(index), acc });
2105 CHECK_EXCEPTION(result, INT_PTR(WIDE_STOBJBYINDEX_PREF_V8_IMM32));
2106 }
2107 }
2108
DECLARE_ASM_HANDLER(HandleStownbyindexImm8V8Imm16)2109 DECLARE_ASM_HANDLER(HandleStownbyindexImm8V8Imm16)
2110 {
2111 GateRef v0 = ReadInst8_1(pc);
2112 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2113 GateRef index = ZExtInt16ToInt32(ReadInst16_2(pc));
2114 GateRef value = acc;
2115 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
2116 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2117 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2118
2119 AccessObjectStubBuilder builder(this, globalEnv);
2120 GateRef result = builder.StoreOwnByIndex(glue, receiver, index, value, profileTypeInfo, slotId, callback);
2121 CHECK_EXCEPTION(result, INT_PTR(STOWNBYINDEX_IMM8_V8_IMM16));
2122 }
2123
DECLARE_ASM_HANDLER(HandleStownbyindexImm16V8Imm16)2124 DECLARE_ASM_HANDLER(HandleStownbyindexImm16V8Imm16)
2125 {
2126 GateRef v0 = ReadInst8_2(pc);
2127 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2128 GateRef index = ZExtInt16ToInt32(ReadInst16_3(pc));
2129 GateRef value = acc;
2130 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
2131 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2132 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2133
2134 AccessObjectStubBuilder builder(this, globalEnv);
2135 GateRef result = builder.StoreOwnByIndex(glue, receiver, index, value, profileTypeInfo, slotId, callback);
2136 CHECK_EXCEPTION(result, INT_PTR(STOWNBYINDEX_IMM16_V8_IMM16));
2137 }
2138
DECLARE_ASM_HANDLER(HandleWideStownbyindexPrefV8Imm32)2139 DECLARE_ASM_HANDLER(HandleWideStownbyindexPrefV8Imm32)
2140 {
2141 auto env = GetEnvironment();
2142
2143 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
2144 GateRef index = ReadInst32_2(pc);
2145 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2146 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2147 Label isHeapObject(env);
2148 Label slowPath(env);
2149 BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
2150 Bind(&isHeapObject);
2151 Label notClassConstructor(env);
2152 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2153 Bind(¬ClassConstructor);
2154 Label notClassPrototype(env);
2155 BRANCH(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
2156 Bind(¬ClassPrototype);
2157 {
2158 // fast path
2159 SetCurrentGlobalEnv(globalEnv);
2160 GateRef result = SetPropertyByIndex(glue, receiver, index, acc, true); // acc is value
2161 Label notHole(env);
2162 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
2163 Bind(¬Hole);
2164 CHECK_EXCEPTION(result, INT_PTR(WIDE_STOWNBYINDEX_PREF_V8_IMM32));
2165 }
2166 Bind(&slowPath);
2167 {
2168 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByIndex),
2169 { receiver, IntToTaggedInt(index), acc });
2170 CHECK_EXCEPTION(result, INT_PTR(WIDE_STOWNBYINDEX_PREF_V8_IMM32));
2171 }
2172 }
2173
DECLARE_ASM_HANDLER(HandleNegImm8)2174 DECLARE_ASM_HANDLER(HandleNegImm8)
2175 {
2176 OperationsStubBuilder builder(this);
2177 GateRef result = builder.Neg(glue, acc, callback);
2178 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NEG_IMM8));
2179 }
2180
DECLARE_ASM_HANDLER(HandleDeprecatedNegPrefV8)2181 DECLARE_ASM_HANDLER(HandleDeprecatedNegPrefV8)
2182 {
2183 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
2184 OperationsStubBuilder builder(this);
2185 GateRef result = builder.Neg(glue, value);
2186 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_NEG_PREF_V8));
2187 }
2188
DECLARE_ASM_HANDLER(HandleNotImm8)2189 DECLARE_ASM_HANDLER(HandleNotImm8)
2190 {
2191 OperationsStubBuilder builder(this);
2192 GateRef result = builder.Not(glue, acc, callback);
2193 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(NOT_IMM8));
2194 }
2195
DECLARE_ASM_HANDLER(HandleDeprecatedNotPrefV8)2196 DECLARE_ASM_HANDLER(HandleDeprecatedNotPrefV8)
2197 {
2198 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
2199 OperationsStubBuilder builder(this);
2200 GateRef result = builder.Not(glue, value);
2201 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_NOT_PREF_V8));
2202 }
2203
DECLARE_ASM_HANDLER(HandleAnd2Imm8V8)2204 DECLARE_ASM_HANDLER(HandleAnd2Imm8V8)
2205 {
2206 GateRef v0 = ReadInst8_1(pc);
2207 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2208 OperationsStubBuilder builder(this);
2209 GateRef result = builder.And(glue, left, acc, callback);
2210 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(AND2_IMM8_V8));
2211 }
2212
DECLARE_ASM_HANDLER(HandleOr2Imm8V8)2213 DECLARE_ASM_HANDLER(HandleOr2Imm8V8)
2214 {
2215 GateRef v0 = ReadInst8_1(pc);
2216 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2217 OperationsStubBuilder builder(this);
2218 GateRef result = builder.Or(glue, left, acc, callback);
2219 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(OR2_IMM8_V8));
2220 }
2221
DECLARE_ASM_HANDLER(HandleXor2Imm8V8)2222 DECLARE_ASM_HANDLER(HandleXor2Imm8V8)
2223 {
2224 GateRef v0 = ReadInst8_1(pc);
2225 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2226 OperationsStubBuilder builder(this);
2227 GateRef result = builder.Xor(glue, left, acc, callback);
2228 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(XOR2_IMM8_V8));
2229 }
2230
DECLARE_ASM_HANDLER(HandleAshr2Imm8V8)2231 DECLARE_ASM_HANDLER(HandleAshr2Imm8V8)
2232 {
2233 GateRef v0 = ReadInst8_1(pc);
2234 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2235 OperationsStubBuilder builder(this);
2236 GateRef result = builder.Ashr(glue, left, acc, callback);
2237 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(ASHR2_IMM8_V8));
2238 }
2239
DECLARE_ASM_HANDLER(HandleShr2Imm8V8)2240 DECLARE_ASM_HANDLER(HandleShr2Imm8V8)
2241 {
2242 GateRef v0 = ReadInst8_1(pc);
2243 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2244 OperationsStubBuilder builder(this);
2245 GateRef result = builder.Shr(glue, left, acc, callback);
2246 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(SHR2_IMM8_V8));
2247 }
2248
DECLARE_ASM_HANDLER(HandleShl2Imm8V8)2249 DECLARE_ASM_HANDLER(HandleShl2Imm8V8)
2250 {
2251 GateRef v0 = ReadInst8_1(pc);
2252 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
2253 OperationsStubBuilder builder(this);
2254 GateRef result = builder.Shl(glue, left, acc, callback);
2255 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(SHL2_IMM8_V8));
2256 }
2257
DECLARE_ASM_HANDLER(HandleStobjbynameImm8Id16V8)2258 DECLARE_ASM_HANDLER(HandleStobjbynameImm8Id16V8)
2259 {
2260 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
2261 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
2262 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2263 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2264
2265 AccessObjectStubBuilder builder(this, globalEnv);
2266 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16);
2267 GateRef result = builder.StoreObjByName(glue, receiver, 0, info, acc, profileTypeInfo, slotId, callback);
2268 CHECK_EXCEPTION(result, INT_PTR(STOBJBYNAME_IMM8_ID16_V8));
2269 }
2270
DECLARE_ASM_HANDLER(HandleStobjbynameImm16Id16V8)2271 DECLARE_ASM_HANDLER(HandleStobjbynameImm16Id16V8)
2272 {
2273 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_4(pc)));
2274 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
2275 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2276 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2277
2278 AccessObjectStubBuilder builder(this, globalEnv);
2279 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
2280 GateRef result = builder.StoreObjByName(glue, receiver, 0, info, acc, profileTypeInfo, slotId, callback);
2281 CHECK_EXCEPTION(result, INT_PTR(STOBJBYNAME_IMM16_ID16_V8));
2282 }
2283
DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm16V8V8)2284 DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm16V8V8)
2285 {
2286 auto env = GetEnvironment();
2287 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
2288 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
2289 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2290 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2291 Label isHeapObject(env);
2292 Label slowPath(env);
2293 Label notClassConstructor(env);
2294 Label notClassPrototype(env);
2295 Label notHole(env);
2296 Label notException(env);
2297 Label notException1(env);
2298 BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
2299 Bind(&isHeapObject);
2300 {
2301 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2302 Bind(¬ClassConstructor);
2303 {
2304 BRANCH(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
2305 Bind(¬ClassPrototype);
2306 {
2307 SetCurrentGlobalEnv(globalEnv);
2308 GateRef res = SetPropertyByValue(glue, receiver, propKey, acc, true, callback, true);
2309 BRANCH(TaggedIsHole(res), &slowPath, ¬Hole);
2310 Bind(¬Hole);
2311 {
2312 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
2313 Bind(¬Exception);
2314 CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
2315 DISPATCH(STOWNBYVALUEWITHNAMESET_IMM16_V8_V8);
2316 }
2317 }
2318 }
2319 }
2320 Bind(&slowPath);
2321 {
2322 GateRef res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValueWithNameSet),
2323 { receiver, propKey, acc });
2324 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
2325 Bind(¬Exception1);
2326 DISPATCH(STOWNBYVALUEWITHNAMESET_IMM16_V8_V8);
2327 }
2328 }
2329
DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm8V8V8)2330 DECLARE_ASM_HANDLER(HandleStownbyvaluewithnamesetImm8V8V8)
2331 {
2332 auto env = GetEnvironment();
2333 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
2334 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
2335 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2336 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2337 Label isHeapObject(env);
2338 Label slowPath(env);
2339 Label notClassConstructor(env);
2340 Label notClassPrototype(env);
2341 Label notHole(env);
2342 Label notException(env);
2343 Label notException1(env);
2344 BRANCH(TaggedIsHeapObject(receiver), &isHeapObject, &slowPath);
2345 Bind(&isHeapObject);
2346 {
2347 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2348 Bind(¬ClassConstructor);
2349 {
2350 BRANCH(IsClassPrototype(glue, receiver), &slowPath, ¬ClassPrototype);
2351 Bind(¬ClassPrototype);
2352 {
2353 SetCurrentGlobalEnv(globalEnv);
2354 GateRef res = SetPropertyByValue(glue, receiver, propKey, acc, true, callback, true);
2355 BRANCH(TaggedIsHole(res), &slowPath, ¬Hole);
2356 Bind(¬Hole);
2357 {
2358 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
2359 Bind(¬Exception);
2360 CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
2361 DISPATCH(STOWNBYVALUEWITHNAMESET_IMM8_V8_V8);
2362 }
2363 }
2364 }
2365 }
2366 Bind(&slowPath);
2367 {
2368 GateRef res = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(StOwnByValueWithNameSet),
2369 { receiver, propKey, acc });
2370 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
2371 Bind(¬Exception1);
2372 DISPATCH(STOWNBYVALUEWITHNAMESET_IMM8_V8_V8);
2373 }
2374 }
2375
DECLARE_ASM_HANDLER(HandleStownbynameImm8Id16V8)2376 DECLARE_ASM_HANDLER(HandleStownbynameImm8Id16V8)
2377 {
2378 auto env = GetEnvironment();
2379 GateRef stringId = ReadInst16_1(pc);
2380 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2381 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
2382 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2383 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
2384 Label checkResult(env);
2385
2386 Label isJSObject(env);
2387 Label slowPath(env);
2388 BRANCH(IsJSObject(glue, receiver), &isJSObject, &slowPath);
2389 Bind(&isJSObject);
2390 {
2391 Label notClassConstructor(env);
2392 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2393 Bind(¬ClassConstructor);
2394 {
2395 Label fastPath(env);
2396 BRANCH(IsClassPrototype(glue, receiver), &slowPath, &fastPath);
2397 Bind(&fastPath);
2398 {
2399 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2400 SetCurrentGlobalEnv(globalEnv);
2401 result = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback);
2402 BRANCH(TaggedIsHole(*result), &slowPath, &checkResult);
2403 }
2404 }
2405 }
2406 Bind(&slowPath);
2407 {
2408 result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByName), { receiver, propKey, acc });
2409 Jump(&checkResult);
2410 }
2411 Bind(&checkResult);
2412 {
2413 CHECK_EXCEPTION(*result, INT_PTR(STOWNBYNAME_IMM8_ID16_V8));
2414 }
2415 }
2416
DECLARE_ASM_HANDLER(HandleStownbynameImm16Id16V8)2417 DECLARE_ASM_HANDLER(HandleStownbynameImm16Id16V8)
2418 {
2419 auto env = GetEnvironment();
2420 GateRef stringId = ReadInst16_2(pc);
2421 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2422 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_4(pc)));
2423 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2424 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
2425 Label checkResult(env);
2426
2427 Label isJSObject(env);
2428 Label slowPath(env);
2429 BRANCH(IsJSObject(glue, receiver), &isJSObject, &slowPath);
2430 Bind(&isJSObject);
2431 {
2432 Label notClassConstructor(env);
2433 BRANCH(IsClassConstructor(glue, receiver), &slowPath, ¬ClassConstructor);
2434 Bind(¬ClassConstructor);
2435 {
2436 Label fastPath(env);
2437 BRANCH(IsClassPrototype(glue, receiver), &slowPath, &fastPath);
2438 Bind(&fastPath);
2439 {
2440 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2441 SetCurrentGlobalEnv(globalEnv);
2442 result = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback);
2443 BRANCH(TaggedIsHole(*result), &slowPath, &checkResult);
2444 }
2445 }
2446 }
2447 Bind(&slowPath);
2448 {
2449 result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByName), { receiver, propKey, acc });
2450 Jump(&checkResult);
2451 }
2452 Bind(&checkResult);
2453 {
2454 CHECK_EXCEPTION(*result, INT_PTR(STOWNBYNAME_IMM16_ID16_V8));
2455 }
2456 }
2457
DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm8Id16V8)2458 DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm8Id16V8)
2459 {
2460 auto env = GetEnvironment();
2461 GateRef stringId = ReadInst16_1(pc);
2462 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
2463 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2464 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2465 Label isJSObject(env);
2466 Label notJSObject(env);
2467 Label notClassConstructor(env);
2468 Label notClassPrototype(env);
2469 Label notHole(env);
2470 Label notException(env);
2471 Label notException1(env);
2472 BRANCH(IsJSObject(glue, receiver), &isJSObject, ¬JSObject);
2473 Bind(&isJSObject);
2474 {
2475 BRANCH(IsClassConstructor(glue, receiver), ¬JSObject, ¬ClassConstructor);
2476 Bind(¬ClassConstructor);
2477 {
2478 BRANCH(IsClassPrototype(glue, receiver), ¬JSObject, ¬ClassPrototype);
2479 Bind(¬ClassPrototype);
2480 {
2481 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2482 SetCurrentGlobalEnv(globalEnv);
2483 GateRef res = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback, false, true);
2484 BRANCH(TaggedIsHole(res), ¬JSObject, ¬Hole);
2485 Bind(¬Hole);
2486 {
2487 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
2488 Bind(¬Exception);
2489 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2490 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
2491 DISPATCH(STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8);
2492 }
2493 }
2494 }
2495 }
2496 Bind(¬JSObject);
2497 {
2498 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByNameWithNameSet),
2499 { receiver, propKey, acc });
2500 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
2501 Bind(¬Exception1);
2502 DISPATCH(STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8);
2503 }
2504 }
DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm16Id16V8)2505 DECLARE_ASM_HANDLER(HandleStownbynamewithnamesetImm16Id16V8)
2506 {
2507 auto env = GetEnvironment();
2508 GateRef stringId = ReadInst16_2(pc);
2509 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_4(pc)));
2510 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2511 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2512 Label isJSObject(env);
2513 Label notJSObject(env);
2514 Label notClassConstructor(env);
2515 Label notClassPrototype(env);
2516 Label notHole(env);
2517 Label notException(env);
2518 Label notException1(env);
2519 BRANCH(IsJSObject(glue, receiver), &isJSObject, ¬JSObject);
2520 Bind(&isJSObject);
2521 {
2522 BRANCH(IsClassConstructor(glue, receiver), ¬JSObject, ¬ClassConstructor);
2523 Bind(¬ClassConstructor);
2524 {
2525 BRANCH(IsClassPrototype(glue, receiver), ¬JSObject, ¬ClassPrototype);
2526 Bind(¬ClassPrototype);
2527 {
2528 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
2529 SetCurrentGlobalEnv(globalEnv);
2530 GateRef res = SetPropertyByName(glue, receiver, propKey, acc, true, True(), callback, false, true);
2531 BRANCH(TaggedIsHole(res), ¬JSObject, ¬Hole);
2532 Bind(¬Hole);
2533 {
2534 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
2535 Bind(¬Exception);
2536 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
2537 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SetFunctionNameNoPrefix), { acc, propKey });
2538 DISPATCH(STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8);
2539 }
2540 }
2541 }
2542 }
2543 Bind(¬JSObject);
2544 {
2545 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StOwnByNameWithNameSet),
2546 { receiver, propKey, acc });
2547 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception1);
2548 Bind(¬Exception1);
2549 DISPATCH(STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8);
2550 }
2551 }
2552
DECLARE_ASM_HANDLER(HandleLdfunction)2553 DECLARE_ASM_HANDLER(HandleLdfunction)
2554 {
2555 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2556
2557 varAcc = GetFunctionFromFrame(glue, GetFrame(sp));
2558 DISPATCH_WITH_ACC(LDFUNCTION);
2559 }
2560
DECLARE_ASM_HANDLER(HandleMovV4V4)2561 DECLARE_ASM_HANDLER(HandleMovV4V4)
2562 {
2563 GateRef vdst = ZExtInt8ToPtr(ReadInst4_0(pc));
2564 GateRef vsrc = ZExtInt8ToPtr(ReadInst4_1(pc));
2565 GateRef value = GetVregValue(glue, sp, vsrc);
2566 SetVregValue(glue, sp, vdst, value);
2567 DISPATCH(MOV_V4_V4);
2568 }
2569
DECLARE_ASM_HANDLER(HandleMovV8V8)2570 DECLARE_ASM_HANDLER(HandleMovV8V8)
2571 {
2572 GateRef vdst = ZExtInt8ToPtr(ReadInst8_0(pc));
2573 GateRef vsrc = ZExtInt8ToPtr(ReadInst8_1(pc));
2574 GateRef value = GetVregValue(glue, sp, vsrc);
2575 SetVregValue(glue, sp, vdst, value);
2576 DISPATCH(MOV_V8_V8);
2577 }
2578
DECLARE_ASM_HANDLER(HandleMovV16V16)2579 DECLARE_ASM_HANDLER(HandleMovV16V16)
2580 {
2581 GateRef vdst = ZExtInt16ToPtr(ReadInst16_0(pc));
2582 GateRef vsrc = ZExtInt16ToPtr(ReadInst16_2(pc));
2583 GateRef value = GetVregValue(glue, sp, vsrc);
2584 SetVregValue(glue, sp, vdst, value);
2585 DISPATCH(MOV_V16_V16);
2586 }
2587
DECLARE_ASM_HANDLER(HandleLdaStrId16)2588 DECLARE_ASM_HANDLER(HandleLdaStrId16)
2589 {
2590 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2591
2592 GateRef stringId = ReadInst16_0(pc);
2593 varAcc = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
2594 DISPATCH_WITH_ACC(LDA_STR_ID16);
2595 }
2596
DECLARE_ASM_HANDLER(HandleLdaiImm32)2597 DECLARE_ASM_HANDLER(HandleLdaiImm32)
2598 {
2599 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2600
2601 GateRef imm = ReadInst32_0(pc);
2602 varAcc = IntToTaggedPtr(imm);
2603 DISPATCH_WITH_ACC(LDAI_IMM32);
2604 }
2605
DECLARE_ASM_HANDLER(HandleFldaiImm64)2606 DECLARE_ASM_HANDLER(HandleFldaiImm64)
2607 {
2608 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2609
2610 GateRef imm = CastInt64ToFloat64(ReadInst64_0(pc));
2611 varAcc = DoubleToTaggedDoublePtr(imm);
2612 DISPATCH_WITH_ACC(FLDAI_IMM64);
2613 }
2614
DECLARE_ASM_HANDLER(HandleJeqzImm8)2615 DECLARE_ASM_HANDLER(HandleJeqzImm8)
2616 {
2617 auto env = GetEnvironment();
2618 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
2619 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2620
2621 Label accEqualFalse(env);
2622 Label accNotEqualFalse(env);
2623 Label accIsInt(env);
2624 Label accNotInt(env);
2625 Label accIsDouble(env);
2626 Label last(env);
2627 BRANCH(TaggedIsFalse(acc), &accEqualFalse, &accNotEqualFalse);
2628 Bind(&accNotEqualFalse);
2629 {
2630 BRANCH(TaggedIsInt(acc), &accIsInt, &accNotInt);
2631 Bind(&accIsInt);
2632 {
2633 BRANCH(Int32Equal(TaggedGetInt(acc), Int32(0)), &accEqualFalse, &accNotInt);
2634 }
2635 Bind(&accNotInt);
2636 {
2637 BRANCH(TaggedIsDouble(acc), &accIsDouble, &last);
2638 Bind(&accIsDouble);
2639 {
2640 BRANCH(DoubleEqual(GetDoubleOfTDouble(acc), Double(0)), &accEqualFalse, &last);
2641 }
2642 }
2643 }
2644 Bind(&accEqualFalse);
2645 {
2646 Label dispatch(env);
2647 Label slowPath(env);
2648 GateRef offset = ReadInstSigned8_0(pc);
2649 UPDATE_HOTNESS(sp, callback);
2650 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
2651 }
2652 Bind(&last);
2653 DISPATCH_BAK(JUMP, INT_PTR(JEQZ_IMM8));
2654 }
2655
DECLARE_ASM_HANDLER(HandleJeqzImm16)2656 DECLARE_ASM_HANDLER(HandleJeqzImm16)
2657 {
2658 auto env = GetEnvironment();
2659 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
2660 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2661
2662 Label accEqualFalse(env);
2663 Label accNotEqualFalse(env);
2664 Label accIsInt(env);
2665 Label accNotInt(env);
2666 Label accIsDouble(env);
2667 Label last(env);
2668 BRANCH(TaggedIsFalse(acc), &accEqualFalse, &accNotEqualFalse);
2669 Bind(&accNotEqualFalse);
2670 {
2671 BRANCH(TaggedIsInt(acc), &accIsInt, &accNotInt);
2672 Bind(&accIsInt);
2673 {
2674 BRANCH(Int32Equal(TaggedGetInt(acc), Int32(0)), &accEqualFalse, &accNotInt);
2675 }
2676 Bind(&accNotInt);
2677 {
2678 BRANCH(TaggedIsDouble(acc), &accIsDouble, &last);
2679 Bind(&accIsDouble);
2680 {
2681 BRANCH(DoubleEqual(GetDoubleOfTDouble(acc), Double(0)), &accEqualFalse, &last);
2682 }
2683 }
2684 }
2685 Bind(&accEqualFalse);
2686 {
2687 Label dispatch(env);
2688 Label slowPath(env);
2689 GateRef offset = ReadInstSigned16_0(pc);
2690 UPDATE_HOTNESS(sp, callback);
2691 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
2692 }
2693 Bind(&last);
2694 DISPATCH_BAK(JUMP, INT_PTR(JEQZ_IMM16));
2695 }
2696
DECLARE_ASM_HANDLER(HandleJeqzImm32)2697 DECLARE_ASM_HANDLER(HandleJeqzImm32)
2698 {
2699 auto env = GetEnvironment();
2700 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
2701 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2702
2703 Label accEqualFalse(env);
2704 Label accNotEqualFalse(env);
2705 Label accIsInt(env);
2706 Label accNotInt(env);
2707 Label accIsDouble(env);
2708 Label last(env);
2709 BRANCH(TaggedIsFalse(acc), &accEqualFalse, &accNotEqualFalse);
2710 Bind(&accNotEqualFalse);
2711 {
2712 BRANCH(TaggedIsInt(acc), &accIsInt, &accNotInt);
2713 Bind(&accIsInt);
2714 {
2715 BRANCH(Int32Equal(TaggedGetInt(acc), Int32(0)), &accEqualFalse, &accNotInt);
2716 }
2717 Bind(&accNotInt);
2718 {
2719 BRANCH(TaggedIsDouble(acc), &accIsDouble, &last);
2720 Bind(&accIsDouble);
2721 {
2722 BRANCH(DoubleEqual(GetDoubleOfTDouble(acc), Double(0)), &accEqualFalse, &last);
2723 }
2724 }
2725 }
2726 Bind(&accEqualFalse);
2727 {
2728 Label dispatch(env);
2729 Label slowPath(env);
2730 GateRef offset = ReadInstSigned32_0(pc);
2731 UPDATE_HOTNESS(sp, callback);
2732 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
2733 }
2734 Bind(&last);
2735 DISPATCH_BAK(JUMP, INT_PTR(JEQZ_IMM32));
2736 }
2737
DECLARE_ASM_HANDLER(HandleJnezImm8)2738 DECLARE_ASM_HANDLER(HandleJnezImm8)
2739 {
2740 auto env = GetEnvironment();
2741 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
2742 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2743
2744 Label accEqualTrue(env);
2745 Label accNotEqualTrue(env);
2746 Label accIsInt(env);
2747 Label accNotInt(env);
2748 Label accIsDouble(env);
2749 Label last(env);
2750 BRANCH(TaggedIsTrue(acc), &accEqualTrue, &accNotEqualTrue);
2751 Bind(&accNotEqualTrue);
2752 {
2753 BRANCH(TaggedIsInt(acc), &accIsInt, &accNotInt);
2754 Bind(&accIsInt);
2755 {
2756 BRANCH(Int32Equal(TaggedGetInt(acc), Int32(0)), &accNotInt, &accEqualTrue);
2757 }
2758 Bind(&accNotInt);
2759 {
2760 BRANCH(TaggedIsDouble(acc), &accIsDouble, &last);
2761 Bind(&accIsDouble);
2762 {
2763 BRANCH(DoubleEqual(GetDoubleOfTDouble(acc), Double(0)), &last, &accEqualTrue);
2764 }
2765 }
2766 }
2767 Bind(&accEqualTrue);
2768 {
2769 Label dispatch(env);
2770 Label slowPath(env);
2771 GateRef offset = ReadInstSigned8_0(pc);
2772 UPDATE_HOTNESS(sp, callback);
2773 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
2774 }
2775 Bind(&last);
2776 DISPATCH_BAK(JUMP, INT_PTR(JNEZ_IMM8));
2777 }
2778
DECLARE_ASM_HANDLER(HandleJnezImm16)2779 DECLARE_ASM_HANDLER(HandleJnezImm16)
2780 {
2781 auto env = GetEnvironment();
2782 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
2783 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2784
2785 Label accEqualTrue(env);
2786 Label accNotEqualTrue(env);
2787 Label accIsInt(env);
2788 Label accNotInt(env);
2789 Label accIsDouble(env);
2790 Label last(env);
2791 BRANCH(TaggedIsTrue(acc), &accEqualTrue, &accNotEqualTrue);
2792 Bind(&accNotEqualTrue);
2793 {
2794 BRANCH(TaggedIsInt(acc), &accIsInt, &accNotInt);
2795 Bind(&accIsInt);
2796 {
2797 BRANCH(Int32Equal(TaggedGetInt(acc), Int32(0)), &accNotInt, &accEqualTrue);
2798 }
2799 Bind(&accNotInt);
2800 {
2801 BRANCH(TaggedIsDouble(acc), &accIsDouble, &last);
2802 Bind(&accIsDouble);
2803 {
2804 BRANCH(DoubleEqual(GetDoubleOfTDouble(acc), Double(0)), &last, &accEqualTrue);
2805 }
2806 }
2807 }
2808 Bind(&accEqualTrue);
2809 {
2810 Label dispatch(env);
2811 Label slowPath(env);
2812 GateRef offset = ReadInstSigned16_0(pc);
2813 UPDATE_HOTNESS(sp, callback);
2814 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
2815 }
2816 Bind(&last);
2817 DISPATCH_BAK(JUMP, INT_PTR(JNEZ_IMM16));
2818 }
2819
DECLARE_ASM_HANDLER(HandleJnezImm32)2820 DECLARE_ASM_HANDLER(HandleJnezImm32)
2821 {
2822 auto env = GetEnvironment();
2823 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_ANY(), profileTypeInfo);
2824 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2825
2826 Label accEqualTrue(env);
2827 Label accNotEqualTrue(env);
2828 Label accIsInt(env);
2829 Label accNotInt(env);
2830 Label accIsDouble(env);
2831 Label last(env);
2832 BRANCH(TaggedIsTrue(acc), &accEqualTrue, &accNotEqualTrue);
2833 Bind(&accNotEqualTrue);
2834 {
2835 BRANCH(TaggedIsInt(acc), &accIsInt, &accNotInt);
2836 Bind(&accIsInt);
2837 {
2838 BRANCH(Int32Equal(TaggedGetInt(acc), Int32(0)), &accNotInt, &accEqualTrue);
2839 }
2840 Bind(&accNotInt);
2841 {
2842 BRANCH(TaggedIsDouble(acc), &accIsDouble, &last);
2843 Bind(&accIsDouble);
2844 {
2845 BRANCH(DoubleEqual(GetDoubleOfTDouble(acc), Double(0)), &last, &accEqualTrue);
2846 }
2847 }
2848 }
2849 Bind(&accEqualTrue);
2850 {
2851 Label dispatch(env);
2852 Label slowPath(env);
2853 GateRef offset = ReadInstSigned32_0(pc);
2854 UPDATE_HOTNESS(sp, callback);
2855 DISPATCH_BAK(JUMP, SExtInt32ToPtr(offset));
2856 }
2857 Bind(&last);
2858 DISPATCH_BAK(JUMP, INT_PTR(JNEZ_IMM32));
2859 }
2860
DECLARE_ASM_HANDLER(HandleReturn)2861 DECLARE_ASM_HANDLER(HandleReturn)
2862 {
2863 auto env = GetEnvironment();
2864 METHOD_EXIT();
2865 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
2866 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
2867 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
2868 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
2869 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
2870 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2871 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2872
2873 Label isBaselineBuiltinFrame(env);
2874 Label notBaselineBuiltinFrame(env);
2875 Label pcEqualNullptr(env);
2876 Label pcNotEqualNullptr(env);
2877 Label pcEqualBaseline(env);
2878 Label pcNotEqualBaseline(env);
2879 Label updateHotness(env);
2880 Label isStable(env);
2881 Label tryContinue(env);
2882 Label dispatch(env);
2883 Label slowPath(env);
2884
2885 GateRef frame = GetFrame(*varSp);
2886 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
2887 Bind(&isStable);
2888 {
2889 GateRef varProfileTypeInfoVal = *varProfileTypeInfo;
2890 GateRef isProfileDumpedAndJitCompiled = LogicAndBuilder(env)
2891 .And(ProfilerStubBuilder(env).IsCompiledOrTryCompile(glue, GetFunctionFromFrame(glue, frame),
2892 varProfileTypeInfoVal, callback, pc))
2893 .And(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(varProfileTypeInfoVal, callback))
2894 .Done();
2895 BRANCH(isProfileDumpedAndJitCompiled, &tryContinue, &updateHotness);
2896 }
2897 Bind(&updateHotness);
2898 {
2899 GateRef function = GetFunctionFromFrame(glue, frame);
2900 GateRef method = Load(VariableType::JS_ANY(), glue, function,
2901 IntPtr(JSFunctionBase::METHOD_OFFSET));
2902 GateRef fistPC = LoadPrimitive(VariableType::NATIVE_POINTER(), method,
2903 IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
2904 GateRef offset = Int32Not(TruncPtrToInt32(PtrSub(*varPc, fistPC)));
2905 UPDATE_HOTNESS(*varSp, callback);
2906 SetHotnessCounter(glue, method, *varHotnessCounter);
2907 Jump(&tryContinue);
2908 }
2909
2910 Bind(&tryContinue);
2911 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
2912 GateRef curFunc = GetFunctionFromFrame(glue, frame);
2913 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
2914 #endif
2915 GateRef currentSp = *varSp;
2916 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
2917 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
2918
2919 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
2920 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
2921 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
2922 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
2923 Bind(&isBaselineBuiltinFrame);
2924 {
2925 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
2926 Jump(¬BaselineBuiltinFrame);
2927 }
2928 Bind(¬BaselineBuiltinFrame);
2929 prevState = GetFrame(*varSp);
2930 varPc = GetPcFromFrame(*prevState);
2931 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
2932 Bind(&pcEqualNullptr);
2933 {
2934 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
2935 Return();
2936 }
2937 Bind(&pcNotEqualNullptr);
2938 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
2939 Bind(&pcEqualBaseline);
2940 {
2941 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
2942 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
2943 Return();
2944 }
2945 Bind(&pcNotEqualBaseline);
2946 {
2947 GateRef function = GetFunctionFromFrame(glue, *prevState);
2948 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
2949 varConstpool = GetConstpoolFromMethod(glue, method);
2950 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
2951 varHotnessCounter = GetHotnessCounterFromMethod(method);
2952 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
2953 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
2954 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
2955 *varAcc, *varHotnessCounter, jumpSize });
2956 Return();
2957 }
2958 }
2959
DECLARE_ASM_HANDLER(HandleReturnundefined)2960 DECLARE_ASM_HANDLER(HandleReturnundefined)
2961 {
2962 auto env = GetEnvironment();
2963 METHOD_EXIT();
2964 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
2965 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
2966 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
2967 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
2968 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
2969 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
2970 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
2971
2972 Label isBaselineBuiltinFrame(env);
2973 Label notBaselineBuiltinFrame(env);
2974 Label pcEqualNullptr(env);
2975 Label pcNotEqualNullptr(env);
2976 Label pcEqualBaseline(env);
2977 Label pcNotEqualBaseline(env);
2978 Label updateHotness(env);
2979 Label isStable(env);
2980 Label tryContinue(env);
2981 Label dispatch(env);
2982 Label slowPath(env);
2983
2984 GateRef frame = GetFrame(*varSp);
2985 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
2986 Bind(&isStable);
2987 {
2988 GateRef varProfileTypeInfoVal = *varProfileTypeInfo;
2989 GateRef isProfileDumpedAndJitCompiled = LogicAndBuilder(env)
2990 .And(ProfilerStubBuilder(env).IsCompiledOrTryCompile(glue, GetFunctionFromFrame(glue, frame),
2991 varProfileTypeInfoVal, callback, pc))
2992 .And(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(varProfileTypeInfoVal, callback))
2993 .Done();
2994 BRANCH(isProfileDumpedAndJitCompiled, &tryContinue, &updateHotness);
2995 }
2996 Bind(&updateHotness);
2997 {
2998 GateRef function = GetFunctionFromFrame(glue, frame);
2999 GateRef method = Load(VariableType::JS_ANY(), glue, function,
3000 IntPtr(JSFunctionBase::METHOD_OFFSET));
3001 GateRef fistPC = LoadPrimitive(VariableType::NATIVE_POINTER(), method,
3002 IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
3003 GateRef offset = Int32Not(TruncPtrToInt32(PtrSub(*varPc, fistPC)));
3004 UPDATE_HOTNESS(*varSp, callback);
3005 SetHotnessCounter(glue, method, *varHotnessCounter);
3006 Jump(&tryContinue);
3007 }
3008
3009 Bind(&tryContinue);
3010 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
3011 GateRef curFunc = GetFunctionFromFrame(glue, frame);
3012 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
3013 #endif
3014 GateRef currentSp = *varSp;
3015 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
3016 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
3017
3018 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
3019 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
3020 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
3021 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
3022 Bind(&isBaselineBuiltinFrame);
3023 {
3024 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
3025 Jump(¬BaselineBuiltinFrame);
3026 }
3027 Bind(¬BaselineBuiltinFrame);
3028 prevState = GetFrame(*varSp);
3029 varPc = GetPcFromFrame(*prevState);
3030 varAcc = Undefined();
3031 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
3032 Bind(&pcEqualNullptr);
3033 {
3034 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
3035 Return();
3036 }
3037 Bind(&pcNotEqualNullptr);
3038 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
3039 Bind(&pcEqualBaseline);
3040 {
3041 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3042 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
3043 Return();
3044 }
3045 Bind(&pcNotEqualBaseline);
3046 {
3047 GateRef function = GetFunctionFromFrame(glue, *prevState);
3048 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
3049 varConstpool = GetConstpoolFromMethod(glue, method);
3050 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
3051 varHotnessCounter = GetHotnessCounterFromMethod(method);
3052 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3053 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
3054 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
3055 *varAcc, *varHotnessCounter, jumpSize });
3056 Return();
3057 }
3058 }
3059
DECLARE_ASM_HANDLER(HandleSuspendgeneratorV8)3060 DECLARE_ASM_HANDLER(HandleSuspendgeneratorV8)
3061 {
3062 auto env = GetEnvironment();
3063 METHOD_EXIT();
3064 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
3065 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
3066 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
3067 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
3068 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
3069 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3070 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
3071
3072 Label isBaselineBuiltinFrame(env);
3073 Label notBaselineBuiltinFrame(env);
3074 Label pcEqualNullptr(env);
3075 Label pcNotEqualNullptr(env);
3076 Label pcEqualBaseline(env);
3077 Label pcNotEqualBaseline(env);
3078 Label updateHotness(env);
3079 Label isStable(env);
3080 Label tryContinue(env);
3081 Label dispatch(env);
3082 Label slowPath(env);
3083
3084 GateRef genObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc)));
3085 GateRef value = *varAcc;
3086 GateRef frame = GetFrame(*varSp);
3087 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3088 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuspendGenerator), { genObj, value });
3089 Label isException(env);
3090 Label notException(env);
3091 BRANCH(TaggedIsException(res), &isException, ¬Exception);
3092 Bind(&isException);
3093 {
3094 DispatchLast(glue, *varSp, *varPc, *varConstpool, *varProfileTypeInfo, *varAcc, *varHotnessCounter);
3095 }
3096 Bind(¬Exception);
3097 varAcc = res;
3098 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
3099 Bind(&isStable);
3100 {
3101 BRANCH(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(*varProfileTypeInfo, callback), &tryContinue,
3102 &updateHotness);
3103 }
3104 Bind(&updateHotness);
3105 {
3106 GateRef function = GetFunctionFromFrame(glue, frame);
3107 GateRef method = Load(VariableType::JS_ANY(), glue, function,
3108 IntPtr(JSFunctionBase::METHOD_OFFSET));
3109 GateRef fistPC = LoadPrimitive(VariableType::NATIVE_POINTER(), method,
3110 IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
3111 GateRef offset = Int32Not(TruncPtrToInt32(PtrSub(*varPc, fistPC)));
3112 UPDATE_HOTNESS(*varSp, callback);
3113 SetHotnessCounter(glue, method, *varHotnessCounter);
3114 Jump(&tryContinue);
3115 }
3116
3117 Bind(&tryContinue);
3118 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
3119 GateRef curFunc = GetFunctionFromFrame(glue, frame);
3120 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
3121 #endif
3122 GateRef currentSp = *varSp;
3123 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
3124 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
3125
3126 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
3127 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
3128 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
3129 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
3130 Bind(&isBaselineBuiltinFrame);
3131 {
3132 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
3133 Jump(¬BaselineBuiltinFrame);
3134 }
3135 Bind(¬BaselineBuiltinFrame);
3136 prevState = GetFrame(*varSp);
3137 varPc = GetPcFromFrame(*prevState);
3138 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
3139 Bind(&pcEqualNullptr);
3140 {
3141 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
3142 Return();
3143 }
3144 Bind(&pcNotEqualNullptr);
3145 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
3146 Bind(&pcEqualBaseline);
3147 {
3148 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3149 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
3150 Return();
3151 }
3152 Bind(&pcNotEqualBaseline);
3153 {
3154 GateRef function = GetFunctionFromFrame(glue, *prevState);
3155 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
3156 varConstpool = GetConstpoolFromMethod(glue, method);
3157 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
3158 varHotnessCounter = GetHotnessCounterFromMethod(method);
3159 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3160 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
3161 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
3162 *varAcc, *varHotnessCounter, jumpSize });
3163 Return();
3164 }
3165 }
3166
DECLARE_ASM_HANDLER(HandleDeprecatedSuspendgeneratorPrefV8V8)3167 DECLARE_ASM_HANDLER(HandleDeprecatedSuspendgeneratorPrefV8V8)
3168 {
3169 auto env = GetEnvironment();
3170 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
3171 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
3172 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
3173 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
3174 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
3175 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3176 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
3177
3178 Label isBaselineBuiltinFrame(env);
3179 Label notBaselineBuiltinFrame(env);
3180 Label pcEqualNullptr(env);
3181 Label pcNotEqualNullptr(env);
3182 Label pcEqualBaseline(env);
3183 Label pcNotEqualBaseline(env);
3184 Label updateHotness(env);
3185 Label isStable(env);
3186 Label tryContinue(env);
3187 Label dispatch(env);
3188 Label slowPath(env);
3189
3190 GateRef genObj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
3191 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
3192 GateRef frame = GetFrame(*varSp);
3193 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3194 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuspendGenerator), { genObj, value });
3195 Label isException(env);
3196 Label notException(env);
3197 BRANCH(TaggedIsException(res), &isException, ¬Exception);
3198 Bind(&isException);
3199 {
3200 DispatchLast(glue, *varSp, *varPc, *varConstpool, *varProfileTypeInfo, *varAcc, *varHotnessCounter);
3201 }
3202 Bind(¬Exception);
3203 varAcc = res;
3204 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
3205 Bind(&isStable);
3206 {
3207 BRANCH(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(*varProfileTypeInfo, callback), &tryContinue,
3208 &updateHotness);
3209 }
3210 Bind(&updateHotness);
3211 {
3212 GateRef function = GetFunctionFromFrame(glue, frame);
3213 GateRef method = Load(VariableType::JS_ANY(), glue, function,
3214 IntPtr(JSFunctionBase::METHOD_OFFSET));
3215 GateRef fistPC = LoadPrimitive(VariableType::NATIVE_POINTER(), method,
3216 IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
3217 GateRef offset = Int32Not(TruncPtrToInt32(PtrSub(*varPc, fistPC)));
3218 UPDATE_HOTNESS(*varSp, callback);
3219 SetHotnessCounter(glue, method, *varHotnessCounter);
3220 Jump(&tryContinue);
3221 }
3222
3223 Bind(&tryContinue);
3224 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
3225 GateRef curFunc = GetFunctionFromFrame(glue, frame);
3226 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
3227 #endif
3228 GateRef currentSp = *varSp;
3229 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
3230 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
3231
3232 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
3233 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
3234 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
3235 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
3236 Bind(&isBaselineBuiltinFrame);
3237 {
3238 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
3239 Jump(¬BaselineBuiltinFrame);
3240 }
3241 Bind(¬BaselineBuiltinFrame);
3242 prevState = GetFrame(*varSp);
3243 varPc = GetPcFromFrame(*prevState);
3244 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
3245 Bind(&pcEqualNullptr);
3246 {
3247 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
3248 Return();
3249 }
3250 Bind(&pcNotEqualNullptr);
3251 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
3252 Bind(&pcEqualBaseline);
3253 {
3254 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3255 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
3256 Return();
3257 }
3258 Bind(&pcNotEqualBaseline);
3259 {
3260 GateRef function = GetFunctionFromFrame(glue, *prevState);
3261 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
3262 varConstpool = GetConstpoolFromMethod(glue, method);
3263 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
3264 varHotnessCounter = GetHotnessCounterFromMethod(method);
3265 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3266 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
3267 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
3268 *varAcc, *varHotnessCounter, jumpSize });
3269 Return();
3270 }
3271 }
3272
DECLARE_ASM_HANDLER(HandleTryldglobalbynameImm8Id16)3273 DECLARE_ASM_HANDLER(HandleTryldglobalbynameImm8Id16)
3274 {
3275 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3276 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
3277 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3278 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3279 AccessObjectStubBuilder builder(this, globalEnv);
3280 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16);
3281 GateRef result = builder.TryLoadGlobalByName(glue, 0, info, profileTypeInfo, slotId, callback);
3282 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(TRYLDGLOBALBYNAME_IMM8_ID16));
3283 }
3284
DECLARE_ASM_HANDLER(HandleTryldglobalbynameImm16Id16)3285 DECLARE_ASM_HANDLER(HandleTryldglobalbynameImm16Id16)
3286 {
3287 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3288
3289 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
3290 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3291 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3292 AccessObjectStubBuilder builder(this, globalEnv);
3293 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
3294 GateRef result = builder.TryLoadGlobalByName(glue, 0, info, profileTypeInfo, slotId, callback);
3295 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(TRYLDGLOBALBYNAME_IMM16_ID16));
3296 }
3297
DECLARE_ASM_HANDLER(HandleTrystglobalbynameImm8Id16)3298 DECLARE_ASM_HANDLER(HandleTrystglobalbynameImm8Id16)
3299 {
3300 GateRef slotId = ZExtInt16ToInt32(ReadInst8_0(pc));
3301 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3302 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3303 AccessObjectStubBuilder builder(this, globalEnv);
3304 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16);
3305 GateRef result = builder.TryStoreGlobalByName(glue, 0, info, acc, profileTypeInfo, slotId, callback);
3306 CHECK_EXCEPTION(result, INT_PTR(TRYSTGLOBALBYNAME_IMM8_ID16));
3307 }
3308
DECLARE_ASM_HANDLER(HandleTrystglobalbynameImm16Id16)3309 DECLARE_ASM_HANDLER(HandleTrystglobalbynameImm16Id16)
3310 {
3311 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
3312 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3313 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3314 AccessObjectStubBuilder builder(this, globalEnv);
3315 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
3316 GateRef result = builder.TryStoreGlobalByName(glue, 0, info, acc, profileTypeInfo, slotId, callback);
3317 CHECK_EXCEPTION(result, INT_PTR(TRYSTGLOBALBYNAME_IMM16_ID16));
3318 }
3319
DECLARE_ASM_HANDLER(HandleLdglobalvarImm16Id16)3320 DECLARE_ASM_HANDLER(HandleLdglobalvarImm16Id16)
3321 {
3322 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3323
3324 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
3325 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3326 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3327 AccessObjectStubBuilder builder(this, globalEnv);
3328 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
3329 GateRef result = builder.LoadGlobalVar(glue, 0, info, profileTypeInfo, slotId, callback);
3330 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDGLOBALVAR_IMM16_ID16));
3331 }
3332
DECLARE_ASM_HANDLER(HandleStglobalvarImm16Id16)3333 DECLARE_ASM_HANDLER(HandleStglobalvarImm16Id16)
3334 {
3335 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
3336 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3337 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3338 AccessObjectStubBuilder builder(this, globalEnv);
3339 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
3340 GateRef result = builder.StoreGlobalVar(glue, 0, info, acc, profileTypeInfo, slotId);
3341 CHECK_EXCEPTION(result, INT_PTR(STGLOBALVAR_IMM16_ID16));
3342 }
3343
DECLARE_ASM_HANDLER(HandleCreateregexpwithliteralImm8Id16Imm8)3344 DECLARE_ASM_HANDLER(HandleCreateregexpwithliteralImm8Id16Imm8)
3345 {
3346 GateRef stringId = ReadInst16_1(pc);
3347 GateRef pattern = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
3348 GateRef flags = ReadInst8_3(pc);
3349 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3350 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateRegExpWithLiteral),
3351 { pattern, Int8ToTaggedInt(flags) });
3352 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEREGEXPWITHLITERAL_IMM8_ID16_IMM8));
3353 }
3354
DECLARE_ASM_HANDLER(HandleCreateregexpwithliteralImm16Id16Imm8)3355 DECLARE_ASM_HANDLER(HandleCreateregexpwithliteralImm16Id16Imm8)
3356 {
3357 GateRef stringId = ReadInst16_2(pc);
3358 GateRef pattern = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
3359 GateRef flags = ReadInst8_4(pc);
3360 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3361 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateRegExpWithLiteral),
3362 { pattern, Int8ToTaggedInt(flags) });
3363 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEREGEXPWITHLITERAL_IMM16_ID16_IMM8));
3364 }
3365
DECLARE_ASM_HANDLER(HandleIstrue)3366 DECLARE_ASM_HANDLER(HandleIstrue)
3367 {
3368 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3369 varAcc = FastToBoolean(glue, *varAcc, true);
3370 DISPATCH_WITH_ACC(ISTRUE);
3371 }
3372
DECLARE_ASM_HANDLER(HandleCallRuntimeIstruePrefImm8)3373 DECLARE_ASM_HANDLER(HandleCallRuntimeIstruePrefImm8)
3374 {
3375 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3376 varAcc = FastToBooleanWithProfile(glue, *varAcc, callback, true);
3377 DISPATCH_WITH_ACC(CALLRUNTIME_ISTRUE_PREF_IMM8);
3378 }
3379
DECLARE_ASM_HANDLER(HandleIsfalse)3380 DECLARE_ASM_HANDLER(HandleIsfalse)
3381 {
3382 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3383 varAcc = FastToBoolean(glue, *varAcc, false);
3384 DISPATCH_WITH_ACC(ISFALSE);
3385 }
3386
DECLARE_ASM_HANDLER(HandleCallRuntimeIsfalsePrefImm8)3387 DECLARE_ASM_HANDLER(HandleCallRuntimeIsfalsePrefImm8)
3388 {
3389 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3390 varAcc = FastToBooleanWithProfile(glue, *varAcc, callback, false);
3391 DISPATCH_WITH_ACC(CALLRUNTIME_ISFALSE_PREF_IMM8);
3392 }
3393
DECLARE_ASM_HANDLER(HandleTonumberImm8)3394 DECLARE_ASM_HANDLER(HandleTonumberImm8)
3395 {
3396 auto env = GetEnvironment();
3397 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3398 GateRef value = *varAcc;
3399 Label valueIsNumber(env);
3400 Label valueNotNumber(env);
3401 BRANCH(TaggedIsNumber(value), &valueIsNumber, &valueNotNumber);
3402 Bind(&valueIsNumber);
3403 {
3404 varAcc = value;
3405 DISPATCH_WITH_ACC(TONUMBER_IMM8);
3406 }
3407 Bind(&valueNotNumber);
3408 {
3409 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3410 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumber), { value });
3411 CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(TONUMBER_IMM8));
3412 }
3413 }
3414
DECLARE_ASM_HANDLER(HandleDeprecatedTonumberPrefV8)3415 DECLARE_ASM_HANDLER(HandleDeprecatedTonumberPrefV8)
3416 {
3417 auto env = GetEnvironment();
3418 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3419 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
3420 Label valueIsNumber(env);
3421 Label valueNotNumber(env);
3422 BRANCH(TaggedIsNumber(value), &valueIsNumber, &valueNotNumber);
3423 Bind(&valueIsNumber);
3424 {
3425 varAcc = value;
3426 DISPATCH_WITH_ACC(DEPRECATED_TONUMBER_PREF_V8);
3427 }
3428 Bind(&valueNotNumber);
3429 {
3430 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3431 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumber), { value });
3432 CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(DEPRECATED_TONUMBER_PREF_V8));
3433 }
3434 }
3435
DECLARE_ASM_HANDLER(HandleAdd2Imm8V8)3436 DECLARE_ASM_HANDLER(HandleAdd2Imm8V8)
3437 {
3438 GateRef v0 = ReadInst8_1(pc);
3439 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3440 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3441 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3442 OperationsStubBuilder builder(this, globalEnv);
3443 GateRef result = builder.Add(glue, left, acc, callback);
3444 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(ADD2_IMM8_V8));
3445 }
3446
DECLARE_ASM_HANDLER(HandleSub2Imm8V8)3447 DECLARE_ASM_HANDLER(HandleSub2Imm8V8)
3448 {
3449 GateRef v0 = ReadInst8_1(pc);
3450 GateRef left = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3451 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3452 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3453 OperationsStubBuilder builder(this, globalEnv);
3454 GateRef result = builder.Sub(glue, left, acc, callback);
3455 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(SUB2_IMM8_V8));
3456 }
3457
DECLARE_ASM_HANDLER(HandleLdbigintId16)3458 DECLARE_ASM_HANDLER(HandleLdbigintId16)
3459 {
3460 GateRef stringId = ReadInst16_0(pc);
3461 GateRef numberBigInt = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
3462 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3463 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdBigInt), { numberBigInt });
3464 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(LDBIGINT_ID16));
3465 }
3466
DECLARE_ASM_HANDLER(HandleTonumericImm8)3467 DECLARE_ASM_HANDLER(HandleTonumericImm8)
3468 {
3469 auto env = GetEnvironment();
3470 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3471 GateRef value = *varAcc;
3472 Label valueIsNumeric(env);
3473 Label valueNotNumeric(env);
3474 BRANCH(TaggedIsNumeric(glue, value), &valueIsNumeric, &valueNotNumeric);
3475 Bind(&valueIsNumeric);
3476 {
3477 if (!callback.IsEmpty()) {
3478 Label valueIsNumber(env);
3479 Label profilerEnd(env);
3480 BRANCH(TaggedIsNumber(value), &valueIsNumber, &profilerEnd);
3481 Bind(&valueIsNumber);
3482 {
3483 Label valueIsInt(env);
3484 Label valueIsDouble(env);
3485 BRANCH(TaggedIsInt(value), &valueIsInt, &valueIsDouble);
3486 Bind(&valueIsInt);
3487 {
3488 callback.ProfileOpType(TaggedInt(PGOSampleType::IntType()));
3489 Jump(&profilerEnd);
3490 }
3491 Bind(&valueIsDouble);
3492 {
3493 callback.ProfileOpType(TaggedInt(PGOSampleType::DoubleType()));
3494 Jump(&profilerEnd);
3495 }
3496 }
3497 Bind(&profilerEnd);
3498 }
3499 varAcc = value;
3500 DISPATCH_WITH_ACC(TONUMERIC_IMM8);
3501 }
3502 Bind(&valueNotNumeric);
3503 {
3504 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3505 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumeric), { value });
3506 CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(TONUMERIC_IMM8));
3507 }
3508 }
3509
DECLARE_ASM_HANDLER(HandleDeprecatedTonumericPrefV8)3510 DECLARE_ASM_HANDLER(HandleDeprecatedTonumericPrefV8)
3511 {
3512 auto env = GetEnvironment();
3513 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3514 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
3515 Label valueIsNumeric(env);
3516 Label valueNotNumeric(env);
3517 BRANCH(TaggedIsNumeric(glue, value), &valueIsNumeric, &valueNotNumeric);
3518 Bind(&valueIsNumeric);
3519 {
3520 varAcc = value;
3521 DISPATCH_WITH_ACC(DEPRECATED_TONUMERIC_PREF_V8);
3522 }
3523 Bind(&valueNotNumeric);
3524 {
3525 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3526 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ToNumeric), { value });
3527 CHECK_EXCEPTION_WITH_VARACC(res, INT_PTR(DEPRECATED_TONUMERIC_PREF_V8));
3528 }
3529 }
3530
DECLARE_ASM_HANDLER(HandleDynamicimport)3531 DECLARE_ASM_HANDLER(HandleDynamicimport)
3532 {
3533 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3534 GateRef specifier = *varAcc;
3535 GateRef frame = GetFrame(sp);
3536 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
3537 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3538 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DynamicImport), { specifier, currentFunc });
3539 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DYNAMICIMPORT));
3540 }
3541
DECLARE_ASM_HANDLER(HandleDeprecatedDynamicimportPrefV8)3542 DECLARE_ASM_HANDLER(HandleDeprecatedDynamicimportPrefV8)
3543 {
3544 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3545 GateRef specifier = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
3546 GateRef frame = GetFrame(sp);
3547 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
3548 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3549 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DynamicImport), { specifier, currentFunc });
3550 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_DYNAMICIMPORT_PREF_V8));
3551 }
3552
DECLARE_ASM_HANDLER(HandleCreateasyncgeneratorobjV8)3553 DECLARE_ASM_HANDLER(HandleCreateasyncgeneratorobjV8)
3554 {
3555 auto env = GetEnvironment();
3556 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3557
3558 GateRef v0 = ReadInst8_0(pc);
3559 GateRef genFunc = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3560 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3561 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateAsyncGeneratorObj), { genFunc });
3562 Label isException(env);
3563 Label notException(env);
3564 BRANCH(TaggedIsException(result), &isException, ¬Exception);
3565 Bind(&isException);
3566 {
3567 DISPATCH_LAST();
3568 }
3569 Bind(¬Exception);
3570 varAcc = result;
3571 DISPATCH_WITH_ACC(CREATEASYNCGENERATOROBJ_V8);
3572 }
3573
DECLARE_ASM_HANDLER(HandleAsyncgeneratorresolveV8V8V8)3574 DECLARE_ASM_HANDLER(HandleAsyncgeneratorresolveV8V8V8)
3575 {
3576 auto env = GetEnvironment();
3577 METHOD_EXIT();
3578 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
3579 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
3580 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
3581 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
3582 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
3583 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
3584 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3585
3586 Label isBaselineBuiltinFrame(env);
3587 Label notBaselineBuiltinFrame(env);
3588 Label pcEqualNullptr(env);
3589 Label pcNotEqualNullptr(env);
3590 Label pcEqualBaseline(env);
3591 Label pcNotEqualBaseline(env);
3592 Label updateHotness(env);
3593 Label isStable(env);
3594 Label tryContinue(env);
3595 Label dispatch(env);
3596 Label slowPath(env);
3597
3598 GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc)));
3599 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
3600 GateRef flag = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
3601 GateRef frame = GetFrame(*varSp);
3602 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3603 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncGeneratorResolve),
3604 { asyncGenerator, value, flag });
3605 Label isException(env);
3606 Label notException(env);
3607 BRANCH(TaggedIsException(res), &isException, ¬Exception);
3608 Bind(&isException);
3609 {
3610 DISPATCH_LAST();
3611 }
3612 Bind(¬Exception);
3613 varAcc = res;
3614 BRANCH(TaggedIsUndefined(*varProfileTypeInfo), &updateHotness, &isStable);
3615 Bind(&isStable);
3616 {
3617 BRANCH(ProfilerStubBuilder(env).IsProfileTypeInfoDumped(*varProfileTypeInfo, callback), &tryContinue,
3618 &updateHotness);
3619 }
3620 Bind(&updateHotness);
3621 {
3622 GateRef function = GetFunctionFromFrame(glue, frame);
3623 GateRef method = Load(VariableType::JS_ANY(), glue, function,
3624 IntPtr(JSFunctionBase::METHOD_OFFSET));
3625 GateRef fistPC = LoadPrimitive(VariableType::NATIVE_POINTER(), method,
3626 IntPtr(Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
3627 GateRef offset = Int32Not(TruncPtrToInt32(PtrSub(*varPc, fistPC)));
3628 UPDATE_HOTNESS(*varSp, callback);
3629 SetHotnessCounter(glue, method, *varHotnessCounter);
3630 Jump(&tryContinue);
3631 }
3632
3633 Bind(&tryContinue);
3634 #if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
3635 GateRef curFunc = GetFunctionFromFrame(glue, frame);
3636 CallNGCRuntime(glue, RTSTUB_ID(EndCallTimer), { glue, curFunc });
3637 #endif
3638 GateRef currentSp = *varSp;
3639 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), frame,
3640 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
3641
3642 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
3643 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
3644 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
3645 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
3646 Bind(&isBaselineBuiltinFrame);
3647 {
3648 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
3649 Jump(¬BaselineBuiltinFrame);
3650 }
3651 Bind(¬BaselineBuiltinFrame);
3652 prevState = GetFrame(*varSp);
3653 varPc = GetPcFromFrame(*prevState);
3654 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
3655 Bind(&pcEqualNullptr);
3656 {
3657 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
3658 Return();
3659 }
3660 Bind(&pcNotEqualNullptr);
3661 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
3662 Bind(&pcEqualBaseline);
3663 {
3664 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3665 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturnBaseline), { glue, *varAcc, *varSp, currentSp, jumpSize });
3666 Return();
3667 }
3668 Bind(&pcNotEqualBaseline);
3669 {
3670 GateRef function = GetFunctionFromFrame(glue, *prevState);
3671 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
3672 varConstpool = GetConstpoolFromMethod(glue, method);
3673 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
3674 varHotnessCounter = GetHotnessCounterFromMethod(method);
3675 GateRef jumpSize = GetCallSizeFromFrame(*prevState);
3676 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
3677 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
3678 *varAcc, *varHotnessCounter, jumpSize });
3679 Return();
3680 }
3681 }
3682
DECLARE_ASM_HANDLER(HandleAsyncgeneratorrejectV8)3683 DECLARE_ASM_HANDLER(HandleAsyncgeneratorrejectV8)
3684 {
3685 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3686 GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_0(pc)));
3687 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3688 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncGeneratorReject),
3689 { asyncGenerator, acc });
3690 CHECK_EXCEPTION_VARACC(res, INT_PTR(ASYNCGENERATORREJECT_V8));
3691 }
3692
DECLARE_ASM_HANDLER(HandleSetgeneratorstateImm8)3693 DECLARE_ASM_HANDLER(HandleSetgeneratorstateImm8)
3694 {
3695 GateRef index = ReadInst8_0(pc);
3696 GateRef value = acc;
3697 CallRuntime(glue, RTSTUB_ID(SetGeneratorState), { value, IntToTaggedInt(index) });
3698 DISPATCH(SETGENERATORSTATE_IMM8);
3699 }
3700
DECLARE_ASM_HANDLER(HandleDeprecatedAsyncgeneratorrejectPrefV8V8)3701 DECLARE_ASM_HANDLER(HandleDeprecatedAsyncgeneratorrejectPrefV8V8)
3702 {
3703 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3704 GateRef asyncGenerator = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
3705 GateRef value = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
3706 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3707 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(AsyncGeneratorReject),
3708 { asyncGenerator, value });
3709 CHECK_EXCEPTION_VARACC(res, INT_PTR(DEPRECATED_ASYNCGENERATORREJECT_PREF_V8_V8));
3710 }
3711
DECLARE_ASM_HANDLER(HandleSupercallthisrangeImm8Imm8V8)3712 DECLARE_ASM_HANDLER(HandleSupercallthisrangeImm8Imm8V8)
3713 {
3714 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3715 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
3716 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
3717 auto env = GetEnvironment();
3718 GateRef range = ZExtInt8ToInt16(ReadInst8_1(pc));
3719 GateRef v0 = ZExtInt8ToInt16(ReadInst8_2(pc));
3720 GateRef actualNumArgs = ZExtInt16ToInt32(range);
3721 GateRef frame = GetFrame(sp);
3722 GateRef thisFunc = GetFunctionFromFrame(glue, frame);
3723 GateRef newTarget = GetNewTarget(glue, sp);
3724 GateRef superCtor = GetPrototype(glue, thisFunc);
3725
3726 Label ctorIsHeapObject(env);
3727 Label ctorIsJSFunction(env);
3728 Label ctorIsConstructor(env);
3729 Label fastPath(env);
3730 Label slowPath(env);
3731 Label checkResult(env);
3732 Label threadCheck(env);
3733 Label dispatch(env);
3734 Label ctorIsBase(env);
3735 Label ctorNotBase(env);
3736 Label isException(env);
3737
3738 BRANCH(TaggedIsHeapObject(superCtor), &ctorIsHeapObject, &slowPath);
3739 Bind(&ctorIsHeapObject);
3740 BRANCH(IsJSFunction(glue, superCtor), &ctorIsJSFunction, &slowPath);
3741 Bind(&ctorIsJSFunction);
3742 BRANCH(IsConstructor(glue, superCtor), &ctorIsConstructor, &slowPath);
3743 Bind(&ctorIsConstructor);
3744 BRANCH(TaggedIsUndefined(newTarget), &slowPath, &fastPath);
3745 Bind(&fastPath);
3746 {
3747 BRANCH(IsBase(glue, superCtor), &ctorIsBase, &ctorNotBase);
3748 Bind(&ctorIsBase);
3749 {
3750 NewObjectStubBuilder newBuilder(this);
3751 thisObj = newBuilder.FastSuperAllocateThis(glue, superCtor, newTarget);
3752 BRANCH(HasPendingException(glue), &isException, &ctorNotBase);
3753 }
3754 Bind(&ctorNotBase);
3755 GateRef argv = PtrAdd(sp, PtrMul(ZExtInt16ToPtr(v0), IntPtr(JSTaggedValue::TaggedTypeSize()))); // skip function
3756 GateRef jumpSize = IntPtr(InterpreterAssembly::GetCallSize(EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8));
3757 METHOD_ENTRY_ENV_DEFINED(superCtor);
3758 JSCallArgs callArgs(JSCallMode::SUPER_CALL_WITH_ARGV);
3759 callArgs.superCallArgs = {
3760 thisFunc, Int16ToTaggedInt(v0), ZExtInt32ToPtr(actualNumArgs), argv, *thisObj, newTarget
3761 };
3762 CallStubBuilder callBuilder(this, glue, superCtor, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs,
3763 callback);
3764 res = callBuilder.JSCallDispatch();
3765 Jump(&threadCheck);
3766 }
3767 Bind(&slowPath);
3768 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3769 res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall),
3770 { thisFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) });
3771 Jump(&checkResult);
3772 Bind(&checkResult);
3773 {
3774 BRANCH(TaggedIsException(*res), &isException, &dispatch);
3775 }
3776 Bind(&threadCheck);
3777 {
3778 BRANCH(HasPendingException(glue), &isException, &dispatch);
3779 }
3780 Bind(&isException);
3781 {
3782 DISPATCH_LAST();
3783 }
3784 Bind(&dispatch);
3785 varAcc = *res;
3786 DISPATCH_WITH_ACC(SUPERCALLTHISRANGE_IMM8_IMM8_V8);
3787 }
3788
DECLARE_ASM_HANDLER(HandleSupercallarrowrangeImm8Imm8V8)3789 DECLARE_ASM_HANDLER(HandleSupercallarrowrangeImm8Imm8V8)
3790 {
3791 GateRef range = ReadInst8_1(pc);
3792 GateRef v0 = ZExtInt8ToInt16(ReadInst8_2(pc));
3793 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3794 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall),
3795 { acc, Int16ToTaggedInt(v0), Int8ToTaggedInt(range) });
3796 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(SUPERCALLARROWRANGE_IMM8_IMM8_V8));
3797 }
3798
DECLARE_ASM_HANDLER(HandleWideSupercallthisrangePrefImm16V8)3799 DECLARE_ASM_HANDLER(HandleWideSupercallthisrangePrefImm16V8)
3800 {
3801 GateRef range = ReadInst16_1(pc);
3802 GateRef v0 = ZExtInt8ToInt16(ReadInst8_3(pc));
3803 GateRef frame = GetFrame(sp);
3804 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
3805 GateRef currentEnv = GetEnvFromFrame(glue, frame);
3806 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall),
3807 { currentFunc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) });
3808 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8));
3809 }
3810
DECLARE_ASM_HANDLER(HandleWideSupercallarrowrangePrefImm16V8)3811 DECLARE_ASM_HANDLER(HandleWideSupercallarrowrangePrefImm16V8)
3812 {
3813 GateRef range = ReadInst16_1(pc);
3814 GateRef v0 = ZExtInt8ToInt16(ReadInst8_3(pc));
3815 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3816 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCall),
3817 { acc, Int16ToTaggedInt(v0), Int16ToTaggedInt(range) });
3818 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8));
3819 }
3820
DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm8V8)3821 DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm8V8)
3822 {
3823 GateRef v0 = ReadInst8_1(pc);
3824 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3825 GateRef propKey = acc;
3826 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3827 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue),
3828 { receiver, propKey }); // sp for thisFunc
3829 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDSUPERBYVALUE_IMM8_V8));
3830 }
DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm16V8)3831 DECLARE_ASM_HANDLER(HandleLdsuperbyvalueImm16V8)
3832 {
3833 GateRef v0 = ReadInst8_2(pc);
3834 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3835 GateRef propKey = acc;
3836 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3837 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue),
3838 { receiver, propKey }); // sp for thisFunc
3839 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDSUPERBYVALUE_IMM16_V8));
3840 }
3841
DECLARE_ASM_HANDLER(HandleDeprecatedLdsuperbyvaluePrefV8V8)3842 DECLARE_ASM_HANDLER(HandleDeprecatedLdsuperbyvaluePrefV8V8)
3843 {
3844 GateRef v0 = ReadInst8_1(pc);
3845 GateRef v1 = ReadInst8_2(pc);
3846 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3847 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
3848 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3849 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue),
3850 { receiver, propKey }); // sp for thisFunc
3851 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_LDSUPERBYVALUE_PREF_V8_V8));
3852 }
3853
DECLARE_ASM_HANDLER(HandleDeprecatedGetiteratornextPrefV8V8)3854 DECLARE_ASM_HANDLER(HandleDeprecatedGetiteratornextPrefV8V8)
3855 {
3856 GateRef v0 = ReadInst8_1(pc);
3857 GateRef v1 = ReadInst8_2(pc);
3858 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3859 GateRef method = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
3860 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3861 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetIteratorNext), { obj, method });
3862 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_GETITERATORNEXT_PREF_V8_V8));
3863 }
3864
DECLARE_ASM_HANDLER(HandleLdobjbyvalueImm8V8)3865 DECLARE_ASM_HANDLER(HandleLdobjbyvalueImm8V8)
3866 {
3867 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3868
3869 GateRef v0 = ReadInst8_1(pc);
3870 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3871 GateRef propKey = acc;
3872 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
3873 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3874 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3875
3876 AccessObjectStubBuilder builder(this, globalEnv);
3877 GateRef result = builder.LoadObjByValue(glue, receiver, propKey, profileTypeInfo, slotId, callback);
3878 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDOBJBYVALUE_IMM8_V8));
3879 }
3880
DECLARE_ASM_HANDLER(HandleLdobjbyvalueImm16V8)3881 DECLARE_ASM_HANDLER(HandleLdobjbyvalueImm16V8)
3882 {
3883 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3884
3885 GateRef v0 = ReadInst8_2(pc);
3886 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3887 GateRef propKey = acc;
3888 GateRef slotId = ZExtInt8ToInt32(ReadInst16_0(pc));
3889 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3890 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3891
3892 AccessObjectStubBuilder builder(this, globalEnv);
3893 GateRef result = builder.LoadObjByValue(glue, receiver, propKey, profileTypeInfo, slotId, callback);
3894 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDOBJBYVALUE_IMM16_V8));
3895 }
3896
DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbyvaluePrefV8V8)3897 DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbyvaluePrefV8V8)
3898 {
3899 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3900
3901 GateRef v0 = ReadInst8_1(pc);
3902 GateRef v1 = ReadInst8_2(pc);
3903 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3904 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
3905 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3906 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3907
3908 AccessObjectStubBuilder builder(this, globalEnv);
3909 GateRef result = builder.DeprecatedLoadObjByValue(glue, receiver, propKey);
3910 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(DEPRECATED_LDOBJBYVALUE_PREF_V8_V8));
3911 }
3912
DECLARE_ASM_HANDLER(HandleLdsuperbynameImm8Id16)3913 DECLARE_ASM_HANDLER(HandleLdsuperbynameImm8Id16)
3914 {
3915 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3916
3917 GateRef stringId = ReadInst16_1(pc);
3918 GateRef receiver = acc;
3919 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
3920 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3921 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), { receiver, propKey });
3922 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDSUPERBYNAME_IMM8_ID16));
3923 }
3924
DECLARE_ASM_HANDLER(HandleLdsuperbynameImm16Id16)3925 DECLARE_ASM_HANDLER(HandleLdsuperbynameImm16Id16)
3926 {
3927 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3928
3929 GateRef stringId = ReadInst16_2(pc);
3930 GateRef receiver = acc;
3931 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
3932 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3933 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), { receiver, propKey });
3934 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDSUPERBYNAME_IMM16_ID16));
3935 }
3936
DECLARE_ASM_HANDLER(HandleDeprecatedLdsuperbynamePrefId32V8)3937 DECLARE_ASM_HANDLER(HandleDeprecatedLdsuperbynamePrefId32V8)
3938 {
3939 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
3940
3941 GateRef stringId = ReadInst32_1(pc);
3942 GateRef v0 = ReadInst8_5(pc);
3943 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
3944 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
3945 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3946 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdSuperByValue), { receiver, propKey });
3947 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(DEPRECATED_LDSUPERBYNAME_PREF_ID32_V8));
3948 }
3949
DECLARE_ASM_HANDLER(HandleLdobjbyindexImm8Imm16)3950 DECLARE_ASM_HANDLER(HandleLdobjbyindexImm8Imm16)
3951 {
3952 auto env = GetEnvironment();
3953
3954 GateRef receiver = acc;
3955 GateRef index = ZExtInt16ToInt32(ReadInst16_1(pc));
3956 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3957 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3958 Label fastPath(env);
3959 Label slowPath(env);
3960 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
3961 Bind(&fastPath);
3962 {
3963 SetCurrentGlobalEnv(globalEnv);
3964 GateRef result = GetPropertyByIndex(glue, receiver, index, callback);
3965 Label notHole(env);
3966 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
3967 Bind(¬Hole);
3968 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDOBJBYINDEX_IMM8_IMM16));
3969 }
3970 Bind(&slowPath);
3971 {
3972 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex),
3973 { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() });
3974 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDOBJBYINDEX_IMM8_IMM16));
3975 }
3976 }
3977
DECLARE_ASM_HANDLER(HandleLdobjbyindexImm16Imm16)3978 DECLARE_ASM_HANDLER(HandleLdobjbyindexImm16Imm16)
3979 {
3980 auto env = GetEnvironment();
3981
3982 GateRef receiver = acc;
3983 GateRef index = ZExtInt16ToInt32(ReadInst16_2(pc));
3984 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
3985 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
3986 Label fastPath(env);
3987 Label slowPath(env);
3988 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
3989 Bind(&fastPath);
3990 {
3991 SetCurrentGlobalEnv(globalEnv);
3992 GateRef result = GetPropertyByIndex(glue, receiver, index, callback);
3993 Label notHole(env);
3994 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
3995 Bind(¬Hole);
3996 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDOBJBYINDEX_IMM16_IMM16));
3997 }
3998 Bind(&slowPath);
3999 {
4000 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex),
4001 { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() });
4002 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(LDOBJBYINDEX_IMM16_IMM16));
4003 }
4004 }
4005
DECLARE_ASM_HANDLER(HandleWideLdobjbyindexPrefImm32)4006 DECLARE_ASM_HANDLER(HandleWideLdobjbyindexPrefImm32)
4007 {
4008 auto env = GetEnvironment();
4009
4010 GateRef receiver = acc;
4011 GateRef index = ReadInst32_1(pc);
4012 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4013 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4014 Label fastPath(env);
4015 Label slowPath(env);
4016 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
4017 Bind(&fastPath);
4018 {
4019 SetCurrentGlobalEnv(globalEnv);
4020 GateRef result = GetPropertyByIndex(glue, receiver, index, callback);
4021 Label notHole(env);
4022 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
4023 Bind(¬Hole);
4024 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(WIDE_LDOBJBYINDEX_PREF_IMM32));
4025 }
4026 Bind(&slowPath);
4027 {
4028 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex),
4029 { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() });
4030 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(WIDE_LDOBJBYINDEX_PREF_IMM32));
4031 }
4032 }
4033
DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbyindexPrefV8Imm32)4034 DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbyindexPrefV8Imm32)
4035 {
4036 auto env = GetEnvironment();
4037
4038 GateRef v0 = ReadInst8_1(pc);
4039 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4040 GateRef index = ReadInst32_2(pc);
4041 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4042 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4043 Label fastPath(env);
4044 Label slowPath(env);
4045 BRANCH(TaggedIsHeapObject(receiver), &fastPath, &slowPath);
4046 Bind(&fastPath);
4047 {
4048 SetCurrentGlobalEnv(globalEnv);
4049 GateRef result = GetPropertyByIndex(glue, receiver, index, callback);
4050 Label notHole(env);
4051 BRANCH(TaggedIsHole(result), &slowPath, ¬Hole);
4052 Bind(¬Hole);
4053 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_LDOBJBYINDEX_PREF_V8_IMM32));
4054 }
4055 Bind(&slowPath);
4056 {
4057 GateRef result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdObjByIndex),
4058 { receiver, IntToTaggedInt(index), TaggedFalse(), Undefined() });
4059 CHECK_EXCEPTION_WITH_ACC(result, INT_PTR(DEPRECATED_LDOBJBYINDEX_PREF_V8_IMM32));
4060 }
4061 }
4062
DECLARE_ASM_HANDLER(HandleStconsttoglobalrecordImm16Id16)4063 DECLARE_ASM_HANDLER(HandleStconsttoglobalrecordImm16Id16)
4064 {
4065 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4066
4067 GateRef stringId = ReadInst16_2(pc);
4068 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
4069 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4070 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord),
4071 { propKey, *varAcc, TaggedTrue() });
4072 CHECK_EXCEPTION_VARACC(result, INT_PTR(STCONSTTOGLOBALRECORD_IMM16_ID16));
4073 }
4074
DECLARE_ASM_HANDLER(HandleSttoglobalrecordImm16Id16)4075 DECLARE_ASM_HANDLER(HandleSttoglobalrecordImm16Id16)
4076 {
4077 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4078
4079 GateRef stringId = ReadInst16_2(pc);
4080 GateRef propKey = GetStringFromConstPool(glue, constpool, ZExtInt16ToInt32(stringId));
4081 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4082 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord),
4083 { propKey, *varAcc, TaggedFalse() });
4084 CHECK_EXCEPTION_VARACC(result, INT_PTR(STTOGLOBALRECORD_IMM16_ID16));
4085 }
4086
DECLARE_ASM_HANDLER(HandleDeprecatedStconsttoglobalrecordPrefId32)4087 DECLARE_ASM_HANDLER(HandleDeprecatedStconsttoglobalrecordPrefId32)
4088 {
4089 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4090
4091 GateRef stringId = ReadInst32_1(pc);
4092 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
4093 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4094 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord),
4095 { propKey, *varAcc, TaggedTrue() });
4096 CHECK_EXCEPTION_VARACC(result, INT_PTR(DEPRECATED_STCONSTTOGLOBALRECORD_PREF_ID32));
4097 }
4098
DECLARE_ASM_HANDLER(HandleDeprecatedStlettoglobalrecordPrefId32)4099 DECLARE_ASM_HANDLER(HandleDeprecatedStlettoglobalrecordPrefId32)
4100 {
4101 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4102
4103 GateRef stringId = ReadInst32_1(pc);
4104 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
4105 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4106 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord),
4107 { propKey, *varAcc, TaggedFalse() });
4108 CHECK_EXCEPTION_VARACC(result, INT_PTR(DEPRECATED_STLETTOGLOBALRECORD_PREF_ID32));
4109 }
4110
DECLARE_ASM_HANDLER(HandleDeprecatedStclasstoglobalrecordPrefId32)4111 DECLARE_ASM_HANDLER(HandleDeprecatedStclasstoglobalrecordPrefId32)
4112 {
4113 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4114
4115 GateRef stringId = ReadInst32_1(pc);
4116 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
4117 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4118 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StGlobalRecord),
4119 { propKey, *varAcc, TaggedFalse() });
4120 CHECK_EXCEPTION_VARACC(result, INT_PTR(DEPRECATED_STCLASSTOGLOBALRECORD_PREF_ID32));
4121 }
4122
DECLARE_ASM_HANDLER(HandleGetmodulenamespaceImm8)4123 DECLARE_ASM_HANDLER(HandleGetmodulenamespaceImm8)
4124 {
4125 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4126
4127 GateRef index = ReadInst8_0(pc);
4128 #if ENABLE_NEXT_OPTIMIZATION
4129 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4130 GateRef module = GetModuleFromFunction(glue, currentFunc);
4131 GateRef moduleRef = LoadModuleNamespaceByIndex(glue, ZExtInt8ToInt32(index), module);
4132 #else
4133 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4134 GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetModuleNamespaceByIndex),
4135 { IntToTaggedInt(index) });
4136 #endif
4137 varAcc = moduleRef;
4138 DISPATCH_WITH_ACC(GETMODULENAMESPACE_IMM8);
4139 }
4140
DECLARE_ASM_HANDLER(HandleWideGetmodulenamespacePrefImm16)4141 DECLARE_ASM_HANDLER(HandleWideGetmodulenamespacePrefImm16)
4142 {
4143 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4144
4145 GateRef index = ReadInst16_1(pc);
4146 #if ENABLE_NEXT_OPTIMIZATION
4147 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4148 GateRef module = GetModuleFromFunction(glue, currentFunc);
4149 GateRef moduleRef = LoadModuleNamespaceByIndex(glue, ZExtInt16ToInt32(index), module);
4150 #else
4151 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4152 GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetModuleNamespaceByIndex),
4153 { Int16ToTaggedInt(index) });
4154 #endif
4155 varAcc = moduleRef;
4156 DISPATCH_WITH_ACC(WIDE_GETMODULENAMESPACE_PREF_IMM16);
4157 }
4158
DECLARE_ASM_HANDLER(HandleDeprecatedGetmodulenamespacePrefId32)4159 DECLARE_ASM_HANDLER(HandleDeprecatedGetmodulenamespacePrefId32)
4160 {
4161 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4162
4163 GateRef stringId = ReadInst32_1(pc);
4164 GateRef prop = GetStringFromConstPool(glue, constpool, stringId);
4165 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4166 GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(GetModuleNamespace), { prop });
4167 varAcc = moduleRef;
4168 DISPATCH_WITH_ACC(DEPRECATED_GETMODULENAMESPACE_PREF_ID32);
4169 }
4170
DECLARE_ASM_HANDLER(HandleLdlocalmodulevarImm8)4171 DECLARE_ASM_HANDLER(HandleLdlocalmodulevarImm8)
4172 {
4173 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4174
4175 GateRef index = ReadInst8_0(pc);
4176 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4177 GateRef module = GetModuleFromFunction(glue, currentFunc);
4178 varAcc = Loadlocalmodulevar(glue, index, module);
4179 DISPATCH_WITH_ACC(LDLOCALMODULEVAR_IMM8);
4180 }
4181
DECLARE_ASM_HANDLER(HandleWideLdlocalmodulevarPrefImm16)4182 DECLARE_ASM_HANDLER(HandleWideLdlocalmodulevarPrefImm16)
4183 {
4184 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4185
4186 GateRef index = ReadInst16_1(pc);
4187 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4188 GateRef module = GetModuleFromFunction(glue, currentFunc);
4189 varAcc = Loadlocalmodulevar(glue, index, module);
4190 DISPATCH_WITH_ACC(WIDE_LDLOCALMODULEVAR_PREF_IMM16);
4191 }
4192
DECLARE_ASM_HANDLER(HandleLdexternalmodulevarImm8)4193 DECLARE_ASM_HANDLER(HandleLdexternalmodulevarImm8)
4194 {
4195 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4196
4197 GateRef index = ReadInst8_0(pc);
4198 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4199 GateRef module = GetModuleFromFunction(glue, currentFunc);
4200 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4201 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4202 SetCurrentGlobalEnv(globalEnv);
4203 #if ENABLE_NEXT_OPTIMIZATION
4204 GateRef indexInt32 = ZExtInt8ToInt32(index);
4205 varAcc = LoadExternalmodulevar(glue, indexInt32, module);
4206 #else
4207 varAcc = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdExternalModuleVarByIndexWithModule),
4208 {Int8ToTaggedInt(index), module});
4209 #endif
4210 DISPATCH_WITH_ACC(LDEXTERNALMODULEVAR_IMM8);
4211 }
4212
DECLARE_ASM_HANDLER(HandleWideLdexternalmodulevarPrefImm16)4213 DECLARE_ASM_HANDLER(HandleWideLdexternalmodulevarPrefImm16)
4214 {
4215 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4216
4217 GateRef index = ReadInst16_1(pc);
4218 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4219 GateRef module = GetModuleFromFunction(glue, currentFunc);
4220 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4221 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4222 SetCurrentGlobalEnv(globalEnv);
4223 #if ENABLE_NEXT_OPTIMIZATION
4224 GateRef indexInt32 = ZExtInt16ToInt32(index);
4225 varAcc = LoadExternalmodulevar(glue, indexInt32, module);
4226 #else
4227 varAcc = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(LdExternalModuleVarByIndexWithModule),
4228 {Int16ToTaggedInt(index), module});
4229 #endif
4230 DISPATCH_WITH_ACC(WIDE_LDEXTERNALMODULEVAR_PREF_IMM16);
4231 }
4232
DECLARE_ASM_HANDLER(HandleDeprecatedLdmodulevarPrefId32Imm8)4233 DECLARE_ASM_HANDLER(HandleDeprecatedLdmodulevarPrefId32Imm8)
4234 {
4235 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4236
4237 GateRef stringId = ReadInst32_1(pc);
4238 GateRef flag = ZExtInt8ToInt32(ReadInst8_5(pc));
4239 GateRef key = GetStringFromConstPool(glue, constpool, stringId);
4240 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4241 GateRef moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdModuleVar),
4242 { key, IntToTaggedInt(flag) });
4243 varAcc = moduleRef;
4244 DISPATCH_WITH_ACC(DEPRECATED_LDMODULEVAR_PREF_ID32_IMM8);
4245 }
4246
DECLARE_ASM_HANDLER(HandleStmodulevarImm8)4247 DECLARE_ASM_HANDLER(HandleStmodulevarImm8)
4248 {
4249 GateRef index = ReadInst8_0(pc);
4250 GateRef value = acc;
4251 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4252 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StModuleVarByIndex), { IntToTaggedInt(index), value });
4253 DISPATCH(STMODULEVAR_IMM8);
4254 }
4255
DECLARE_ASM_HANDLER(HandleWideStmodulevarPrefImm16)4256 DECLARE_ASM_HANDLER(HandleWideStmodulevarPrefImm16)
4257 {
4258 GateRef index = ReadInst16_1(pc);
4259 GateRef value = acc;
4260 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4261 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StModuleVarByIndex), { Int16ToTaggedInt(index), value });
4262 DISPATCH(WIDE_STMODULEVAR_PREF_IMM16);
4263 }
4264
DECLARE_ASM_HANDLER(HandleDeprecatedStmodulevarPrefId32)4265 DECLARE_ASM_HANDLER(HandleDeprecatedStmodulevarPrefId32)
4266 {
4267 GateRef stringId = ReadInst32_1(pc);
4268 GateRef prop = GetStringFromConstPool(glue, constpool, stringId);
4269 GateRef value = acc;
4270 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4271 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StModuleVar), { prop, value });
4272 DISPATCH(DEPRECATED_STMODULEVAR_PREF_ID32);
4273 }
4274
DECLARE_ASM_HANDLER(HandleNewlexenvImm8)4275 DECLARE_ASM_HANDLER(HandleNewlexenvImm8)
4276 {
4277 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4278 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
4279 auto env = GetEnvironment();
4280 GateRef numVars = ReadInst8_0(pc);
4281 GateRef state = GetFrame(sp);
4282 auto parent = GetEnvFromFrame(glue, state);
4283 NewObjectStubBuilder newBuilder(this);
4284 newBuilder.SetParameters(glue, 0);
4285 Label afterNew(env);
4286 newBuilder.NewLexicalEnv(&result, &afterNew, ZExtInt16ToInt32(numVars), parent);
4287 Bind(&afterNew);
4288 Label notException(env);
4289 CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
4290 Bind(¬Exception);
4291 varAcc = *result;
4292 SetEnvToFrame(glue, GetFrame(sp), *result);
4293 DISPATCH_WITH_ACC(NEWLEXENV_IMM8);
4294 }
4295
DECLARE_ASM_HANDLER(HandleWideNewlexenvPrefImm16)4296 DECLARE_ASM_HANDLER(HandleWideNewlexenvPrefImm16)
4297 {
4298 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4299 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
4300 auto env = GetEnvironment();
4301 GateRef numVars = ReadInst16_1(pc);
4302 GateRef state = GetFrame(sp);
4303 auto parent = GetEnvFromFrame(glue, state);
4304 NewObjectStubBuilder newBuilder(this);
4305 newBuilder.SetParameters(glue, 0);
4306 Label afterNew(env);
4307 newBuilder.NewLexicalEnv(&result, &afterNew, ZExtInt16ToInt32(numVars), parent);
4308 Bind(&afterNew);
4309 Label notException(env);
4310 CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
4311 Bind(¬Exception);
4312 varAcc = *result;
4313 SetEnvToFrame(glue, GetFrame(sp), *result);
4314 DISPATCH_WITH_ACC(WIDE_NEWLEXENV_PREF_IMM16);
4315 }
4316
DECLARE_ASM_HANDLER(HandleNewlexenvwithnameImm8Id16)4317 DECLARE_ASM_HANDLER(HandleNewlexenvwithnameImm8Id16)
4318 {
4319 auto env = GetEnvironment();
4320 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4321 GateRef numVars = ZExtInt8ToInt16(ReadInst8_0(pc));
4322 GateRef scopeId = ReadInst16_1(pc);
4323 GateRef state = GetFrame(sp);
4324 GateRef currentEnv = GetEnvFromFrame(glue, state);
4325 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewLexicalEnvWithName),
4326 { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) });
4327 Label notException(env);
4328 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
4329 Bind(¬Exception);
4330 varAcc = res;
4331 SetEnvToFrame(glue, state, res);
4332 DISPATCH_WITH_ACC(NEWLEXENVWITHNAME_IMM8_ID16);
4333 }
4334
DECLARE_ASM_HANDLER(HandleWideNewlexenvwithnamePrefImm16Id16)4335 DECLARE_ASM_HANDLER(HandleWideNewlexenvwithnamePrefImm16Id16)
4336 {
4337 auto env = GetEnvironment();
4338 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4339 GateRef numVars = ReadInst16_1(pc);
4340 GateRef scopeId = ReadInst16_3(pc);
4341 GateRef state = GetFrame(sp);
4342 GateRef currentEnv = GetEnvFromFrame(glue, state);
4343 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewLexicalEnvWithName),
4344 { Int16ToTaggedInt(numVars), Int16ToTaggedInt(scopeId) });
4345 Label notException(env);
4346 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
4347 Bind(¬Exception);
4348 varAcc = res;
4349 SetEnvToFrame(glue, state, res);
4350 DISPATCH_WITH_ACC(WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16);
4351 }
4352
DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm8Id16Id16Imm16V8)4353 DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm8Id16Id16Imm16V8)
4354 {
4355 auto env = GetEnvironment();
4356 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4357
4358 GateRef methodId = ReadInst16_1(pc);
4359 GateRef literalId = ReadInst16_3(pc);
4360 GateRef length = ReadInst16_5(pc);
4361 GateRef v0 = ReadInst8_7(pc);
4362 GateRef frame = GetFrame(sp);
4363 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4364 GateRef currentEnv = GetEnvFromFrame(glue, frame);
4365 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4366 GateRef module = GetModuleFromFunction(glue, currentFunc);
4367 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateClassWithBuffer),
4368 { proto, currentEnv, constpool, Int16ToTaggedInt(methodId), Int16ToTaggedInt(literalId),
4369 module, Int16ToTaggedInt(length) });
4370
4371 Label isException(env);
4372 Label isNotException(env);
4373 BRANCH(TaggedIsException(res), &isException, &isNotException);
4374 Bind(&isException);
4375 {
4376 DISPATCH_LAST_WITH_ACC();
4377 }
4378 Bind(&isNotException);
4379 #if ECMASCRIPT_ENABLE_IC
4380 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
4381 UpdateProfileTypeInfoCellToFunction(glue, res, profileTypeInfo, slotId);
4382 callback.ProfileDefineClass(res);
4383 #endif
4384 varAcc = res;
4385 DISPATCH_WITH_ACC(DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8);
4386 }
4387
DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm16Id16Id16Imm16V8)4388 DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm16Id16Id16Imm16V8)
4389 {
4390 auto env = GetEnvironment();
4391 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4392
4393 GateRef methodId = ReadInst16_2(pc);
4394 GateRef literalId = ReadInst16_4(pc);
4395 GateRef length = ReadInst16_6(pc);
4396 GateRef v0 = ReadInst8_8(pc);
4397 GateRef frame = GetFrame(sp);
4398 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4399 GateRef currentEnv = GetEnvFromFrame(glue, frame);
4400 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4401 GateRef module = GetModuleFromFunction(glue, currentFunc);
4402 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateClassWithBuffer),
4403 { proto, currentEnv, constpool, Int16ToTaggedInt(methodId),
4404 Int16ToTaggedInt(literalId), module, Int16ToTaggedInt(length) });
4405
4406 Label isException(env);
4407 Label isNotException(env);
4408 BRANCH(TaggedIsException(res), &isException, &isNotException);
4409 Bind(&isException);
4410 {
4411 DISPATCH_LAST_WITH_ACC();
4412 }
4413 Bind(&isNotException);
4414 #if ECMASCRIPT_ENABLE_IC
4415 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
4416 UpdateProfileTypeInfoCellToFunction(glue, res, profileTypeInfo, slotId);
4417 callback.ProfileDefineClass(res);
4418 #endif
4419 varAcc = res;
4420 DISPATCH_WITH_ACC(DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8);
4421 }
4422
DECLARE_ASM_HANDLER(HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8)4423 DECLARE_ASM_HANDLER(HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8)
4424 {
4425 auto env = GetEnvironment();
4426 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4427
4428 GateRef methodId = ReadInst16_1(pc);
4429 GateRef literalId = ReadInst16_3(pc);
4430 GateRef length = ReadInst16_5(pc);
4431 GateRef v0 = ReadInst8_7(pc);
4432 GateRef v1 = ReadInst8_8(pc);
4433
4434 GateRef lexicalEnv = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
4435 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
4436 GateRef frame = GetFrame(sp);
4437 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4438 GateRef module = GetModuleFromFunction(glue, currentFunc);
4439 GateRef currentEnv = GetEnvFromFrame(glue, frame);
4440 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateClassWithBuffer),
4441 { proto, lexicalEnv, constpool, Int16ToTaggedInt(methodId),
4442 Int16ToTaggedInt(literalId), module, Int16ToTaggedInt(length) });
4443
4444 Label isException(env);
4445 Label isNotException(env);
4446 BRANCH(TaggedIsException(res), &isException, &isNotException);
4447 Bind(&isException);
4448 {
4449 DISPATCH_LAST_WITH_ACC();
4450 }
4451 Bind(&isNotException);
4452 varAcc = res;
4453 DISPATCH_WITH_ACC(DEPRECATED_DEFINECLASSWITHBUFFER_PREF_ID16_IMM16_IMM16_V8_V8);
4454 }
4455
DECLARE_ASM_HANDLER(HandleLdobjbynameImm8Id16)4456 DECLARE_ASM_HANDLER(HandleLdobjbynameImm8Id16)
4457 {
4458 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4459
4460 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
4461 GateRef receiver = acc;
4462 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4463 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4464 AccessObjectStubBuilder builder(this, globalEnv);
4465 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16);
4466 GateRef result = builder.LoadObjByName(glue, receiver, 0, info, profileTypeInfo, slotId, callback);
4467 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDOBJBYNAME_IMM8_ID16));
4468 }
4469
DECLARE_ASM_HANDLER(HandleLdobjbynameImm16Id16)4470 DECLARE_ASM_HANDLER(HandleLdobjbynameImm16Id16)
4471 {
4472 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4473
4474 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
4475 GateRef receiver = acc;
4476 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4477 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4478 AccessObjectStubBuilder builder(this, globalEnv);
4479 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
4480 GateRef result = builder.LoadObjByName(glue, receiver, 0, info, profileTypeInfo, slotId, callback);
4481 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDOBJBYNAME_IMM16_ID16));
4482 }
4483
DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbynamePrefId32V8)4484 DECLARE_ASM_HANDLER(HandleDeprecatedLdobjbynamePrefId32V8)
4485 {
4486 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4487
4488 GateRef receiver = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_5(pc)));
4489 GateRef stringId = ReadInst32_1(pc);
4490 GateRef propKey = GetStringFromConstPool(glue, constpool, stringId);
4491 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4492 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4493 AccessObjectStubBuilder builder(this, globalEnv);
4494 GateRef result = builder.DeprecatedLoadObjByName(glue, receiver, propKey);
4495 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(DEPRECATED_LDOBJBYNAME_PREF_ID32_V8));
4496 }
4497
DECLARE_ASM_HANDLER(HandleCallarg0Imm8)4498 DECLARE_ASM_HANDLER(HandleCallarg0Imm8)
4499 {
4500 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG0);
4501 GateRef func = acc;
4502 METHOD_ENTRY(func);
4503 GateRef jumpSize = INT_PTR(CALLARG0_IMM8);
4504 JSCallArgs callArgs(JSCallMode::CALL_ARG0);
4505 callArgs.callArgs = { 0, 0, 0 };
4506 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4507 GateRef res = callBuilder.JSCallDispatch();
4508 CHECK_PENDING_EXCEPTION(res, jumpSize);
4509 }
4510
DECLARE_ASM_HANDLER(HandleDeprecatedCallarg0PrefV8)4511 DECLARE_ASM_HANDLER(HandleDeprecatedCallarg0PrefV8)
4512 {
4513 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG0);
4514 GateRef funcReg = ReadInst8_1(pc);
4515 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4516 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARG0_PREF_V8);
4517 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG0);
4518 callArgs.callArgs = { 0, 0, 0 };
4519 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4520 GateRef res = callBuilder.JSCallDispatch();
4521 CHECK_PENDING_EXCEPTION(res, jumpSize);
4522 }
4523
DECLARE_ASM_HANDLER(HandleCallarg1Imm8V8)4524 DECLARE_ASM_HANDLER(HandleCallarg1Imm8V8)
4525 {
4526 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG1);
4527 GateRef a0 = ReadInst8_1(pc);
4528 GateRef func = acc;
4529 METHOD_ENTRY(func);
4530 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4531 GateRef jumpSize = INT_PTR(CALLARG1_IMM8_V8);
4532 JSCallArgs callArgs(JSCallMode::CALL_ARG1);
4533 callArgs.callArgs = { a0Value, 0, 0 };
4534 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4535 GateRef res = callBuilder.JSCallDispatch();
4536 CHECK_PENDING_EXCEPTION(res, jumpSize);
4537 }
4538
DECLARE_ASM_HANDLER(HandleDeprecatedCallarg1PrefV8V8)4539 DECLARE_ASM_HANDLER(HandleDeprecatedCallarg1PrefV8V8)
4540 {
4541 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG1);
4542 GateRef funcReg = ReadInst8_1(pc);
4543 GateRef a0 = ReadInst8_2(pc);
4544 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4545 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4546 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARG1_PREF_V8_V8);
4547 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG1);
4548 callArgs.callArgs = { a0Value, 0, 0 };
4549 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4550 GateRef res = callBuilder.JSCallDispatch();
4551 CHECK_PENDING_EXCEPTION(res, jumpSize);
4552 }
4553
DECLARE_ASM_HANDLER(HandleCallargs2Imm8V8V8)4554 DECLARE_ASM_HANDLER(HandleCallargs2Imm8V8V8)
4555 {
4556 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARGS2);
4557 GateRef a0 = ReadInst8_1(pc);
4558 GateRef a1 = ReadInst8_2(pc);
4559 GateRef func = acc;
4560 METHOD_ENTRY(func);
4561 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4562 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4563 GateRef jumpSize = INT_PTR(CALLARGS2_IMM8_V8_V8);
4564 JSCallArgs callArgs(JSCallMode::CALL_ARG2);
4565 callArgs.callArgs = { a0Value, a1Value, 0 };
4566 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4567 GateRef res = callBuilder.JSCallDispatch();
4568 CHECK_PENDING_EXCEPTION(res, jumpSize);
4569 }
4570
DECLARE_ASM_HANDLER(HandleDeprecatedCallargs2PrefV8V8V8)4571 DECLARE_ASM_HANDLER(HandleDeprecatedCallargs2PrefV8V8V8)
4572 {
4573 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARGS2);
4574 GateRef funcReg = ReadInst8_1(pc);
4575 GateRef a0 = ReadInst8_2(pc);
4576 GateRef a1 = ReadInst8_3(pc);
4577 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4578 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4579 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4580 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARGS2_PREF_V8_V8_V8);
4581 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG2);
4582 callArgs.callArgs = { a0Value, a1Value, 0 };
4583 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4584 GateRef res = callBuilder.JSCallDispatch();
4585 CHECK_PENDING_EXCEPTION(res, jumpSize);
4586 }
4587
DECLARE_ASM_HANDLER(HandleCallargs3Imm8V8V8V8)4588 DECLARE_ASM_HANDLER(HandleCallargs3Imm8V8V8V8)
4589 {
4590 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARGS3);
4591 GateRef a0 = ReadInst8_1(pc);
4592 GateRef a1 = ReadInst8_2(pc);
4593 GateRef a2 = ReadInst8_3(pc);
4594 GateRef func = acc;
4595 METHOD_ENTRY(func);
4596 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4597 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4598 GateRef a2Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a2));
4599 GateRef jumpSize = INT_PTR(CALLARGS3_IMM8_V8_V8_V8);
4600 JSCallArgs callArgs(JSCallMode::CALL_ARG3);
4601 callArgs.callArgs = { a0Value, a1Value, a2Value };
4602 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4603 GateRef res = callBuilder.JSCallDispatch();
4604 CHECK_PENDING_EXCEPTION(res, jumpSize);
4605 }
4606
DECLARE_ASM_HANDLER(HandleDeprecatedCallargs3PrefV8V8V8V8)4607 DECLARE_ASM_HANDLER(HandleDeprecatedCallargs3PrefV8V8V8V8)
4608 {
4609 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARGS3);
4610 GateRef funcReg = ReadInst8_1(pc);
4611 GateRef a0 = ReadInst8_2(pc);
4612 GateRef a1 = ReadInst8_3(pc);
4613 GateRef a2 = ReadInst8_4(pc);
4614 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4615 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4616 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4617 GateRef a2Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a2));
4618 GateRef jumpSize = INT_PTR(DEPRECATED_CALLARGS3_PREF_V8_V8_V8_V8);
4619 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_ARG3);
4620 callArgs.callArgs = { a0Value, a1Value, a2Value };
4621 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4622 GateRef res = callBuilder.JSCallDispatch();
4623 CHECK_PENDING_EXCEPTION(res, jumpSize);
4624 }
4625
DECLARE_ASM_HANDLER(HandleCallrangeImm8Imm8V8)4626 DECLARE_ASM_HANDLER(HandleCallrangeImm8Imm8V8)
4627 {
4628 GateRef actualNumArgs = ZExtInt8ToInt32(ReadInst8_1(pc));
4629 GateRef func = acc;
4630 METHOD_ENTRY(func);
4631 GateRef argv = PtrAdd(sp, PtrMul(ZExtInt8ToPtr(ReadInst8_2(pc)), IntPtr(8))); // 8: byteSize
4632 GateRef jumpSize = INT_PTR(CALLRANGE_IMM8_IMM8_V8);
4633 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4634 JSCallArgs callArgs(JSCallMode::CALL_WITH_ARGV);
4635 callArgs.callArgv = { numArgs, argv };
4636 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4637 GateRef res = callBuilder.JSCallDispatch();
4638 CHECK_PENDING_EXCEPTION(res, jumpSize);
4639 }
4640
DECLARE_ASM_HANDLER(HandleWideCallrangePrefImm16V8)4641 DECLARE_ASM_HANDLER(HandleWideCallrangePrefImm16V8)
4642 {
4643 GateRef actualNumArgs = ZExtInt16ToInt32(ReadInst16_1(pc));
4644 GateRef func = acc;
4645 METHOD_ENTRY(func);
4646 GateRef argv = PtrAdd(sp, PtrMul(ZExtInt8ToPtr(ReadInst8_2(pc)), IntPtr(8))); // 8: byteSize
4647 GateRef jumpSize = INT_PTR(WIDE_CALLRANGE_PREF_IMM16_V8);
4648 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4649 JSCallArgs callArgs(JSCallMode::CALL_WITH_ARGV);
4650 callArgs.callArgv = { numArgs, argv };
4651 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4652 GateRef res = callBuilder.JSCallDispatch();
4653 CHECK_PENDING_EXCEPTION(res, jumpSize);
4654 }
4655
DECLARE_ASM_HANDLER(HandleDeprecatedCallrangePrefImm16V8)4656 DECLARE_ASM_HANDLER(HandleDeprecatedCallrangePrefImm16V8)
4657 {
4658 GateRef actualNumArgs = ZExtInt16ToInt32(ReadInst16_1(pc));
4659 GateRef funcReg = ReadInst8_3(pc);
4660 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(funcReg));
4661 GateRef argv = PtrAdd(sp, PtrMul(
4662 PtrAdd(ZExtInt8ToPtr(funcReg), IntPtr(1)), IntPtr(8))); // 1: skip function
4663 GateRef jumpSize = INT_PTR(DEPRECATED_CALLRANGE_PREF_IMM16_V8);
4664 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4665 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_WITH_ARGV);
4666 callArgs.callArgv = { numArgs, argv };
4667 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4668 GateRef res = callBuilder.JSCallDispatch();
4669 CHECK_PENDING_EXCEPTION(res, jumpSize);
4670 }
4671
DECLARE_ASM_HANDLER(HandleCallthisrangeImm8Imm8V8)4672 DECLARE_ASM_HANDLER(HandleCallthisrangeImm8Imm8V8)
4673 {
4674 GateRef actualNumArgs = ZExtInt8ToInt32(ReadInst8_1(pc));
4675 GateRef thisReg = ZExtInt8ToPtr(ReadInst8_2(pc));
4676 GateRef func = acc;
4677 METHOD_ENTRY(func);
4678 GateRef thisValue = GetVregValue(glue, sp, thisReg);
4679 GateRef argv = PtrAdd(sp, PtrMul(
4680 PtrAdd(thisReg, IntPtr(1)), IntPtr(8))); // 1: skip this
4681 GateRef jumpSize = INT_PTR(CALLTHISRANGE_IMM8_IMM8_V8);
4682 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4683 JSCallArgs callArgs(JSCallMode::CALL_THIS_WITH_ARGV);
4684 callArgs.callArgvWithThis = { numArgs, argv, thisValue };
4685 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4686 GateRef res = callBuilder.JSCallDispatch();
4687 CHECK_PENDING_EXCEPTION(res, jumpSize);
4688 }
4689
DECLARE_ASM_HANDLER(HandleWideCallthisrangePrefImm16V8)4690 DECLARE_ASM_HANDLER(HandleWideCallthisrangePrefImm16V8)
4691 {
4692 GateRef actualNumArgs = ZExtInt16ToInt32(ReadInst16_1(pc));
4693 GateRef thisReg = ZExtInt8ToPtr(ReadInst8_3(pc));
4694 GateRef func = acc;
4695 METHOD_ENTRY(func);
4696 GateRef thisValue = GetVregValue(glue, sp, thisReg);
4697 GateRef argv = PtrAdd(sp, PtrMul(
4698 PtrAdd(thisReg, IntPtr(1)), IntPtr(8))); // 1: skip this
4699 GateRef jumpSize = INT_PTR(WIDE_CALLTHISRANGE_PREF_IMM16_V8);
4700 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4701 JSCallArgs callArgs(JSCallMode::CALL_THIS_WITH_ARGV);
4702 callArgs.callArgvWithThis = { numArgs, argv, thisValue };
4703 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4704 GateRef res = callBuilder.JSCallDispatch();
4705 CHECK_PENDING_EXCEPTION(res, jumpSize);
4706 }
4707
DECLARE_ASM_HANDLER(HandleDeprecatedCallthisrangePrefImm16V8)4708 DECLARE_ASM_HANDLER(HandleDeprecatedCallthisrangePrefImm16V8)
4709 {
4710 GateRef actualNumArgs = Int32Sub(ZExtInt16ToInt32(ReadInst16_1(pc)), Int32(1)); // 1: exclude this
4711 GateRef funcReg = ReadInst8_3(pc);
4712 funcReg = ZExtInt8ToPtr(funcReg);
4713 GateRef func = GetVregValue(glue, sp, funcReg);
4714 GateRef thisValue = GetVregValue(glue, sp, PtrAdd(funcReg, IntPtr(1)));
4715 GateRef argv = PtrAdd(sp, PtrMul(
4716 PtrAdd(funcReg, IntPtr(2)), IntPtr(8))); // 2: skip function&this
4717 GateRef jumpSize = INT_PTR(DEPRECATED_CALLTHISRANGE_PREF_IMM16_V8);
4718 GateRef numArgs = ZExtInt32ToPtr(actualNumArgs);
4719 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_THIS_WITH_ARGV);
4720 callArgs.callArgvWithThis = { numArgs, argv, thisValue };
4721 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4722 GateRef res = callBuilder.JSCallDispatch();
4723 CHECK_PENDING_EXCEPTION(res, jumpSize);
4724 }
4725
DECLARE_ASM_HANDLER(HandleCallthis0Imm8V8)4726 DECLARE_ASM_HANDLER(HandleCallthis0Imm8V8)
4727 {
4728 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG0);
4729 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
4730 GateRef func = acc;
4731 METHOD_ENTRY(func);
4732 GateRef jumpSize = INT_PTR(CALLTHIS0_IMM8_V8);
4733 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG0);
4734 callArgs.callArgsWithThis = { 0, 0, 0, thisValue };
4735 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4736 GateRef res = callBuilder.JSCallDispatch();
4737 CHECK_PENDING_EXCEPTION(res, jumpSize);
4738 }
4739
DECLARE_ASM_HANDLER(HandleCallthis1Imm8V8V8)4740 DECLARE_ASM_HANDLER(HandleCallthis1Imm8V8V8)
4741 {
4742 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG1);
4743 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
4744 GateRef a0 = ReadInst8_2(pc);
4745 GateRef func = acc;
4746 METHOD_ENTRY(func);
4747 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4748 GateRef jumpSize = INT_PTR(CALLTHIS1_IMM8_V8_V8);
4749 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG1);
4750 callArgs.callArgsWithThis = { a0Value, 0, 0, thisValue };
4751 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4752 GateRef res = callBuilder.JSCallDispatch();
4753 CHECK_PENDING_EXCEPTION(res, jumpSize);
4754 }
4755
DECLARE_ASM_HANDLER(HandleCallthis2Imm8V8V8V8)4756 DECLARE_ASM_HANDLER(HandleCallthis2Imm8V8V8V8)
4757 {
4758 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARGS2);
4759 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
4760 GateRef a0 = ReadInst8_2(pc);
4761 GateRef a1 = ReadInst8_3(pc);
4762 GateRef func = acc;
4763 METHOD_ENTRY(func);
4764 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4765 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4766 GateRef jumpSize = INT_PTR(CALLTHIS2_IMM8_V8_V8_V8);
4767 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG2);
4768 callArgs.callArgsWithThis = { a0Value, a1Value, 0, thisValue };
4769 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4770 GateRef res = callBuilder.JSCallDispatch();
4771 CHECK_PENDING_EXCEPTION(res, jumpSize);
4772 }
4773
DECLARE_ASM_HANDLER(HandleCallthis3Imm8V8V8V8V8)4774 DECLARE_ASM_HANDLER(HandleCallthis3Imm8V8V8V8V8)
4775 {
4776 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARGS3);
4777 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
4778 GateRef a0 = ReadInst8_2(pc);
4779 GateRef a1 = ReadInst8_3(pc);
4780 GateRef a2 = ReadInst8_4(pc);
4781 GateRef func = acc;
4782 METHOD_ENTRY(func);
4783 GateRef a0Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a0));
4784 GateRef a1Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a1));
4785 GateRef a2Value = GetVregValue(glue, sp, ZExtInt8ToPtr(a2));
4786 GateRef jumpSize = INT_PTR(CALLTHIS3_IMM8_V8_V8_V8_V8);
4787 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG3);
4788 callArgs.callArgsWithThis = { a0Value, a1Value, a2Value, thisValue };
4789 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
4790 GateRef res = callBuilder.JSCallDispatch();
4791 CHECK_PENDING_EXCEPTION(res, jumpSize);
4792 }
4793
DECLARE_ASM_HANDLER(HandleCreatearraywithbufferImm8Id16)4794 DECLARE_ASM_HANDLER(HandleCreatearraywithbufferImm8Id16)
4795 {
4796 GateRef imm = ZExtInt16ToInt32(ReadInst16_1(pc));
4797 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4798 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
4799 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4800 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4801
4802 NewObjectStubBuilder newBuilder(this, globalEnv);
4803 GateRef res = newBuilder.CreateArrayWithBuffer(
4804 glue, imm, currentFunc, { pc, 0, true }, profileTypeInfo, slotId, callback);
4805 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEARRAYWITHBUFFER_IMM8_ID16));
4806 }
4807
DECLARE_ASM_HANDLER(HandleCreatearraywithbufferImm16Id16)4808 DECLARE_ASM_HANDLER(HandleCreatearraywithbufferImm16Id16)
4809 {
4810 GateRef imm = ZExtInt16ToInt32(ReadInst16_2(pc));
4811 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4812 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
4813 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4814 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4815
4816 NewObjectStubBuilder newBuilder(this, globalEnv);
4817 GateRef res = newBuilder.CreateArrayWithBuffer(
4818 glue, imm, currentFunc, { pc, 0, true }, profileTypeInfo, slotId, callback);
4819 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CREATEARRAYWITHBUFFER_IMM16_ID16));
4820 }
4821
DECLARE_ASM_HANDLER(HandleDeprecatedCreatearraywithbufferPrefImm16)4822 DECLARE_ASM_HANDLER(HandleDeprecatedCreatearraywithbufferPrefImm16)
4823 {
4824 GateRef imm = ZExtInt16ToInt32(ReadInst16_1(pc));
4825 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
4826 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
4827 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4828 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4829
4830 NewObjectStubBuilder newBuilder(this, globalEnv);
4831 GateRef res = newBuilder.CreateArrayWithBuffer(
4832 glue, imm, currentFunc, { pc, 0, true }, profileTypeInfo, slotId, callback);
4833 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_CREATEARRAYWITHBUFFER_PREF_IMM16));
4834 }
4835
DECLARE_ASM_HANDLER(HandleCreateobjectwithbufferImm8Id16)4836 DECLARE_ASM_HANDLER(HandleCreateobjectwithbufferImm8Id16)
4837 {
4838 GateRef imm = ZExtInt16ToInt32(ReadInst16_1(pc));
4839 GateRef frame = GetFrame(sp);
4840 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4841 GateRef module = GetModuleFromFunction(glue, currentFunc);
4842 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
4843 GateRef currentEnv = GetEnvFromFrame(glue, frame);
4844 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4845 NewObjectStubBuilder newBuilder(this, globalEnv);
4846 GateRef res = newBuilder.CreateObjectHavingMethod(glue, result, currentEnv);
4847
4848 auto env = GetEnvironment();
4849 Label isException(env);
4850 Label isNotException(env);
4851 BRANCH(TaggedIsException(res), &isException, &isNotException);
4852 Bind(&isException);
4853 DISPATCH_LAST();
4854 Bind(&isNotException);
4855 callback.ProfileCreateObject(res);
4856 DEFVARIABLE(varAcc, VariableType::JS_ANY(), res);
4857 DISPATCH_VARACC(INT_PTR(CREATEOBJECTWITHBUFFER_IMM8_ID16));
4858 }
4859
DECLARE_ASM_HANDLER(HandleCreateobjectwithbufferImm16Id16)4860 DECLARE_ASM_HANDLER(HandleCreateobjectwithbufferImm16Id16)
4861 {
4862 GateRef imm = ZExtInt16ToInt32(ReadInst16_2(pc));
4863 GateRef frame = GetFrame(sp);
4864 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4865 GateRef module = GetModuleFromFunction(glue, currentFunc);
4866 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
4867 GateRef currentEnv = GetEnvFromFrame(glue, frame);
4868 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
4869 NewObjectStubBuilder newBuilder(this, globalEnv);
4870 GateRef res = newBuilder.CreateObjectHavingMethod(glue, result, currentEnv);
4871
4872 auto env = GetEnvironment();
4873 Label isException(env);
4874 Label isNotException(env);
4875 BRANCH(TaggedIsException(res), &isException, &isNotException);
4876 Bind(&isException);
4877 DISPATCH_LAST();
4878 Bind(&isNotException);
4879 callback.ProfileCreateObject(res);
4880 DEFVARIABLE(varAcc, VariableType::JS_ANY(), res);
4881 DISPATCH_VARACC(INT_PTR(CREATEOBJECTWITHBUFFER_IMM16_ID16));
4882 }
4883
DECLARE_ASM_HANDLER(HandleDeprecatedCreateobjectwithbufferPrefImm16)4884 DECLARE_ASM_HANDLER(HandleDeprecatedCreateobjectwithbufferPrefImm16)
4885 {
4886 GateRef imm = ZExtInt16ToInt32(ReadInst16_1(pc));
4887 GateRef frame = GetFrame(sp);
4888 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
4889 GateRef module = GetModuleFromFunction(glue, currentFunc);
4890 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
4891 GateRef currentEnv = GetEnvFromFrame(glue, frame);
4892 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreateObjectWithBuffer), { result });
4893 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_CREATEOBJECTWITHBUFFER_PREF_IMM16));
4894 }
4895
DECLARE_ASM_HANDLER(HandleNewobjrangeImm8Imm8V8)4896 DECLARE_ASM_HANDLER(HandleNewobjrangeImm8Imm8V8)
4897 {
4898 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4899 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
4900 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
4901 auto env = GetEnvironment();
4902 GateRef numArgs = ZExtInt8ToInt16(ReadInst8_1(pc));
4903 GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_2(pc));
4904 GateRef firstArgOffset = Int16(1);
4905 GateRef ctor = GetVregValue(glue, sp, ZExtInt16ToPtr(firstArgRegIdx));
4906 GateRef actualNumArgs = ZExtInt16ToInt32(Int16Sub(numArgs, firstArgOffset));
4907
4908 Label ctorIsHeapObject(env);
4909 Label ctorIsJSFunction(env);
4910 Label fastPath(env);
4911 Label slowPath(env);
4912 Label checkResult(env);
4913 Label threadCheck(env);
4914 Label dispatch(env);
4915 Label ctorIsBase(env);
4916 Label ctorNotBase(env);
4917 Label isException(env);
4918
4919 BRANCH(TaggedIsHeapObject(ctor), &ctorIsHeapObject, &slowPath);
4920 Bind(&ctorIsHeapObject);
4921 BRANCH(IsJSFunction(glue, ctor), &ctorIsJSFunction, &slowPath);
4922 Bind(&ctorIsJSFunction);
4923 BRANCH(IsConstructor(glue, ctor), &fastPath, &slowPath);
4924 Bind(&fastPath);
4925 {
4926 BRANCH(IsBase(glue, ctor), &ctorIsBase, &ctorNotBase);
4927 Bind(&ctorIsBase);
4928 {
4929 NewObjectStubBuilder newBuilder(this);
4930 thisObj = newBuilder.FastNewThisObject(glue, ctor);
4931 BRANCH(HasPendingException(glue), &isException, &ctorNotBase);
4932 }
4933 Bind(&ctorNotBase);
4934 GateRef argv = PtrAdd(sp, PtrMul(
4935 PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
4936 GateRef jumpSize = IntPtr(InterpreterAssembly::GetCallSize(EcmaOpcode::NEWOBJRANGE_IMM8_IMM8_V8));
4937 METHOD_ENTRY_ENV_DEFINED(ctor);
4938 JSCallArgs callArgs(JSCallMode::CALL_CONSTRUCTOR_WITH_ARGV);
4939 callArgs.callConstructorArgs = { ZExtInt32ToPtr(actualNumArgs), argv, *thisObj };
4940 CallStubBuilder callBuilder(this, glue, ctor, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs,
4941 callback);
4942 res = callBuilder.JSCallDispatch();
4943 Jump(&threadCheck);
4944 }
4945 Bind(&slowPath);
4946 if (!callback.IsEmpty()) {
4947 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
4948 UpdateProfileTypeInfoAsMega(glue, profileTypeInfo, slotId);
4949 }
4950 GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset);
4951 GateRef length = Int16Sub(numArgs, firstArgOffset);
4952 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
4953 res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjRange),
4954 { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) });
4955 Jump(&checkResult);
4956 Bind(&checkResult);
4957 {
4958 BRANCH(TaggedIsException(*res), &isException, &dispatch);
4959 }
4960 Bind(&threadCheck);
4961 {
4962 BRANCH(HasPendingException(glue), &isException, &dispatch);
4963 }
4964 Bind(&isException);
4965 {
4966 DISPATCH_LAST();
4967 }
4968 Bind(&dispatch);
4969 varAcc = *res;
4970 DISPATCH_WITH_ACC(NEWOBJRANGE_IMM8_IMM8_V8);
4971 }
4972
DECLARE_ASM_HANDLER(HandleNewobjrangeImm16Imm8V8)4973 DECLARE_ASM_HANDLER(HandleNewobjrangeImm16Imm8V8)
4974 {
4975 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
4976 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
4977 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
4978 auto env = GetEnvironment();
4979 GateRef numArgs = ZExtInt8ToInt16(ReadInst8_2(pc));
4980 GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_3(pc));
4981 GateRef firstArgOffset = Int16(1);
4982 GateRef ctor = GetVregValue(glue, sp, ZExtInt16ToPtr(firstArgRegIdx));
4983 GateRef actualNumArgs = ZExtInt16ToInt32(Int16Sub(numArgs, firstArgOffset));
4984
4985 Label ctorIsHeapObject(env);
4986 Label ctorIsJSFunction(env);
4987 Label fastPath(env);
4988 Label slowPath(env);
4989 Label checkResult(env);
4990 Label threadCheck(env);
4991 Label dispatch(env);
4992 Label ctorIsBase(env);
4993 Label ctorNotBase(env);
4994 Label isException(env);
4995
4996 BRANCH(TaggedIsHeapObject(ctor), &ctorIsHeapObject, &slowPath);
4997 Bind(&ctorIsHeapObject);
4998 BRANCH(IsJSFunction(glue, ctor), &ctorIsJSFunction, &slowPath);
4999 Bind(&ctorIsJSFunction);
5000 BRANCH(IsConstructor(glue, ctor), &fastPath, &slowPath);
5001 Bind(&fastPath);
5002 {
5003 BRANCH(IsBase(glue, ctor), &ctorIsBase, &ctorNotBase);
5004 Bind(&ctorIsBase);
5005 {
5006 NewObjectStubBuilder newBuilder(this);
5007 thisObj = newBuilder.FastNewThisObject(glue, ctor);
5008 BRANCH(HasPendingException(glue), &isException, &ctorNotBase);
5009 }
5010 Bind(&ctorNotBase);
5011 GateRef argv = PtrAdd(sp, PtrMul(
5012 PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
5013 GateRef jumpSize =
5014 IntPtr(-static_cast<int64_t>(BytecodeInstruction::Size(BytecodeInstruction::Format::IMM16_IMM8_V8)));
5015 METHOD_ENTRY_ENV_DEFINED(ctor);
5016 JSCallArgs callArgs(JSCallMode::CALL_CONSTRUCTOR_WITH_ARGV);
5017 callArgs.callConstructorArgs = { ZExtInt32ToPtr(actualNumArgs), argv, *thisObj };
5018 CallStubBuilder callBuilder(this, glue, ctor, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs,
5019 callback);
5020 res = callBuilder.JSCallDispatch();
5021 Jump(&threadCheck);
5022 }
5023 Bind(&slowPath);
5024 if (!callback.IsEmpty()) {
5025 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5026 UpdateProfileTypeInfoAsMega(glue, profileTypeInfo, slotId);
5027 }
5028 GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset);
5029 GateRef length = Int16Sub(numArgs, firstArgOffset);
5030 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5031 res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjRange),
5032 { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) });
5033 Jump(&checkResult);
5034 Bind(&checkResult);
5035 {
5036 BRANCH(TaggedIsException(*res), &isException, &dispatch);
5037 }
5038 Bind(&threadCheck);
5039 {
5040 BRANCH(HasPendingException(glue), &isException, &dispatch);
5041 }
5042 Bind(&isException);
5043 {
5044 DISPATCH_LAST();
5045 }
5046 Bind(&dispatch);
5047 varAcc = *res;
5048 DISPATCH_WITH_ACC(NEWOBJRANGE_IMM16_IMM8_V8);
5049 }
5050
DECLARE_ASM_HANDLER(HandleWideNewobjrangePrefImm16V8)5051 DECLARE_ASM_HANDLER(HandleWideNewobjrangePrefImm16V8)
5052 {
5053 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5054 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
5055 DEFVARIABLE(thisObj, VariableType::JS_ANY(), Undefined());
5056 auto env = GetEnvironment();
5057 GateRef numArgs = ReadInst16_1(pc);
5058 GateRef firstArgRegIdx = ZExtInt8ToInt16(ReadInst8_3(pc));
5059 GateRef firstArgOffset = Int16(1);
5060 GateRef ctor = GetVregValue(glue, sp, ZExtInt16ToPtr(firstArgRegIdx));
5061 GateRef actualNumArgs = ZExtInt16ToInt32(Int16Sub(numArgs, firstArgOffset));
5062
5063 Label ctorIsHeapObject(env);
5064 Label ctorIsJSFunction(env);
5065 Label fastPath(env);
5066 Label slowPath(env);
5067 Label checkResult(env);
5068 Label threadCheck(env);
5069 Label dispatch(env);
5070 Label ctorIsBase(env);
5071 Label ctorNotBase(env);
5072 Label isException(env);
5073
5074 BRANCH(TaggedIsHeapObject(ctor), &ctorIsHeapObject, &slowPath);
5075 Bind(&ctorIsHeapObject);
5076 BRANCH(IsJSFunction(glue, ctor), &ctorIsJSFunction, &slowPath);
5077 Bind(&ctorIsJSFunction);
5078 BRANCH(IsConstructor(glue, ctor), &fastPath, &slowPath);
5079 Bind(&fastPath);
5080 {
5081 BRANCH(IsBase(glue, ctor), &ctorIsBase, &ctorNotBase);
5082 Bind(&ctorIsBase);
5083 {
5084 NewObjectStubBuilder newBuilder(this);
5085 thisObj = newBuilder.FastNewThisObject(glue, ctor);
5086 BRANCH(HasPendingException(glue), &isException, &ctorNotBase);
5087 }
5088 Bind(&ctorNotBase);
5089 GateRef argv = PtrAdd(sp, PtrMul(
5090 PtrAdd(firstArgRegIdx, firstArgOffset), IntPtr(8))); // 8: skip function
5091 GateRef jumpSize = IntPtr(InterpreterAssembly::GetCallSize(EcmaOpcode::WIDE_NEWOBJRANGE_PREF_IMM16_V8));
5092 JSCallArgs callArgs(JSCallMode::DEPRECATED_CALL_CONSTRUCTOR_WITH_ARGV);
5093 callArgs.callConstructorArgs = { ZExtInt32ToPtr(actualNumArgs), argv, *thisObj };
5094 CallStubBuilder callBuilder(this, glue, ctor, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs,
5095 callback);
5096 res = callBuilder.JSCallDispatch();
5097 Jump(&threadCheck);
5098 }
5099 Bind(&slowPath);
5100 GateRef firstArgIdx = Int16Add(firstArgRegIdx, firstArgOffset);
5101 GateRef length = Int16Sub(numArgs, firstArgOffset);
5102 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5103 res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(NewObjRange),
5104 { ctor, ctor, Int16ToTaggedInt(firstArgIdx), Int16ToTaggedInt(length) });
5105 Jump(&checkResult);
5106 Bind(&checkResult);
5107 {
5108 BRANCH(TaggedIsException(*res), &isException, &dispatch);
5109 }
5110 Bind(&threadCheck);
5111 {
5112 BRANCH(HasPendingException(glue), &isException, &dispatch);
5113 }
5114 Bind(&isException);
5115 {
5116 DISPATCH_LAST();
5117 }
5118 Bind(&dispatch);
5119 varAcc = *res;
5120 DISPATCH_WITH_ACC(WIDE_NEWOBJRANGE_PREF_IMM16_V8);
5121 }
5122
DECLARE_ASM_HANDLER(HandleDefinefuncImm8Id16Imm8)5123 DECLARE_ASM_HANDLER(HandleDefinefuncImm8Id16Imm8)
5124 {
5125 auto env = GetEnvironment();
5126 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5127 GateRef methodId = ReadInst16_1(pc);
5128 GateRef length = ReadInst8_3(pc);
5129 #if ECMASCRIPT_ENABLE_TRACE_DEFINEFUNC
5130 GateRef index = ZExtInt8ToInt32(ReadInst8_0(pc));
5131 StartTraceDefineFunc(glue, Int16ToTaggedInt(methodId), profileTypeInfo, index);
5132 #endif
5133 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5134 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5135 SetCurrentGlobalEnv(globalEnv);
5136 GateRef result = DefineFunc(glue, constpool, ZExtInt16ToInt32(methodId));
5137 Label notException(env);
5138 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
5139 Bind(¬Exception);
5140 {
5141 SetLengthToFunction(glue, result, ZExtInt8ToInt32(length));
5142 auto frame = GetFrame(sp);
5143 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5144 GateRef module = GetModuleFromFunction(glue, currentFunc);
5145 Label isSendableFunc(env);
5146 Label isNotSendableFunc(env);
5147 Label afterSendableFunc(env);
5148 BRANCH(IsSendableFunction(GetMethodFromFunction(glue, result)), &isSendableFunc, &isNotSendableFunc);
5149 Bind(&isSendableFunc);
5150 {
5151 GateRef smodule = CallRuntime(glue, RTSTUB_ID(GetSharedModule), { module });
5152 Label isSourceTextModule(env);
5153 Label isNotSourceTextModule(env);
5154 BRANCH(IsSourceTextModule(glue, module), &isSourceTextModule, &isNotSourceTextModule);
5155 Bind(&isSourceTextModule);
5156 {
5157 SetSendableEnvToModule(glue, smodule, GetSendableEnvFromModule(glue, module));
5158 Jump(&isNotSourceTextModule);
5159 }
5160 Bind(&isNotSourceTextModule);
5161 SetModuleToFunction(glue, result, smodule, MemoryAttribute::DefaultWithShareBarrier());
5162 GateRef emptySFunctionEnvHandle = GetGlobalConstantValue(VariableType::JS_ANY(), glue, ConstantIndex::EMPTY_SFUNCTION_ENV_INDEX);
5163 SetLexicalEnvToFunction(glue, result, emptySFunctionEnvHandle);
5164 Jump(&afterSendableFunc);
5165 }
5166 Bind(&isNotSendableFunc);
5167 {
5168 GateRef envHandle = GetEnvFromFrame(glue, frame);
5169 SetLexicalEnvToFunction(glue, result, envHandle);
5170 SetModuleToFunction(glue, result, module);
5171 SetHomeObjectToFunction(glue, result, GetHomeObjectFromFunction(glue, currentFunc));
5172 #if ECMASCRIPT_ENABLE_IC
5173 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5174 UpdateProfileTypeInfoCellToFunction(glue, result, profileTypeInfo, slotId);
5175 callback.ProfileDefineClass(result);
5176 #endif
5177 Jump(&afterSendableFunc);
5178 }
5179 Bind(&afterSendableFunc);
5180 EndTraceDefineFunc(glue);
5181 varAcc = result;
5182 DISPATCH_WITH_ACC(DEFINEFUNC_IMM8_ID16_IMM8);
5183 }
5184 }
5185
DECLARE_ASM_HANDLER(HandleDefinefuncImm16Id16Imm8)5186 DECLARE_ASM_HANDLER(HandleDefinefuncImm16Id16Imm8)
5187 {
5188 auto env = GetEnvironment();
5189 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5190 GateRef methodId = ReadInst16_2(pc);
5191 GateRef length = ReadInst8_4(pc);
5192 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5193 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5194 SetCurrentGlobalEnv(globalEnv);
5195 GateRef result = DefineFunc(glue, constpool, ZExtInt16ToInt32(methodId));
5196 Label notException(env);
5197 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
5198 Bind(¬Exception);
5199 {
5200 SetLengthToFunction(glue, result, ZExtInt8ToInt32(length));
5201 auto frame = GetFrame(sp);
5202 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5203 GateRef module = GetModuleFromFunction(glue, currentFunc);
5204 Label isSendableFunc(env);
5205 Label isNotSendableFunc(env);
5206 Label afterSendableFunc(env);
5207 BRANCH(IsSendableFunction(GetMethodFromFunction(glue, result)), &isSendableFunc, &isNotSendableFunc);
5208 Bind(&isSendableFunc);
5209 {
5210 GateRef smodule = CallRuntime(glue, RTSTUB_ID(GetSharedModule), { module });
5211 Label isSourceTextModule(env);
5212 Label isNotSourceTextModule(env);
5213 BRANCH(IsSourceTextModule(glue, module), &isSourceTextModule, &isNotSourceTextModule);
5214 Bind(&isSourceTextModule);
5215 {
5216 SetSendableEnvToModule(glue, smodule, GetSendableEnvFromModule(glue, module));
5217 Jump(&isNotSourceTextModule);
5218 }
5219 Bind(&isNotSourceTextModule);
5220 SetModuleToFunction(glue, result, smodule, MemoryAttribute::DefaultWithShareBarrier());
5221 GateRef emptySFunctionEnvHandle = GetGlobalConstantValue(VariableType::JS_ANY(), glue, ConstantIndex::EMPTY_SFUNCTION_ENV_INDEX);
5222 SetLexicalEnvToFunction(glue, result, emptySFunctionEnvHandle);
5223 Jump(&afterSendableFunc);
5224 }
5225 Bind(&isNotSendableFunc);
5226 {
5227 GateRef envHandle = GetEnvFromFrame(glue, frame);
5228 SetLexicalEnvToFunction(glue, result, envHandle);
5229 SetModuleToFunction(glue, result, module);
5230 SetHomeObjectToFunction(glue, result, GetHomeObjectFromFunction(glue, currentFunc));
5231 #if ECMASCRIPT_ENABLE_IC
5232 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5233 UpdateProfileTypeInfoCellToFunction(glue, result, profileTypeInfo, slotId);
5234 callback.ProfileDefineClass(result);
5235 #endif
5236 Jump(&afterSendableFunc);
5237 }
5238 Bind(&afterSendableFunc);
5239 varAcc = result;
5240 DISPATCH_WITH_ACC(DEFINEFUNC_IMM16_ID16_IMM8);
5241 }
5242 }
5243
DECLARE_ASM_HANDLER(HandleDefinemethodImm8Id16Imm8)5244 DECLARE_ASM_HANDLER(HandleDefinemethodImm8Id16Imm8)
5245 {
5246 auto env = GetEnvironment();
5247 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5248 GateRef methodId = ReadInst16_1(pc);
5249 GateRef length = ReadInst8_3(pc);
5250 GateRef frame = GetFrame(sp);
5251 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5252 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5253 DEFVARIABLE(result, VariableType::JS_POINTER(),
5254 GetMethodFromConstPool(glue, constpool, ZExtInt16ToInt32(methodId)));
5255 #if ENABLE_NEXT_OPTIMIZATION
5256 NewObjectStubBuilder newBuilder(this, globalEnv);
5257 result = newBuilder.DefineMethod(glue, *result, acc, ZExtInt8ToInt32(length), currentEnv, GetModule(glue, sp));
5258 #else
5259 result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length),
5260 currentEnv, GetModule(glue, sp) });
5261 #endif
5262
5263 #if ECMASCRIPT_ENABLE_IC
5264 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5265 UpdateProfileTypeInfoCellToFunction(glue, *result, profileTypeInfo, slotId);
5266 #endif
5267 Label notException(env);
5268 CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
5269 Bind(¬Exception);
5270 {
5271 varAcc = *result;
5272 DISPATCH_WITH_ACC(DEFINEMETHOD_IMM8_ID16_IMM8);
5273 }
5274 }
5275
DECLARE_ASM_HANDLER(HandleDefinemethodImm16Id16Imm8)5276 DECLARE_ASM_HANDLER(HandleDefinemethodImm16Id16Imm8)
5277 {
5278 auto env = GetEnvironment();
5279 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5280 GateRef methodId = ReadInst16_2(pc);
5281 GateRef length = ReadInst8_4(pc);
5282 GateRef frame = GetFrame(sp);
5283 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5284 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5285 DEFVARIABLE(result, VariableType::JS_POINTER(),
5286 GetMethodFromConstPool(glue, constpool, ZExtInt16ToInt32(methodId)));
5287 #if ENABLE_NEXT_OPTIMIZATION
5288 NewObjectStubBuilder newBuilder(this, globalEnv);
5289 result = newBuilder.DefineMethod(glue, *result, acc, ZExtInt8ToInt32(length), currentEnv, GetModule(glue, sp));
5290 #else
5291 result = CallRuntimeWithGlobalEnv(glue, globalEnv, RTSTUB_ID(DefineMethod), { *result, acc, Int8ToTaggedInt(length),
5292 currentEnv, GetModule(glue, sp) });
5293 #endif
5294
5295 #if ECMASCRIPT_ENABLE_IC
5296 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5297 UpdateProfileTypeInfoCellToFunction(glue, *result, profileTypeInfo, slotId);
5298 #endif
5299 Label notException(env);
5300 CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
5301 Bind(¬Exception);
5302 {
5303 varAcc = *result;
5304 DISPATCH_WITH_ACC(DEFINEMETHOD_IMM16_ID16_IMM8);
5305 }
5306 }
5307
DECLARE_ASM_HANDLER(HandleApplyImm8V8V8)5308 DECLARE_ASM_HANDLER(HandleApplyImm8V8V8)
5309 {
5310 GateRef func = acc;
5311 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
5312 GateRef array = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
5313 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5314 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CallSpread), { func, obj, array });
5315 CHECK_PENDING_EXCEPTION(res, INT_PTR(APPLY_IMM8_V8_V8));
5316 }
5317
DECLARE_ASM_HANDLER(HandleDeprecatedCallspreadPrefV8V8V8)5318 DECLARE_ASM_HANDLER(HandleDeprecatedCallspreadPrefV8V8V8)
5319 {
5320 GateRef func = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
5321 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
5322 GateRef array = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_3(pc)));
5323 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5324 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CallSpread), { func, obj, array });
5325 CHECK_PENDING_EXCEPTION(res, INT_PTR(DEPRECATED_CALLSPREAD_PREF_V8_V8_V8));
5326 }
5327
DECLARE_ASM_HANDLER(HandleThrowNotexistsPrefNone)5328 DECLARE_ASM_HANDLER(HandleThrowNotexistsPrefNone)
5329 {
5330 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5331 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowThrowNotExists), {});
5332 DISPATCH_LAST();
5333 }
DECLARE_ASM_HANDLER(HandleThrowPrefNone)5334 DECLARE_ASM_HANDLER(HandleThrowPrefNone)
5335 {
5336 CallRuntime(glue, RTSTUB_ID(Throw), { acc });
5337 DISPATCH_LAST();
5338 }
5339
DECLARE_ASM_HANDLER(HandleJnstricteqV8Imm16)5340 DECLARE_ASM_HANDLER(HandleJnstricteqV8Imm16)
5341 {
5342 DISPATCH(NOP);
5343 }
DECLARE_ASM_HANDLER(HandleJnstricteqV8Imm8)5344 DECLARE_ASM_HANDLER(HandleJnstricteqV8Imm8)
5345 {
5346 DISPATCH(NOP);
5347 }
DECLARE_ASM_HANDLER(HandleJstricteqV8Imm16)5348 DECLARE_ASM_HANDLER(HandleJstricteqV8Imm16)
5349 {
5350 DISPATCH(NOP);
5351 }
DECLARE_ASM_HANDLER(HandleJstricteqV8Imm8)5352 DECLARE_ASM_HANDLER(HandleJstricteqV8Imm8)
5353 {
5354 DISPATCH(NOP);
5355 }
DECLARE_ASM_HANDLER(HandleJneV8Imm16)5356 DECLARE_ASM_HANDLER(HandleJneV8Imm16)
5357 {
5358 DISPATCH(NOP);
5359 }
DECLARE_ASM_HANDLER(HandleJneV8Imm8)5360 DECLARE_ASM_HANDLER(HandleJneV8Imm8)
5361 {
5362 DISPATCH(NOP);
5363 }
DECLARE_ASM_HANDLER(HandleJeqV8Imm16)5364 DECLARE_ASM_HANDLER(HandleJeqV8Imm16)
5365 {
5366 DISPATCH(NOP);
5367 }
DECLARE_ASM_HANDLER(HandleJeqV8Imm8)5368 DECLARE_ASM_HANDLER(HandleJeqV8Imm8)
5369 {
5370 DISPATCH(NOP);
5371 }
DECLARE_ASM_HANDLER(HandleJnstrictequndefinedImm16)5372 DECLARE_ASM_HANDLER(HandleJnstrictequndefinedImm16)
5373 {
5374 DISPATCH(NOP);
5375 }
DECLARE_ASM_HANDLER(HandleJnstrictequndefinedImm8)5376 DECLARE_ASM_HANDLER(HandleJnstrictequndefinedImm8)
5377 {
5378 DISPATCH(NOP);
5379 }
DECLARE_ASM_HANDLER(HandleJstrictequndefinedImm16)5380 DECLARE_ASM_HANDLER(HandleJstrictequndefinedImm16)
5381 {
5382 DISPATCH(NOP);
5383 }
DECLARE_ASM_HANDLER(HandleJstrictequndefinedImm8)5384 DECLARE_ASM_HANDLER(HandleJstrictequndefinedImm8)
5385 {
5386 DISPATCH(NOP);
5387 }
DECLARE_ASM_HANDLER(HandleJneundefinedImm16)5388 DECLARE_ASM_HANDLER(HandleJneundefinedImm16)
5389 {
5390 DISPATCH(NOP);
5391 }
DECLARE_ASM_HANDLER(HandleJneundefinedImm8)5392 DECLARE_ASM_HANDLER(HandleJneundefinedImm8)
5393 {
5394 DISPATCH(NOP);
5395 }
DECLARE_ASM_HANDLER(HandleJnstricteqnullImm16)5396 DECLARE_ASM_HANDLER(HandleJnstricteqnullImm16)
5397 {
5398 DISPATCH(NOP);
5399 }
DECLARE_ASM_HANDLER(HandleJnstricteqnullImm8)5400 DECLARE_ASM_HANDLER(HandleJnstricteqnullImm8)
5401 {
5402 DISPATCH(NOP);
5403 }
DECLARE_ASM_HANDLER(HandleJstricteqnullImm16)5404 DECLARE_ASM_HANDLER(HandleJstricteqnullImm16)
5405 {
5406 DISPATCH(NOP);
5407 }
DECLARE_ASM_HANDLER(HandleJstricteqnullImm8)5408 DECLARE_ASM_HANDLER(HandleJstricteqnullImm8)
5409 {
5410 DISPATCH(NOP);
5411 }
DECLARE_ASM_HANDLER(HandleJnenullImm16)5412 DECLARE_ASM_HANDLER(HandleJnenullImm16)
5413 {
5414 DISPATCH(NOP);
5415 }
DECLARE_ASM_HANDLER(HandleJnenullImm8)5416 DECLARE_ASM_HANDLER(HandleJnenullImm8)
5417 {
5418 DISPATCH(NOP);
5419 }
DECLARE_ASM_HANDLER(HandleJeqnullImm16)5420 DECLARE_ASM_HANDLER(HandleJeqnullImm16)
5421 {
5422 DISPATCH(NOP);
5423 }
DECLARE_ASM_HANDLER(HandleJeqnullImm8)5424 DECLARE_ASM_HANDLER(HandleJeqnullImm8)
5425 {
5426 DISPATCH(NOP);
5427 }
5428
DECLARE_ASM_HANDLER(HandleJnstricteqzImm16)5429 DECLARE_ASM_HANDLER(HandleJnstricteqzImm16)
5430 {
5431 DISPATCH(NOP);
5432 }
DECLARE_ASM_HANDLER(HandleJnstricteqzImm8)5433 DECLARE_ASM_HANDLER(HandleJnstricteqzImm8)
5434 {
5435 DISPATCH(NOP);
5436 }
DECLARE_ASM_HANDLER(HandleJstricteqzImm16)5437 DECLARE_ASM_HANDLER(HandleJstricteqzImm16)
5438 {
5439 DISPATCH(NOP);
5440 }
DECLARE_ASM_HANDLER(HandleJstricteqzImm8)5441 DECLARE_ASM_HANDLER(HandleJstricteqzImm8)
5442 {
5443 DISPATCH(NOP);
5444 }
DECLARE_ASM_HANDLER(HandleStthisbyvalueImm16V8)5445 DECLARE_ASM_HANDLER(HandleStthisbyvalueImm16V8)
5446 {
5447 GateRef v0 = ReadInst8_2(pc);
5448 GateRef frame = GetFrame(sp);
5449 GateRef receiver = GetThisFromFrame(glue, frame);
5450 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5451 GateRef value = acc;
5452 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5453 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5454 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5455
5456 AccessObjectStubBuilder builder(this, globalEnv);
5457 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, value, profileTypeInfo, slotId, callback);
5458 CHECK_EXCEPTION(result, INT_PTR(STTHISBYVALUE_IMM16_V8));
5459 }
DECLARE_ASM_HANDLER(HandleStthisbyvalueImm8V8)5460 DECLARE_ASM_HANDLER(HandleStthisbyvalueImm8V8)
5461 {
5462 GateRef v0 = ReadInst8_1(pc);
5463 GateRef frame = GetFrame(sp);
5464 GateRef receiver = GetThisFromFrame(glue, frame);
5465 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5466 GateRef value = acc;
5467 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5468 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5469 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5470
5471 AccessObjectStubBuilder builder(this, globalEnv);
5472 GateRef result = builder.StoreObjByValue(glue, receiver, propKey, value, profileTypeInfo, slotId, callback);
5473 CHECK_EXCEPTION(result, INT_PTR(STTHISBYVALUE_IMM8_V8));
5474 }
DECLARE_ASM_HANDLER(HandleLdthisbyvalueImm16)5475 DECLARE_ASM_HANDLER(HandleLdthisbyvalueImm16)
5476 {
5477 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5478
5479 GateRef receiver = GetThisFromFrame(glue, GetFrame(sp));
5480 GateRef propKey = acc;
5481 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5482 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5483 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5484
5485 AccessObjectStubBuilder builder(this, globalEnv);
5486 GateRef result = builder.LoadObjByValue(glue, receiver, propKey, profileTypeInfo, slotId, callback);
5487 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDTHISBYVALUE_IMM16));
5488 }
DECLARE_ASM_HANDLER(HandleLdthisbyvalueImm8)5489 DECLARE_ASM_HANDLER(HandleLdthisbyvalueImm8)
5490 {
5491 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5492
5493 GateRef receiver = GetThisFromFrame(glue, GetFrame(sp));
5494 GateRef propKey = acc;
5495 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5496 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5497 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5498
5499 AccessObjectStubBuilder builder(this, globalEnv);
5500 GateRef result = builder.LoadObjByValue(glue, receiver, propKey, profileTypeInfo, slotId, callback);
5501 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDTHISBYVALUE_IMM8));
5502 }
DECLARE_ASM_HANDLER(HandleStthisbynameImm16Id16)5503 DECLARE_ASM_HANDLER(HandleStthisbynameImm16Id16)
5504 {
5505 GateRef receiver = GetThisFromFrame(glue, GetFrame(sp));
5506 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5507 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5508 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5509
5510 AccessObjectStubBuilder builder(this, globalEnv);
5511 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
5512 GateRef result = builder.StoreObjByName(glue, receiver, 0, info, acc, profileTypeInfo, slotId, callback);
5513 CHECK_EXCEPTION(result, INT_PTR(STTHISBYNAME_IMM16_ID16));
5514 }
DECLARE_ASM_HANDLER(HandleStthisbynameImm8Id16)5515 DECLARE_ASM_HANDLER(HandleStthisbynameImm8Id16)
5516 {
5517 GateRef receiver = GetThisFromFrame(glue, GetFrame(sp));
5518 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5519 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5520 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5521
5522 AccessObjectStubBuilder builder(this, globalEnv);
5523 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16);
5524 GateRef result = builder.StoreObjByName(glue, receiver, 0, info, acc, profileTypeInfo, slotId, callback);
5525 CHECK_EXCEPTION(result, INT_PTR(STTHISBYNAME_IMM8_ID16));
5526 }
DECLARE_ASM_HANDLER(HandleLdthisbynameImm16Id16)5527 DECLARE_ASM_HANDLER(HandleLdthisbynameImm16Id16)
5528 {
5529 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5530 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5531 GateRef frame = GetFrame(sp);
5532 GateRef receiver = GetThisFromFrame(glue, frame);
5533 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5534 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5535
5536 AccessObjectStubBuilder builder(this, globalEnv);
5537 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_2, StringIdInfo::Length::BITS_16);
5538 GateRef result = builder.LoadObjByName(glue, receiver, 0, info, profileTypeInfo, slotId, callback);
5539 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDTHISBYNAME_IMM16_ID16));
5540 }
DECLARE_ASM_HANDLER(HandleLdthisbynameImm8Id16)5541 DECLARE_ASM_HANDLER(HandleLdthisbynameImm8Id16)
5542 {
5543 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5544 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5545 GateRef frame = GetFrame(sp);
5546 GateRef receiver = GetThisFromFrame(glue, frame);
5547 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5548 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5549
5550 AccessObjectStubBuilder builder(this, globalEnv);
5551 StringIdInfo info(constpool, pc, StringIdInfo::Offset::BYTE_1, StringIdInfo::Length::BITS_16);
5552 GateRef result = builder.LoadObjByName(glue, receiver, 0, info, profileTypeInfo, slotId, callback);
5553 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(LDTHISBYNAME_IMM8_ID16));
5554 }
DECLARE_ASM_HANDLER(HandleLdthis)5555 DECLARE_ASM_HANDLER(HandleLdthis)
5556 {
5557 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5558 varAcc = GetThisFromFrame(glue, GetFrame(sp));
5559 DISPATCH_WITH_ACC(LDTHIS);
5560 }
DECLARE_ASM_HANDLER(HandleLdnewtarget)5561 DECLARE_ASM_HANDLER(HandleLdnewtarget)
5562 {
5563 DISPATCH(NOP);
5564 }
5565
DECLARE_ASM_HANDLER(HandleDeprecatedLdlexenvPrefNone)5566 DECLARE_ASM_HANDLER(HandleDeprecatedLdlexenvPrefNone)
5567 {
5568 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5569 GateRef state = GetFrame(sp);
5570 varAcc = GetEnvFromFrame(glue, state);
5571 DISPATCH_WITH_ACC(DEPRECATED_LDLEXENV_PREF_NONE);
5572 }
5573
DECLARE_ASM_HANDLER(HandleDeprecatedLdhomeobjectPrefNone)5574 DECLARE_ASM_HANDLER(HandleDeprecatedLdhomeobjectPrefNone)
5575 {
5576 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5577 GateRef state = GetFunctionFromFrame(glue, GetFrame(sp));
5578 varAcc = GetHomeObjectFromJSFunction(glue, state);
5579 DISPATCH_WITH_ACC(DEPRECATED_LDHOMEOBJECT_PREF_NONE);
5580 }
5581
DECLARE_ASM_HANDLER(HandleDeprecatedCreateobjecthavingmethodPrefImm16)5582 DECLARE_ASM_HANDLER(HandleDeprecatedCreateobjecthavingmethodPrefImm16)
5583 {
5584 GateRef imm = ZExtInt16ToInt32(ReadInst16_1(pc));
5585 GateRef frame = GetFrame(sp);
5586 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5587 GateRef module = GetModuleFromFunction(glue, currentFunc);
5588 GateRef result = GetObjectLiteralFromConstPool(glue, constpool, imm, module);
5589 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5590 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5591 NewObjectStubBuilder newBuilder(this, globalEnv);
5592 GateRef res = newBuilder.CreateObjectHavingMethod(glue, result, acc);
5593 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(DEPRECATED_CREATEOBJECTHAVINGMETHOD_PREF_IMM16));
5594 }
5595
5596 #define DECLARE_UNUSED_ASM_HANDLE(name) \
5597 DECLARE_ASM_HANDLER(name) \
5598 { \
5599 FatalPrint(glue, { Int32(GET_MESSAGE_STRING_ID(name)) }); \
5600 DISPATCH_BAK(OFFSET, IntPtr(0)); \
5601 }
5602 ASM_UNUSED_BC_STUB_LIST(DECLARE_UNUSED_ASM_HANDLE)
5603 #undef DECLARE_UNUSED_ASM_HANDLE
5604
DECLARE_ASM_HANDLER_NOPRINT(HandleThrow)5605 DECLARE_ASM_HANDLER_NOPRINT(HandleThrow)
5606 {
5607 GateRef opcode = ZExtInt8ToPtr(ReadInst8_0(pc));
5608 auto index = IntPtr(kungfu::BytecodeStubCSigns::ID_Throw_Start);
5609 auto jumpIndex = PtrAdd(opcode, index);
5610 DispatchWithId(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, jumpIndex);
5611 }
5612
DECLARE_ASM_HANDLER_NOPRINT(HandleWide)5613 DECLARE_ASM_HANDLER_NOPRINT(HandleWide)
5614 {
5615 GateRef opcode = ZExtInt8ToPtr(ReadInst8_0(pc));
5616 auto index = IntPtr(kungfu::BytecodeStubCSigns::ID_Wide_Start);
5617 auto jumpIndex = PtrAdd(opcode, index);
5618 DispatchWithId(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, jumpIndex);
5619 }
5620
DECLARE_ASM_HANDLER_NOPRINT(HandleDeprecated)5621 DECLARE_ASM_HANDLER_NOPRINT(HandleDeprecated)
5622 {
5623 GateRef opcode = ZExtInt8ToPtr(ReadInst8_0(pc));
5624 auto index = IntPtr(kungfu::BytecodeStubCSigns::ID_Deprecated_Start);
5625 auto jumpIndex = PtrAdd(opcode, index);
5626 DispatchWithId(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, jumpIndex);
5627 }
5628
DECLARE_ASM_HANDLER_NOPRINT(HandleCallRuntime)5629 DECLARE_ASM_HANDLER_NOPRINT(HandleCallRuntime)
5630 {
5631 GateRef opcode = ZExtInt8ToPtr(ReadInst8_0(pc));
5632 auto index = IntPtr(kungfu::BytecodeStubCSigns::ID_CallRuntime_Start);
5633 auto jumpIndex = PtrAdd(opcode, index);
5634 DispatchWithId(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter, jumpIndex);
5635 }
5636
5637 // interpreter helper handler
DECLARE_ASM_HANDLER_NOPRINT(ExceptionHandler)5638 DECLARE_ASM_HANDLER_NOPRINT(ExceptionHandler)
5639 {
5640 auto env = GetEnvironment();
5641 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
5642 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
5643 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
5644 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
5645 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5646 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5647
5648 Label pcIsInvalid(env);
5649 Label pcNotInvalid(env);
5650 GateRef exceptionOffset = IntPtr(JSThread::GlueData::GetExceptionOffset(env->IsArch32Bit()));
5651 GateRef exception = LoadPrimitive(VariableType::JS_ANY(), glue, exceptionOffset);
5652 varPc = TaggedCastToIntPtr(CallRuntime(glue, RTSTUB_ID(UpFrame), {}));
5653 varSp = GetCurrentFrame(glue);
5654 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcIsInvalid, &pcNotInvalid);
5655 Bind(&pcIsInvalid);
5656 {
5657 CallNGCRuntime(glue, RTSTUB_ID(ResumeUncaughtFrameAndReturn), { glue, *varSp, *varAcc });
5658 Return();
5659 }
5660 Bind(&pcNotInvalid);
5661 {
5662 varAcc = exception;
5663 // clear exception
5664 Store(VariableType::INT64(), glue, glue, exceptionOffset, Hole());
5665 GateRef function = GetFunctionFromFrame(glue, GetFrame(*varSp));
5666 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5667 varConstpool = GetConstpoolFromMethod(glue, method);
5668 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5669 varHotnessCounter = GetHotnessCounterFromMethod(method);
5670 CallNGCRuntime(glue, RTSTUB_ID(ResumeCaughtFrameAndDispatch), {
5671 glue, *varSp, *varPc, *varConstpool,
5672 *varProfileTypeInfo, *varAcc, *varHotnessCounter});
5673 Return();
5674 }
5675 }
5676
DECLARE_ASM_HANDLER(SingleStepDebugging)5677 DECLARE_ASM_HANDLER(SingleStepDebugging)
5678 {
5679 auto env = GetEnvironment();
5680 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
5681 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
5682 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
5683 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
5684 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5685 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5686
5687 GateRef frame = GetFrame(*varSp);
5688 SetPcToFrame(glue, frame, *varPc);
5689 GateRef currentSp = *varSp;
5690 varSp = TaggedCastToIntPtr(CallRuntime(glue,
5691 RTSTUB_ID(JumpToCInterpreter),
5692 { constpool, profileTypeInfo, acc,
5693 IntToTaggedInt(hotnessCounter)}));
5694 GateRef frameAfter = GetFrame(*varSp);
5695 varPc = GetPcFromFrame(frameAfter);
5696 Label shouldReturn(env);
5697 Label shouldContinue(env);
5698
5699 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &shouldReturn, &shouldContinue);
5700 Bind(&shouldReturn);
5701 {
5702 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { Undefined(), *varSp, currentSp });
5703 Return();
5704 }
5705 Bind(&shouldContinue);
5706 {
5707 varAcc = GetAccFromFrame(glue, frameAfter);
5708 GateRef function = GetFunctionFromFrame(glue, frameAfter);
5709 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5710 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5711 varConstpool = GetConstpoolFromMethod(glue, method);
5712 varHotnessCounter = GetHotnessCounterFromMethod(method);
5713 }
5714 Label isException(env);
5715 Label notException(env);
5716 BRANCH(TaggedIsException(*varAcc), &isException, ¬Exception);
5717 Bind(&isException);
5718 DispatchLast(glue, *varSp, *varPc, *varConstpool, *varProfileTypeInfo, *varAcc,
5719 *varHotnessCounter);
5720 Bind(¬Exception);
5721 DISPATCH_BAK(SSD, IntPtr(0));
5722 }
5723
DECLARE_ASM_HANDLER(BCDebuggerEntry)5724 DECLARE_ASM_HANDLER(BCDebuggerEntry)
5725 {
5726 auto env = GetEnvironment();
5727 Label callByteCodeChanged(env);
5728 Label isFrameDroppedTrue(env);
5729 Label isFrameDroppedFalse(env);
5730 Label isEntryFrameDroppedPending(env);
5731 Label isEntryFrameDroppedNotTrue(env);
5732 Label isBaselineBuiltinFrame(env);
5733 Label notBaselineBuiltinFrame(env);
5734 Label pcEqualNullptr(env);
5735 Label pcNotEqualNullptr(env);
5736 Label pcEqualBaseline(env);
5737 Label pcNotEqualBaseline(env);
5738 GateRef frame = GetFrame(sp);
5739 GateRef isEntryFrameDropped = LoadPrimitive(VariableType::INT8(), glue,
5740 IntPtr(JSThread::GlueData::GetEntryFrameDroppedStateOffset(env->Is32Bit())));
5741 BRANCH(Int8Equal(isEntryFrameDropped, Int8(JSThread::FrameDroppedState::StatePending)),
5742 &isEntryFrameDroppedPending, &callByteCodeChanged);
5743 Bind(&isEntryFrameDroppedPending);
5744 {
5745 Store(VariableType::INT8(), glue, glue,
5746 IntPtr(JSThread::GlueData::GetEntryFrameDroppedStateOffset(env->Is32Bit())),
5747 Int8(JSThread::FrameDroppedState::StateFalse));
5748 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
5749 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5750 varPc = GetPcFromFrame(frame);
5751 varAcc = GetAccFromFrame(glue, frame);
5752 Dispatch(glue, sp, *varPc, constpool, profileTypeInfo, *varAcc, hotnessCounter, IntPtr(0));
5753 }
5754 Bind(&callByteCodeChanged);
5755 SetPcToFrame(glue, frame, pc);
5756 // NOTIFY_DEBUGGER_EVENT()
5757 CallRuntime(glue, RTSTUB_ID(NotifyBytecodePcChanged), {});
5758 GateRef isFrameDropped = LoadPrimitive(VariableType::BOOL(), glue,
5759 IntPtr(JSThread::GlueData::GetIsFrameDroppedOffset(env->Is32Bit())));
5760 BRANCH(isFrameDropped, &isFrameDroppedTrue, &isFrameDroppedFalse);
5761 Bind(&isFrameDroppedTrue);
5762 {
5763 DEFVARIABLE(varPc, VariableType::NATIVE_POINTER(), pc);
5764 DEFVARIABLE(varSp, VariableType::NATIVE_POINTER(), sp);
5765 DEFVARIABLE(prevState, VariableType::NATIVE_POINTER(), sp);
5766 DEFVARIABLE(varConstpool, VariableType::JS_POINTER(), constpool);
5767 DEFVARIABLE(varProfileTypeInfo, VariableType::JS_POINTER(), profileTypeInfo);
5768 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5769 DEFVARIABLE(varHotnessCounter, VariableType::INT32(), hotnessCounter);
5770 GateRef state = GetFrame(*varSp);
5771 GateRef currentSp = *varSp;
5772 Store(VariableType::BOOL(), glue, glue,
5773 IntPtr(JSThread::GlueData::GetIsFrameDroppedOffset(env->Is32Bit())), False());
5774 varSp = LoadPrimitive(VariableType::NATIVE_POINTER(), state,
5775 IntPtr(AsmInterpretedFrame::GetBaseOffset(env->IsArch32Bit())));
5776 isEntryFrameDropped = LoadPrimitive(VariableType::INT8(), glue,
5777 IntPtr(JSThread::GlueData::GetEntryFrameDroppedStateOffset(env->Is32Bit())));
5778 BRANCH(Int8Equal(isEntryFrameDropped, Int8(JSThread::FrameDroppedState::StateTrue)),
5779 &pcEqualNullptr, &isEntryFrameDroppedNotTrue);
5780 Bind(&isEntryFrameDroppedNotTrue);
5781 GateRef typePos = PtrSub(*varSp, IntPtr(JSTaggedValue::TaggedTypeSize()));
5782 GateRef maybeFrameType = LoadZeroOffsetPrimitive(VariableType::INT64(), typePos);
5783 BRANCH(Int64Equal(maybeFrameType, Int64(static_cast<int64_t>(FrameType::BASELINE_BUILTIN_FRAME))),
5784 &isBaselineBuiltinFrame, ¬BaselineBuiltinFrame);
5785 Bind(&isBaselineBuiltinFrame);
5786 {
5787 varSp = LoadZeroOffsetPrimitive(VariableType::NATIVE_POINTER(), *varSp);
5788 Jump(¬BaselineBuiltinFrame);
5789 }
5790 Bind(¬BaselineBuiltinFrame);
5791 prevState = GetFrame(*varSp);
5792 varPc = GetPcFromFrame(*prevState);
5793 BRANCH(IntPtrEqual(*varPc, IntPtr(0)), &pcEqualNullptr, &pcNotEqualNullptr);
5794 Bind(&pcEqualNullptr);
5795 {
5796 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
5797 Return();
5798 }
5799 Bind(&pcNotEqualNullptr);
5800 BRANCH(IntPtrEqual(*varPc, IntPtr(BASELINEJIT_PC_FLAG)), &pcEqualBaseline, &pcNotEqualBaseline);
5801 Bind(&pcEqualBaseline);
5802 {
5803 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndReturn), { *varAcc, *varSp, currentSp });
5804 Return();
5805 }
5806 Bind(&pcNotEqualBaseline);
5807 {
5808 GateRef function = GetFunctionFromFrame(glue, *prevState);
5809 GateRef method = Load(VariableType::JS_ANY(), glue, function, IntPtr(JSFunctionBase::METHOD_OFFSET));
5810 varConstpool = GetConstpoolFromMethod(glue, method);
5811 varProfileTypeInfo = GetProfileTypeInfoFromFunction(glue, function);
5812 varHotnessCounter = GetHotnessCounterFromMethod(method);
5813 GateRef jumpSize = IntPtr(0);
5814 CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndRollback),
5815 { glue, currentSp, *varPc, *varConstpool, *varProfileTypeInfo,
5816 *varAcc, *varHotnessCounter, jumpSize });
5817 Return();
5818 }
5819 }
5820 Bind(&isFrameDroppedFalse);
5821 SetAccToFrame(glue, frame, acc);
5822 // goto normal handle stub
5823 DispatchDebugger(glue, sp, pc, constpool, profileTypeInfo, acc, hotnessCounter);
5824 }
5825
DECLARE_ASM_HANDLER(BCDebuggerExceptionEntry)5826 DECLARE_ASM_HANDLER(BCDebuggerExceptionEntry)
5827 {
5828 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5829 varAcc = Hole();
5830 GateRef frame = GetFrame(sp);
5831 SetPcToFrame(glue, frame, pc);
5832 // NOTIFY_DEBUGGER_EVENT()
5833 CallRuntime(glue, RTSTUB_ID(NotifyBytecodePcChanged), {});
5834 // goto last handle stub
5835 DispatchDebuggerLast(glue, sp, pc, constpool, profileTypeInfo, *varAcc, hotnessCounter);
5836 }
5837
DECLARE_ASM_HANDLER(NewObjectRangeThrowException)5838 DECLARE_ASM_HANDLER(NewObjectRangeThrowException)
5839 {
5840 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5841 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowDerivedMustReturnException), {});
5842 DISPATCH_LAST();
5843 }
5844
DECLARE_ASM_HANDLER(ThrowStackOverflowException)5845 DECLARE_ASM_HANDLER(ThrowStackOverflowException)
5846 {
5847 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5848 CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(ThrowStackOverflowException), {});
5849 DISPATCH_LAST();
5850 }
5851
DECLARE_ASM_HANDLER(HandleDefinefuncImm8Id16Imm8ColdReload)5852 DECLARE_ASM_HANDLER(HandleDefinefuncImm8Id16Imm8ColdReload)
5853 {
5854 auto env = GetEnvironment();
5855 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5856 GateRef methodId = ReadInst16_1(pc);
5857 GateRef length = ReadInst8_3(pc);
5858 auto frame = GetFrame(sp);
5859 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5860 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5861 SetCurrentGlobalEnv(globalEnv);
5862 GateRef result = DefineFunc(glue, constpool, ZExtInt16ToInt32(methodId));
5863 Label notException(env);
5864 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
5865 Bind(¬Exception);
5866 {
5867 SetLengthToFunction(glue, result, ZExtInt8ToInt32(length));
5868 SetLexicalEnvToFunction(glue, result, currentEnv);
5869 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5870 SetModuleToFunction(glue, result, GetModuleFromFunction(glue, currentFunc));
5871 CallRuntime(glue, RTSTUB_ID(SetPatchModule), { result });
5872 SetHomeObjectToFunction(glue, result, GetHomeObjectFromFunction(glue, currentFunc));
5873 #if ECMASCRIPT_ENABLE_IC
5874 GateRef slotId = ZExtInt8ToInt32(ReadInst8_0(pc));
5875 UpdateProfileTypeInfoCellToFunction(glue, result, profileTypeInfo, slotId);
5876 callback.ProfileDefineClass(result);
5877 #endif
5878 varAcc = result;
5879 DISPATCH_WITH_ACC(DEFINEFUNC_IMM8_ID16_IMM8);
5880 }
5881 }
5882
DECLARE_ASM_HANDLER(HandleDefinefuncImm16Id16Imm8ColdReload)5883 DECLARE_ASM_HANDLER(HandleDefinefuncImm16Id16Imm8ColdReload)
5884 {
5885 auto env = GetEnvironment();
5886 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5887 GateRef methodId = ReadInst16_2(pc);
5888 GateRef length = ReadInst8_4(pc);
5889 auto frame = GetFrame(sp);
5890 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5891 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5892 SetCurrentGlobalEnv(globalEnv);
5893 GateRef result = DefineFunc(glue, constpool, ZExtInt16ToInt32(methodId));
5894 Label notException(env);
5895 CHECK_EXCEPTION_WITH_JUMP(result, ¬Exception);
5896 Bind(¬Exception);
5897 {
5898 SetLengthToFunction(glue, result, ZExtInt8ToInt32(length));
5899 SetLexicalEnvToFunction(glue, result, currentEnv);
5900 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5901 SetHomeObjectToFunction(glue, result, GetHomeObjectFromFunction(glue, currentFunc));
5902 SetModuleToFunction(glue, result, GetModuleFromFunction(glue, currentFunc));
5903 CallRuntime(glue, RTSTUB_ID(SetPatchModule), { result });
5904 #if ECMASCRIPT_ENABLE_IC
5905 GateRef slotId = ZExtInt16ToInt32(ReadInst16_0(pc));
5906 UpdateProfileTypeInfoCellToFunction(glue, result, profileTypeInfo, slotId);
5907 callback.ProfileDefineClass(result);
5908 #endif
5909 varAcc = result;
5910 DISPATCH_WITH_ACC(DEFINEFUNC_IMM16_ID16_IMM8);
5911 }
5912 }
5913
DECLARE_ASM_HANDLER(HandleWideLdpatchvarPrefImm16)5914 DECLARE_ASM_HANDLER(HandleWideLdpatchvarPrefImm16)
5915 {
5916 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
5917
5918 GateRef index = ReadInst16_1(pc);
5919 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5920 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdPatchVar), { Int16ToTaggedInt(index) });
5921 CHECK_EXCEPTION_WITH_VARACC(result, INT_PTR(WIDE_LDPATCHVAR_PREF_IMM16));
5922 }
5923
DECLARE_ASM_HANDLER(HandleWideStpatchvarPrefImm16)5924 DECLARE_ASM_HANDLER(HandleWideStpatchvarPrefImm16)
5925 {
5926 GateRef index = ReadInst16_1(pc);
5927 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5928 GateRef result = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(StPatchVar),
5929 { Int16ToTaggedInt(index), acc });
5930 CHECK_EXCEPTION(result, INT_PTR(WIDE_STPATCHVAR_PREF_IMM16));
5931 }
5932
DECLARE_ASM_HANDLER(HandleCallRuntimeNotifyConcurrentResultPrefNone)5933 DECLARE_ASM_HANDLER(HandleCallRuntimeNotifyConcurrentResultPrefNone)
5934 {
5935 GateRef funcObj = GetFunctionFromFrame(glue, GetFrame(sp));
5936 CallRuntime(glue, RTSTUB_ID(NotifyConcurrentResult), {acc, funcObj});
5937 DISPATCH(CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE);
5938 }
5939
DECLARE_ASM_HANDLER(HandleDefineFieldByNameImm8Id16V8)5940 DECLARE_ASM_HANDLER(HandleDefineFieldByNameImm8Id16V8)
5941 {
5942 auto env = GetEnvironment();
5943 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
5944 DEFINE_BY_NAME(Boolean(false));
5945 CHECK_EXCEPTION_WITH_ACC(*result, INT_PTR(DEFINEFIELDBYNAME_IMM8_ID16_V8));
5946 }
5947
DECLARE_ASM_HANDLER(HandleDefinePropertyByNameImm8Id16V8)5948 DECLARE_ASM_HANDLER(HandleDefinePropertyByNameImm8Id16V8)
5949 {
5950 auto env = GetEnvironment();
5951 DEFVARIABLE(result, VariableType::JS_ANY(), Hole());
5952 DEFINE_BY_NAME(Boolean(true));
5953 CHECK_EXCEPTION_WITH_ACC(*result, INT_PTR(DEFINEPROPERTYBYNAME_IMM8_ID16_V8));
5954 }
5955
DECLARE_ASM_HANDLER(HandleCallRuntimeDefineFieldByValuePrefImm8V8V8)5956 DECLARE_ASM_HANDLER(HandleCallRuntimeDefineFieldByValuePrefImm8V8V8)
5957 {
5958 GateRef v0 = ReadInst8_2(pc);
5959 GateRef v1 = ReadInst8_3(pc);
5960 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v1));
5961 GateRef propKey = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5962 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5963 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5964 SetCurrentGlobalEnv(globalEnv);
5965 GateRef res = DefineField(glue, obj, propKey, acc); // acc as value
5966 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8));
5967 }
5968
DECLARE_ASM_HANDLER(HandleCallRuntimeDefineFieldByIndexPrefImm8Imm32V8)5969 DECLARE_ASM_HANDLER(HandleCallRuntimeDefineFieldByIndexPrefImm8Imm32V8)
5970 {
5971 GateRef index = ReadInst32_2(pc);
5972 GateRef v0 = ReadInst8_6(pc);
5973 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
5974 GateRef propKey = IntToTaggedPtr(index);
5975 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5976 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5977 SetCurrentGlobalEnv(globalEnv);
5978 GateRef res = DefineField(glue, obj, propKey, acc); // acc as value
5979 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_DEFINEFIELDBYINDEX_PREF_IMM8_IMM32_V8));
5980 }
5981
DECLARE_ASM_HANDLER(HandleCallRuntimeToPropertyKeyPrefNone)5982 DECLARE_ASM_HANDLER(HandleCallRuntimeToPropertyKeyPrefNone)
5983 {
5984 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
5985 GateRef globalEnv = GetCurrentGlobalEnv(glue, currentEnv);
5986 SetCurrentGlobalEnv(globalEnv);
5987 GateRef res = ToPropertyKey(glue, acc);
5988 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_TOPROPERTYKEY_PREF_NONE));
5989 }
5990
DECLARE_ASM_HANDLER(HandleCallRuntimeCreatePrivatePropertyPrefImm16Id16)5991 DECLARE_ASM_HANDLER(HandleCallRuntimeCreatePrivatePropertyPrefImm16Id16)
5992 {
5993 GateRef frame = GetFrame(sp);
5994 GateRef currentEnv = GetEnvFromFrame(glue, frame);
5995 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
5996 GateRef module = GetModuleFromFunction(glue, currentFunc);
5997 GateRef count = ZExtInt16ToInt32(ReadInst16_1(pc));
5998 GateRef literalId = ZExtInt16ToInt32(ReadInst16_3(pc));
5999 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(CreatePrivateProperty),
6000 { currentEnv, IntToTaggedInt(count), constpool, IntToTaggedInt(literalId), module });
6001 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16));
6002 }
6003
DECLARE_ASM_HANDLER(HandleCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8)6004 DECLARE_ASM_HANDLER(HandleCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8)
6005 {
6006 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
6007 GateRef levelIndex = ReadInst16_2(pc);
6008 GateRef slotIndex = ReadInst16_4(pc);
6009 GateRef v0 = ReadInst8_6(pc);
6010 GateRef obj = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
6011 GateRef res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(DefinePrivateProperty),
6012 { currentEnv, IntToTaggedInt(levelIndex), IntToTaggedInt(slotIndex), obj, acc }); // acc as value
6013 CHECK_EXCEPTION_WITH_ACC(res, INT_PTR(CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8));
6014 }
6015
DECLARE_ASM_HANDLER(HandleCallRuntimeCallInitPrefImm8V8)6016 DECLARE_ASM_HANDLER(HandleCallRuntimeCallInitPrefImm8V8)
6017 {
6018 // same as callthis0
6019 GateRef actualNumArgs = Int32(InterpreterAssembly::ActualNumArgsOfCall::CALLARG0);
6020 GateRef thisValue = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_2(pc)));
6021 GateRef func = acc;
6022 METHOD_ENTRY(func);
6023 GateRef jumpSize = INT_PTR(CALLRUNTIME_CALLINIT_PREF_IMM8_V8);
6024 JSCallArgs callArgs(JSCallMode::CALL_THIS_ARG0);
6025 callArgs.callArgsWithThis = { 0, 0, 0, thisValue };
6026 CallStubBuilder callBuilder(this, glue, func, actualNumArgs, jumpSize, nullptr, hotnessCounter, callArgs, callback);
6027 GateRef res = callBuilder.JSCallDispatch();
6028 CHECK_PENDING_EXCEPTION(res, jumpSize);
6029 }
6030
DECLARE_ASM_HANDLER(HandleCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8)6031 DECLARE_ASM_HANDLER(HandleCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8)
6032 {
6033 auto env = GetEnvironment();
6034 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6035
6036 GateRef methodId = ReadInst16_3(pc);
6037 GateRef literalId = ReadInst16_5(pc);
6038 GateRef length = ReadInst16_7(pc);
6039 GateRef v0 = ReadInst8_9(pc);
6040
6041 GateRef proto = GetVregValue(glue, sp, ZExtInt8ToPtr(v0));
6042 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6043 GateRef module = GetModuleFromFunction(glue, currentFunc);
6044 GateRef res = CallRuntime(glue, RTSTUB_ID(CreateSharedClass),
6045 { proto, constpool,
6046 Int16ToTaggedInt(methodId),
6047 Int16ToTaggedInt(literalId),
6048 Int16ToTaggedInt(length), module });
6049
6050 Label isException(env);
6051 Label isNotException(env);
6052 BRANCH(TaggedIsException(res), &isException, &isNotException);
6053 Bind(&isException);
6054 {
6055 DISPATCH_LAST_WITH_ACC();
6056 }
6057 Bind(&isNotException);
6058 varAcc = res;
6059 DISPATCH_WITH_ACC(CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8);
6060 }
6061
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableClassPrefImm16)6062 DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableClassPrefImm16)
6063 {
6064 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6065 GateRef level = ReadInst16_1(pc);
6066 GateRef lexEnv = GetEnvFromFrame(glue, GetFrame(sp));
6067 varAcc = CallRuntime(glue, RTSTUB_ID(LdSendableClass), { lexEnv, Int16ToTaggedInt(level) });
6068 DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16);
6069 }
6070
DECLARE_ASM_HANDLER(HandleCallRuntimeLdsendableexternalmodulevarImm8)6071 DECLARE_ASM_HANDLER(HandleCallRuntimeLdsendableexternalmodulevarImm8)
6072 {
6073 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6074 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6075 GateRef index = ReadInst8_1(pc);
6076
6077 // LdSendableExternalModuleVarByIndex may load uninitialized module lazy. Exception could happened.
6078 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6079 moduleRef = CallRuntime(glue, RTSTUB_ID(LdSendableExternalModuleVarByIndex), {Int8ToTaggedInt(index), currentFunc});
6080
6081 auto env = GetEnvironment();
6082 Label notException(env);
6083 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6084 Bind(¬Exception);
6085 {
6086 varAcc = *moduleRef;
6087 DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8);
6088 }
6089 }
6090
DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdsendableexternalmodulevarPrefImm16)6091 DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdsendableexternalmodulevarPrefImm16)
6092 {
6093 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6094 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6095
6096 GateRef index = ReadInst16_1(pc);
6097
6098 // LdSendableExternalModuleVarByIndex may load uninitialized module lazy. Exception could happened.
6099 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6100 moduleRef =
6101 CallRuntime(glue, RTSTUB_ID(LdSendableExternalModuleVarByIndex), {Int16ToTaggedInt(index), currentFunc});
6102
6103 auto env = GetEnvironment();
6104 Label notException(env);
6105 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6106 Bind(¬Exception);
6107 {
6108 varAcc = *moduleRef;
6109 DISPATCH_WITH_ACC(CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16);
6110 }
6111 }
6112
DECLARE_ASM_HANDLER(HandleCallRuntimeNewSendableEnvImm8)6113 DECLARE_ASM_HANDLER(HandleCallRuntimeNewSendableEnvImm8)
6114 {
6115 auto env = GetEnvironment();
6116 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6117 GateRef numVars = ZExtInt8ToInt16(ReadInst8_1(pc));
6118 GateRef res = CallRuntime(glue, RTSTUB_ID(NewSendableEnv),
6119 { Int16ToTaggedInt(numVars) });
6120 Label notException(env);
6121 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
6122 Bind(¬Exception);
6123 varAcc = res;
6124 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6125 GateRef module = GetModuleFromFunction(glue, currentFunc);
6126 SetSendableEnvToModule(glue, module, res);
6127 DISPATCH_WITH_ACC(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8);
6128 }
6129
DECLARE_ASM_HANDLER(HandleCallRuntimeNewSendableEnvImm16)6130 DECLARE_ASM_HANDLER(HandleCallRuntimeNewSendableEnvImm16)
6131 {
6132 auto env = GetEnvironment();
6133 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6134 GateRef numVars = ReadInst16_1(pc);
6135 GateRef res = CallRuntime(glue, RTSTUB_ID(NewSendableEnv),
6136 { Int16ToTaggedInt(numVars) });
6137 Label notException(env);
6138 CHECK_EXCEPTION_WITH_JUMP(res, ¬Exception);
6139 Bind(¬Exception);
6140 varAcc = res;
6141 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6142 GateRef module = GetModuleFromFunction(glue, currentFunc);
6143 SetSendableEnvToModule(glue, module, res);
6144 DISPATCH_WITH_ACC(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16);
6145 }
6146
DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm4Imm4)6147 DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm4Imm4)
6148 {
6149 auto env = GetEnvironment();
6150 GateRef level = ZExtInt8ToInt32(ReadInst4_2(pc));
6151 GateRef slot = ZExtInt8ToInt32(ReadInst4_3(pc));
6152
6153 GateRef value = acc;
6154 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6155 GateRef module = GetModuleFromFunction(glue, currentFunc);
6156 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(glue, module));
6157 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
6158
6159 Label loopHead(env);
6160 Label loopEnd(env);
6161 Label afterLoop(env);
6162 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
6163 LoopBegin(&loopHead);
6164 currentEnv = GetSendableParentEnv(glue, *currentEnv);
6165 i = Int32Add(*i, Int32(1));
6166 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
6167 Bind(&loopEnd);
6168 LoopEndWithCheckSafePoint(&loopHead, env, glue);
6169 Bind(&afterLoop);
6170 SetPropertiesToSendableEnv(glue, *currentEnv, slot, value);
6171 DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4);
6172 }
6173
DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm8Imm8)6174 DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm8Imm8)
6175 {
6176 auto env = GetEnvironment();
6177 GateRef level = ZExtInt8ToInt32(ReadInst8_1(pc));
6178 GateRef slot = ZExtInt8ToInt32(ReadInst8_2(pc));
6179
6180 GateRef value = acc;
6181 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6182 GateRef module = GetModuleFromFunction(glue, currentFunc);
6183 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(glue, module));
6184 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
6185
6186 Label loopHead(env);
6187 Label loopEnd(env);
6188 Label afterLoop(env);
6189 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
6190 LoopBegin(&loopHead);
6191 currentEnv = GetSendableParentEnv(glue, *currentEnv);
6192 i = Int32Add(*i, Int32(1));
6193 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
6194 Bind(&loopEnd);
6195 LoopEndWithCheckSafePoint(&loopHead, env, glue);
6196 Bind(&afterLoop);
6197 SetPropertiesToSendableEnv(glue, *currentEnv, slot, value);
6198 DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8);
6199 }
6200
DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm16Imm16)6201 DECLARE_ASM_HANDLER(HandleCallRuntimeStSendableVarImm16Imm16)
6202 {
6203 auto env = GetEnvironment();
6204 GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
6205 GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
6206
6207 GateRef value = acc;
6208 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6209 GateRef module = GetModuleFromFunction(glue, currentFunc);
6210 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(glue, module));
6211 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
6212
6213 Label loopHead(env);
6214 Label loopEnd(env);
6215 Label afterLoop(env);
6216 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
6217 LoopBegin(&loopHead);
6218 currentEnv = GetSendableParentEnv(glue, *currentEnv);
6219 i = Int32Add(*i, Int32(1));
6220 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
6221 Bind(&loopEnd);
6222 LoopEndWithCheckSafePoint(&loopHead, env, glue);
6223 Bind(&afterLoop);
6224 SetPropertiesToSendableEnv(glue, *currentEnv, slot, value);
6225 DISPATCH(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16);
6226 }
6227
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm4Imm4)6228 DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm4Imm4)
6229 {
6230 auto env = GetEnvironment();
6231 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6232
6233 GateRef level = ZExtInt8ToInt32(ReadInst4_2(pc));
6234 GateRef slot = ZExtInt8ToInt32(ReadInst4_3(pc));
6235 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6236 GateRef module = GetModuleFromFunction(glue, currentFunc);
6237 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(glue, module));
6238 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
6239
6240 Label loopHead(env);
6241 Label loopEnd(env);
6242 Label afterLoop(env);
6243 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
6244 LoopBegin(&loopHead);
6245 currentEnv = GetSendableParentEnv(glue, *currentEnv);
6246 i = Int32Add(*i, Int32(1));
6247 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
6248 Bind(&loopEnd);
6249 LoopEndWithCheckSafePoint(&loopHead, env, glue);
6250 Bind(&afterLoop);
6251 GateRef variable = GetPropertiesFromSendableEnv(glue, *currentEnv, slot);
6252 varAcc = variable;
6253
6254 DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4);
6255 }
6256
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm8Imm8)6257 DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm8Imm8)
6258 {
6259 auto env = GetEnvironment();
6260 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6261
6262 GateRef level = ZExtInt8ToInt32(ReadInst8_1(pc));
6263 GateRef slot = ZExtInt8ToInt32(ReadInst8_2(pc));
6264
6265 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6266 GateRef module = GetModuleFromFunction(glue, currentFunc);
6267 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(glue, module));
6268 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
6269
6270 Label loopHead(env);
6271 Label loopEnd(env);
6272 Label afterLoop(env);
6273 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
6274 LoopBegin(&loopHead);
6275 currentEnv = GetSendableParentEnv(glue, *currentEnv);
6276 i = Int32Add(*i, Int32(1));
6277 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
6278 Bind(&loopEnd);
6279 LoopEndWithCheckSafePoint(&loopHead, env, glue);
6280 Bind(&afterLoop);
6281 GateRef variable = GetPropertiesFromSendableEnv(glue, *currentEnv, slot);
6282 varAcc = variable;
6283
6284 DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8);
6285 }
6286
DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm16Imm16)6287 DECLARE_ASM_HANDLER(HandleCallRuntimeLdSendableVarImm16Imm16)
6288 {
6289 auto env = GetEnvironment();
6290 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6291
6292 GateRef level = ZExtInt16ToInt32(ReadInst16_1(pc));
6293 GateRef slot = ZExtInt16ToInt32(ReadInst16_3(pc));
6294
6295 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6296 GateRef module = GetModuleFromFunction(glue, currentFunc);
6297 DEFVARIABLE(currentEnv, VariableType::JS_ANY(), GetSendableEnvFromModule(glue, module));
6298 DEFVARIABLE(i, VariableType::INT32(), Int32(0));
6299
6300 Label loopHead(env);
6301 Label loopEnd(env);
6302 Label afterLoop(env);
6303 BRANCH(Int32LessThan(*i, level), &loopHead, &afterLoop);
6304 LoopBegin(&loopHead);
6305 currentEnv = GetSendableParentEnv(glue, *currentEnv);
6306 i = Int32Add(*i, Int32(1));
6307 BRANCH(Int32LessThan(*i, level), &loopEnd, &afterLoop);
6308 Bind(&loopEnd);
6309 LoopEndWithCheckSafePoint(&loopHead, env, glue);
6310 Bind(&afterLoop);
6311 GateRef variable = GetPropertiesFromSendableEnv(glue, *currentEnv, slot);
6312 varAcc = variable;
6313
6314 DISPATCH_WITH_ACC(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16);
6315 }
DECLARE_ASM_HANDLER(HandleCallRuntimeLdLazyModuleVarPrefImm8)6316 DECLARE_ASM_HANDLER(HandleCallRuntimeLdLazyModuleVarPrefImm8)
6317 {
6318 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6319 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6320 GateRef index = ReadInst8_1(pc);
6321 GateRef frame = GetFrame(sp);
6322 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
6323 GateRef currentEnv = GetEnvFromFrame(glue, frame);
6324 moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdLazyExternalModuleVarByIndex),
6325 { Int8ToTaggedInt(index), currentFunc });
6326
6327 auto env = GetEnvironment();
6328 Label notException(env);
6329 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6330 Bind(¬Exception);
6331 {
6332 varAcc = *moduleRef;
6333 DISPATCH_WITH_ACC(CALLRUNTIME_LDLAZYMODULEVAR_PREF_IMM8);
6334 }
6335 }
6336
DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdLazyModuleVarPrefImm16)6337 DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdLazyModuleVarPrefImm16)
6338 {
6339 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6340 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6341
6342 GateRef index = ReadInst16_1(pc);
6343 GateRef frame = GetFrame(sp);
6344 GateRef currentFunc = GetFunctionFromFrame(glue, frame);
6345 GateRef currentEnv = GetEnvFromFrame(glue, frame);
6346 moduleRef = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(LdLazyExternalModuleVarByIndex),
6347 { Int16ToTaggedInt(index), currentFunc });
6348
6349 auto env = GetEnvironment();
6350 Label notException(env);
6351 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6352 Bind(¬Exception);
6353 {
6354 varAcc = *moduleRef;
6355 DISPATCH_WITH_ACC(CALLRUNTIME_WIDELDLAZYMODULEVAR_PREF_IMM16);
6356 }
6357 }
6358
DECLARE_ASM_HANDLER(HandleCallRuntimeLdLazySendableModuleVarPrefImm8)6359 DECLARE_ASM_HANDLER(HandleCallRuntimeLdLazySendableModuleVarPrefImm8)
6360 {
6361 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6362 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6363 GateRef index = ReadInst8_1(pc);
6364
6365 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6366 moduleRef = CallRuntime(glue, RTSTUB_ID(LdLazySendableExternalModuleVarByIndex),
6367 { Int8ToTaggedInt(index), currentFunc });
6368
6369 auto env = GetEnvironment();
6370 Label notException(env);
6371 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6372 Bind(¬Exception);
6373 {
6374 varAcc = *moduleRef;
6375 DISPATCH_WITH_ACC(CALLRUNTIME_LDLAZYSENDABLEMODULEVAR_PREF_IMM8);
6376 }
6377 }
6378
DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdLazySendableModuleVarPrefImm16)6379 DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdLazySendableModuleVarPrefImm16)
6380 {
6381 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6382 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6383
6384 GateRef index = ReadInst16_1(pc);
6385
6386 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6387 moduleRef = CallRuntime(glue, RTSTUB_ID(LdLazySendableExternalModuleVarByIndex),
6388 { Int16ToTaggedInt(index), currentFunc });
6389
6390 auto env = GetEnvironment();
6391 Label notException(env);
6392 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6393 Bind(¬Exception);
6394 {
6395 varAcc = *moduleRef;
6396 DISPATCH_WITH_ACC(CALLRUNTIME_WIDELDLAZYSENDABLEMODULEVAR_PREF_IMM16);
6397 }
6398 }
6399
DECLARE_ASM_HANDLER(HandleCallRuntimeSuperCallForwardAllArgsV8)6400 DECLARE_ASM_HANDLER(HandleCallRuntimeSuperCallForwardAllArgsV8)
6401 {
6402 DEFVARIABLE(varAcc, VariableType::JS_ANY(), Undefined());
6403 DEFVARIABLE(res, VariableType::JS_ANY(), Undefined());
6404
6405 auto env = GetEnvironment();
6406 Label resIsException(env);
6407 Label isException(env);
6408 Label dispatch(env);
6409
6410 GateRef thisFunc = GetVregValue(glue, sp, ZExtInt8ToPtr(ReadInst8_1(pc)));
6411 GateRef currentEnv = GetEnvFromFrame(glue, GetFrame(sp));
6412 res = CallRuntimeWithCurrentEnv(glue, currentEnv, RTSTUB_ID(SuperCallForwardAllArgs), { thisFunc });
6413
6414 BRANCH(TaggedIsException(*res), &resIsException, &dispatch);
6415 Bind(&resIsException);
6416 BRANCH(HasPendingException(glue), &isException, &dispatch);
6417 Bind(&isException);
6418 {
6419 DISPATCH_LAST();
6420 }
6421 Bind(&dispatch);
6422 {
6423 varAcc = *res;
6424 DISPATCH_WITH_ACC(CALLRUNTIME_SUPERCALLFORWARDALLARGS_PREF_V8);
6425 }
6426 }
6427
DECLARE_ASM_HANDLER(HandleCallRuntimeLdsendablelocalmodulevarImm8)6428 DECLARE_ASM_HANDLER(HandleCallRuntimeLdsendablelocalmodulevarImm8)
6429 {
6430 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6431 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6432 GateRef index = ReadInst8_1(pc);
6433
6434 // LdSendableLocalModuleVarByIndex may load uninitialized module lazy. Exception could happened.
6435 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6436 moduleRef = CallRuntime(glue, RTSTUB_ID(LdSendableLocalModuleVarByIndex), {Int8ToTaggedInt(index), currentFunc});
6437
6438 auto env = GetEnvironment();
6439 Label notException(env);
6440 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6441 Bind(¬Exception);
6442 {
6443 varAcc = *moduleRef;
6444 DISPATCH_WITH_ACC(CALLRUNTIME_LDSENDABLELOCALMODULEVAR_PREF_IMM8);
6445 }
6446 }
6447
DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdsendablelocalmodulevarPrefImm16)6448 DECLARE_ASM_HANDLER(HandleCallRuntimeWideLdsendablelocalmodulevarPrefImm16)
6449 {
6450 DEFVARIABLE(varAcc, VariableType::JS_ANY(), acc);
6451 DEFVARIABLE(moduleRef, VariableType::JS_ANY(), Undefined());
6452
6453 GateRef index = ReadInst16_1(pc);
6454
6455 // LdSendableLocalModuleVarByIndex may load uninitialized module lazy. Exception could happened.
6456 GateRef currentFunc = GetFunctionFromFrame(glue, GetFrame(sp));
6457 moduleRef =
6458 CallRuntime(glue, RTSTUB_ID(LdSendableLocalModuleVarByIndex), {Int16ToTaggedInt(index), currentFunc});
6459
6460 auto env = GetEnvironment();
6461 Label notException(env);
6462 CHECK_EXCEPTION_WITH_JUMP(*moduleRef, ¬Exception);
6463 Bind(¬Exception);
6464 {
6465 varAcc = *moduleRef;
6466 DISPATCH_WITH_ACC(CALLRUNTIME_WIDELDSENDABLELOCALMODULEVAR_PREF_IMM16);
6467 }
6468 }
6469
6470 ASM_INTERPRETER_BC_TYPE_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
6471 ASM_INTERPRETER_BC_LAYOUT_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
6472 ASM_INTERPRETER_BC_FUNC_HOT_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
6473 ASM_INTERPRETER_BC_FUNC_COUNT_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_PROFILE)
6474 ASM_INTERPRETER_BC_FUNC_HOT_JIT_PROFILER_STUB_LIST(DECLARE_ASM_HANDLER_JIT_PROFILE)
6475 ASM_INTERPRETER_BC_STW_COPY_STUB_LIST(DECLARE_ASM_HANDLER_STW_COPY)
6476
6477 #undef DECLARE_ASM_HANDLER
6478 #undef DISPATCH
6479 #undef DISPATCH_WITH_ACC
6480 #undef DISPATCH_LAST
6481 #undef DISPATCH_LAST_WITH_ACC
6482 #undef USE_PARAMS
6483 } // namespace panda::ecmascript::kungfu
6484