14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci#include "ecmascript/interpreter/interpreter_assembly.h" 174514f5e3Sopenharmony_ci 184514f5e3Sopenharmony_ci#include "ecmascript/ic/ic_runtime_stub-inl.h" 194514f5e3Sopenharmony_ci#include "ecmascript/interpreter/slow_runtime_stub.h" 204514f5e3Sopenharmony_ci#include "ecmascript/js_async_generator_object.h" 214514f5e3Sopenharmony_ci 224514f5e3Sopenharmony_ci#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER) 234514f5e3Sopenharmony_ci#include "ecmascript/dfx/cpu_profiler/cpu_profiler.h" 244514f5e3Sopenharmony_ci#endif 254514f5e3Sopenharmony_ci 264514f5e3Sopenharmony_cinamespace panda::ecmascript { 274514f5e3Sopenharmony_ciusing panda::ecmascript::kungfu::CommonStubCSigns; 284514f5e3Sopenharmony_ci#if defined(__clang__) 294514f5e3Sopenharmony_ci#pragma clang diagnostic push 304514f5e3Sopenharmony_ci#pragma clang diagnostic ignored "-Wvoid-ptr-dereference" 314514f5e3Sopenharmony_ci#pragma clang diagnostic ignored "-Wgnu-label-as-value" 324514f5e3Sopenharmony_ci#pragma clang diagnostic ignored "-Wunused-parameter" 334514f5e3Sopenharmony_ci#elif defined(__GNUC__) 344514f5e3Sopenharmony_ci#pragma GCC diagnostic push 354514f5e3Sopenharmony_ci#pragma GCC diagnostic ignored "-Wpedantic" 364514f5e3Sopenharmony_ci#pragma GCC diagnostic ignored "-Wunused-parameter" 374514f5e3Sopenharmony_ci#endif 384514f5e3Sopenharmony_ci 394514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_INTERPRETER_LOG 404514f5e3Sopenharmony_ci#define LOG_INST() LOG_INTERPRETER(DEBUG) 414514f5e3Sopenharmony_ci#else 424514f5e3Sopenharmony_ci#define LOG_INST() false && LOG_INTERPRETER(DEBUG) 434514f5e3Sopenharmony_ci#endif 444514f5e3Sopenharmony_ci 454514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 464514f5e3Sopenharmony_ci#define ADVANCE_PC(offset) \ 474514f5e3Sopenharmony_ci pc += (offset); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic, cppcoreguidelines-macro-usage) 484514f5e3Sopenharmony_ci 494514f5e3Sopenharmony_ci#define GOTO_NEXT() // NOLINT(clang-diagnostic-gnu-label-as-value, cppcoreguidelines-macro-usage) 504514f5e3Sopenharmony_ci 514514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 524514f5e3Sopenharmony_ci#define DISPATCH_OFFSET(offset) \ 534514f5e3Sopenharmony_ci do { \ 544514f5e3Sopenharmony_ci ADVANCE_PC(offset) \ 554514f5e3Sopenharmony_ci SAVE_PC(); \ 564514f5e3Sopenharmony_ci SAVE_ACC(); \ 574514f5e3Sopenharmony_ci AsmInterpretedFrame *frame = GET_ASM_FRAME(sp); \ 584514f5e3Sopenharmony_ci auto currentMethod = ECMAObject::Cast(frame->function.GetTaggedObject())->GetCallTarget(); \ 594514f5e3Sopenharmony_ci currentMethod->SetHotnessCounter(static_cast<int16_t>(hotnessCounter)); \ 604514f5e3Sopenharmony_ci return; \ 614514f5e3Sopenharmony_ci } while (false) 624514f5e3Sopenharmony_ci 634514f5e3Sopenharmony_ci#define DISPATCH(opcode) DISPATCH_OFFSET(BytecodeInstruction::Size(BytecodeInstruction::Opcode::opcode)) 644514f5e3Sopenharmony_ci 654514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 664514f5e3Sopenharmony_ci#define GET_ASM_FRAME(CurrentSp) \ 674514f5e3Sopenharmony_ci (reinterpret_cast<AsmInterpretedFrame *>(CurrentSp) - 1) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 684514f5e3Sopenharmony_ci#define GET_ENTRY_FRAME(sp) \ 694514f5e3Sopenharmony_ci (reinterpret_cast<InterpretedEntryFrame *>(sp) - 1) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 704514f5e3Sopenharmony_ci#define GET_BUILTIN_FRAME(sp) \ 714514f5e3Sopenharmony_ci (reinterpret_cast<InterpretedBuiltinFrame *>(sp) - 1) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 724514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 734514f5e3Sopenharmony_ci#define SAVE_PC() (GET_ASM_FRAME(sp)->pc = pc) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 744514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 754514f5e3Sopenharmony_ci#define SAVE_ACC() (GET_ASM_FRAME(sp)->acc = acc) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 764514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 774514f5e3Sopenharmony_ci#define RESTORE_ACC() (acc = GET_ASM_FRAME(sp)->acc) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 784514f5e3Sopenharmony_ci 794514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 804514f5e3Sopenharmony_ci#define INTERPRETER_GOTO_EXCEPTION_HANDLER() \ 814514f5e3Sopenharmony_ci do { \ 824514f5e3Sopenharmony_ci SAVE_PC(); \ 834514f5e3Sopenharmony_ci GET_ASM_FRAME(sp)->acc = JSTaggedValue::Exception(); \ 844514f5e3Sopenharmony_ci return; \ 854514f5e3Sopenharmony_ci } while (false) 864514f5e3Sopenharmony_ci 874514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 884514f5e3Sopenharmony_ci#define INTERPRETER_HANDLE_RETURN() \ 894514f5e3Sopenharmony_ci do { \ 904514f5e3Sopenharmony_ci JSFunction* prevFunc = JSFunction::Cast(prevState->function.GetTaggedObject()); \ 914514f5e3Sopenharmony_ci method = prevFunc->GetCallTarget(); \ 924514f5e3Sopenharmony_ci hotnessCounter = static_cast<int32_t>(method->GetHotnessCounter()); \ 934514f5e3Sopenharmony_ci ASSERT(prevState->callSize == GetJumpSizeAfterCall(pc)); \ 944514f5e3Sopenharmony_ci DISPATCH_OFFSET(prevState->callSize); \ 954514f5e3Sopenharmony_ci } while (false) 964514f5e3Sopenharmony_ci 974514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 984514f5e3Sopenharmony_ci#define INTERPRETER_RETURN_IF_ABRUPT(result) \ 994514f5e3Sopenharmony_ci do { \ 1004514f5e3Sopenharmony_ci if ((result).IsException()) { \ 1014514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); \ 1024514f5e3Sopenharmony_ci } \ 1034514f5e3Sopenharmony_ci } while (false) 1044514f5e3Sopenharmony_ci 1054514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 1064514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 1074514f5e3Sopenharmony_ci#define UPDATE_HOTNESS_COUNTER(offset) \ 1084514f5e3Sopenharmony_ci do { \ 1094514f5e3Sopenharmony_ci hotnessCounter += offset; \ 1104514f5e3Sopenharmony_ci if (UNLIKELY(hotnessCounter <= 0)) { \ 1114514f5e3Sopenharmony_ci SAVE_ACC(); \ 1124514f5e3Sopenharmony_ci profileTypeInfo = UpdateHotnessCounter(thread, sp); \ 1134514f5e3Sopenharmony_ci RESTORE_ACC(); \ 1144514f5e3Sopenharmony_ci hotnessCounter = EcmaInterpreter::METHOD_HOTNESS_THRESHOLD; \ 1154514f5e3Sopenharmony_ci } \ 1164514f5e3Sopenharmony_ci } while (false) 1174514f5e3Sopenharmony_ci#else 1184514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 1194514f5e3Sopenharmony_ci#define UPDATE_HOTNESS_COUNTER(offset) static_cast<void>(0) 1204514f5e3Sopenharmony_ci#endif 1214514f5e3Sopenharmony_ci 1224514f5e3Sopenharmony_ci#define READ_INST_OP() READ_INST_8(0) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1234514f5e3Sopenharmony_ci#define READ_INST_4_0() (READ_INST_8(1) & 0xf) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1244514f5e3Sopenharmony_ci#define READ_INST_4_1() (READ_INST_8(1) >> 4 & 0xf) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1254514f5e3Sopenharmony_ci#define READ_INST_4_2() (READ_INST_8(2) & 0xf) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1264514f5e3Sopenharmony_ci#define READ_INST_4_3() (READ_INST_8(2) >> 4 & 0xf) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1274514f5e3Sopenharmony_ci#define READ_INST_8_0() READ_INST_8(1) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1284514f5e3Sopenharmony_ci#define READ_INST_8_1() READ_INST_8(2) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1294514f5e3Sopenharmony_ci#define READ_INST_8_2() READ_INST_8(3) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1304514f5e3Sopenharmony_ci#define READ_INST_8_3() READ_INST_8(4) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1314514f5e3Sopenharmony_ci#define READ_INST_8_4() READ_INST_8(5) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1324514f5e3Sopenharmony_ci#define READ_INST_8_5() READ_INST_8(6) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1334514f5e3Sopenharmony_ci#define READ_INST_8_6() READ_INST_8(7) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1344514f5e3Sopenharmony_ci#define READ_INST_8_7() READ_INST_8(8) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1354514f5e3Sopenharmony_ci#define READ_INST_8_8() READ_INST_8(9) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1364514f5e3Sopenharmony_ci#define READ_INST_8_9() READ_INST_8(10) // NOLINT(hicpp-signed-bitwise, cppcoreguidelines-macro-usage) 1374514f5e3Sopenharmony_ci#define READ_INST_8(offset) (*(pc + (offset))) 1384514f5e3Sopenharmony_ci#define MOVE_AND_READ_INST_8(currentInst, offset) \ 1394514f5e3Sopenharmony_ci (currentInst) <<= 8; \ 1404514f5e3Sopenharmony_ci (currentInst) += READ_INST_8(offset); \ 1414514f5e3Sopenharmony_ci 1424514f5e3Sopenharmony_ci#define READ_INST_16_0() READ_INST_16(2) 1434514f5e3Sopenharmony_ci#define READ_INST_16_1() READ_INST_16(3) 1444514f5e3Sopenharmony_ci#define READ_INST_16_2() READ_INST_16(4) 1454514f5e3Sopenharmony_ci#define READ_INST_16_3() READ_INST_16(5) 1464514f5e3Sopenharmony_ci#define READ_INST_16_5() READ_INST_16(7) 1474514f5e3Sopenharmony_ci#define READ_INST_16_7() READ_INST_16(9) 1484514f5e3Sopenharmony_ci#define READ_INST_16(offset) \ 1494514f5e3Sopenharmony_ci ({ \ 1504514f5e3Sopenharmony_ci uint16_t currentInst = READ_INST_8(offset); \ 1514514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, (offset) - 1) \ 1524514f5e3Sopenharmony_ci }) 1534514f5e3Sopenharmony_ci 1544514f5e3Sopenharmony_ci#define READ_INST_32_0() READ_INST_32(4) 1554514f5e3Sopenharmony_ci#define READ_INST_32_1() READ_INST_32(5) 1564514f5e3Sopenharmony_ci#define READ_INST_32_2() READ_INST_32(6) 1574514f5e3Sopenharmony_ci#define READ_INST_32(offset) \ 1584514f5e3Sopenharmony_ci ({ \ 1594514f5e3Sopenharmony_ci uint32_t currentInst = READ_INST_8(offset); \ 1604514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, (offset) - 1) \ 1614514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, (offset) - 2) \ 1624514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, (offset) - 3) \ 1634514f5e3Sopenharmony_ci }) 1644514f5e3Sopenharmony_ci 1654514f5e3Sopenharmony_ci#define READ_INST_64_0() \ 1664514f5e3Sopenharmony_ci ({ \ 1674514f5e3Sopenharmony_ci uint64_t currentInst = READ_INST_8(8); \ 1684514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 7) \ 1694514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 6) \ 1704514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 5) \ 1714514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 4) \ 1724514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 3) \ 1734514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 2) \ 1744514f5e3Sopenharmony_ci MOVE_AND_READ_INST_8(currentInst, 1) \ 1754514f5e3Sopenharmony_ci }) 1764514f5e3Sopenharmony_ci 1774514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 1784514f5e3Sopenharmony_ci#define GET_VREG(idx) (sp[idx]) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 1794514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 1804514f5e3Sopenharmony_ci#define GET_VREG_VALUE(idx) (JSTaggedValue(sp[idx])) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 1814514f5e3Sopenharmony_ci// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) 1824514f5e3Sopenharmony_ci#define SET_VREG(idx, val) (sp[idx] = (val)); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) 1834514f5e3Sopenharmony_ci#define GET_ACC() (acc) // NOLINT(cppcoreguidelines-macro-usage) 1844514f5e3Sopenharmony_ci#define SET_ACC(val) (acc = val) // NOLINT(cppcoreguidelines-macro-usage) 1854514f5e3Sopenharmony_ci 1864514f5e3Sopenharmony_ciusing InterpreterEntry = JSTaggedType (*)(uintptr_t glue, ECMAObject *callTarget, 1874514f5e3Sopenharmony_ci Method *method, uint64_t callField, size_t argc, uintptr_t argv); 1884514f5e3Sopenharmony_ciusing GeneratorReEnterInterpEntry = JSTaggedType (*)(uintptr_t glue, JSTaggedType context); 1894514f5e3Sopenharmony_ci 1904514f5e3Sopenharmony_civoid InterpreterAssembly::InitStackFrame(JSThread *thread) 1914514f5e3Sopenharmony_ci{ 1924514f5e3Sopenharmony_ci InitStackFrameForSP(const_cast<JSTaggedType *>(thread->GetCurrentSPFrame())); 1934514f5e3Sopenharmony_ci} 1944514f5e3Sopenharmony_ci 1954514f5e3Sopenharmony_civoid InterpreterAssembly::InitStackFrame(EcmaContext *context) 1964514f5e3Sopenharmony_ci{ 1974514f5e3Sopenharmony_ci InitStackFrameForSP(const_cast<JSTaggedType *>(context->GetCurrentFrame())); 1984514f5e3Sopenharmony_ci} 1994514f5e3Sopenharmony_ci 2004514f5e3Sopenharmony_civoid InterpreterAssembly::InitStackFrameForSP(JSTaggedType *prevSp) 2014514f5e3Sopenharmony_ci{ 2024514f5e3Sopenharmony_ci InterpretedEntryFrame *entryState = InterpretedEntryFrame::GetFrameFromSp(prevSp); 2034514f5e3Sopenharmony_ci entryState->base.type = FrameType::INTERPRETER_ENTRY_FRAME; 2044514f5e3Sopenharmony_ci entryState->base.prev = nullptr; 2054514f5e3Sopenharmony_ci entryState->pc = nullptr; 2064514f5e3Sopenharmony_ci} 2074514f5e3Sopenharmony_ci 2084514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::Execute(EcmaRuntimeCallInfo *info) 2094514f5e3Sopenharmony_ci{ 2104514f5e3Sopenharmony_ci ASSERT(info); 2114514f5e3Sopenharmony_ci JSThread *thread = info->GetThread(); 2124514f5e3Sopenharmony_ci INTERPRETER_TRACE(thread, AsmExecute); 2134514f5e3Sopenharmony_ci // When the function is jit-compiled, the Method object is reinstalled. 2144514f5e3Sopenharmony_ci // In this case, the AotWithCall field may be updated. 2154514f5e3Sopenharmony_ci // This causes a Construct that is not a ClassConstructor to call jit code. 2164514f5e3Sopenharmony_ci ECMAObject *callTarget = reinterpret_cast<ECMAObject*>(info->GetFunctionValue().GetTaggedObject()); 2174514f5e3Sopenharmony_ci Method *method = callTarget->GetCallTarget(); 2184514f5e3Sopenharmony_ci bool isCompiledCode = JSFunctionBase::IsCompiledCodeFromCallTarget(info->GetFunctionValue()); 2194514f5e3Sopenharmony_ci 2204514f5e3Sopenharmony_ci // check is or not debugger 2214514f5e3Sopenharmony_ci thread->CheckSwitchDebuggerBCStub(); 2224514f5e3Sopenharmony_ci thread->CheckSafepoint(); 2234514f5e3Sopenharmony_ci uint32_t argc = info->GetArgsNumber(); 2244514f5e3Sopenharmony_ci uintptr_t argv = reinterpret_cast<uintptr_t>(info->GetArgs()); 2254514f5e3Sopenharmony_ci auto entry = thread->GetRTInterface(kungfu::RuntimeStubCSigns::ID_AsmInterpreterEntry); 2264514f5e3Sopenharmony_ci 2274514f5e3Sopenharmony_ci callTarget = reinterpret_cast<ECMAObject*>(info->GetFunctionValue().GetTaggedObject()); 2284514f5e3Sopenharmony_ci method = callTarget->GetCallTarget(); 2294514f5e3Sopenharmony_ci if (isCompiledCode) { 2304514f5e3Sopenharmony_ci JSHandle<JSFunction> func(thread, info->GetFunctionValue()); 2314514f5e3Sopenharmony_ci if (func->IsClassConstructor()) { 2324514f5e3Sopenharmony_ci { 2334514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 2344514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 2354514f5e3Sopenharmony_ci JSHandle<JSObject> error = factory->GetJSError(ErrorType::TYPE_ERROR, 2364514f5e3Sopenharmony_ci "class constructor cannot called without 'new'", StackCheck::NO); 2374514f5e3Sopenharmony_ci thread->SetException(error.GetTaggedValue()); 2384514f5e3Sopenharmony_ci } 2394514f5e3Sopenharmony_ci return thread->GetException(); 2404514f5e3Sopenharmony_ci } 2414514f5e3Sopenharmony_ci JSTaggedValue res = JSFunction::InvokeOptimizedEntrypoint(thread, func, info); 2424514f5e3Sopenharmony_ci const JSTaggedType *curSp = thread->GetCurrentSPFrame(); 2434514f5e3Sopenharmony_ci InterpretedEntryFrame *entryState = InterpretedEntryFrame::GetFrameFromSp(curSp); 2444514f5e3Sopenharmony_ci JSTaggedType *prevSp = entryState->base.prev; 2454514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(prevSp); 2464514f5e3Sopenharmony_ci if (thread->HasPendingException()) { 2474514f5e3Sopenharmony_ci return thread->GetException(); 2484514f5e3Sopenharmony_ci } 2494514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_STUB_RESULT_CHECK 2504514f5e3Sopenharmony_ci thread->CheckJSTaggedType(JSTaggedValue(res).GetRawData()); 2514514f5e3Sopenharmony_ci#endif 2524514f5e3Sopenharmony_ci return JSTaggedValue(res); 2534514f5e3Sopenharmony_ci } 2544514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER 2554514f5e3Sopenharmony_ci RuntimeStubs::StartCallTimer(thread->GetGlueAddr(), info->GetFunctionValue().GetRawData(), false); 2564514f5e3Sopenharmony_ci#endif 2574514f5e3Sopenharmony_ci if (thread->IsDebugMode() && !method->IsNativeWithCallField()) { 2584514f5e3Sopenharmony_ci JSHandle<JSFunction> func(thread, info->GetFunctionValue()); 2594514f5e3Sopenharmony_ci JSTaggedValue env = func->GetLexicalEnv(); 2604514f5e3Sopenharmony_ci MethodEntry(thread, method, env); 2614514f5e3Sopenharmony_ci } 2624514f5e3Sopenharmony_ci auto acc = reinterpret_cast<InterpreterEntry>(entry)(thread->GetGlueAddr(), 2634514f5e3Sopenharmony_ci callTarget, method, method->GetCallField(), argc, argv); 2644514f5e3Sopenharmony_ci 2654514f5e3Sopenharmony_ci if (thread->IsEntryFrameDroppedTrue()) { 2664514f5e3Sopenharmony_ci thread->PendingEntryFrameDroppedState(); 2674514f5e3Sopenharmony_ci return JSTaggedValue::Hole(); 2684514f5e3Sopenharmony_ci } 2694514f5e3Sopenharmony_ci 2704514f5e3Sopenharmony_ci auto sp = const_cast<JSTaggedType *>(thread->GetCurrentSPFrame()); 2714514f5e3Sopenharmony_ci ASSERT(FrameHandler::GetFrameType(sp) == FrameType::INTERPRETER_ENTRY_FRAME); 2724514f5e3Sopenharmony_ci auto prevEntry = InterpretedEntryFrame::GetFrameFromSp(sp)->GetPrevFrameFp(); 2734514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(prevEntry); 2744514f5e3Sopenharmony_ci 2754514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_STUB_RESULT_CHECK 2764514f5e3Sopenharmony_ci thread->CheckJSTaggedType(JSTaggedValue(acc).GetRawData()); 2774514f5e3Sopenharmony_ci#endif 2784514f5e3Sopenharmony_ci return JSTaggedValue(acc); 2794514f5e3Sopenharmony_ci} 2804514f5e3Sopenharmony_ci 2814514f5e3Sopenharmony_civoid InterpreterAssembly::MethodEntry(JSThread *thread, Method *method, JSTaggedValue env) 2824514f5e3Sopenharmony_ci{ 2834514f5e3Sopenharmony_ci FrameHandler frameHandler(thread); 2844514f5e3Sopenharmony_ci for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) { 2854514f5e3Sopenharmony_ci if (frameHandler.IsEntryFrame()) { 2864514f5e3Sopenharmony_ci continue; 2874514f5e3Sopenharmony_ci } 2884514f5e3Sopenharmony_ci auto *debuggerMgr = thread->GetEcmaVM()->GetJsDebuggerManager(); 2894514f5e3Sopenharmony_ci debuggerMgr->GetNotificationManager()->MethodEntryEvent(thread, method, env); 2904514f5e3Sopenharmony_ci return; 2914514f5e3Sopenharmony_ci } 2924514f5e3Sopenharmony_ci} 2934514f5e3Sopenharmony_ci 2944514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GeneratorReEnterInterpreter(JSThread *thread, JSHandle<GeneratorContext> context) 2954514f5e3Sopenharmony_ci{ 2964514f5e3Sopenharmony_ci // check is or not debugger 2974514f5e3Sopenharmony_ci thread->CheckSwitchDebuggerBCStub(); 2984514f5e3Sopenharmony_ci auto entry = thread->GetRTInterface(kungfu::RuntimeStubCSigns::ID_GeneratorReEnterAsmInterp); 2994514f5e3Sopenharmony_ci JSTaggedValue func = context->GetMethod(); 3004514f5e3Sopenharmony_ci Method *method = ECMAObject::Cast(func.GetTaggedObject())->GetCallTarget(); 3014514f5e3Sopenharmony_ci JSTaggedValue env = context->GetLexicalEnv(); 3024514f5e3Sopenharmony_ci if (thread->IsDebugMode() && !method->IsNativeWithCallField()) { 3034514f5e3Sopenharmony_ci MethodEntry(thread, method, env); 3044514f5e3Sopenharmony_ci } 3054514f5e3Sopenharmony_ci auto acc = reinterpret_cast<GeneratorReEnterInterpEntry>(entry)(thread->GetGlueAddr(), context.GetTaggedType()); 3064514f5e3Sopenharmony_ci return JSTaggedValue(acc); 3074514f5e3Sopenharmony_ci} 3084514f5e3Sopenharmony_ci#ifndef EXCLUDE_C_INTERPRETER 3094514f5e3Sopenharmony_civoid InterpreterAssembly::HandleMovV4V4( 3104514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3114514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3124514f5e3Sopenharmony_ci{ 3134514f5e3Sopenharmony_ci uint16_t vdst = READ_INST_4_0(); 3144514f5e3Sopenharmony_ci uint16_t vsrc = READ_INST_4_1(); 3154514f5e3Sopenharmony_ci LOG_INST() << "mov v" << vdst << ", v" << vsrc; 3164514f5e3Sopenharmony_ci uint64_t value = GET_VREG(vsrc); 3174514f5e3Sopenharmony_ci SET_VREG(vdst, value) 3184514f5e3Sopenharmony_ci DISPATCH(MOV_V4_V4); 3194514f5e3Sopenharmony_ci} 3204514f5e3Sopenharmony_ci 3214514f5e3Sopenharmony_civoid InterpreterAssembly::HandleMovV8V8( 3224514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3234514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3244514f5e3Sopenharmony_ci{ 3254514f5e3Sopenharmony_ci uint16_t vdst = READ_INST_8_0(); 3264514f5e3Sopenharmony_ci uint16_t vsrc = READ_INST_8_1(); 3274514f5e3Sopenharmony_ci LOG_INST() << "mov v" << vdst << ", v" << vsrc; 3284514f5e3Sopenharmony_ci uint64_t value = GET_VREG(vsrc); 3294514f5e3Sopenharmony_ci SET_VREG(vdst, value) 3304514f5e3Sopenharmony_ci DISPATCH(MOV_V8_V8); 3314514f5e3Sopenharmony_ci} 3324514f5e3Sopenharmony_ci 3334514f5e3Sopenharmony_civoid InterpreterAssembly::HandleMovV16V16( 3344514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3354514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3364514f5e3Sopenharmony_ci{ 3374514f5e3Sopenharmony_ci uint16_t vdst = READ_INST_16_0(); 3384514f5e3Sopenharmony_ci uint16_t vsrc = READ_INST_16_2(); 3394514f5e3Sopenharmony_ci LOG_INST() << "mov v" << vdst << ", v" << vsrc; 3404514f5e3Sopenharmony_ci uint64_t value = GET_VREG(vsrc); 3414514f5e3Sopenharmony_ci SET_VREG(vdst, value) 3424514f5e3Sopenharmony_ci DISPATCH(MOV_V16_V16); 3434514f5e3Sopenharmony_ci} 3444514f5e3Sopenharmony_ci 3454514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdaStrId16( 3464514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3474514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3484514f5e3Sopenharmony_ci{ 3494514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_0(); 3504514f5e3Sopenharmony_ci LOG_INST() << "lda.str " << std::hex << stringId; 3514514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 3524514f5e3Sopenharmony_ci SET_ACC(ConstantPool::GetStringFromCache(thread, constpool, stringId)); 3534514f5e3Sopenharmony_ci DISPATCH(LDA_STR_ID16); 3544514f5e3Sopenharmony_ci} 3554514f5e3Sopenharmony_ci 3564514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJmpImm8( 3574514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3584514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3594514f5e3Sopenharmony_ci{ 3604514f5e3Sopenharmony_ci int8_t offset = READ_INST_8_0(); 3614514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 3624514f5e3Sopenharmony_ci LOG_INST() << "jmp " << std::hex << static_cast<int32_t>(offset); 3634514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 3644514f5e3Sopenharmony_ci} 3654514f5e3Sopenharmony_ci 3664514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJmpImm16( 3674514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3684514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3694514f5e3Sopenharmony_ci{ 3704514f5e3Sopenharmony_ci int16_t offset = static_cast<int16_t>(READ_INST_16_0()); 3714514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 3724514f5e3Sopenharmony_ci LOG_INST() << "jmp " << std::hex << static_cast<int32_t>(offset); 3734514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 3744514f5e3Sopenharmony_ci} 3754514f5e3Sopenharmony_ci 3764514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJmpImm32( 3774514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3784514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3794514f5e3Sopenharmony_ci{ 3804514f5e3Sopenharmony_ci int32_t offset = static_cast<int32_t>(READ_INST_32_0()); 3814514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 3824514f5e3Sopenharmony_ci LOG_INST() << "jmp " << std::hex << offset; 3834514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 3844514f5e3Sopenharmony_ci} 3854514f5e3Sopenharmony_ci 3864514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqzImm8( 3874514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 3884514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 3894514f5e3Sopenharmony_ci{ 3904514f5e3Sopenharmony_ci int8_t offset = READ_INST_8_0(); 3914514f5e3Sopenharmony_ci LOG_INST() << "jeqz ->\t" 3924514f5e3Sopenharmony_ci << "cond jmpz " << std::hex << static_cast<int32_t>(offset); 3934514f5e3Sopenharmony_ci if (GET_ACC().IsFalse() || (GET_ACC().IsInt() && GET_ACC().GetInt() == 0) || 3944514f5e3Sopenharmony_ci (GET_ACC().IsDouble() && GET_ACC().GetDouble() == 0)) { 3954514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 3964514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 3974514f5e3Sopenharmony_ci } else { 3984514f5e3Sopenharmony_ci DISPATCH(JEQZ_IMM8); 3994514f5e3Sopenharmony_ci } 4004514f5e3Sopenharmony_ci} 4014514f5e3Sopenharmony_ci 4024514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqzImm16( 4034514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4044514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4054514f5e3Sopenharmony_ci{ 4064514f5e3Sopenharmony_ci int16_t offset = static_cast<int16_t>(READ_INST_16_0()); 4074514f5e3Sopenharmony_ci LOG_INST() << "jeqz ->\t" 4084514f5e3Sopenharmony_ci << "cond jmpz " << std::hex << static_cast<int32_t>(offset); 4094514f5e3Sopenharmony_ci if (GET_ACC().IsFalse() || (GET_ACC().IsInt() && GET_ACC().GetInt() == 0) || 4104514f5e3Sopenharmony_ci (GET_ACC().IsDouble() && GET_ACC().GetDouble() == 0)) { 4114514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 4124514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 4134514f5e3Sopenharmony_ci } else { 4144514f5e3Sopenharmony_ci DISPATCH(JEQZ_IMM16); 4154514f5e3Sopenharmony_ci } 4164514f5e3Sopenharmony_ci} 4174514f5e3Sopenharmony_ci 4184514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqzImm32( 4194514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4204514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4214514f5e3Sopenharmony_ci{ 4224514f5e3Sopenharmony_ci int32_t offset = static_cast<int32_t>(READ_INST_32_0()); 4234514f5e3Sopenharmony_ci LOG_INST() << "jeqz ->\t" 4244514f5e3Sopenharmony_ci << "cond jmpz " << std::hex << offset; 4254514f5e3Sopenharmony_ci if (GET_ACC().IsFalse() || (GET_ACC().IsInt() && GET_ACC().GetInt() == 0) || 4264514f5e3Sopenharmony_ci (GET_ACC().IsDouble() && GET_ACC().GetDouble() == 0)) { 4274514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 4284514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 4294514f5e3Sopenharmony_ci } else { 4304514f5e3Sopenharmony_ci DISPATCH(JEQZ_IMM16); 4314514f5e3Sopenharmony_ci } 4324514f5e3Sopenharmony_ci} 4334514f5e3Sopenharmony_ci 4344514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnezImm8( 4354514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4364514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4374514f5e3Sopenharmony_ci{ 4384514f5e3Sopenharmony_ci int8_t offset = READ_INST_8_0(); 4394514f5e3Sopenharmony_ci LOG_INST() << "jnez ->\t" 4404514f5e3Sopenharmony_ci << "cond jmpz " << std::hex << static_cast<int32_t>(offset); 4414514f5e3Sopenharmony_ci if (GET_ACC().IsTrue() || (GET_ACC().IsInt() && GET_ACC().GetInt() != 0) || 4424514f5e3Sopenharmony_ci (GET_ACC().IsDouble() && GET_ACC().GetDouble() != 0)) { 4434514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 4444514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 4454514f5e3Sopenharmony_ci } else { 4464514f5e3Sopenharmony_ci DISPATCH(JNEZ_IMM8); 4474514f5e3Sopenharmony_ci } 4484514f5e3Sopenharmony_ci} 4494514f5e3Sopenharmony_ci 4504514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnezImm16( 4514514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4524514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4534514f5e3Sopenharmony_ci{ 4544514f5e3Sopenharmony_ci int16_t offset = static_cast<int16_t>(READ_INST_16_0()); 4554514f5e3Sopenharmony_ci LOG_INST() << "jnez ->\t" 4564514f5e3Sopenharmony_ci << "cond jmpz " << std::hex << static_cast<int32_t>(offset); 4574514f5e3Sopenharmony_ci if (GET_ACC().IsTrue() || (GET_ACC().IsInt() && GET_ACC().GetInt() != 0) || 4584514f5e3Sopenharmony_ci (GET_ACC().IsDouble() && GET_ACC().GetDouble() != 0)) { 4594514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 4604514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 4614514f5e3Sopenharmony_ci } else { 4624514f5e3Sopenharmony_ci DISPATCH(JNEZ_IMM16); 4634514f5e3Sopenharmony_ci } 4644514f5e3Sopenharmony_ci} 4654514f5e3Sopenharmony_ci 4664514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnezImm32( 4674514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4684514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4694514f5e3Sopenharmony_ci{ 4704514f5e3Sopenharmony_ci int32_t offset = static_cast<int32_t>(READ_INST_32_0()); 4714514f5e3Sopenharmony_ci LOG_INST() << "jnez ->\t" 4724514f5e3Sopenharmony_ci << "cond jmpz " << std::hex << offset; 4734514f5e3Sopenharmony_ci if (GET_ACC().IsTrue() || (GET_ACC().IsInt() && GET_ACC().GetInt() != 0) || 4744514f5e3Sopenharmony_ci (GET_ACC().IsDouble() && GET_ACC().GetDouble() != 0)) { 4754514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(offset); 4764514f5e3Sopenharmony_ci DISPATCH_OFFSET(offset); 4774514f5e3Sopenharmony_ci } else { 4784514f5e3Sopenharmony_ci DISPATCH(JNEZ_IMM32); 4794514f5e3Sopenharmony_ci } 4804514f5e3Sopenharmony_ci} 4814514f5e3Sopenharmony_ci 4824514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdaV8( 4834514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4844514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4854514f5e3Sopenharmony_ci{ 4864514f5e3Sopenharmony_ci uint16_t vsrc = READ_INST_8_0(); 4874514f5e3Sopenharmony_ci LOG_INST() << "lda v" << vsrc; 4884514f5e3Sopenharmony_ci uint64_t value = GET_VREG(vsrc); 4894514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(value)); 4904514f5e3Sopenharmony_ci DISPATCH(LDA_V8); 4914514f5e3Sopenharmony_ci} 4924514f5e3Sopenharmony_ci 4934514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStaV8( 4944514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 4954514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 4964514f5e3Sopenharmony_ci{ 4974514f5e3Sopenharmony_ci uint16_t vdst = READ_INST_8_0(); 4984514f5e3Sopenharmony_ci LOG_INST() << "sta v" << vdst; 4994514f5e3Sopenharmony_ci SET_VREG(vdst, GET_ACC().GetRawData()) 5004514f5e3Sopenharmony_ci DISPATCH(STA_V8); 5014514f5e3Sopenharmony_ci} 5024514f5e3Sopenharmony_ci 5034514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdaiImm32( 5044514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 5054514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 5064514f5e3Sopenharmony_ci{ 5074514f5e3Sopenharmony_ci int32_t imm = static_cast<int32_t>(READ_INST_32_0()); 5084514f5e3Sopenharmony_ci LOG_INST() << "ldai " << std::hex << imm; 5094514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(imm)); 5104514f5e3Sopenharmony_ci DISPATCH(LDAI_IMM32); 5114514f5e3Sopenharmony_ci} 5124514f5e3Sopenharmony_ci 5134514f5e3Sopenharmony_civoid InterpreterAssembly::HandleFldaiImm64( 5144514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 5154514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 5164514f5e3Sopenharmony_ci{ 5174514f5e3Sopenharmony_ci auto imm = base::bit_cast<double>(READ_INST_64_0()); 5184514f5e3Sopenharmony_ci LOG_INST() << "fldai " << imm; 5194514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(imm)); 5204514f5e3Sopenharmony_ci DISPATCH(FLDAI_IMM64); 5214514f5e3Sopenharmony_ci} 5224514f5e3Sopenharmony_ci 5234514f5e3Sopenharmony_civoid InterpreterAssembly::HandleReturn( 5244514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 5254514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 5264514f5e3Sopenharmony_ci{ 5274514f5e3Sopenharmony_ci LOG_INST() << "returnla "; 5284514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 5294514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime Call " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 5304514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(state->pc); 5314514f5e3Sopenharmony_ci Method *method = ECMAObject::Cast(state->function.GetTaggedObject())->GetCallTarget(); 5324514f5e3Sopenharmony_ci [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); 5334514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); 5344514f5e3Sopenharmony_ci method->SetHotnessCounter(static_cast<int16_t>(hotnessCounter)); 5354514f5e3Sopenharmony_ci sp = state->base.prev; 5364514f5e3Sopenharmony_ci ASSERT(sp != nullptr); 5374514f5e3Sopenharmony_ci 5384514f5e3Sopenharmony_ci AsmInterpretedFrame *prevState = GET_ASM_FRAME(sp); 5394514f5e3Sopenharmony_ci pc = prevState->pc; 5404514f5e3Sopenharmony_ci thread->SetCurrentFrame(sp); 5414514f5e3Sopenharmony_ci // entry frame 5424514f5e3Sopenharmony_ci if (pc == nullptr) { 5434514f5e3Sopenharmony_ci state->acc = acc; 5444514f5e3Sopenharmony_ci return; 5454514f5e3Sopenharmony_ci } 5464514f5e3Sopenharmony_ci 5474514f5e3Sopenharmony_ci // new stackless not supported 5484514f5e3Sopenharmony_ci INTERPRETER_HANDLE_RETURN(); 5494514f5e3Sopenharmony_ci} 5504514f5e3Sopenharmony_ci 5514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleReturnundefined( 5524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 5534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 5544514f5e3Sopenharmony_ci{ 5554514f5e3Sopenharmony_ci LOG_INST() << "return.undefined"; 5564514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 5574514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime Call " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 5584514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(state->pc); 5594514f5e3Sopenharmony_ci Method *method = ECMAObject::Cast(state->function.GetTaggedObject())->GetCallTarget(); 5604514f5e3Sopenharmony_ci [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); 5614514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); 5624514f5e3Sopenharmony_ci method->SetHotnessCounter(static_cast<int16_t>(hotnessCounter)); 5634514f5e3Sopenharmony_ci sp = state->base.prev; 5644514f5e3Sopenharmony_ci ASSERT(sp != nullptr); 5654514f5e3Sopenharmony_ci 5664514f5e3Sopenharmony_ci AsmInterpretedFrame *prevState = GET_ASM_FRAME(sp); 5674514f5e3Sopenharmony_ci pc = prevState->pc; 5684514f5e3Sopenharmony_ci thread->SetCurrentFrame(sp); 5694514f5e3Sopenharmony_ci // entry frame 5704514f5e3Sopenharmony_ci if (pc == nullptr) { 5714514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Undefined(); 5724514f5e3Sopenharmony_ci return; 5734514f5e3Sopenharmony_ci } 5744514f5e3Sopenharmony_ci 5754514f5e3Sopenharmony_ci // new stackless not supported 5764514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::Undefined()); 5774514f5e3Sopenharmony_ci INTERPRETER_HANDLE_RETURN(); 5784514f5e3Sopenharmony_ci} 5794514f5e3Sopenharmony_ci 5804514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdnan( 5814514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 5824514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 5834514f5e3Sopenharmony_ci{ 5844514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldnan"; 5854514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(base::NAN_VALUE)); 5864514f5e3Sopenharmony_ci DISPATCH(LDNAN); 5874514f5e3Sopenharmony_ci} 5884514f5e3Sopenharmony_ci 5894514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdinfinity( 5904514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 5914514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 5924514f5e3Sopenharmony_ci{ 5934514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldinfinity"; 5944514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(base::POSITIVE_INFINITY)); 5954514f5e3Sopenharmony_ci DISPATCH(LDINFINITY); 5964514f5e3Sopenharmony_ci} 5974514f5e3Sopenharmony_ci 5984514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdundefined( 5994514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6004514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6014514f5e3Sopenharmony_ci{ 6024514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldundefined"; 6034514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::Undefined()); 6044514f5e3Sopenharmony_ci DISPATCH(LDUNDEFINED); 6054514f5e3Sopenharmony_ci} 6064514f5e3Sopenharmony_ci 6074514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdnull( 6084514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6094514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6104514f5e3Sopenharmony_ci{ 6114514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldnull"; 6124514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::Null()); 6134514f5e3Sopenharmony_ci DISPATCH(LDNULL); 6144514f5e3Sopenharmony_ci} 6154514f5e3Sopenharmony_ci 6164514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdsymbol( 6174514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6184514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6194514f5e3Sopenharmony_ci{ 6204514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsymbol"; 6214514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 6224514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 6234514f5e3Sopenharmony_ci SET_ACC(globalEnv->GetSymbolFunction().GetTaggedValue()); 6244514f5e3Sopenharmony_ci DISPATCH(LDSYMBOL); 6254514f5e3Sopenharmony_ci} 6264514f5e3Sopenharmony_ci 6274514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdglobal( 6284514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6294514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6304514f5e3Sopenharmony_ci{ 6314514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldglobal"; 6324514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 6334514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 6344514f5e3Sopenharmony_ci JSTaggedValue globalObj = globalEnv->GetGlobalObject(); 6354514f5e3Sopenharmony_ci SET_ACC(globalObj); 6364514f5e3Sopenharmony_ci DISPATCH(LDGLOBAL); 6374514f5e3Sopenharmony_ci} 6384514f5e3Sopenharmony_ci 6394514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdtrue( 6404514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6414514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6424514f5e3Sopenharmony_ci{ 6434514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldtrue"; 6444514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::True()); 6454514f5e3Sopenharmony_ci DISPATCH(LDTRUE); 6464514f5e3Sopenharmony_ci} 6474514f5e3Sopenharmony_ci 6484514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdfalse( 6494514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6504514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6514514f5e3Sopenharmony_ci{ 6524514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldfalse"; 6534514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::False()); 6544514f5e3Sopenharmony_ci DISPATCH(LDFALSE); 6554514f5e3Sopenharmony_ci} 6564514f5e3Sopenharmony_ci 6574514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetunmappedargs( 6584514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6594514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6604514f5e3Sopenharmony_ci{ 6614514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getunmappedargs"; 6624514f5e3Sopenharmony_ci 6634514f5e3Sopenharmony_ci uint32_t startIdx = 0; 6644514f5e3Sopenharmony_ci uint32_t actualNumArgs = GetNumArgs(sp, 0, startIdx); 6654514f5e3Sopenharmony_ci 6664514f5e3Sopenharmony_ci SAVE_PC(); 6674514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetUnmapedArgs(thread, sp, actualNumArgs, startIdx); 6684514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 6694514f5e3Sopenharmony_ci SET_ACC(res); 6704514f5e3Sopenharmony_ci DISPATCH(GETUNMAPPEDARGS); 6714514f5e3Sopenharmony_ci} 6724514f5e3Sopenharmony_ci 6734514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAsyncfunctionenter( 6744514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6754514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6764514f5e3Sopenharmony_ci{ 6774514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionenter"; 6784514f5e3Sopenharmony_ci SAVE_PC(); 6794514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionEnter(thread); 6804514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 6814514f5e3Sopenharmony_ci SET_ACC(res); 6824514f5e3Sopenharmony_ci DISPATCH(ASYNCFUNCTIONENTER); 6834514f5e3Sopenharmony_ci} 6844514f5e3Sopenharmony_ci 6854514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTonumberImm8( 6864514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 6874514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 6884514f5e3Sopenharmony_ci{ 6894514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::tonumber"; 6904514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 6914514f5e3Sopenharmony_ci if (value.IsNumber()) { 6924514f5e3Sopenharmony_ci // fast path 6934514f5e3Sopenharmony_ci SET_ACC(value); 6944514f5e3Sopenharmony_ci } else { 6954514f5e3Sopenharmony_ci // slow path 6964514f5e3Sopenharmony_ci SAVE_PC(); 6974514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::ToNumber(thread, value); 6984514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 6994514f5e3Sopenharmony_ci SET_ACC(res); 7004514f5e3Sopenharmony_ci } 7014514f5e3Sopenharmony_ci DISPATCH(TONUMBER_IMM8); 7024514f5e3Sopenharmony_ci} 7034514f5e3Sopenharmony_ci 7044514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNegImm8( 7054514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 7064514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 7074514f5e3Sopenharmony_ci{ 7084514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::neg"; 7094514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 7104514f5e3Sopenharmony_ci // fast path 7114514f5e3Sopenharmony_ci if (value.IsInt()) { 7124514f5e3Sopenharmony_ci if (value.GetInt() == 0) { 7134514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-0.0)); 7144514f5e3Sopenharmony_ci } else { 7154514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-value.GetInt())); 7164514f5e3Sopenharmony_ci } 7174514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 7184514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-value.GetDouble())); 7194514f5e3Sopenharmony_ci } else { // slow path 7204514f5e3Sopenharmony_ci SAVE_PC(); 7214514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Neg(thread, value); 7224514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 7234514f5e3Sopenharmony_ci SET_ACC(res); 7244514f5e3Sopenharmony_ci } 7254514f5e3Sopenharmony_ci DISPATCH(NEG_IMM8); 7264514f5e3Sopenharmony_ci} 7274514f5e3Sopenharmony_ci 7284514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNotImm8( 7294514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 7304514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 7314514f5e3Sopenharmony_ci{ 7324514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::not"; 7334514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 7344514f5e3Sopenharmony_ci int32_t number; 7354514f5e3Sopenharmony_ci // number, fast path 7364514f5e3Sopenharmony_ci if (value.IsInt()) { 7374514f5e3Sopenharmony_ci number = static_cast<int32_t>(value.GetInt()); 7384514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(~number)); // NOLINT(hicpp-signed-bitwise); 7394514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 7404514f5e3Sopenharmony_ci number = base::NumberHelper::DoubleToInt(value.GetDouble(), base::INT32_BITS); 7414514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(~number)); // NOLINT(hicpp-signed-bitwise); 7424514f5e3Sopenharmony_ci } else { 7434514f5e3Sopenharmony_ci // slow path 7444514f5e3Sopenharmony_ci SAVE_PC(); 7454514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Not(thread, value); 7464514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 7474514f5e3Sopenharmony_ci SET_ACC(res); 7484514f5e3Sopenharmony_ci } 7494514f5e3Sopenharmony_ci DISPATCH(NOT_IMM8); 7504514f5e3Sopenharmony_ci} 7514514f5e3Sopenharmony_ci 7524514f5e3Sopenharmony_civoid InterpreterAssembly::HandleIncImm8( 7534514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 7544514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 7554514f5e3Sopenharmony_ci{ 7564514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::inc"; 7574514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 7584514f5e3Sopenharmony_ci // number fast path 7594514f5e3Sopenharmony_ci if (value.IsInt()) { 7604514f5e3Sopenharmony_ci int32_t a0 = value.GetInt(); 7614514f5e3Sopenharmony_ci if (UNLIKELY(a0 == INT32_MAX)) { 7624514f5e3Sopenharmony_ci auto ret = static_cast<double>(a0) + 1.0; 7634514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 7644514f5e3Sopenharmony_ci } else { 7654514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(a0 + 1)); 7664514f5e3Sopenharmony_ci } 7674514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 7684514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(value.GetDouble() + 1.0)); 7694514f5e3Sopenharmony_ci } else { 7704514f5e3Sopenharmony_ci // slow path 7714514f5e3Sopenharmony_ci SAVE_PC(); 7724514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Inc(thread, value); 7734514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 7744514f5e3Sopenharmony_ci SET_ACC(res); 7754514f5e3Sopenharmony_ci } 7764514f5e3Sopenharmony_ci DISPATCH(INC_IMM8); 7774514f5e3Sopenharmony_ci} 7784514f5e3Sopenharmony_ci 7794514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDecImm8( 7804514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 7814514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 7824514f5e3Sopenharmony_ci{ 7834514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::dec"; 7844514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 7854514f5e3Sopenharmony_ci // number, fast path 7864514f5e3Sopenharmony_ci if (value.IsInt()) { 7874514f5e3Sopenharmony_ci int32_t a0 = value.GetInt(); 7884514f5e3Sopenharmony_ci if (UNLIKELY(a0 == INT32_MIN)) { 7894514f5e3Sopenharmony_ci auto ret = static_cast<double>(a0) - 1.0; 7904514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 7914514f5e3Sopenharmony_ci } else { 7924514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(a0 - 1)); 7934514f5e3Sopenharmony_ci } 7944514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 7954514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(value.GetDouble() - 1.0)); 7964514f5e3Sopenharmony_ci } else { 7974514f5e3Sopenharmony_ci // slow path 7984514f5e3Sopenharmony_ci SAVE_PC(); 7994514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Dec(thread, value); 8004514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 8014514f5e3Sopenharmony_ci SET_ACC(res); 8024514f5e3Sopenharmony_ci } 8034514f5e3Sopenharmony_ci DISPATCH(DEC_IMM8); 8044514f5e3Sopenharmony_ci} 8054514f5e3Sopenharmony_ci 8064514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrow( 8074514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8084514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8094514f5e3Sopenharmony_ci{ 8104514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::throw"; 8114514f5e3Sopenharmony_ci SAVE_PC(); 8124514f5e3Sopenharmony_ci SlowRuntimeStub::Throw(thread, GET_ACC()); 8134514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 8144514f5e3Sopenharmony_ci} 8154514f5e3Sopenharmony_ci 8164514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTypeofImm8( 8174514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8184514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8194514f5e3Sopenharmony_ci{ 8204514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::typeof"; 8214514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastTypeOf(thread, GET_ACC()); 8224514f5e3Sopenharmony_ci SET_ACC(res); 8234514f5e3Sopenharmony_ci DISPATCH(TYPEOF_IMM8); 8244514f5e3Sopenharmony_ci} 8254514f5e3Sopenharmony_ci 8264514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetpropiterator( 8274514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8284514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8294514f5e3Sopenharmony_ci{ 8304514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getpropiterator"; 8314514f5e3Sopenharmony_ci SAVE_PC(); 8324514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetPropIterator(thread, GET_ACC()); 8334514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 8344514f5e3Sopenharmony_ci SET_ACC(res); 8354514f5e3Sopenharmony_ci DISPATCH(GETPROPITERATOR); 8364514f5e3Sopenharmony_ci} 8374514f5e3Sopenharmony_ci 8384514f5e3Sopenharmony_civoid InterpreterAssembly::HandleResumegenerator( 8394514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8404514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8414514f5e3Sopenharmony_ci{ 8424514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::resumegenerator"; 8434514f5e3Sopenharmony_ci JSTaggedValue objVal = GET_ACC(); 8444514f5e3Sopenharmony_ci if (objVal.IsAsyncGeneratorObject()) { 8454514f5e3Sopenharmony_ci JSAsyncGeneratorObject *obj = JSAsyncGeneratorObject::Cast(objVal.GetTaggedObject()); 8464514f5e3Sopenharmony_ci SET_ACC(obj->GetResumeResult()); 8474514f5e3Sopenharmony_ci } else { 8484514f5e3Sopenharmony_ci JSGeneratorObject *obj = JSGeneratorObject::Cast(objVal.GetTaggedObject()); 8494514f5e3Sopenharmony_ci SET_ACC(obj->GetResumeResult()); 8504514f5e3Sopenharmony_ci } 8514514f5e3Sopenharmony_ci DISPATCH(RESUMEGENERATOR); 8524514f5e3Sopenharmony_ci} 8534514f5e3Sopenharmony_ci 8544514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetresumemode( 8554514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8564514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8574514f5e3Sopenharmony_ci{ 8584514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getresumemode"; 8594514f5e3Sopenharmony_ci JSTaggedValue objVal = GET_ACC(); 8604514f5e3Sopenharmony_ci if (objVal.IsAsyncGeneratorObject()) { 8614514f5e3Sopenharmony_ci JSAsyncGeneratorObject *obj = JSAsyncGeneratorObject::Cast(objVal.GetTaggedObject()); 8624514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int>(obj->GetResumeMode()))); 8634514f5e3Sopenharmony_ci } else { 8644514f5e3Sopenharmony_ci JSGeneratorObject *obj = JSGeneratorObject::Cast(objVal.GetTaggedObject()); 8654514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int>(obj->GetResumeMode()))); 8664514f5e3Sopenharmony_ci } 8674514f5e3Sopenharmony_ci DISPATCH(GETRESUMEMODE); 8684514f5e3Sopenharmony_ci} 8694514f5e3Sopenharmony_ci 8704514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetiteratorImm8( 8714514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8724514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8734514f5e3Sopenharmony_ci{ 8744514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getiterator"; 8754514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 8764514f5e3Sopenharmony_ci // slow path 8774514f5e3Sopenharmony_ci SAVE_PC(); 8784514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetIterator(thread, obj); 8794514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 8804514f5e3Sopenharmony_ci SET_ACC(res); 8814514f5e3Sopenharmony_ci DISPATCH(GETITERATOR_IMM8); 8824514f5e3Sopenharmony_ci} 8834514f5e3Sopenharmony_ci 8844514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetasynciteratorImm8( 8854514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 8864514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 8874514f5e3Sopenharmony_ci{ 8884514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getasynciterator"; 8894514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 8904514f5e3Sopenharmony_ci // slow path 8914514f5e3Sopenharmony_ci SAVE_PC(); 8924514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetAsyncIterator(thread, obj); 8934514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 8944514f5e3Sopenharmony_ci SET_ACC(res); 8954514f5e3Sopenharmony_ci DISPATCH(GETASYNCITERATOR_IMM8); 8964514f5e3Sopenharmony_ci} 8974514f5e3Sopenharmony_ci 8984514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowConstassignmentPrefV8( 8994514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 9004514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 9014514f5e3Sopenharmony_ci{ 9024514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 9034514f5e3Sopenharmony_ci LOG_INST() << "throwconstassignment" 9044514f5e3Sopenharmony_ci << " v" << v0; 9054514f5e3Sopenharmony_ci SAVE_PC(); 9064514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowConstAssignment(thread, GET_VREG_VALUE(v0)); 9074514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 9084514f5e3Sopenharmony_ci} 9094514f5e3Sopenharmony_ci 9104514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowPatternnoncoerciblePrefNone( 9114514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 9124514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 9134514f5e3Sopenharmony_ci{ 9144514f5e3Sopenharmony_ci LOG_INST() << "throwpatternnoncoercible"; 9154514f5e3Sopenharmony_ci 9164514f5e3Sopenharmony_ci SAVE_PC(); 9174514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowPatternNonCoercible(thread); 9184514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 9194514f5e3Sopenharmony_ci} 9204514f5e3Sopenharmony_ci 9214514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowIfnotobjectPrefV8( 9224514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 9234514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 9244514f5e3Sopenharmony_ci{ 9254514f5e3Sopenharmony_ci LOG_INST() << "throwifnotobject"; 9264514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 9274514f5e3Sopenharmony_ci 9284514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 9294514f5e3Sopenharmony_ci // fast path 9304514f5e3Sopenharmony_ci if (value.IsECMAObject()) { 9314514f5e3Sopenharmony_ci DISPATCH(THROW_IFNOTOBJECT_PREF_V8); 9324514f5e3Sopenharmony_ci } 9334514f5e3Sopenharmony_ci 9344514f5e3Sopenharmony_ci // slow path 9354514f5e3Sopenharmony_ci SAVE_PC(); 9364514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowIfNotObject(thread); 9374514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 9384514f5e3Sopenharmony_ci} 9394514f5e3Sopenharmony_ci 9404514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCloseiteratorImm8V8( 9414514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 9424514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 9434514f5e3Sopenharmony_ci{ 9444514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 9454514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::closeiterator" 9464514f5e3Sopenharmony_ci << " v" << v0; 9474514f5e3Sopenharmony_ci SAVE_PC(); 9484514f5e3Sopenharmony_ci JSTaggedValue iter = GET_VREG_VALUE(v0); 9494514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CloseIterator(thread, iter); 9504514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 9514514f5e3Sopenharmony_ci SET_ACC(res); 9524514f5e3Sopenharmony_ci DISPATCH(CLOSEITERATOR_IMM8_V8); 9534514f5e3Sopenharmony_ci} 9544514f5e3Sopenharmony_ci 9554514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAdd2Imm8V8( 9564514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 9574514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 9584514f5e3Sopenharmony_ci{ 9594514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 9604514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::add2" 9614514f5e3Sopenharmony_ci << " v" << v0; 9624514f5e3Sopenharmony_ci int32_t a0; 9634514f5e3Sopenharmony_ci int32_t a1; 9644514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 9654514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 9664514f5e3Sopenharmony_ci // number, fast path 9674514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 9684514f5e3Sopenharmony_ci a0 = left.GetInt(); 9694514f5e3Sopenharmony_ci a1 = right.GetInt(); 9704514f5e3Sopenharmony_ci if ((a0 > 0 && a1 > INT32_MAX - a0) || (a0 < 0 && a1 < INT32_MIN - a0)) { 9714514f5e3Sopenharmony_ci auto ret = static_cast<double>(a0) + static_cast<double>(a1); 9724514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 9734514f5e3Sopenharmony_ci } else { 9744514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(a0 + a1)); 9754514f5e3Sopenharmony_ci } 9764514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 9774514f5e3Sopenharmony_ci double a0Double = left.IsInt() ? left.GetInt() : left.GetDouble(); 9784514f5e3Sopenharmony_ci double a1Double = right.IsInt() ? right.GetInt() : right.GetDouble(); 9794514f5e3Sopenharmony_ci double ret = a0Double + a1Double; 9804514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 9814514f5e3Sopenharmony_ci } else { 9824514f5e3Sopenharmony_ci // one or both are not number, slow path 9834514f5e3Sopenharmony_ci SAVE_PC(); 9844514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Add2(thread, left, right); 9854514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 9864514f5e3Sopenharmony_ci SET_ACC(res); 9874514f5e3Sopenharmony_ci } 9884514f5e3Sopenharmony_ci DISPATCH(ADD2_IMM8_V8); 9894514f5e3Sopenharmony_ci} 9904514f5e3Sopenharmony_ci 9914514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSub2Imm8V8( 9924514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 9934514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 9944514f5e3Sopenharmony_ci{ 9954514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 9964514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::sub2" 9974514f5e3Sopenharmony_ci << " v" << v0; 9984514f5e3Sopenharmony_ci int32_t a0; 9994514f5e3Sopenharmony_ci int32_t a1; 10004514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 10014514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 10024514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 10034514f5e3Sopenharmony_ci a0 = left.GetInt(); 10044514f5e3Sopenharmony_ci a1 = -right.GetInt(); 10054514f5e3Sopenharmony_ci if ((a0 > 0 && a1 > INT32_MAX - a0) || (a0 < 0 && a1 < INT32_MIN - a0)) { 10064514f5e3Sopenharmony_ci auto ret = static_cast<double>(a0) + static_cast<double>(a1); 10074514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 10084514f5e3Sopenharmony_ci } else { 10094514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(a0 + a1)); 10104514f5e3Sopenharmony_ci } 10114514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 10124514f5e3Sopenharmony_ci double a0Double = left.IsInt() ? left.GetInt() : left.GetDouble(); 10134514f5e3Sopenharmony_ci double a1Double = right.IsInt() ? right.GetInt() : right.GetDouble(); 10144514f5e3Sopenharmony_ci double ret = a0Double - a1Double; 10154514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 10164514f5e3Sopenharmony_ci } else { 10174514f5e3Sopenharmony_ci // one or both are not number, slow path 10184514f5e3Sopenharmony_ci SAVE_PC(); 10194514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Sub2(thread, left, right); 10204514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 10214514f5e3Sopenharmony_ci SET_ACC(res); 10224514f5e3Sopenharmony_ci } 10234514f5e3Sopenharmony_ci DISPATCH(SUB2_IMM8_V8); 10244514f5e3Sopenharmony_ci} 10254514f5e3Sopenharmony_civoid InterpreterAssembly::HandleMul2Imm8V8( 10264514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 10274514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 10284514f5e3Sopenharmony_ci{ 10294514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 10304514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::mul2" 10314514f5e3Sopenharmony_ci << " v" << v0; 10324514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 10334514f5e3Sopenharmony_ci JSTaggedValue right = acc; 10344514f5e3Sopenharmony_ci JSTaggedValue value = FastRuntimeStub::FastMul(left, right); 10354514f5e3Sopenharmony_ci if (!value.IsHole()) { 10364514f5e3Sopenharmony_ci SET_ACC(value); 10374514f5e3Sopenharmony_ci } else { 10384514f5e3Sopenharmony_ci // slow path 10394514f5e3Sopenharmony_ci SAVE_PC(); 10404514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Mul2(thread, left, right); 10414514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 10424514f5e3Sopenharmony_ci SET_ACC(res); 10434514f5e3Sopenharmony_ci } 10444514f5e3Sopenharmony_ci DISPATCH(MUL2_IMM8_V8); 10454514f5e3Sopenharmony_ci} 10464514f5e3Sopenharmony_ci 10474514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDiv2Imm8V8( 10484514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 10494514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 10504514f5e3Sopenharmony_ci{ 10514514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 10524514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::div2" 10534514f5e3Sopenharmony_ci << " v" << v0; 10544514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 10554514f5e3Sopenharmony_ci JSTaggedValue right = acc; 10564514f5e3Sopenharmony_ci // fast path 10574514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastDiv(left, right); 10584514f5e3Sopenharmony_ci if (!res.IsHole()) { 10594514f5e3Sopenharmony_ci SET_ACC(res); 10604514f5e3Sopenharmony_ci } else { 10614514f5e3Sopenharmony_ci // slow path 10624514f5e3Sopenharmony_ci SAVE_PC(); 10634514f5e3Sopenharmony_ci JSTaggedValue slowRes = SlowRuntimeStub::Div2(thread, left, right); 10644514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(slowRes); 10654514f5e3Sopenharmony_ci SET_ACC(slowRes); 10664514f5e3Sopenharmony_ci } 10674514f5e3Sopenharmony_ci DISPATCH(DIV2_IMM8_V8); 10684514f5e3Sopenharmony_ci} 10694514f5e3Sopenharmony_ci 10704514f5e3Sopenharmony_civoid InterpreterAssembly::HandleMod2Imm8V8( 10714514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 10724514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 10734514f5e3Sopenharmony_ci{ 10744514f5e3Sopenharmony_ci uint16_t vs = READ_INST_8_1(); 10754514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::mod2" 10764514f5e3Sopenharmony_ci << " v" << vs; 10774514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(vs); 10784514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 10794514f5e3Sopenharmony_ci 10804514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastMod(left, right); 10814514f5e3Sopenharmony_ci if (!res.IsHole()) { 10824514f5e3Sopenharmony_ci SET_ACC(res); 10834514f5e3Sopenharmony_ci } else { 10844514f5e3Sopenharmony_ci // slow path 10854514f5e3Sopenharmony_ci SAVE_PC(); 10864514f5e3Sopenharmony_ci JSTaggedValue slowRes = SlowRuntimeStub::Mod2(thread, left, right); 10874514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(slowRes); 10884514f5e3Sopenharmony_ci SET_ACC(slowRes); 10894514f5e3Sopenharmony_ci } 10904514f5e3Sopenharmony_ci DISPATCH(MOD2_IMM8_V8); 10914514f5e3Sopenharmony_ci} 10924514f5e3Sopenharmony_ci 10934514f5e3Sopenharmony_civoid InterpreterAssembly::HandleEqImm8V8( 10944514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 10954514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 10964514f5e3Sopenharmony_ci{ 10974514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 10984514f5e3Sopenharmony_ci 10994514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::eq" 11004514f5e3Sopenharmony_ci << " v" << v0; 11014514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 11024514f5e3Sopenharmony_ci JSTaggedValue right = acc; 11034514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastEqual(left, right); 11044514f5e3Sopenharmony_ci if (!res.IsHole()) { 11054514f5e3Sopenharmony_ci SET_ACC(res); 11064514f5e3Sopenharmony_ci } else { 11074514f5e3Sopenharmony_ci // slow path 11084514f5e3Sopenharmony_ci SAVE_PC(); 11094514f5e3Sopenharmony_ci res = SlowRuntimeStub::Eq(thread, left, right); 11104514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 11114514f5e3Sopenharmony_ci SET_ACC(res); 11124514f5e3Sopenharmony_ci } 11134514f5e3Sopenharmony_ci 11144514f5e3Sopenharmony_ci DISPATCH(EQ_IMM8_V8); 11154514f5e3Sopenharmony_ci} 11164514f5e3Sopenharmony_ci 11174514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNoteqImm8V8( 11184514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 11194514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 11204514f5e3Sopenharmony_ci{ 11214514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 11224514f5e3Sopenharmony_ci 11234514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::noteq" 11244514f5e3Sopenharmony_ci << " v" << v0; 11254514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 11264514f5e3Sopenharmony_ci JSTaggedValue right = acc; 11274514f5e3Sopenharmony_ci 11284514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastEqual(left, right); 11294514f5e3Sopenharmony_ci if (!res.IsHole()) { 11304514f5e3Sopenharmony_ci res = res.IsTrue() ? JSTaggedValue::False() : JSTaggedValue::True(); 11314514f5e3Sopenharmony_ci SET_ACC(res); 11324514f5e3Sopenharmony_ci } else { 11334514f5e3Sopenharmony_ci // slow path 11344514f5e3Sopenharmony_ci SAVE_PC(); 11354514f5e3Sopenharmony_ci res = SlowRuntimeStub::NotEq(thread, left, right); 11364514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 11374514f5e3Sopenharmony_ci SET_ACC(res); 11384514f5e3Sopenharmony_ci } 11394514f5e3Sopenharmony_ci DISPATCH(NOTEQ_IMM8_V8); 11404514f5e3Sopenharmony_ci} 11414514f5e3Sopenharmony_ci 11424514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLessImm8V8( 11434514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 11444514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 11454514f5e3Sopenharmony_ci{ 11464514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 11474514f5e3Sopenharmony_ci 11484514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::less" 11494514f5e3Sopenharmony_ci << " v" << v0; 11504514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 11514514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 11524514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 11534514f5e3Sopenharmony_ci // fast path 11544514f5e3Sopenharmony_ci bool ret = left.GetInt() < right.GetInt(); 11554514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 11564514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 11574514f5e3Sopenharmony_ci // fast path 11584514f5e3Sopenharmony_ci double valueA = left.IsInt() ? static_cast<double>(left.GetInt()) : left.GetDouble(); 11594514f5e3Sopenharmony_ci double valueB = right.IsInt() ? static_cast<double>(right.GetInt()) : right.GetDouble(); 11604514f5e3Sopenharmony_ci bool ret = JSTaggedValue::StrictNumberCompare(valueA, valueB) == ComparisonResult::LESS; 11614514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 11624514f5e3Sopenharmony_ci } else if (left.IsBigInt() && right.IsBigInt()) { 11634514f5e3Sopenharmony_ci bool result = BigInt::LessThan(left, right); 11644514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(result)); 11654514f5e3Sopenharmony_ci } else { 11664514f5e3Sopenharmony_ci // slow path 11674514f5e3Sopenharmony_ci SAVE_PC(); 11684514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Less(thread, left, right); 11694514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 11704514f5e3Sopenharmony_ci SET_ACC(res); 11714514f5e3Sopenharmony_ci } 11724514f5e3Sopenharmony_ci DISPATCH(LESS_IMM8_V8); 11734514f5e3Sopenharmony_ci} 11744514f5e3Sopenharmony_ci 11754514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLesseqImm8V8( 11764514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 11774514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 11784514f5e3Sopenharmony_ci{ 11794514f5e3Sopenharmony_ci uint16_t vs = READ_INST_8_1(); 11804514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::lesseq " 11814514f5e3Sopenharmony_ci << " v" << vs; 11824514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(vs); 11834514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 11844514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 11854514f5e3Sopenharmony_ci // fast path 11864514f5e3Sopenharmony_ci bool ret = ((left.GetInt() < right.GetInt()) || (left.GetInt() == right.GetInt())); 11874514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 11884514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 11894514f5e3Sopenharmony_ci // fast path 11904514f5e3Sopenharmony_ci double valueA = left.IsInt() ? static_cast<double>(left.GetInt()) : left.GetDouble(); 11914514f5e3Sopenharmony_ci double valueB = right.IsInt() ? static_cast<double>(right.GetInt()) : right.GetDouble(); 11924514f5e3Sopenharmony_ci bool ret = JSTaggedValue::StrictNumberCompare(valueA, valueB) <= ComparisonResult::EQUAL; 11934514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 11944514f5e3Sopenharmony_ci } else if (left.IsBigInt() && right.IsBigInt()) { 11954514f5e3Sopenharmony_ci bool result = BigInt::LessThan(left, right) || BigInt::Equal(left, right); 11964514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(result)); 11974514f5e3Sopenharmony_ci } else { 11984514f5e3Sopenharmony_ci // slow path 11994514f5e3Sopenharmony_ci SAVE_PC(); 12004514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LessEq(thread, left, right); 12014514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 12024514f5e3Sopenharmony_ci SET_ACC(res); 12034514f5e3Sopenharmony_ci } 12044514f5e3Sopenharmony_ci DISPATCH(LESSEQ_IMM8_V8); 12054514f5e3Sopenharmony_ci} 12064514f5e3Sopenharmony_ci 12074514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGreaterImm8V8( 12084514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 12094514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 12104514f5e3Sopenharmony_ci{ 12114514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 12124514f5e3Sopenharmony_ci 12134514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::greater" 12144514f5e3Sopenharmony_ci << " v" << v0; 12154514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 12164514f5e3Sopenharmony_ci JSTaggedValue right = acc; 12174514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 12184514f5e3Sopenharmony_ci // fast path 12194514f5e3Sopenharmony_ci bool ret = left.GetInt() > right.GetInt(); 12204514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 12214514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 12224514f5e3Sopenharmony_ci // fast path 12234514f5e3Sopenharmony_ci double valueA = left.IsInt() ? static_cast<double>(left.GetInt()) : left.GetDouble(); 12244514f5e3Sopenharmony_ci double valueB = right.IsInt() ? static_cast<double>(right.GetInt()) : right.GetDouble(); 12254514f5e3Sopenharmony_ci bool ret = JSTaggedValue::StrictNumberCompare(valueA, valueB) == ComparisonResult::GREAT; 12264514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 12274514f5e3Sopenharmony_ci } else if (left.IsBigInt() && right.IsBigInt()) { 12284514f5e3Sopenharmony_ci bool result = BigInt::LessThan(right, left); 12294514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(result)); 12304514f5e3Sopenharmony_ci } else { 12314514f5e3Sopenharmony_ci // slow path 12324514f5e3Sopenharmony_ci SAVE_PC(); 12334514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Greater(thread, left, right); 12344514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 12354514f5e3Sopenharmony_ci SET_ACC(res); 12364514f5e3Sopenharmony_ci } 12374514f5e3Sopenharmony_ci DISPATCH(GREATER_IMM8_V8); 12384514f5e3Sopenharmony_ci} 12394514f5e3Sopenharmony_ci 12404514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGreatereqImm8V8( 12414514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 12424514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 12434514f5e3Sopenharmony_ci{ 12444514f5e3Sopenharmony_ci uint16_t vs = READ_INST_8_1(); 12454514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::greateq " 12464514f5e3Sopenharmony_ci << " v" << vs; 12474514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(vs); 12484514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 12494514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 12504514f5e3Sopenharmony_ci // fast path 12514514f5e3Sopenharmony_ci bool ret = ((left.GetInt() > right.GetInt()) || (left.GetInt() == right.GetInt())); 12524514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 12534514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 12544514f5e3Sopenharmony_ci // fast path 12554514f5e3Sopenharmony_ci double valueA = left.IsInt() ? static_cast<double>(left.GetInt()) : left.GetDouble(); 12564514f5e3Sopenharmony_ci double valueB = right.IsInt() ? static_cast<double>(right.GetInt()) : right.GetDouble(); 12574514f5e3Sopenharmony_ci ComparisonResult comparison = JSTaggedValue::StrictNumberCompare(valueA, valueB); 12584514f5e3Sopenharmony_ci bool ret = (comparison == ComparisonResult::GREAT) || (comparison == ComparisonResult::EQUAL); 12594514f5e3Sopenharmony_ci SET_ACC(ret ? JSTaggedValue::True() : JSTaggedValue::False()); 12604514f5e3Sopenharmony_ci } else if (left.IsBigInt() && right.IsBigInt()) { 12614514f5e3Sopenharmony_ci bool result = BigInt::LessThan(right, left) || BigInt::Equal(right, left); 12624514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(result)); 12634514f5e3Sopenharmony_ci } else { 12644514f5e3Sopenharmony_ci // slow path 12654514f5e3Sopenharmony_ci SAVE_PC(); 12664514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GreaterEq(thread, left, right); 12674514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 12684514f5e3Sopenharmony_ci SET_ACC(res); 12694514f5e3Sopenharmony_ci } 12704514f5e3Sopenharmony_ci DISPATCH(GREATEREQ_IMM8_V8); 12714514f5e3Sopenharmony_ci} 12724514f5e3Sopenharmony_ci 12734514f5e3Sopenharmony_civoid InterpreterAssembly::HandleShl2Imm8V8( 12744514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 12754514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 12764514f5e3Sopenharmony_ci{ 12774514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 12784514f5e3Sopenharmony_ci 12794514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::shl2" 12804514f5e3Sopenharmony_ci << " v" << v0; 12814514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 12824514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 12834514f5e3Sopenharmony_ci // both number, fast path 12844514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 12854514f5e3Sopenharmony_ci int32_t opNumber0 = left.GetInt(); 12864514f5e3Sopenharmony_ci int32_t opNumber1 = right.GetInt(); 12874514f5e3Sopenharmony_ci uint32_t shift = 12884514f5e3Sopenharmony_ci static_cast<uint32_t>(opNumber1) & 0x1f; // NOLINT(hicpp-signed-bitwise, readability-magic-numbers) 12894514f5e3Sopenharmony_ci using unsigned_type = std::make_unsigned_t<int32_t>; 12904514f5e3Sopenharmony_ci auto ret = 12914514f5e3Sopenharmony_ci static_cast<int32_t>(static_cast<unsigned_type>(opNumber0) << shift); // NOLINT(hicpp-signed-bitwise) 12924514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 12934514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 12944514f5e3Sopenharmony_ci int32_t opNumber0 = 12954514f5e3Sopenharmony_ci left.IsInt() ? left.GetInt() : base::NumberHelper::DoubleToInt(left.GetDouble(), base::INT32_BITS); 12964514f5e3Sopenharmony_ci int32_t opNumber1 = 12974514f5e3Sopenharmony_ci right.IsInt() ? right.GetInt() : base::NumberHelper::DoubleToInt(right.GetDouble(), base::INT32_BITS); 12984514f5e3Sopenharmony_ci uint32_t shift = 12994514f5e3Sopenharmony_ci static_cast<uint32_t>(opNumber1) & 0x1f; // NOLINT(hicpp-signed-bitwise, readability-magic-numbers) 13004514f5e3Sopenharmony_ci using unsigned_type = std::make_unsigned_t<int32_t>; 13014514f5e3Sopenharmony_ci auto ret = 13024514f5e3Sopenharmony_ci static_cast<int32_t>(static_cast<unsigned_type>(opNumber0) << shift); // NOLINT(hicpp-signed-bitwise) 13034514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 13044514f5e3Sopenharmony_ci } else { 13054514f5e3Sopenharmony_ci // slow path 13064514f5e3Sopenharmony_ci SAVE_PC(); 13074514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Shl2(thread, left, right); 13084514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 13094514f5e3Sopenharmony_ci SET_ACC(res); 13104514f5e3Sopenharmony_ci } 13114514f5e3Sopenharmony_ci DISPATCH(SHL2_IMM8_V8); 13124514f5e3Sopenharmony_ci} 13134514f5e3Sopenharmony_ci 13144514f5e3Sopenharmony_civoid InterpreterAssembly::HandleShr2Imm8V8( 13154514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 13164514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 13174514f5e3Sopenharmony_ci{ 13184514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 13194514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::shr2" 13204514f5e3Sopenharmony_ci << " v" << v0; 13214514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 13224514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 13234514f5e3Sopenharmony_ci // both number, fast path 13244514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 13254514f5e3Sopenharmony_ci int32_t opNumber0 = left.GetInt(); 13264514f5e3Sopenharmony_ci int32_t opNumber1 = right.GetInt(); 13274514f5e3Sopenharmony_ci uint32_t shift = 13284514f5e3Sopenharmony_ci static_cast<uint32_t>(opNumber1) & 0x1f; // NOLINT(hicpp-signed-bitwise, readability-magic-numbers) 13294514f5e3Sopenharmony_ci using unsigned_type = std::make_unsigned_t<uint32_t>; 13304514f5e3Sopenharmony_ci auto ret = 13314514f5e3Sopenharmony_ci static_cast<uint32_t>(static_cast<unsigned_type>(opNumber0) >> shift); // NOLINT(hicpp-signed-bitwise) 13324514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 13334514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 13344514f5e3Sopenharmony_ci int32_t opNumber0 = 13354514f5e3Sopenharmony_ci left.IsInt() ? left.GetInt() : base::NumberHelper::DoubleToInt(left.GetDouble(), base::INT32_BITS); 13364514f5e3Sopenharmony_ci int32_t opNumber1 = 13374514f5e3Sopenharmony_ci right.IsInt() ? right.GetInt() : base::NumberHelper::DoubleToInt(right.GetDouble(), base::INT32_BITS); 13384514f5e3Sopenharmony_ci uint32_t shift = 13394514f5e3Sopenharmony_ci static_cast<uint32_t>(opNumber1) & 0x1f; // NOLINT(hicpp-signed-bitwise, readability-magic-numbers) 13404514f5e3Sopenharmony_ci using unsigned_type = std::make_unsigned_t<uint32_t>; 13414514f5e3Sopenharmony_ci auto ret = 13424514f5e3Sopenharmony_ci static_cast<uint32_t>(static_cast<unsigned_type>(opNumber0) >> shift); // NOLINT(hicpp-signed-bitwise) 13434514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 13444514f5e3Sopenharmony_ci } else { 13454514f5e3Sopenharmony_ci // slow path 13464514f5e3Sopenharmony_ci SAVE_PC(); 13474514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Shr2(thread, left, right); 13484514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 13494514f5e3Sopenharmony_ci SET_ACC(res); 13504514f5e3Sopenharmony_ci } 13514514f5e3Sopenharmony_ci DISPATCH(SHR2_IMM8_V8); 13524514f5e3Sopenharmony_ci} 13534514f5e3Sopenharmony_ci 13544514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAshr2Imm8V8( 13554514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 13564514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 13574514f5e3Sopenharmony_ci{ 13584514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 13594514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ashr2" 13604514f5e3Sopenharmony_ci << " v" << v0; 13614514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 13624514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 13634514f5e3Sopenharmony_ci // both number, fast path 13644514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 13654514f5e3Sopenharmony_ci int32_t opNumber0 = left.GetInt(); 13664514f5e3Sopenharmony_ci int32_t opNumber1 = right.GetInt(); 13674514f5e3Sopenharmony_ci uint32_t shift = 13684514f5e3Sopenharmony_ci static_cast<uint32_t>(opNumber1) & 0x1f; // NOLINT(hicpp-signed-bitwise, readability-magic-numbers) 13694514f5e3Sopenharmony_ci auto ret = static_cast<int32_t>(opNumber0 >> shift); // NOLINT(hicpp-signed-bitwise) 13704514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 13714514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 13724514f5e3Sopenharmony_ci int32_t opNumber0 = 13734514f5e3Sopenharmony_ci left.IsInt() ? left.GetInt() : base::NumberHelper::DoubleToInt(left.GetDouble(), base::INT32_BITS); 13744514f5e3Sopenharmony_ci int32_t opNumber1 = 13754514f5e3Sopenharmony_ci right.IsInt() ? right.GetInt() : base::NumberHelper::DoubleToInt(right.GetDouble(), base::INT32_BITS); 13764514f5e3Sopenharmony_ci uint32_t shift = 13774514f5e3Sopenharmony_ci static_cast<uint32_t>(opNumber1) & 0x1f; // NOLINT(hicpp-signed-bitwise, readability-magic-numbers) 13784514f5e3Sopenharmony_ci auto ret = static_cast<int32_t>(opNumber0 >> shift); // NOLINT(hicpp-signed-bitwise) 13794514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 13804514f5e3Sopenharmony_ci } else { 13814514f5e3Sopenharmony_ci // slow path 13824514f5e3Sopenharmony_ci SAVE_PC(); 13834514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Ashr2(thread, left, right); 13844514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 13854514f5e3Sopenharmony_ci SET_ACC(res); 13864514f5e3Sopenharmony_ci } 13874514f5e3Sopenharmony_ci DISPATCH(ASHR2_IMM8_V8); 13884514f5e3Sopenharmony_ci} 13894514f5e3Sopenharmony_ci 13904514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAnd2Imm8V8( 13914514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 13924514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 13934514f5e3Sopenharmony_ci{ 13944514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 13954514f5e3Sopenharmony_ci 13964514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::and2" 13974514f5e3Sopenharmony_ci << " v" << v0; 13984514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 13994514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 14004514f5e3Sopenharmony_ci // both number, fast path 14014514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 14024514f5e3Sopenharmony_ci int32_t opNumber0 = left.GetInt(); 14034514f5e3Sopenharmony_ci int32_t opNumber1 = right.GetInt(); 14044514f5e3Sopenharmony_ci // NOLINT(hicpp-signed-bitwise) 14054514f5e3Sopenharmony_ci auto ret = static_cast<uint32_t>(opNumber0) & static_cast<uint32_t>(opNumber1); 14064514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int32_t>(ret))); 14074514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 14084514f5e3Sopenharmony_ci int32_t opNumber0 = 14094514f5e3Sopenharmony_ci left.IsInt() ? left.GetInt() : base::NumberHelper::DoubleToInt(left.GetDouble(), base::INT32_BITS); 14104514f5e3Sopenharmony_ci int32_t opNumber1 = 14114514f5e3Sopenharmony_ci right.IsInt() ? right.GetInt() : base::NumberHelper::DoubleToInt(right.GetDouble(), base::INT32_BITS); 14124514f5e3Sopenharmony_ci // NOLINT(hicpp-signed-bitwise) 14134514f5e3Sopenharmony_ci auto ret = static_cast<uint32_t>(opNumber0) & static_cast<uint32_t>(opNumber1); 14144514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int32_t>(ret))); 14154514f5e3Sopenharmony_ci } else { 14164514f5e3Sopenharmony_ci // slow path 14174514f5e3Sopenharmony_ci SAVE_PC(); 14184514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::And2(thread, left, right); 14194514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 14204514f5e3Sopenharmony_ci SET_ACC(res); 14214514f5e3Sopenharmony_ci } 14224514f5e3Sopenharmony_ci DISPATCH(AND2_IMM8_V8); 14234514f5e3Sopenharmony_ci} 14244514f5e3Sopenharmony_ci 14254514f5e3Sopenharmony_civoid InterpreterAssembly::HandleOr2Imm8V8( 14264514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 14274514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 14284514f5e3Sopenharmony_ci{ 14294514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 14304514f5e3Sopenharmony_ci 14314514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::or2" 14324514f5e3Sopenharmony_ci << " v" << v0; 14334514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 14344514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 14354514f5e3Sopenharmony_ci // both number, fast path 14364514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 14374514f5e3Sopenharmony_ci int32_t opNumber0 = left.GetInt(); 14384514f5e3Sopenharmony_ci int32_t opNumber1 = right.GetInt(); 14394514f5e3Sopenharmony_ci // NOLINT(hicpp-signed-bitwise) 14404514f5e3Sopenharmony_ci auto ret = static_cast<uint32_t>(opNumber0) | static_cast<uint32_t>(opNumber1); 14414514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int32_t>(ret))); 14424514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 14434514f5e3Sopenharmony_ci int32_t opNumber0 = 14444514f5e3Sopenharmony_ci left.IsInt() ? left.GetInt() : base::NumberHelper::DoubleToInt(left.GetDouble(), base::INT32_BITS); 14454514f5e3Sopenharmony_ci int32_t opNumber1 = 14464514f5e3Sopenharmony_ci right.IsInt() ? right.GetInt() : base::NumberHelper::DoubleToInt(right.GetDouble(), base::INT32_BITS); 14474514f5e3Sopenharmony_ci // NOLINT(hicpp-signed-bitwise) 14484514f5e3Sopenharmony_ci auto ret = static_cast<uint32_t>(opNumber0) | static_cast<uint32_t>(opNumber1); 14494514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int32_t>(ret))); 14504514f5e3Sopenharmony_ci } else { 14514514f5e3Sopenharmony_ci // slow path 14524514f5e3Sopenharmony_ci SAVE_PC(); 14534514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Or2(thread, left, right); 14544514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 14554514f5e3Sopenharmony_ci SET_ACC(res); 14564514f5e3Sopenharmony_ci } 14574514f5e3Sopenharmony_ci DISPATCH(OR2_IMM8_V8); 14584514f5e3Sopenharmony_ci} 14594514f5e3Sopenharmony_ci 14604514f5e3Sopenharmony_civoid InterpreterAssembly::HandleXor2Imm8V8( 14614514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 14624514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 14634514f5e3Sopenharmony_ci{ 14644514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 14654514f5e3Sopenharmony_ci 14664514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::xor2" 14674514f5e3Sopenharmony_ci << " v" << v0; 14684514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 14694514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 14704514f5e3Sopenharmony_ci // both number, fast path 14714514f5e3Sopenharmony_ci if (left.IsInt() && right.IsInt()) { 14724514f5e3Sopenharmony_ci int32_t opNumber0 = left.GetInt(); 14734514f5e3Sopenharmony_ci int32_t opNumber1 = right.GetInt(); 14744514f5e3Sopenharmony_ci // NOLINT(hicpp-signed-bitwise) 14754514f5e3Sopenharmony_ci auto ret = static_cast<uint32_t>(opNumber0) ^ static_cast<uint32_t>(opNumber1); 14764514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int32_t>(ret))); 14774514f5e3Sopenharmony_ci } else if (left.IsNumber() && right.IsNumber()) { 14784514f5e3Sopenharmony_ci int32_t opNumber0 = 14794514f5e3Sopenharmony_ci left.IsInt() ? left.GetInt() : base::NumberHelper::DoubleToInt(left.GetDouble(), base::INT32_BITS); 14804514f5e3Sopenharmony_ci int32_t opNumber1 = 14814514f5e3Sopenharmony_ci right.IsInt() ? right.GetInt() : base::NumberHelper::DoubleToInt(right.GetDouble(), base::INT32_BITS); 14824514f5e3Sopenharmony_ci // NOLINT(hicpp-signed-bitwise) 14834514f5e3Sopenharmony_ci auto ret = static_cast<uint32_t>(opNumber0) ^ static_cast<uint32_t>(opNumber1); 14844514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int32_t>(ret))); 14854514f5e3Sopenharmony_ci } else { 14864514f5e3Sopenharmony_ci // slow path 14874514f5e3Sopenharmony_ci SAVE_PC(); 14884514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Xor2(thread, left, right); 14894514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 14904514f5e3Sopenharmony_ci SET_ACC(res); 14914514f5e3Sopenharmony_ci } 14924514f5e3Sopenharmony_ci DISPATCH(XOR2_IMM8_V8); 14934514f5e3Sopenharmony_ci} 14944514f5e3Sopenharmony_ci 14954514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDelobjpropV8( 14964514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 14974514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 14984514f5e3Sopenharmony_ci{ 14994514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 15004514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::delobjprop" 15014514f5e3Sopenharmony_ci << " v0" << v0; 15024514f5e3Sopenharmony_ci 15034514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 15044514f5e3Sopenharmony_ci JSTaggedValue prop = GET_ACC(); 15054514f5e3Sopenharmony_ci SAVE_PC(); 15064514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::DelObjProp(thread, obj, prop); 15074514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 15084514f5e3Sopenharmony_ci SET_ACC(res); 15094514f5e3Sopenharmony_ci 15104514f5e3Sopenharmony_ci DISPATCH(DELOBJPROP_V8); 15114514f5e3Sopenharmony_ci} 15124514f5e3Sopenharmony_ci 15134514f5e3Sopenharmony_civoid InterpreterAssembly::HandleExpImm8V8( 15144514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 15154514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 15164514f5e3Sopenharmony_ci{ 15174514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 15184514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::exp" 15194514f5e3Sopenharmony_ci << " v" << v0; 15204514f5e3Sopenharmony_ci JSTaggedValue base = GET_VREG_VALUE(v0); 15214514f5e3Sopenharmony_ci JSTaggedValue exponent = GET_ACC(); 15224514f5e3Sopenharmony_ci if (base.IsNumber() && exponent.IsNumber()) { 15234514f5e3Sopenharmony_ci // fast path 15244514f5e3Sopenharmony_ci double doubleBase = base.IsInt() ? base.GetInt() : base.GetDouble(); 15254514f5e3Sopenharmony_ci double doubleExponent = exponent.IsInt() ? exponent.GetInt() : exponent.GetDouble(); 15264514f5e3Sopenharmony_ci if (std::abs(doubleBase) == 1 && std::isinf(doubleExponent)) { 15274514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(base::NAN_VALUE)); 15284514f5e3Sopenharmony_ci } 15294514f5e3Sopenharmony_ci bool baseZero = doubleBase == 0 && 15304514f5e3Sopenharmony_ci (base::bit_cast<uint64_t>(doubleBase) & base::DOUBLE_SIGN_MASK) == base::DOUBLE_SIGN_MASK; 15314514f5e3Sopenharmony_ci bool isFinite = std::isfinite(doubleExponent); 15324514f5e3Sopenharmony_ci bool truncEqual = base::NumberHelper::TruncateDouble(doubleExponent) == doubleExponent; 15334514f5e3Sopenharmony_ci bool halfTruncEqual = (base::NumberHelper::TruncateDouble(doubleExponent / 2) + base::HALF) == 15344514f5e3Sopenharmony_ci (doubleExponent / 2); 15354514f5e3Sopenharmony_ci if (baseZero && isFinite && truncEqual && halfTruncEqual) { 15364514f5e3Sopenharmony_ci if (doubleExponent > 0) { 15374514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-0.0)); 15384514f5e3Sopenharmony_ci } 15394514f5e3Sopenharmony_ci if (doubleExponent < 0) { 15404514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-base::POSITIVE_INFINITY)); 15414514f5e3Sopenharmony_ci } 15424514f5e3Sopenharmony_ci } 15434514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(std::pow(doubleBase, doubleExponent))); 15444514f5e3Sopenharmony_ci } else { 15454514f5e3Sopenharmony_ci // slow path 15464514f5e3Sopenharmony_ci SAVE_PC(); 15474514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Exp(thread, base, exponent); 15484514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 15494514f5e3Sopenharmony_ci SET_ACC(res); 15504514f5e3Sopenharmony_ci } 15514514f5e3Sopenharmony_ci DISPATCH(EXP_IMM8_V8); 15524514f5e3Sopenharmony_ci} 15534514f5e3Sopenharmony_ci 15544514f5e3Sopenharmony_civoid InterpreterAssembly::HandleIsinImm8V8( 15554514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 15564514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 15574514f5e3Sopenharmony_ci{ 15584514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 15594514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::isin" 15604514f5e3Sopenharmony_ci << " v" << v0; 15614514f5e3Sopenharmony_ci JSTaggedValue prop = GET_VREG_VALUE(v0); 15624514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 15634514f5e3Sopenharmony_ci SAVE_PC(); 15644514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::IsIn(thread, prop, obj); 15654514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 15664514f5e3Sopenharmony_ci SET_ACC(res); 15674514f5e3Sopenharmony_ci DISPATCH(ISIN_IMM8_V8); 15684514f5e3Sopenharmony_ci} 15694514f5e3Sopenharmony_ci 15704514f5e3Sopenharmony_civoid InterpreterAssembly::HandleInstanceofImm8V8( 15714514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 15724514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 15734514f5e3Sopenharmony_ci{ 15744514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 15754514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::instanceof" 15764514f5e3Sopenharmony_ci << " v" << v0; 15774514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 15784514f5e3Sopenharmony_ci JSTaggedValue target = GET_ACC(); 15794514f5e3Sopenharmony_ci SAVE_PC(); 15804514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Instanceof(thread, obj, target); 15814514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 15824514f5e3Sopenharmony_ci SET_ACC(res); 15834514f5e3Sopenharmony_ci DISPATCH(INSTANCEOF_IMM8_V8); 15844514f5e3Sopenharmony_ci} 15854514f5e3Sopenharmony_ci 15864514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStrictnoteqImm8V8( 15874514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 15884514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 15894514f5e3Sopenharmony_ci{ 15904514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 15914514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::strictnoteq" 15924514f5e3Sopenharmony_ci << " v" << v0; 15934514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 15944514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 15954514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastStrictEqual(left, right); 15964514f5e3Sopenharmony_ci if (!res.IsHole()) { 15974514f5e3Sopenharmony_ci res = res.IsTrue() ? JSTaggedValue::False() : JSTaggedValue::True(); 15984514f5e3Sopenharmony_ci SET_ACC(res); 15994514f5e3Sopenharmony_ci } else { 16004514f5e3Sopenharmony_ci // slow path 16014514f5e3Sopenharmony_ci res = SlowRuntimeStub::NotEq(thread, left, right); 16024514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 16034514f5e3Sopenharmony_ci SET_ACC(res); 16044514f5e3Sopenharmony_ci } 16054514f5e3Sopenharmony_ci DISPATCH(STRICTNOTEQ_IMM8_V8); 16064514f5e3Sopenharmony_ci} 16074514f5e3Sopenharmony_ci 16084514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStricteqImm8V8( 16094514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 16104514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 16114514f5e3Sopenharmony_ci{ 16124514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 16134514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stricteq" 16144514f5e3Sopenharmony_ci << " v" << v0; 16154514f5e3Sopenharmony_ci JSTaggedValue left = GET_VREG_VALUE(v0); 16164514f5e3Sopenharmony_ci JSTaggedValue right = GET_ACC(); 16174514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastStrictEqual(left, right); 16184514f5e3Sopenharmony_ci if (!res.IsHole()) { 16194514f5e3Sopenharmony_ci SET_ACC(res); 16204514f5e3Sopenharmony_ci } else { 16214514f5e3Sopenharmony_ci // slow path 16224514f5e3Sopenharmony_ci res = SlowRuntimeStub::Eq(thread, left, right); 16234514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 16244514f5e3Sopenharmony_ci SET_ACC(res); 16254514f5e3Sopenharmony_ci } 16264514f5e3Sopenharmony_ci DISPATCH(STRICTEQ_IMM8_V8); 16274514f5e3Sopenharmony_ci} 16284514f5e3Sopenharmony_ci 16294514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdlexvarImm8Imm8( 16304514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 16314514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 16324514f5e3Sopenharmony_ci{ 16334514f5e3Sopenharmony_ci uint16_t level = READ_INST_8_0(); 16344514f5e3Sopenharmony_ci uint16_t slot = READ_INST_8_1(); 16354514f5e3Sopenharmony_ci 16364514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlexvar" 16374514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 16384514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 16394514f5e3Sopenharmony_ci JSTaggedValue currentLexenv = state->env; 16404514f5e3Sopenharmony_ci JSTaggedValue env(currentLexenv); 16414514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 16424514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 16434514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 16444514f5e3Sopenharmony_ci env = taggedParentEnv; 16454514f5e3Sopenharmony_ci } 16464514f5e3Sopenharmony_ci SET_ACC(LexicalEnv::Cast(env.GetTaggedObject())->GetProperties(slot)); 16474514f5e3Sopenharmony_ci DISPATCH(LDLEXVAR_IMM8_IMM8); 16484514f5e3Sopenharmony_ci} 16494514f5e3Sopenharmony_ci 16504514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdlexvarImm4Imm4( 16514514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 16524514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 16534514f5e3Sopenharmony_ci{ 16544514f5e3Sopenharmony_ci uint16_t level = READ_INST_4_0(); 16554514f5e3Sopenharmony_ci uint16_t slot = READ_INST_4_1(); 16564514f5e3Sopenharmony_ci 16574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlexvar" 16584514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 16594514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 16604514f5e3Sopenharmony_ci JSTaggedValue currentLexenv = state->env; 16614514f5e3Sopenharmony_ci JSTaggedValue env(currentLexenv); 16624514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 16634514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 16644514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 16654514f5e3Sopenharmony_ci env = taggedParentEnv; 16664514f5e3Sopenharmony_ci } 16674514f5e3Sopenharmony_ci SET_ACC(LexicalEnv::Cast(env.GetTaggedObject())->GetProperties(slot)); 16684514f5e3Sopenharmony_ci DISPATCH(LDLEXVAR_IMM4_IMM4); 16694514f5e3Sopenharmony_ci} 16704514f5e3Sopenharmony_ci 16714514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideStlexvarPrefImm16Imm16( 16724514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 16734514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 16744514f5e3Sopenharmony_ci{ 16754514f5e3Sopenharmony_ci uint16_t level = READ_INST_16_1(); 16764514f5e3Sopenharmony_ci uint16_t slot = READ_INST_16_3(); 16774514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlexvar" 16784514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 16794514f5e3Sopenharmony_ci 16804514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 16814514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 16824514f5e3Sopenharmony_ci JSTaggedValue env = state->env; 16834514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 16844514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 16854514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 16864514f5e3Sopenharmony_ci env = taggedParentEnv; 16874514f5e3Sopenharmony_ci } 16884514f5e3Sopenharmony_ci LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 16894514f5e3Sopenharmony_ci 16904514f5e3Sopenharmony_ci DISPATCH(WIDE_STLEXVAR_PREF_IMM16_IMM16); 16914514f5e3Sopenharmony_ci} 16924514f5e3Sopenharmony_ci 16934514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStlexvarImm8Imm8( 16944514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 16954514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 16964514f5e3Sopenharmony_ci{ 16974514f5e3Sopenharmony_ci uint16_t level = READ_INST_8_0(); 16984514f5e3Sopenharmony_ci uint16_t slot = READ_INST_8_1(); 16994514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlexvar" 17004514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 17014514f5e3Sopenharmony_ci 17024514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 17034514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 17044514f5e3Sopenharmony_ci JSTaggedValue env = state->env; 17054514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 17064514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 17074514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 17084514f5e3Sopenharmony_ci env = taggedParentEnv; 17094514f5e3Sopenharmony_ci } 17104514f5e3Sopenharmony_ci LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 17114514f5e3Sopenharmony_ci 17124514f5e3Sopenharmony_ci DISPATCH(STLEXVAR_IMM8_IMM8); 17134514f5e3Sopenharmony_ci} 17144514f5e3Sopenharmony_ci 17154514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStlexvarImm4Imm4( 17164514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 17174514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 17184514f5e3Sopenharmony_ci{ 17194514f5e3Sopenharmony_ci uint16_t level = READ_INST_4_0(); 17204514f5e3Sopenharmony_ci uint16_t slot = READ_INST_4_1(); 17214514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlexvar" 17224514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 17234514f5e3Sopenharmony_ci 17244514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 17254514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 17264514f5e3Sopenharmony_ci JSTaggedValue env = state->env; 17274514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 17284514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 17294514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 17304514f5e3Sopenharmony_ci env = taggedParentEnv; 17314514f5e3Sopenharmony_ci } 17324514f5e3Sopenharmony_ci LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 17334514f5e3Sopenharmony_ci 17344514f5e3Sopenharmony_ci DISPATCH(STLEXVAR_IMM4_IMM4); 17354514f5e3Sopenharmony_ci} 17364514f5e3Sopenharmony_ci 17374514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNewlexenvImm8( 17384514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 17394514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 17404514f5e3Sopenharmony_ci{ 17414514f5e3Sopenharmony_ci uint8_t numVars = READ_INST_8_0(); 17424514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newlexenv" 17434514f5e3Sopenharmony_ci << " imm " << numVars; 17444514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 17454514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 17464514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::NewLexicalEnv(thread, factory, numVars); 17474514f5e3Sopenharmony_ci if (res.IsHole()) { 17484514f5e3Sopenharmony_ci res = SlowRuntimeStub::NewLexicalEnv(thread, numVars); 17494514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 17504514f5e3Sopenharmony_ci } 17514514f5e3Sopenharmony_ci SET_ACC(res); 17524514f5e3Sopenharmony_ci GET_ASM_FRAME(sp)->env = res; 17534514f5e3Sopenharmony_ci DISPATCH(NEWLEXENV_IMM8); 17544514f5e3Sopenharmony_ci} 17554514f5e3Sopenharmony_ci 17564514f5e3Sopenharmony_civoid InterpreterAssembly::HandlePoplexenv( 17574514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 17584514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 17594514f5e3Sopenharmony_ci{ 17604514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 17614514f5e3Sopenharmony_ci JSTaggedValue currentLexenv = state->env; 17624514f5e3Sopenharmony_ci JSTaggedValue parentLexenv = LexicalEnv::Cast(currentLexenv.GetTaggedObject())->GetParentEnv(); 17634514f5e3Sopenharmony_ci GET_ASM_FRAME(sp)->env = parentLexenv; 17644514f5e3Sopenharmony_ci DISPATCH(POPLEXENV); 17654514f5e3Sopenharmony_ci} 17664514f5e3Sopenharmony_ci 17674514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateiterresultobjV8V8( 17684514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 17694514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 17704514f5e3Sopenharmony_ci{ 17714514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 17724514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_1(); 17734514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createiterresultobj" 17744514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 17754514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 17764514f5e3Sopenharmony_ci JSTaggedValue flag = GET_VREG_VALUE(v1); 17774514f5e3Sopenharmony_ci SAVE_PC(); 17784514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateIterResultObj(thread, value, flag); 17794514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 17804514f5e3Sopenharmony_ci SET_ACC(res); 17814514f5e3Sopenharmony_ci DISPATCH(CREATEITERRESULTOBJ_V8_V8); 17824514f5e3Sopenharmony_ci} 17834514f5e3Sopenharmony_ci 17844514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSuspendgeneratorV8( 17854514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 17864514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 17874514f5e3Sopenharmony_ci{ 17884514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 17894514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::suspendgenerator" 17904514f5e3Sopenharmony_ci << " v" << v0; 17914514f5e3Sopenharmony_ci JSTaggedValue genObj = GET_VREG_VALUE(v0); 17924514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 17934514f5e3Sopenharmony_ci // suspend will record bytecode offset 17944514f5e3Sopenharmony_ci SAVE_PC(); 17954514f5e3Sopenharmony_ci SAVE_ACC(); 17964514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuspendGenerator(thread, genObj, value); 17974514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 17984514f5e3Sopenharmony_ci SET_ACC(res); 17994514f5e3Sopenharmony_ci 18004514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 18014514f5e3Sopenharmony_ci Method *method = ECMAObject::Cast(state->function.GetTaggedObject())->GetCallTarget(); 18024514f5e3Sopenharmony_ci [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); 18034514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); 18044514f5e3Sopenharmony_ci LOG_INST() << "Exit: SuspendGenerator " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 18054514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(state->pc); 18064514f5e3Sopenharmony_ci sp = state->base.prev; 18074514f5e3Sopenharmony_ci ASSERT(sp != nullptr); 18084514f5e3Sopenharmony_ci 18094514f5e3Sopenharmony_ci AsmInterpretedFrame *prevState = GET_ASM_FRAME(sp); 18104514f5e3Sopenharmony_ci pc = prevState->pc; 18114514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 18124514f5e3Sopenharmony_ci // entry frame 18134514f5e3Sopenharmony_ci if (pc == nullptr) { 18144514f5e3Sopenharmony_ci state->acc = acc; 18154514f5e3Sopenharmony_ci return; 18164514f5e3Sopenharmony_ci } 18174514f5e3Sopenharmony_ci 18184514f5e3Sopenharmony_ci ASSERT(prevState->callSize == GetJumpSizeAfterCall(pc)); 18194514f5e3Sopenharmony_ci DISPATCH_OFFSET(prevState->callSize); 18204514f5e3Sopenharmony_ci} 18214514f5e3Sopenharmony_ci 18224514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAsyncfunctionawaituncaughtV8( 18234514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 18244514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 18254514f5e3Sopenharmony_ci{ 18264514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 18274514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionawaituncaught" 18284514f5e3Sopenharmony_ci << " v" << v0; 18294514f5e3Sopenharmony_ci JSTaggedValue asyncFuncObj = GET_VREG_VALUE(v0); 18304514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 18314514f5e3Sopenharmony_ci SAVE_PC(); 18324514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionAwaitUncaught(thread, asyncFuncObj, value); 18334514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 18344514f5e3Sopenharmony_ci SET_ACC(res); 18354514f5e3Sopenharmony_ci DISPATCH(ASYNCFUNCTIONAWAITUNCAUGHT_V8); 18364514f5e3Sopenharmony_ci} 18374514f5e3Sopenharmony_ci 18384514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAsyncfunctionresolveV8( 18394514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 18404514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 18414514f5e3Sopenharmony_ci{ 18424514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 18434514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionresolve" 18444514f5e3Sopenharmony_ci << " v" << v0; 18454514f5e3Sopenharmony_ci 18464514f5e3Sopenharmony_ci JSTaggedValue asyncFuncObj = GET_VREG_VALUE(v0); 18474514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 18484514f5e3Sopenharmony_ci SAVE_PC(); 18494514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionResolveOrReject(thread, asyncFuncObj, value, true); 18504514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 18514514f5e3Sopenharmony_ci SET_ACC(res); 18524514f5e3Sopenharmony_ci DISPATCH(ASYNCFUNCTIONRESOLVE_V8); 18534514f5e3Sopenharmony_ci} 18544514f5e3Sopenharmony_ci 18554514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAsyncfunctionrejectV8( 18564514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 18574514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 18584514f5e3Sopenharmony_ci{ 18594514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 18604514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionreject" 18614514f5e3Sopenharmony_ci << " v" << v0; 18624514f5e3Sopenharmony_ci 18634514f5e3Sopenharmony_ci JSTaggedValue asyncFuncObj = GET_VREG_VALUE(v0); 18644514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 18654514f5e3Sopenharmony_ci SAVE_PC(); 18664514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionResolveOrReject(thread, asyncFuncObj, value, false); 18674514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 18684514f5e3Sopenharmony_ci SET_ACC(res); 18694514f5e3Sopenharmony_ci DISPATCH(ASYNCFUNCTIONREJECT_V8); 18704514f5e3Sopenharmony_ci} 18714514f5e3Sopenharmony_ci 18724514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNewobjapplyImm8V8( 18734514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 18744514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 18754514f5e3Sopenharmony_ci{ 18764514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 18774514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::newobjspeard" 18784514f5e3Sopenharmony_ci << " v" << v0; 18794514f5e3Sopenharmony_ci JSTaggedValue func = GET_VREG_VALUE(v0); 18804514f5e3Sopenharmony_ci JSTaggedValue array = GET_ACC(); 18814514f5e3Sopenharmony_ci SAVE_PC(); 18824514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewObjApply(thread, func, array); 18834514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 18844514f5e3Sopenharmony_ci SET_ACC(res); 18854514f5e3Sopenharmony_ci DISPATCH(NEWOBJAPPLY_IMM8_V8); 18864514f5e3Sopenharmony_ci} 18874514f5e3Sopenharmony_ci 18884514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowUndefinedifholePrefV8V8( 18894514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 18904514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 18914514f5e3Sopenharmony_ci{ 18924514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 18934514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 18944514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::throwundefinedifhole" 18954514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 18964514f5e3Sopenharmony_ci JSTaggedValue hole = GET_VREG_VALUE(v0); 18974514f5e3Sopenharmony_ci if (!hole.IsHole()) { 18984514f5e3Sopenharmony_ci DISPATCH(THROW_UNDEFINEDIFHOLE_PREF_V8_V8); 18994514f5e3Sopenharmony_ci } 19004514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v1); 19014514f5e3Sopenharmony_ci ASSERT(obj.IsString()); 19024514f5e3Sopenharmony_ci SAVE_PC(); 19034514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowUndefinedIfHole(thread, obj); 19044514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 19054514f5e3Sopenharmony_ci} 19064514f5e3Sopenharmony_ci 19074514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowUndefinedifholewithnamePrefId16( 19084514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 19094514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 19104514f5e3Sopenharmony_ci{ 19114514f5e3Sopenharmony_ci JSTaggedValue hole = acc; 19124514f5e3Sopenharmony_ci if (!hole.IsHole()) { 19134514f5e3Sopenharmony_ci DISPATCH(THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16); 19144514f5e3Sopenharmony_ci } 19154514f5e3Sopenharmony_ci 19164514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 19174514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::throwundefinedifholewithname" << std::hex << stringId; 19184514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 19194514f5e3Sopenharmony_ci JSTaggedValue obj = ConstantPool::GetStringFromCache(thread, constpool, stringId); 19204514f5e3Sopenharmony_ci ASSERT(obj.IsString()); 19214514f5e3Sopenharmony_ci SAVE_PC(); 19224514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowUndefinedIfHole(thread, obj); 19234514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 19244514f5e3Sopenharmony_ci} 19254514f5e3Sopenharmony_ci 19264514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbynameImm8Id16V8( 19274514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 19284514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 19294514f5e3Sopenharmony_ci{ 19304514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 19314514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_3(); 19324514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyname " 19334514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId; 19344514f5e3Sopenharmony_ci 19354514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 19364514f5e3Sopenharmony_ci if (receiver.IsJSObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 19374514f5e3Sopenharmony_ci SAVE_ACC(); 19384514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 19394514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 19404514f5e3Sopenharmony_ci RESTORE_ACC(); 19414514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 19424514f5e3Sopenharmony_ci // fast path 19434514f5e3Sopenharmony_ci SAVE_ACC(); 19444514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 19454514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName<ObjectFastOperator::Status::UseOwn> 19464514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 19474514f5e3Sopenharmony_ci if (!res.IsHole()) { 19484514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 19494514f5e3Sopenharmony_ci RESTORE_ACC(); 19504514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAME_IMM8_ID16_V8); 19514514f5e3Sopenharmony_ci } 19524514f5e3Sopenharmony_ci RESTORE_ACC(); 19534514f5e3Sopenharmony_ci } 19544514f5e3Sopenharmony_ci 19554514f5e3Sopenharmony_ci SAVE_ACC(); 19564514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 19574514f5e3Sopenharmony_ci auto propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); // Maybe moved by GC 19584514f5e3Sopenharmony_ci RESTORE_ACC(); 19594514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 19604514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 19614514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByName(thread, receiver, propKey, value); 19624514f5e3Sopenharmony_ci RESTORE_ACC(); 19634514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 19644514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAME_IMM8_ID16_V8); 19654514f5e3Sopenharmony_ci} 19664514f5e3Sopenharmony_ci 19674514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateemptyarrayImm8( 19684514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 19694514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 19704514f5e3Sopenharmony_ci{ 19714514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createemptyarray"; 19724514f5e3Sopenharmony_ci SAVE_PC(); 19734514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 19744514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 19754514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 19764514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateEmptyArray(thread, factory, globalEnv); 19774514f5e3Sopenharmony_ci SET_ACC(res); 19784514f5e3Sopenharmony_ci DISPATCH(CREATEEMPTYARRAY_IMM8); 19794514f5e3Sopenharmony_ci} 19804514f5e3Sopenharmony_ci 19814514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateemptyobject( 19824514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 19834514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 19844514f5e3Sopenharmony_ci{ 19854514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createemptyobject"; 19864514f5e3Sopenharmony_ci SAVE_PC(); 19874514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 19884514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 19894514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 19904514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateEmptyObject(thread, factory, globalEnv); 19914514f5e3Sopenharmony_ci SET_ACC(res); 19924514f5e3Sopenharmony_ci DISPATCH(CREATEEMPTYOBJECT); 19934514f5e3Sopenharmony_ci} 19944514f5e3Sopenharmony_ci 19954514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSetobjectwithprotoImm8V8( 19964514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 19974514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 19984514f5e3Sopenharmony_ci{ 19994514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 20004514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::setobjectwithproto" 20014514f5e3Sopenharmony_ci << " v" << v0; 20024514f5e3Sopenharmony_ci JSTaggedValue proto = GET_VREG_VALUE(v0); 20034514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 20044514f5e3Sopenharmony_ci SAVE_ACC(); 20054514f5e3Sopenharmony_ci SAVE_PC(); 20064514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SetObjectWithProto(thread, proto, obj); 20074514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 20084514f5e3Sopenharmony_ci RESTORE_ACC(); 20094514f5e3Sopenharmony_ci DISPATCH(SETOBJECTWITHPROTO_IMM8_V8); 20104514f5e3Sopenharmony_ci} 20114514f5e3Sopenharmony_ci 20124514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateregexpwithliteralImm8Id16Imm8( 20134514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 20144514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 20154514f5e3Sopenharmony_ci{ 20164514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 20174514f5e3Sopenharmony_ci SAVE_ACC(); 20184514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 20194514f5e3Sopenharmony_ci JSTaggedValue pattern = ConstantPool::GetStringFromCache(thread, constpool, stringId); 20204514f5e3Sopenharmony_ci uint8_t flags = READ_INST_8_3(); 20214514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createregexpwithliteral " 20224514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(pattern.GetTaggedObject())) 20234514f5e3Sopenharmony_ci << ", flags:" << flags; 20244514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateRegExpWithLiteral(thread, pattern, flags); 20254514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 20264514f5e3Sopenharmony_ci SET_ACC(res); 20274514f5e3Sopenharmony_ci DISPATCH(CREATEREGEXPWITHLITERAL_IMM8_ID16_IMM8); 20284514f5e3Sopenharmony_ci} 20294514f5e3Sopenharmony_ci 20304514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGettemplateobjectImm8( 20314514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 20324514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 20334514f5e3Sopenharmony_ci{ 20344514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::gettemplateobject"; 20354514f5e3Sopenharmony_ci 20364514f5e3Sopenharmony_ci JSTaggedValue literal = GET_ACC(); 20374514f5e3Sopenharmony_ci SAVE_PC(); 20384514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetTemplateObject(thread, literal); 20394514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 20404514f5e3Sopenharmony_ci SET_ACC(res); 20414514f5e3Sopenharmony_ci DISPATCH(GETTEMPLATEOBJECT_IMM8); 20424514f5e3Sopenharmony_ci} 20434514f5e3Sopenharmony_ci 20444514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetnextpropnameV8( 20454514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 20464514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 20474514f5e3Sopenharmony_ci{ 20484514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 20494514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::getnextpropname" 20504514f5e3Sopenharmony_ci << " v" << v0; 20514514f5e3Sopenharmony_ci JSTaggedValue iter = GET_VREG_VALUE(v0); 20524514f5e3Sopenharmony_ci SAVE_PC(); 20534514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetNextPropName(thread, iter); 20544514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 20554514f5e3Sopenharmony_ci SET_ACC(res); 20564514f5e3Sopenharmony_ci DISPATCH(GETNEXTPROPNAME_V8); 20574514f5e3Sopenharmony_ci} 20584514f5e3Sopenharmony_ci 20594514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCopydatapropertiesV8( 20604514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 20614514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 20624514f5e3Sopenharmony_ci{ 20634514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 20644514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::copydataproperties" 20654514f5e3Sopenharmony_ci << " v" << v0; 20664514f5e3Sopenharmony_ci JSTaggedValue dst = GET_VREG_VALUE(v0); 20674514f5e3Sopenharmony_ci JSTaggedValue src = GET_ACC(); 20684514f5e3Sopenharmony_ci SAVE_PC(); 20694514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CopyDataProperties(thread, dst, src); 20704514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 20714514f5e3Sopenharmony_ci SET_ACC(res); 20724514f5e3Sopenharmony_ci DISPATCH(COPYDATAPROPERTIES_V8); 20734514f5e3Sopenharmony_ci} 20744514f5e3Sopenharmony_ci 20754514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbyindexImm8V8Imm16( 20764514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 20774514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 20784514f5e3Sopenharmony_ci{ 20794514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 20804514f5e3Sopenharmony_ci uint16_t index = READ_INST_16_2(); 20814514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyindex" 20824514f5e3Sopenharmony_ci << " v" << v0 << " imm" << index; 20834514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 20844514f5e3Sopenharmony_ci // fast path 20854514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 20864514f5e3Sopenharmony_ci SAVE_ACC(); 20874514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 20884514f5e3Sopenharmony_ci // fast path 20894514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByIndex<ObjectFastOperator::Status::UseOwn> 20904514f5e3Sopenharmony_ci (thread, receiver, index, value); 20914514f5e3Sopenharmony_ci if (!res.IsHole()) { 20924514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 20934514f5e3Sopenharmony_ci RESTORE_ACC(); 20944514f5e3Sopenharmony_ci DISPATCH(STOWNBYINDEX_IMM8_V8_IMM16); 20954514f5e3Sopenharmony_ci } 20964514f5e3Sopenharmony_ci RESTORE_ACC(); 20974514f5e3Sopenharmony_ci } 20984514f5e3Sopenharmony_ci SAVE_ACC(); 20994514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 21004514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 21014514f5e3Sopenharmony_ci SAVE_PC(); 21024514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByIndex(thread, receiver, index, value); 21034514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 21044514f5e3Sopenharmony_ci RESTORE_ACC(); 21054514f5e3Sopenharmony_ci DISPATCH(STOWNBYINDEX_IMM8_V8_IMM16); 21064514f5e3Sopenharmony_ci} 21074514f5e3Sopenharmony_ci 21084514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbyvalueImm8V8V8( 21094514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 21104514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 21114514f5e3Sopenharmony_ci{ 21124514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 21134514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_2(); 21144514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyvalue" 21154514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 21164514f5e3Sopenharmony_ci 21174514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 21184514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 21194514f5e3Sopenharmony_ci SAVE_ACC(); 21204514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 21214514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 21224514f5e3Sopenharmony_ci // fast path 21234514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue<ObjectFastOperator::Status::UseOwn> 21244514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 21254514f5e3Sopenharmony_ci 21264514f5e3Sopenharmony_ci // SetPropertyByValue maybe gc need update the value 21274514f5e3Sopenharmony_ci RESTORE_ACC(); 21284514f5e3Sopenharmony_ci propKey = GET_VREG_VALUE(v1); 21294514f5e3Sopenharmony_ci value = GET_ACC(); 21304514f5e3Sopenharmony_ci if (!res.IsHole()) { 21314514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 21324514f5e3Sopenharmony_ci RESTORE_ACC(); 21334514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUE_IMM8_V8_V8); 21344514f5e3Sopenharmony_ci } 21354514f5e3Sopenharmony_ci } 21364514f5e3Sopenharmony_ci 21374514f5e3Sopenharmony_ci // slow path 21384514f5e3Sopenharmony_ci SAVE_ACC(); 21394514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 21404514f5e3Sopenharmony_ci auto propKey = GET_VREG_VALUE(v1); // Maybe moved by GC 21414514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 21424514f5e3Sopenharmony_ci SAVE_PC(); 21434514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByValue(thread, receiver, propKey, value); 21444514f5e3Sopenharmony_ci RESTORE_ACC(); 21454514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 21464514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUE_IMM8_V8_V8); 21474514f5e3Sopenharmony_ci} 21484514f5e3Sopenharmony_ci 21494514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateobjectwithexcludedkeysImm8V8V8( 21504514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 21514514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 21524514f5e3Sopenharmony_ci{ 21534514f5e3Sopenharmony_ci uint8_t numKeys = READ_INST_8_0(); 21544514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 21554514f5e3Sopenharmony_ci uint16_t firstArgRegIdx = READ_INST_8_2(); 21564514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createobjectwithexcludedkeys " << numKeys << " v" << firstArgRegIdx; 21574514f5e3Sopenharmony_ci 21584514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 21594514f5e3Sopenharmony_ci 21604514f5e3Sopenharmony_ci SAVE_PC(); 21614514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateObjectWithExcludedKeys(thread, numKeys, obj, firstArgRegIdx); 21624514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 21634514f5e3Sopenharmony_ci SET_ACC(res); 21644514f5e3Sopenharmony_ci DISPATCH(CREATEOBJECTWITHEXCLUDEDKEYS_IMM8_V8_V8); 21654514f5e3Sopenharmony_ci} 21664514f5e3Sopenharmony_ci 21674514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdhole( 21684514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 21694514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 21704514f5e3Sopenharmony_ci{ 21714514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::ldhole"; 21724514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::Hole()); 21734514f5e3Sopenharmony_ci DISPATCH(LDHOLE); 21744514f5e3Sopenharmony_ci} 21754514f5e3Sopenharmony_ci 21764514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCopyrestargsImm8( 21774514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 21784514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 21794514f5e3Sopenharmony_ci{ 21804514f5e3Sopenharmony_ci uint16_t restIdx = READ_INST_8_0(); 21814514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::copyrestargs" 21824514f5e3Sopenharmony_ci << " index: " << restIdx; 21834514f5e3Sopenharmony_ci 21844514f5e3Sopenharmony_ci uint32_t startIdx = 0; 21854514f5e3Sopenharmony_ci uint32_t restNumArgs = GetNumArgs(sp, restIdx, startIdx); 21864514f5e3Sopenharmony_ci 21874514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CopyRestArgs(thread, sp, restNumArgs, startIdx); 21884514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 21894514f5e3Sopenharmony_ci SET_ACC(res); 21904514f5e3Sopenharmony_ci DISPATCH(COPYRESTARGS_IMM8); 21914514f5e3Sopenharmony_ci} 21924514f5e3Sopenharmony_ci 21934514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefinegettersetterbyvalueV8V8V8V8( 21944514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 21954514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 21964514f5e3Sopenharmony_ci{ 21974514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 21984514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_1(); 21994514f5e3Sopenharmony_ci uint16_t v2 = READ_INST_8_2(); 22004514f5e3Sopenharmony_ci uint16_t v3 = READ_INST_8_3(); 22014514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::definegettersetterbyvalue" 22024514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1 << " v" << v2 << " v" << v3; 22034514f5e3Sopenharmony_ci 22044514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 22054514f5e3Sopenharmony_ci JSTaggedValue prop = GET_VREG_VALUE(v1); 22064514f5e3Sopenharmony_ci JSTaggedValue getter = GET_VREG_VALUE(v2); 22074514f5e3Sopenharmony_ci JSTaggedValue setter = GET_VREG_VALUE(v3); 22084514f5e3Sopenharmony_ci JSTaggedValue flag = GET_ACC(); 22094514f5e3Sopenharmony_ci SAVE_PC(); 22104514f5e3Sopenharmony_ci JSTaggedValue res = 22114514f5e3Sopenharmony_ci SlowRuntimeStub::DefineGetterSetterByValue(thread, obj, prop, getter, setter, flag.ToBoolean()); 22124514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 22134514f5e3Sopenharmony_ci SET_ACC(res); 22144514f5e3Sopenharmony_ci DISPATCH(DEFINEGETTERSETTERBYVALUE_V8_V8_V8_V8); 22154514f5e3Sopenharmony_ci} 22164514f5e3Sopenharmony_ci 22174514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStobjbyindexImm8V8Imm16( 22184514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 22194514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 22204514f5e3Sopenharmony_ci{ 22214514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 22224514f5e3Sopenharmony_ci uint32_t index = READ_INST_16_2(); 22234514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyindex" 22244514f5e3Sopenharmony_ci << " v" << v0 << " imm" << index; 22254514f5e3Sopenharmony_ci 22264514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 22274514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 22284514f5e3Sopenharmony_ci SAVE_ACC(); 22294514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 22304514f5e3Sopenharmony_ci // fast path 22314514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByIndex(thread, receiver, index, value); 22324514f5e3Sopenharmony_ci if (!res.IsHole()) { 22334514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 22344514f5e3Sopenharmony_ci RESTORE_ACC(); 22354514f5e3Sopenharmony_ci DISPATCH(STOBJBYINDEX_IMM8_V8_IMM16); 22364514f5e3Sopenharmony_ci } 22374514f5e3Sopenharmony_ci RESTORE_ACC(); 22384514f5e3Sopenharmony_ci } 22394514f5e3Sopenharmony_ci // slow path 22404514f5e3Sopenharmony_ci SAVE_ACC(); 22414514f5e3Sopenharmony_ci SAVE_PC(); 22424514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 22434514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 22444514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByIndex(thread, receiver, index, value); 22454514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 22464514f5e3Sopenharmony_ci RESTORE_ACC(); 22474514f5e3Sopenharmony_ci DISPATCH(STOBJBYINDEX_IMM8_V8_IMM16); 22484514f5e3Sopenharmony_ci} 22494514f5e3Sopenharmony_ci 22504514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStobjbyvalueImm8V8V8( 22514514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 22524514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 22534514f5e3Sopenharmony_ci{ 22544514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 22554514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_2(); 22564514f5e3Sopenharmony_ci 22574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyvalue" 22584514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 22594514f5e3Sopenharmony_ci 22604514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 22614514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 22624514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 22634514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 22644514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 22654514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 22664514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 22674514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 22684514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 22694514f5e3Sopenharmony_ci SAVE_ACC(); 22704514f5e3Sopenharmony_ci 22714514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 22724514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 22734514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByValue(thread, receiver, propKey, firstValue, secondValue, value); 22744514f5e3Sopenharmony_ci } 22754514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 22764514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 22774514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByValue(thread, 22784514f5e3Sopenharmony_ci profileTypeArray, 22794514f5e3Sopenharmony_ci receiver, propKey, value, slotId); 22804514f5e3Sopenharmony_ci } 22814514f5e3Sopenharmony_ci 22824514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 22834514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 22844514f5e3Sopenharmony_ci RESTORE_ACC(); 22854514f5e3Sopenharmony_ci DISPATCH(STOBJBYVALUE_IMM8_V8_V8); 22864514f5e3Sopenharmony_ci } 22874514f5e3Sopenharmony_ci } 22884514f5e3Sopenharmony_ci#endif 22894514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 22904514f5e3Sopenharmony_ci SAVE_ACC(); 22914514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 22924514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 22934514f5e3Sopenharmony_ci // fast path 22944514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue(thread, receiver, propKey, value); 22954514f5e3Sopenharmony_ci if (!res.IsHole()) { 22964514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 22974514f5e3Sopenharmony_ci RESTORE_ACC(); 22984514f5e3Sopenharmony_ci DISPATCH(STOBJBYVALUE_IMM8_V8_V8); 22994514f5e3Sopenharmony_ci } 23004514f5e3Sopenharmony_ci RESTORE_ACC(); 23014514f5e3Sopenharmony_ci } 23024514f5e3Sopenharmony_ci { 23034514f5e3Sopenharmony_ci // slow path 23044514f5e3Sopenharmony_ci SAVE_ACC(); 23054514f5e3Sopenharmony_ci SAVE_PC(); 23064514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 23074514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); // Maybe moved by GC 23084514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 23094514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByValue(thread, receiver, propKey, value); 23104514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 23114514f5e3Sopenharmony_ci RESTORE_ACC(); 23124514f5e3Sopenharmony_ci } 23134514f5e3Sopenharmony_ci DISPATCH(STOBJBYVALUE_IMM8_V8_V8); 23144514f5e3Sopenharmony_ci} 23154514f5e3Sopenharmony_ci 23164514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStsuperbyvalueImm8V8V8( 23174514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 23184514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 23194514f5e3Sopenharmony_ci{ 23204514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 23214514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_2(); 23224514f5e3Sopenharmony_ci 23234514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsuperbyvalue" 23244514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 23254514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 23264514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 23274514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 23284514f5e3Sopenharmony_ci 23294514f5e3Sopenharmony_ci // slow path 23304514f5e3Sopenharmony_ci SAVE_ACC(); 23314514f5e3Sopenharmony_ci SAVE_PC(); 23324514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 23334514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StSuperByValue(thread, receiver, propKey, value, thisFunc); 23344514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 23354514f5e3Sopenharmony_ci RESTORE_ACC(); 23364514f5e3Sopenharmony_ci DISPATCH(STSUPERBYVALUE_IMM8_V8_V8); 23374514f5e3Sopenharmony_ci} 23384514f5e3Sopenharmony_ci 23394514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTryldglobalbynameImm8Id16( 23404514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 23414514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 23424514f5e3Sopenharmony_ci{ 23434514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 23444514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 23454514f5e3Sopenharmony_ci auto prop = ConstantPool::GetStringFromCache(thread, constpool, stringId); 23464514f5e3Sopenharmony_ci 23474514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 23484514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 23494514f5e3Sopenharmony_ci JSTaggedValue globalObj = globalEnv->GetGlobalObject(); 23504514f5e3Sopenharmony_ci 23514514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::tryldglobalbyname " 23524514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(prop.GetTaggedObject())); 23534514f5e3Sopenharmony_ci 23544514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 23554514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 23564514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 23574514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 23584514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 23594514f5e3Sopenharmony_ci JSTaggedValue res = ICRuntimeStub::LoadGlobalICByName(thread, 23604514f5e3Sopenharmony_ci ProfileTypeInfo::Cast( 23614514f5e3Sopenharmony_ci tmpProfileTypeInfo.GetTaggedObject()), 23624514f5e3Sopenharmony_ci globalObj, prop, slotId, true); 23634514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 23644514f5e3Sopenharmony_ci SET_ACC(res); 23654514f5e3Sopenharmony_ci DISPATCH(TRYLDGLOBALBYNAME_IMM8_ID16); 23664514f5e3Sopenharmony_ci } 23674514f5e3Sopenharmony_ci#endif 23684514f5e3Sopenharmony_ci 23694514f5e3Sopenharmony_ci // order: 1. global record 2. global object 23704514f5e3Sopenharmony_ci JSTaggedValue result = SlowRuntimeStub::LdGlobalRecord(thread, prop); 23714514f5e3Sopenharmony_ci if (!result.IsUndefined()) { 23724514f5e3Sopenharmony_ci SET_ACC(PropertyBox::Cast(result.GetTaggedObject())->GetValue()); 23734514f5e3Sopenharmony_ci } else { 23744514f5e3Sopenharmony_ci JSTaggedValue globalResult = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj, prop); 23754514f5e3Sopenharmony_ci if (!globalResult.IsHole()) { 23764514f5e3Sopenharmony_ci SET_ACC(globalResult); 23774514f5e3Sopenharmony_ci } else { 23784514f5e3Sopenharmony_ci // slow path 23794514f5e3Sopenharmony_ci SAVE_PC(); 23804514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::TryLdGlobalByNameFromGlobalProto(thread, globalObj, prop); 23814514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 23824514f5e3Sopenharmony_ci SET_ACC(res); 23834514f5e3Sopenharmony_ci } 23844514f5e3Sopenharmony_ci } 23854514f5e3Sopenharmony_ci 23864514f5e3Sopenharmony_ci DISPATCH(TRYLDGLOBALBYNAME_IMM8_ID16); 23874514f5e3Sopenharmony_ci} 23884514f5e3Sopenharmony_ci 23894514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTrystglobalbynameImm8Id16( 23904514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 23914514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 23924514f5e3Sopenharmony_ci{ 23934514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 23944514f5e3Sopenharmony_ci SAVE_ACC(); 23954514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 23964514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 23974514f5e3Sopenharmony_ci 23984514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 23994514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 24004514f5e3Sopenharmony_ci JSTaggedValue globalObj = globalEnv->GetGlobalObject(); 24014514f5e3Sopenharmony_ci 24024514f5e3Sopenharmony_ci RESTORE_ACC(); 24034514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::trystglobalbyname" 24044514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 24054514f5e3Sopenharmony_ci 24064514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 24074514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 24084514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 24094514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 24104514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 24114514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 24124514f5e3Sopenharmony_ci SAVE_ACC(); 24134514f5e3Sopenharmony_ci JSTaggedValue res = ICRuntimeStub::StoreGlobalICByName(thread, 24144514f5e3Sopenharmony_ci ProfileTypeInfo::Cast( 24154514f5e3Sopenharmony_ci tmpProfileTypeInfo.GetTaggedObject()), 24164514f5e3Sopenharmony_ci globalObj, propKey, value, slotId, true); 24174514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 24184514f5e3Sopenharmony_ci RESTORE_ACC(); 24194514f5e3Sopenharmony_ci DISPATCH(TRYSTGLOBALBYNAME_IMM8_ID16); 24204514f5e3Sopenharmony_ci } 24214514f5e3Sopenharmony_ci#endif 24224514f5e3Sopenharmony_ci 24234514f5e3Sopenharmony_ci auto recordResult = SlowRuntimeStub::LdGlobalRecord(thread, propKey); 24244514f5e3Sopenharmony_ci SAVE_PC(); 24254514f5e3Sopenharmony_ci // 1. find from global record 24264514f5e3Sopenharmony_ci if (!recordResult.IsUndefined()) { 24274514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 24284514f5e3Sopenharmony_ci SAVE_ACC(); 24294514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::TryUpdateGlobalRecord(thread, propKey, value); 24304514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 24314514f5e3Sopenharmony_ci RESTORE_ACC(); 24324514f5e3Sopenharmony_ci } else { 24334514f5e3Sopenharmony_ci // 2. find from global object 24344514f5e3Sopenharmony_ci auto globalResult = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj, propKey); 24354514f5e3Sopenharmony_ci if (globalResult.IsHole()) { 24364514f5e3Sopenharmony_ci auto result = SlowRuntimeStub::ThrowReferenceError(thread, propKey, " is not defined"); 24374514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(result); 24384514f5e3Sopenharmony_ci } 24394514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 24404514f5e3Sopenharmony_ci SAVE_ACC(); 24414514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalVar(thread, propKey, value); 24424514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 24434514f5e3Sopenharmony_ci RESTORE_ACC(); 24444514f5e3Sopenharmony_ci } 24454514f5e3Sopenharmony_ci DISPATCH(TRYSTGLOBALBYNAME_IMM8_ID16); 24464514f5e3Sopenharmony_ci} 24474514f5e3Sopenharmony_ci 24484514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbyvaluewithnamesetImm8V8V8( 24494514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 24504514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 24514514f5e3Sopenharmony_ci{ 24524514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 24534514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_2(); 24544514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyvaluewithnameset" 24554514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 24564514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 24574514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 24584514f5e3Sopenharmony_ci SAVE_ACC(); 24594514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 24604514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 24614514f5e3Sopenharmony_ci // fast path 24624514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue<ObjectFastOperator::Status::UseOwn> 24634514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 24644514f5e3Sopenharmony_ci 24654514f5e3Sopenharmony_ci // SetPropertyByValue maybe gc need update the value 24664514f5e3Sopenharmony_ci RESTORE_ACC(); 24674514f5e3Sopenharmony_ci propKey = GET_VREG_VALUE(v1); 24684514f5e3Sopenharmony_ci value = GET_ACC(); 24694514f5e3Sopenharmony_ci if (!res.IsHole()) { 24704514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 24714514f5e3Sopenharmony_ci JSFunction::SetFunctionNameNoPrefix(thread, JSFunction::Cast(value.GetTaggedObject()), propKey); 24724514f5e3Sopenharmony_ci RESTORE_ACC(); 24734514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUEWITHNAMESET_IMM8_V8_V8); 24744514f5e3Sopenharmony_ci } 24754514f5e3Sopenharmony_ci } 24764514f5e3Sopenharmony_ci 24774514f5e3Sopenharmony_ci // slow path 24784514f5e3Sopenharmony_ci SAVE_ACC(); 24794514f5e3Sopenharmony_ci SAVE_PC(); 24804514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 24814514f5e3Sopenharmony_ci auto propKey = GET_VREG_VALUE(v1); // Maybe moved by GC 24824514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 24834514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByValueWithNameSet(thread, receiver, propKey, value); 24844514f5e3Sopenharmony_ci RESTORE_ACC(); 24854514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 24864514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUEWITHNAMESET_IMM8_V8_V8); 24874514f5e3Sopenharmony_ci} 24884514f5e3Sopenharmony_ci 24894514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbynamewithnamesetImm8Id16V8( 24904514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 24914514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 24924514f5e3Sopenharmony_ci{ 24934514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 24944514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_3(); 24954514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbynamewithnameset " 24964514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId; 24974514f5e3Sopenharmony_ci 24984514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 24994514f5e3Sopenharmony_ci if (receiver.IsJSObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 25004514f5e3Sopenharmony_ci SAVE_ACC(); 25014514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 25024514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 25034514f5e3Sopenharmony_ci RESTORE_ACC(); 25044514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 25054514f5e3Sopenharmony_ci // fast path 25064514f5e3Sopenharmony_ci SAVE_ACC(); 25074514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName<ObjectFastOperator::Status::UseOwn> 25084514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 25094514f5e3Sopenharmony_ci if (!res.IsHole()) { 25104514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 25114514f5e3Sopenharmony_ci JSFunction::SetFunctionNameNoPrefix(thread, JSFunction::Cast(value.GetTaggedObject()), propKey); 25124514f5e3Sopenharmony_ci RESTORE_ACC(); 25134514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8); 25144514f5e3Sopenharmony_ci } 25154514f5e3Sopenharmony_ci RESTORE_ACC(); 25164514f5e3Sopenharmony_ci } 25174514f5e3Sopenharmony_ci 25184514f5e3Sopenharmony_ci SAVE_ACC(); 25194514f5e3Sopenharmony_ci SAVE_PC(); 25204514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 25214514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); // Maybe moved by GC 25224514f5e3Sopenharmony_ci auto propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); // Maybe moved by GC 25234514f5e3Sopenharmony_ci RESTORE_ACC(); 25244514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 25254514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByNameWithNameSet(thread, receiver, propKey, value); 25264514f5e3Sopenharmony_ci RESTORE_ACC(); 25274514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 25284514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAMEWITHNAMESET_IMM8_ID16_V8); 25294514f5e3Sopenharmony_ci} 25304514f5e3Sopenharmony_ci 25314514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdglobalvarImm16Id16( 25324514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 25334514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 25344514f5e3Sopenharmony_ci{ 25354514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 25364514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldglobalvar stringId:" << stringId; 25374514f5e3Sopenharmony_ci SAVE_ACC(); 25384514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 25394514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 25404514f5e3Sopenharmony_ci 25414514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 25424514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 25434514f5e3Sopenharmony_ci JSTaggedValue globalObj = globalEnv->GetGlobalObject(); 25444514f5e3Sopenharmony_ci 25454514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 25464514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 25474514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 25484514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 25494514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 25504514f5e3Sopenharmony_ci JSTaggedValue res = ICRuntimeStub::LoadGlobalICByName(thread, 25514514f5e3Sopenharmony_ci ProfileTypeInfo::Cast( 25524514f5e3Sopenharmony_ci tmpProfileTypeInfo.GetTaggedObject()), 25534514f5e3Sopenharmony_ci globalObj, propKey, slotId, false); 25544514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 25554514f5e3Sopenharmony_ci SET_ACC(res); 25564514f5e3Sopenharmony_ci DISPATCH(LDGLOBALVAR_IMM16_ID16); 25574514f5e3Sopenharmony_ci } 25584514f5e3Sopenharmony_ci#endif 25594514f5e3Sopenharmony_ci 25604514f5e3Sopenharmony_ci JSTaggedValue result = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj, propKey); 25614514f5e3Sopenharmony_ci if (!result.IsHole()) { 25624514f5e3Sopenharmony_ci SET_ACC(result); 25634514f5e3Sopenharmony_ci } else { 25644514f5e3Sopenharmony_ci // slow path 25654514f5e3Sopenharmony_ci SAVE_PC(); 25664514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdGlobalVarFromGlobalProto(thread, globalObj, propKey); 25674514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 25684514f5e3Sopenharmony_ci SET_ACC(res); 25694514f5e3Sopenharmony_ci } 25704514f5e3Sopenharmony_ci DISPATCH(LDGLOBALVAR_IMM16_ID16); 25714514f5e3Sopenharmony_ci} 25724514f5e3Sopenharmony_ci 25734514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStobjbynameImm8Id16V8( 25744514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 25754514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 25764514f5e3Sopenharmony_ci{ 25774514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_3(); 25784514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 25794514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 25804514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 25814514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 25824514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 25834514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 25844514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 25854514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 25864514f5e3Sopenharmony_ci SAVE_ACC(); 25874514f5e3Sopenharmony_ci 25884514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 25894514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 25904514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 25914514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 25924514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByName(thread, receiver, firstValue, secondValue, value); 25934514f5e3Sopenharmony_ci } 25944514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 25954514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 25964514f5e3Sopenharmony_ci RESTORE_ACC(); 25974514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM8_ID16_V8); 25984514f5e3Sopenharmony_ci } else if (!firstValue.IsHole()) { // IC miss and not enter the megamorphic state, store as polymorphic 25994514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 26004514f5e3Sopenharmony_ci SAVE_ACC(); 26014514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 26024514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 26034514f5e3Sopenharmony_ci RESTORE_ACC(); 26044514f5e3Sopenharmony_ci value = GET_ACC(); 26054514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 26064514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 26074514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByName(thread, 26084514f5e3Sopenharmony_ci profileTypeArray, 26094514f5e3Sopenharmony_ci receiver, propKey, value, slotId); 26104514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 26114514f5e3Sopenharmony_ci RESTORE_ACC(); 26124514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM8_ID16_V8); 26134514f5e3Sopenharmony_ci } 26144514f5e3Sopenharmony_ci } 26154514f5e3Sopenharmony_ci#endif 26164514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 26174514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyname " 26184514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId; 26194514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 26204514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 26214514f5e3Sopenharmony_ci SAVE_ACC(); 26224514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 26234514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 26244514f5e3Sopenharmony_ci RESTORE_ACC(); 26254514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 26264514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 26274514f5e3Sopenharmony_ci // fast path 26284514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName(thread, receiver, propKey, value); 26294514f5e3Sopenharmony_ci if (!res.IsHole()) { 26304514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 26314514f5e3Sopenharmony_ci RESTORE_ACC(); 26324514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM8_ID16_V8); 26334514f5e3Sopenharmony_ci } 26344514f5e3Sopenharmony_ci RESTORE_ACC(); 26354514f5e3Sopenharmony_ci } 26364514f5e3Sopenharmony_ci // slow path 26374514f5e3Sopenharmony_ci SAVE_ACC(); 26384514f5e3Sopenharmony_ci SAVE_PC(); 26394514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); // Maybe moved by GC 26404514f5e3Sopenharmony_ci auto propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); // Maybe moved by GC 26414514f5e3Sopenharmony_ci RESTORE_ACC(); 26424514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 26434514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 26444514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByName(thread, receiver, propKey, value); 26454514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 26464514f5e3Sopenharmony_ci RESTORE_ACC(); 26474514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM8_ID16_V8); 26484514f5e3Sopenharmony_ci} 26494514f5e3Sopenharmony_ci 26504514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStsuperbynameImm8Id16V8( 26514514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 26524514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 26534514f5e3Sopenharmony_ci{ 26544514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 26554514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_3(); 26564514f5e3Sopenharmony_ci 26574514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 26584514f5e3Sopenharmony_ci SAVE_ACC(); 26594514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 26604514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 26614514f5e3Sopenharmony_ci RESTORE_ACC(); 26624514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 26634514f5e3Sopenharmony_ci 26644514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsuperbyname" 26654514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId << ", " 26664514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << obj.GetRawData() 26674514f5e3Sopenharmony_ci << ", value:" << value.GetRawData(); 26684514f5e3Sopenharmony_ci 26694514f5e3Sopenharmony_ci // slow path 26704514f5e3Sopenharmony_ci SAVE_ACC(); 26714514f5e3Sopenharmony_ci SAVE_PC(); 26724514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 26734514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StSuperByValue(thread, obj, propKey, value, thisFunc); 26744514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 26754514f5e3Sopenharmony_ci RESTORE_ACC(); 26764514f5e3Sopenharmony_ci DISPATCH(STSUPERBYNAME_IMM8_ID16_V8); 26774514f5e3Sopenharmony_ci} 26784514f5e3Sopenharmony_ci 26794514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStglobalvarImm16Id16( 26804514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 26814514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 26824514f5e3Sopenharmony_ci{ 26834514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 26844514f5e3Sopenharmony_ci SAVE_ACC(); 26854514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 26864514f5e3Sopenharmony_ci JSTaggedValue prop = ConstantPool::GetStringFromCache(thread, constpool, stringId); 26874514f5e3Sopenharmony_ci RESTORE_ACC(); 26884514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 26894514f5e3Sopenharmony_ci 26904514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stglobalvar " 26914514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(prop.GetTaggedObject())) 26924514f5e3Sopenharmony_ci << ", value:" << value.GetRawData(); 26934514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 26944514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 26954514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 26964514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 26974514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 26984514f5e3Sopenharmony_ci SAVE_ACC(); 26994514f5e3Sopenharmony_ci JSTaggedValue res = ICRuntimeStub::StoreGlobalICByName(thread, 27004514f5e3Sopenharmony_ci ProfileTypeInfo::Cast( 27014514f5e3Sopenharmony_ci tmpProfileTypeInfo.GetTaggedObject()), 27024514f5e3Sopenharmony_ci globalObj, prop, value, slotId, false); 27034514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 27044514f5e3Sopenharmony_ci RESTORE_ACC(); 27054514f5e3Sopenharmony_ci DISPATCH(STGLOBALVAR_IMM16_ID16); 27064514f5e3Sopenharmony_ci } 27074514f5e3Sopenharmony_ci#endif 27084514f5e3Sopenharmony_ci SAVE_ACC(); 27094514f5e3Sopenharmony_ci SAVE_PC(); 27104514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalVar(thread, prop, value); 27114514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 27124514f5e3Sopenharmony_ci RESTORE_ACC(); 27134514f5e3Sopenharmony_ci DISPATCH(STGLOBALVAR_IMM16_ID16); 27144514f5e3Sopenharmony_ci} 27154514f5e3Sopenharmony_ci 27164514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreategeneratorobjV8( 27174514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 27184514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 27194514f5e3Sopenharmony_ci{ 27204514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 27214514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::creategeneratorobj" 27224514f5e3Sopenharmony_ci << " v" << v0; 27234514f5e3Sopenharmony_ci SAVE_PC(); 27244514f5e3Sopenharmony_ci JSTaggedValue genFunc = GET_VREG_VALUE(v0); 27254514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateGeneratorObj(thread, genFunc); 27264514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 27274514f5e3Sopenharmony_ci SET_ACC(res); 27284514f5e3Sopenharmony_ci DISPATCH(CREATEGENERATOROBJ_V8); 27294514f5e3Sopenharmony_ci} 27304514f5e3Sopenharmony_ci 27314514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateasyncgeneratorobjV8( 27324514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 27334514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 27344514f5e3Sopenharmony_ci{ 27354514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 27364514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createasyncgeneratorobj" 27374514f5e3Sopenharmony_ci << " v" << v0; 27384514f5e3Sopenharmony_ci SAVE_PC(); 27394514f5e3Sopenharmony_ci JSTaggedValue genFunc = GET_VREG_VALUE(v0); 27404514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateAsyncGeneratorObj(thread, genFunc); 27414514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 27424514f5e3Sopenharmony_ci SET_ACC(res); 27434514f5e3Sopenharmony_ci DISPATCH(CREATEASYNCGENERATOROBJ_V8); 27444514f5e3Sopenharmony_ci} 27454514f5e3Sopenharmony_ci 27464514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAsyncgeneratorresolveV8V8V8( 27474514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 27484514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 27494514f5e3Sopenharmony_ci{ 27504514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 27514514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_1(); 27524514f5e3Sopenharmony_ci uint16_t v2 = READ_INST_8_2(); 27534514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncgeneratorresolve" 27544514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1 << " v" << v2; 27554514f5e3Sopenharmony_ci JSTaggedValue asyncGenerator = GET_VREG_VALUE(v0); 27564514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v1); 27574514f5e3Sopenharmony_ci JSTaggedValue flag = GET_VREG_VALUE(v2); 27584514f5e3Sopenharmony_ci SAVE_PC(); 27594514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncGeneratorResolve(thread, asyncGenerator, value, flag); 27604514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 27614514f5e3Sopenharmony_ci SET_ACC(res); 27624514f5e3Sopenharmony_ci 27634514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 27644514f5e3Sopenharmony_ci Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget(); 27654514f5e3Sopenharmony_ci [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); 27664514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); 27674514f5e3Sopenharmony_ci LOG_INST() << "Exit: AsyncGeneratorresolve " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 27684514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(state->pc); 27694514f5e3Sopenharmony_ci sp = state->base.prev; 27704514f5e3Sopenharmony_ci ASSERT(sp != nullptr); 27714514f5e3Sopenharmony_ci InterpretedFrame *prevState = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 27724514f5e3Sopenharmony_ci pc = prevState->pc; 27734514f5e3Sopenharmony_ci // entry frame 27744514f5e3Sopenharmony_ci if (FrameHandler::IsEntryFrame(pc)) { 27754514f5e3Sopenharmony_ci state->acc = acc; 27764514f5e3Sopenharmony_ci return; 27774514f5e3Sopenharmony_ci } 27784514f5e3Sopenharmony_ci 27794514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 27804514f5e3Sopenharmony_ci 27814514f5e3Sopenharmony_ci size_t jumpSize = GetJumpSizeAfterCall(pc); 27824514f5e3Sopenharmony_ci DISPATCH_OFFSET(jumpSize); 27834514f5e3Sopenharmony_ci} 27844514f5e3Sopenharmony_ci 27854514f5e3Sopenharmony_civoid InterpreterAssembly::HandleAsyncgeneratorrejectV8( 27864514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 27874514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 27884514f5e3Sopenharmony_ci{ 27894514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 27904514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncgeneratorreject" 27914514f5e3Sopenharmony_ci << " v" << v0; 27924514f5e3Sopenharmony_ci JSTaggedValue asyncGenerator = GET_VREG_VALUE(v0); 27934514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 27944514f5e3Sopenharmony_ci SAVE_PC(); 27954514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncGeneratorReject(thread, asyncGenerator, value); 27964514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 27974514f5e3Sopenharmony_ci SET_ACC(res); 27984514f5e3Sopenharmony_ci DISPATCH(ASYNCGENERATORREJECT_V8); 27994514f5e3Sopenharmony_ci} 28004514f5e3Sopenharmony_ci 28014514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSetgeneratorstateImm8( 28024514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28034514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28044514f5e3Sopenharmony_ci{ 28054514f5e3Sopenharmony_ci uint32_t index = READ_INST_8_0(); 28064514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::setgeneratorstate index" << index; 28074514f5e3Sopenharmony_ci JSTaggedValue objVal = GET_ACC(); 28084514f5e3Sopenharmony_ci 28094514f5e3Sopenharmony_ci SAVE_PC(); 28104514f5e3Sopenharmony_ci SAVE_ACC(); 28114514f5e3Sopenharmony_ci SlowRuntimeStub::SetGeneratorState(thread, objVal, index); 28124514f5e3Sopenharmony_ci RESTORE_ACC(); 28134514f5e3Sopenharmony_ci DISPATCH(SETGENERATORSTATE_IMM8); 28144514f5e3Sopenharmony_ci} 28154514f5e3Sopenharmony_ci 28164514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedAsyncgeneratorrejectPrefV8V8( 28174514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28184514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28194514f5e3Sopenharmony_ci{ 28204514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 28214514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 28224514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncgeneratorreject" 28234514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 28244514f5e3Sopenharmony_ci JSTaggedValue asyncGenerator = GET_VREG_VALUE(v0); 28254514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v1); 28264514f5e3Sopenharmony_ci SAVE_PC(); 28274514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncGeneratorReject(thread, asyncGenerator, value); 28284514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 28294514f5e3Sopenharmony_ci SET_ACC(res); 28304514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_ASYNCGENERATORREJECT_PREF_V8_V8); 28314514f5e3Sopenharmony_ci} 28324514f5e3Sopenharmony_ci 28334514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStarrayspreadV8V8( 28344514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28354514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28364514f5e3Sopenharmony_ci{ 28374514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 28384514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_1(); 28394514f5e3Sopenharmony_ci LOG_INST() << "ecmascript::intrinsics::starrayspread" 28404514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1 << "acc"; 28414514f5e3Sopenharmony_ci JSTaggedValue dst = GET_VREG_VALUE(v0); 28424514f5e3Sopenharmony_ci JSTaggedValue index = GET_VREG_VALUE(v1); 28434514f5e3Sopenharmony_ci JSTaggedValue src = GET_ACC(); 28444514f5e3Sopenharmony_ci SAVE_PC(); 28454514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StArraySpread(thread, dst, index, src); 28464514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 28474514f5e3Sopenharmony_ci SET_ACC(res); 28484514f5e3Sopenharmony_ci DISPATCH(STARRAYSPREAD_V8_V8); 28494514f5e3Sopenharmony_ci} 28504514f5e3Sopenharmony_ci 28514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdfunction( 28524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28544514f5e3Sopenharmony_ci{ 28554514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::ldfunction"; 28564514f5e3Sopenharmony_ci SET_ACC(GetFunction(sp)); 28574514f5e3Sopenharmony_ci DISPATCH(LDFUNCTION); 28584514f5e3Sopenharmony_ci} 28594514f5e3Sopenharmony_ci 28604514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdbigintId16( 28614514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28624514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28634514f5e3Sopenharmony_ci{ 28644514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_0(); 28654514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::ldbigint"; 28664514f5e3Sopenharmony_ci SAVE_ACC(); 28674514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 28684514f5e3Sopenharmony_ci JSTaggedValue numberBigInt = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 28694514f5e3Sopenharmony_ci SAVE_PC(); 28704514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdBigInt(thread, numberBigInt); 28714514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 28724514f5e3Sopenharmony_ci SET_ACC(res); 28734514f5e3Sopenharmony_ci DISPATCH(LDBIGINT_ID16); 28744514f5e3Sopenharmony_ci} 28754514f5e3Sopenharmony_ci 28764514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTonumericImm8( 28774514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28784514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28794514f5e3Sopenharmony_ci{ 28804514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::tonumeric"; 28814514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 28824514f5e3Sopenharmony_ci if (value.IsNumber() || value.IsBigInt()) { 28834514f5e3Sopenharmony_ci // fast path 28844514f5e3Sopenharmony_ci SET_ACC(value); 28854514f5e3Sopenharmony_ci } else { 28864514f5e3Sopenharmony_ci // slow path 28874514f5e3Sopenharmony_ci SAVE_PC(); 28884514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::ToNumeric(thread, value); 28894514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 28904514f5e3Sopenharmony_ci SET_ACC(res); 28914514f5e3Sopenharmony_ci } 28924514f5e3Sopenharmony_ci DISPATCH(TONUMERIC_IMM8); 28934514f5e3Sopenharmony_ci} 28944514f5e3Sopenharmony_ci 28954514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSupercallspreadImm8V8( 28964514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 28974514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 28984514f5e3Sopenharmony_ci{ 28994514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 29004514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::supercallspread" 29014514f5e3Sopenharmony_ci << " array: v" << v0; 29024514f5e3Sopenharmony_ci 29034514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GET_ACC(); 29044514f5e3Sopenharmony_ci JSTaggedValue newTarget = GetNewTarget(sp); 29054514f5e3Sopenharmony_ci JSTaggedValue array = GET_VREG_VALUE(v0); 29064514f5e3Sopenharmony_ci 29074514f5e3Sopenharmony_ci SAVE_PC(); 29084514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuperCallSpread(thread, thisFunc, newTarget, array); 29094514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 29104514f5e3Sopenharmony_ci SET_ACC(res); 29114514f5e3Sopenharmony_ci DISPATCH(SUPERCALLSPREAD_IMM8_V8); 29124514f5e3Sopenharmony_ci} 29134514f5e3Sopenharmony_ci 29144514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowIfsupernotcorrectcallPrefImm16( 29154514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29164514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29174514f5e3Sopenharmony_ci{ 29184514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_1(); 29194514f5e3Sopenharmony_ci JSTaggedValue thisValue = GET_ACC(); 29204514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::throwifsupernotcorrectcall" 29214514f5e3Sopenharmony_ci << " imm:" << imm; 29224514f5e3Sopenharmony_ci SAVE_PC(); 29234514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::ThrowIfSuperNotCorrectCall(thread, imm, thisValue); 29244514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 29254514f5e3Sopenharmony_ci DISPATCH(THROW_IFSUPERNOTCORRECTCALL_PREF_IMM16); 29264514f5e3Sopenharmony_ci} 29274514f5e3Sopenharmony_ci 29284514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowDeletesuperpropertyPrefNone( 29294514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29304514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29314514f5e3Sopenharmony_ci{ 29324514f5e3Sopenharmony_ci LOG_INST() << "throwdeletesuperproperty"; 29334514f5e3Sopenharmony_ci 29344514f5e3Sopenharmony_ci SAVE_PC(); 29354514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowDeleteSuperProperty(thread); 29364514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 29374514f5e3Sopenharmony_ci} 29384514f5e3Sopenharmony_ci 29394514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDebugger( 29404514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29414514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29424514f5e3Sopenharmony_ci{ 29434514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::debugger"; 29444514f5e3Sopenharmony_ci DISPATCH(DEBUGGER); 29454514f5e3Sopenharmony_ci} 29464514f5e3Sopenharmony_ci 29474514f5e3Sopenharmony_civoid InterpreterAssembly::HandleIstrue( 29484514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29494514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29504514f5e3Sopenharmony_ci{ 29514514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::istrue"; 29524514f5e3Sopenharmony_ci if (GET_ACC().ToBoolean()) { 29534514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::True()); 29544514f5e3Sopenharmony_ci } else { 29554514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::False()); 29564514f5e3Sopenharmony_ci } 29574514f5e3Sopenharmony_ci DISPATCH(ISTRUE); 29584514f5e3Sopenharmony_ci} 29594514f5e3Sopenharmony_ci 29604514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeIstruePrefImm8( 29614514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29624514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29634514f5e3Sopenharmony_ci{ 29644514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::callruntimeistrueprefimm8"; 29654514f5e3Sopenharmony_ci if (GET_ACC().ToBoolean()) { 29664514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::True()); 29674514f5e3Sopenharmony_ci } else { 29684514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::False()); 29694514f5e3Sopenharmony_ci } 29704514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_ISTRUE_PREF_IMM8); 29714514f5e3Sopenharmony_ci} 29724514f5e3Sopenharmony_ci 29734514f5e3Sopenharmony_civoid InterpreterAssembly::HandleIsfalse( 29744514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29754514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29764514f5e3Sopenharmony_ci{ 29774514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::isfalse"; 29784514f5e3Sopenharmony_ci if (GET_ACC().ToBoolean()) { 29794514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::False()); 29804514f5e3Sopenharmony_ci } else { 29814514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::True()); 29824514f5e3Sopenharmony_ci } 29834514f5e3Sopenharmony_ci DISPATCH(ISFALSE); 29844514f5e3Sopenharmony_ci} 29854514f5e3Sopenharmony_ci 29864514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeIsfalsePrefImm8( 29874514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 29884514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 29894514f5e3Sopenharmony_ci{ 29904514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::callruntimeisfalseprefimm8"; 29914514f5e3Sopenharmony_ci if (GET_ACC().ToBoolean()) { 29924514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::False()); 29934514f5e3Sopenharmony_ci } else { 29944514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue::True()); 29954514f5e3Sopenharmony_ci } 29964514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_ISFALSE_PREF_IMM8); 29974514f5e3Sopenharmony_ci} 29984514f5e3Sopenharmony_ci 29994514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTypeofImm16( 30004514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30014514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30024514f5e3Sopenharmony_ci{ 30034514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::typeof"; 30044514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::FastTypeOf(thread, GET_ACC()); 30054514f5e3Sopenharmony_ci SET_ACC(res); 30064514f5e3Sopenharmony_ci DISPATCH(TYPEOF_IMM16); 30074514f5e3Sopenharmony_ci} 30084514f5e3Sopenharmony_ci 30094514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateemptyarrayImm16( 30104514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30114514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30124514f5e3Sopenharmony_ci{ 30134514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createemptyarray"; 30144514f5e3Sopenharmony_ci SAVE_PC(); 30154514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 30164514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 30174514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 30184514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateEmptyArray(thread, factory, globalEnv); 30194514f5e3Sopenharmony_ci SET_ACC(res); 30204514f5e3Sopenharmony_ci DISPATCH(CREATEEMPTYARRAY_IMM16); 30214514f5e3Sopenharmony_ci} 30224514f5e3Sopenharmony_ci 30234514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetiteratorImm16( 30244514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30254514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30264514f5e3Sopenharmony_ci{ 30274514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getiterator"; 30284514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 30294514f5e3Sopenharmony_ci // slow path 30304514f5e3Sopenharmony_ci SAVE_PC(); 30314514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetIterator(thread, obj); 30324514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 30334514f5e3Sopenharmony_ci SET_ACC(res); 30344514f5e3Sopenharmony_ci DISPATCH(GETITERATOR_IMM16); 30354514f5e3Sopenharmony_ci} 30364514f5e3Sopenharmony_ci 30374514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGettemplateobjectImm16( 30384514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30394514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30404514f5e3Sopenharmony_ci{ 30414514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::gettemplateobject"; 30424514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 30434514f5e3Sopenharmony_ci // slow path 30444514f5e3Sopenharmony_ci SAVE_PC(); 30454514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetTemplateObject(thread, obj); 30464514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 30474514f5e3Sopenharmony_ci SET_ACC(res); 30484514f5e3Sopenharmony_ci DISPATCH(GETTEMPLATEOBJECT_IMM16); 30494514f5e3Sopenharmony_ci} 30504514f5e3Sopenharmony_ci 30514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCloseiteratorImm16V8( 30524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30544514f5e3Sopenharmony_ci{ 30554514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_2(); 30564514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::closeiterator" 30574514f5e3Sopenharmony_ci << " v" << v0; 30584514f5e3Sopenharmony_ci SAVE_PC(); 30594514f5e3Sopenharmony_ci JSTaggedValue iter = GET_VREG_VALUE(v0); 30604514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CloseIterator(thread, iter); 30614514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 30624514f5e3Sopenharmony_ci SET_ACC(res); 30634514f5e3Sopenharmony_ci DISPATCH(CLOSEITERATOR_IMM16_V8); 30644514f5e3Sopenharmony_ci} 30654514f5e3Sopenharmony_ci 30664514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSetobjectwithprotoImm16V8( 30674514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30684514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30694514f5e3Sopenharmony_ci{ 30704514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_2(); 30714514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::setobjectwithproto" 30724514f5e3Sopenharmony_ci << " v" << v0; 30734514f5e3Sopenharmony_ci JSTaggedValue proto = GET_VREG_VALUE(v0); 30744514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 30754514f5e3Sopenharmony_ci SAVE_ACC(); 30764514f5e3Sopenharmony_ci SAVE_PC(); 30774514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SetObjectWithProto(thread, proto, obj); 30784514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 30794514f5e3Sopenharmony_ci RESTORE_ACC(); 30804514f5e3Sopenharmony_ci DISPATCH(SETOBJECTWITHPROTO_IMM16_V8); 30814514f5e3Sopenharmony_ci} 30824514f5e3Sopenharmony_ci 30834514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStobjbyvalueImm16V8V8( 30844514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 30854514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 30864514f5e3Sopenharmony_ci{ 30874514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 30884514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_3(); 30894514f5e3Sopenharmony_ci 30904514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyvalue" 30914514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 30924514f5e3Sopenharmony_ci 30934514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 30944514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 30954514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 30964514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 30974514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 30984514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 30994514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 31004514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 31014514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 31024514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 31034514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 31044514f5e3Sopenharmony_ci SAVE_ACC(); 31054514f5e3Sopenharmony_ci 31064514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 31074514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 31084514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByValue(thread, receiver, propKey, firstValue, secondValue, value); 31094514f5e3Sopenharmony_ci } 31104514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 31114514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 31124514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByValue(thread, 31134514f5e3Sopenharmony_ci profileTypeArray, 31144514f5e3Sopenharmony_ci receiver, propKey, value, slotId); 31154514f5e3Sopenharmony_ci } 31164514f5e3Sopenharmony_ci 31174514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 31184514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 31194514f5e3Sopenharmony_ci RESTORE_ACC(); 31204514f5e3Sopenharmony_ci DISPATCH(STOBJBYVALUE_IMM16_V8_V8); 31214514f5e3Sopenharmony_ci } 31224514f5e3Sopenharmony_ci } 31234514f5e3Sopenharmony_ci#endif 31244514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 31254514f5e3Sopenharmony_ci SAVE_ACC(); 31264514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 31274514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 31284514f5e3Sopenharmony_ci // fast path 31294514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue(thread, receiver, propKey, value); 31304514f5e3Sopenharmony_ci if (!res.IsHole()) { 31314514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 31324514f5e3Sopenharmony_ci RESTORE_ACC(); 31334514f5e3Sopenharmony_ci DISPATCH(STOBJBYVALUE_IMM16_V8_V8); 31344514f5e3Sopenharmony_ci } 31354514f5e3Sopenharmony_ci RESTORE_ACC(); 31364514f5e3Sopenharmony_ci } 31374514f5e3Sopenharmony_ci { 31384514f5e3Sopenharmony_ci // slow path 31394514f5e3Sopenharmony_ci SAVE_ACC(); 31404514f5e3Sopenharmony_ci SAVE_PC(); 31414514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 31424514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); // Maybe moved by GC 31434514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 31444514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByValue(thread, receiver, propKey, value); 31454514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 31464514f5e3Sopenharmony_ci RESTORE_ACC(); 31474514f5e3Sopenharmony_ci } 31484514f5e3Sopenharmony_ci DISPATCH(STOBJBYVALUE_IMM16_V8_V8); 31494514f5e3Sopenharmony_ci} 31504514f5e3Sopenharmony_ci 31514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbyvalueImm16V8V8( 31524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 31534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 31544514f5e3Sopenharmony_ci{ 31554514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 31564514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_3(); 31574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyvalue" 31584514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 31594514f5e3Sopenharmony_ci 31604514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 31614514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 31624514f5e3Sopenharmony_ci SAVE_ACC(); 31634514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 31644514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 31654514f5e3Sopenharmony_ci // fast path 31664514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue<ObjectFastOperator::Status::UseOwn> 31674514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 31684514f5e3Sopenharmony_ci 31694514f5e3Sopenharmony_ci // SetPropertyByValue maybe gc need update the value 31704514f5e3Sopenharmony_ci RESTORE_ACC(); 31714514f5e3Sopenharmony_ci propKey = GET_VREG_VALUE(v1); 31724514f5e3Sopenharmony_ci value = GET_ACC(); 31734514f5e3Sopenharmony_ci if (!res.IsHole()) { 31744514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 31754514f5e3Sopenharmony_ci RESTORE_ACC(); 31764514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUE_IMM16_V8_V8); 31774514f5e3Sopenharmony_ci } 31784514f5e3Sopenharmony_ci } 31794514f5e3Sopenharmony_ci 31804514f5e3Sopenharmony_ci // slow path 31814514f5e3Sopenharmony_ci SAVE_ACC(); 31824514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 31834514f5e3Sopenharmony_ci auto propKey = GET_VREG_VALUE(v1); // Maybe moved by GC 31844514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 31854514f5e3Sopenharmony_ci SAVE_PC(); 31864514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByValue(thread, receiver, propKey, value); 31874514f5e3Sopenharmony_ci RESTORE_ACC(); 31884514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 31894514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUE_IMM16_V8_V8); 31904514f5e3Sopenharmony_ci} 31914514f5e3Sopenharmony_ci 31924514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStobjbyindexImm16V8Imm16( 31934514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 31944514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 31954514f5e3Sopenharmony_ci{ 31964514f5e3Sopenharmony_ci uint8_t v0 = READ_INST_8_2(); 31974514f5e3Sopenharmony_ci uint16_t index = READ_INST_16_3(); 31984514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyindex" 31994514f5e3Sopenharmony_ci << " v" << v0 << " imm" << index; 32004514f5e3Sopenharmony_ci 32014514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 32024514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 32034514f5e3Sopenharmony_ci SAVE_ACC(); 32044514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 32054514f5e3Sopenharmony_ci // fast path 32064514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByIndex(thread, receiver, index, value); 32074514f5e3Sopenharmony_ci if (!res.IsHole()) { 32084514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 32094514f5e3Sopenharmony_ci RESTORE_ACC(); 32104514f5e3Sopenharmony_ci DISPATCH(STOBJBYINDEX_IMM16_V8_IMM16); 32114514f5e3Sopenharmony_ci } 32124514f5e3Sopenharmony_ci RESTORE_ACC(); 32134514f5e3Sopenharmony_ci } 32144514f5e3Sopenharmony_ci // slow path 32154514f5e3Sopenharmony_ci SAVE_ACC(); 32164514f5e3Sopenharmony_ci SAVE_PC(); 32174514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 32184514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 32194514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByIndex(thread, receiver, index, value); 32204514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 32214514f5e3Sopenharmony_ci RESTORE_ACC(); 32224514f5e3Sopenharmony_ci DISPATCH(STOBJBYINDEX_IMM16_V8_IMM16); 32234514f5e3Sopenharmony_ci} 32244514f5e3Sopenharmony_ci 32254514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbyindexImm16V8Imm16( 32264514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 32274514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 32284514f5e3Sopenharmony_ci{ 32294514f5e3Sopenharmony_ci uint8_t v0 = READ_INST_8_2(); 32304514f5e3Sopenharmony_ci uint16_t index = READ_INST_16_3(); 32314514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyindex" 32324514f5e3Sopenharmony_ci << " v" << v0 << " imm" << index; 32334514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 32344514f5e3Sopenharmony_ci // fast path 32354514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 32364514f5e3Sopenharmony_ci SAVE_ACC(); 32374514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 32384514f5e3Sopenharmony_ci // fast path 32394514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByIndex<ObjectFastOperator::Status::UseOwn> 32404514f5e3Sopenharmony_ci (thread, receiver, index, value); 32414514f5e3Sopenharmony_ci if (!res.IsHole()) { 32424514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 32434514f5e3Sopenharmony_ci RESTORE_ACC(); 32444514f5e3Sopenharmony_ci DISPATCH(STOWNBYINDEX_IMM16_V8_IMM16); 32454514f5e3Sopenharmony_ci } 32464514f5e3Sopenharmony_ci RESTORE_ACC(); 32474514f5e3Sopenharmony_ci } 32484514f5e3Sopenharmony_ci SAVE_ACC(); 32494514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 32504514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 32514514f5e3Sopenharmony_ci SAVE_PC(); 32524514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByIndex(thread, receiver, index, value); 32534514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 32544514f5e3Sopenharmony_ci RESTORE_ACC(); 32554514f5e3Sopenharmony_ci DISPATCH(STOWNBYINDEX_IMM16_V8_IMM16); 32564514f5e3Sopenharmony_ci} 32574514f5e3Sopenharmony_ci 32584514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowIfsupernotcorrectcallPrefImm8( 32594514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 32604514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 32614514f5e3Sopenharmony_ci{ 32624514f5e3Sopenharmony_ci uint8_t imm = READ_INST_8_1(); 32634514f5e3Sopenharmony_ci JSTaggedValue thisValue = GET_ACC(); 32644514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::throwifsupernotcorrectcall" 32654514f5e3Sopenharmony_ci << " imm:" << imm; 32664514f5e3Sopenharmony_ci SAVE_PC(); 32674514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::ThrowIfSuperNotCorrectCall(thread, imm, thisValue); 32684514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 32694514f5e3Sopenharmony_ci DISPATCH(THROW_IFSUPERNOTCORRECTCALL_PREF_IMM8); 32704514f5e3Sopenharmony_ci} 32714514f5e3Sopenharmony_ci 32724514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowNotexistsPrefNone( 32734514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 32744514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 32754514f5e3Sopenharmony_ci{ 32764514f5e3Sopenharmony_ci LOG_INST() << "throwthrownotexists"; 32774514f5e3Sopenharmony_ci 32784514f5e3Sopenharmony_ci SAVE_PC(); 32794514f5e3Sopenharmony_ci SlowRuntimeStub::ThrowThrowNotExists(thread); 32804514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 32814514f5e3Sopenharmony_ci} 32824514f5e3Sopenharmony_ci 32834514f5e3Sopenharmony_civoid InterpreterAssembly::HandleThrowPrefNone( 32844514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 32854514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 32864514f5e3Sopenharmony_ci{ 32874514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::throw"; 32884514f5e3Sopenharmony_ci SAVE_PC(); 32894514f5e3Sopenharmony_ci SlowRuntimeStub::Throw(thread, GET_ACC()); 32904514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 32914514f5e3Sopenharmony_ci} 32924514f5e3Sopenharmony_ci 32934514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideLdexternalmodulevarPrefImm16( 32944514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 32954514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 32964514f5e3Sopenharmony_ci{ 32974514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 32984514f5e3Sopenharmony_ci 32994514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldmodulevar index:" << index; 33004514f5e3Sopenharmony_ci 33014514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdExternalModuleVar(thread, index); 33024514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 33034514f5e3Sopenharmony_ci SET_ACC(moduleVar); 33044514f5e3Sopenharmony_ci DISPATCH(WIDE_LDEXTERNALMODULEVAR_PREF_IMM16); 33054514f5e3Sopenharmony_ci} 33064514f5e3Sopenharmony_ci 33074514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeWideLdsendableexternalmodulevarPrefImm16( 33084514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 33094514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 33104514f5e3Sopenharmony_ci{ 33114514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 33124514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 33134514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsendableexternalmodulevar index:" << index; 33144514f5e3Sopenharmony_ci 33154514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdSendableExternalModuleVar(thread, index, thisFunc); 33164514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 33174514f5e3Sopenharmony_ci SET_ACC(moduleVar); 33184514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_WIDELDSENDABLEEXTERNALMODULEVAR_PREF_IMM16); 33194514f5e3Sopenharmony_ci} 33204514f5e3Sopenharmony_ci 33214514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideLdlocalmodulevarPrefImm16( 33224514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 33234514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 33244514f5e3Sopenharmony_ci{ 33254514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 33264514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldmodulevar index:" << index; 33274514f5e3Sopenharmony_ci 33284514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdLocalModuleVar(thread, index); 33294514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 33304514f5e3Sopenharmony_ci SET_ACC(moduleVar); 33314514f5e3Sopenharmony_ci DISPATCH(WIDE_LDLOCALMODULEVAR_PREF_IMM16); 33324514f5e3Sopenharmony_ci} 33334514f5e3Sopenharmony_ci 33344514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideStmodulevarPrefImm16( 33354514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 33364514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 33374514f5e3Sopenharmony_ci{ 33384514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 33394514f5e3Sopenharmony_ci 33404514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stmodulevar index:" << index; 33414514f5e3Sopenharmony_ci 33424514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 33434514f5e3Sopenharmony_ci 33444514f5e3Sopenharmony_ci SlowRuntimeStub::StModuleVar(thread, index, value); 33454514f5e3Sopenharmony_ci RESTORE_ACC(); 33464514f5e3Sopenharmony_ci DISPATCH(WIDE_STMODULEVAR_PREF_IMM16); 33474514f5e3Sopenharmony_ci} 33484514f5e3Sopenharmony_ci 33494514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideGetmodulenamespacePrefImm16( 33504514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 33514514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 33524514f5e3Sopenharmony_ci{ 33534514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 33544514f5e3Sopenharmony_ci 33554514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getmodulenamespace index:" << index; 33564514f5e3Sopenharmony_ci 33574514f5e3Sopenharmony_ci JSTaggedValue moduleNamespace = SlowRuntimeStub::GetModuleNamespace(thread, index); 33584514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleNamespace); 33594514f5e3Sopenharmony_ci SET_ACC(moduleNamespace); 33604514f5e3Sopenharmony_ci DISPATCH(WIDE_GETMODULENAMESPACE_PREF_IMM16); 33614514f5e3Sopenharmony_ci} 33624514f5e3Sopenharmony_ci 33634514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideLdlexvarPrefImm16Imm16( 33644514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 33654514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 33664514f5e3Sopenharmony_ci{ 33674514f5e3Sopenharmony_ci uint16_t level = READ_INST_16_1(); 33684514f5e3Sopenharmony_ci uint16_t slot = READ_INST_16_3(); 33694514f5e3Sopenharmony_ci 33704514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlexvar" 33714514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 33724514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 33734514f5e3Sopenharmony_ci JSTaggedValue currentLexenv = state->env; 33744514f5e3Sopenharmony_ci JSTaggedValue env(currentLexenv); 33754514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 33764514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 33774514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 33784514f5e3Sopenharmony_ci env = taggedParentEnv; 33794514f5e3Sopenharmony_ci } 33804514f5e3Sopenharmony_ci SET_ACC(LexicalEnv::Cast(env.GetTaggedObject())->GetProperties(slot)); 33814514f5e3Sopenharmony_ci DISPATCH(WIDE_LDLEXVAR_PREF_IMM16_IMM16); 33824514f5e3Sopenharmony_ci} 33834514f5e3Sopenharmony_ci 33844514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideCopyrestargsPrefImm16( 33854514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 33864514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 33874514f5e3Sopenharmony_ci{ 33884514f5e3Sopenharmony_ci uint16_t restIdx = READ_INST_16_1(); 33894514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::copyrestargs" 33904514f5e3Sopenharmony_ci << " index: " << restIdx; 33914514f5e3Sopenharmony_ci 33924514f5e3Sopenharmony_ci uint32_t startIdx = 0; 33934514f5e3Sopenharmony_ci uint32_t restNumArgs = GetNumArgs(sp, restIdx, startIdx); 33944514f5e3Sopenharmony_ci 33954514f5e3Sopenharmony_ci SAVE_PC(); 33964514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CopyRestArgs(thread, sp, restNumArgs, startIdx); 33974514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 33984514f5e3Sopenharmony_ci SET_ACC(res); 33994514f5e3Sopenharmony_ci DISPATCH(WIDE_COPYRESTARGS_PREF_IMM16); 34004514f5e3Sopenharmony_ci} 34014514f5e3Sopenharmony_ci 34024514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideStownbyindexPrefV8Imm32( 34034514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 34044514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 34054514f5e3Sopenharmony_ci{ 34064514f5e3Sopenharmony_ci uint8_t v0 = READ_INST_8_1(); 34074514f5e3Sopenharmony_ci uint32_t index = READ_INST_32_2(); 34084514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyindex" 34094514f5e3Sopenharmony_ci << " v" << v0 << " imm" << index; 34104514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 34114514f5e3Sopenharmony_ci // fast path 34124514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 34134514f5e3Sopenharmony_ci SAVE_ACC(); 34144514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 34154514f5e3Sopenharmony_ci // fast path 34164514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByIndex<ObjectFastOperator::Status::UseOwn> 34174514f5e3Sopenharmony_ci (thread, receiver, index, value); 34184514f5e3Sopenharmony_ci if (!res.IsHole()) { 34194514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 34204514f5e3Sopenharmony_ci RESTORE_ACC(); 34214514f5e3Sopenharmony_ci DISPATCH(WIDE_STOWNBYINDEX_PREF_V8_IMM32); 34224514f5e3Sopenharmony_ci } 34234514f5e3Sopenharmony_ci RESTORE_ACC(); 34244514f5e3Sopenharmony_ci } 34254514f5e3Sopenharmony_ci SAVE_ACC(); 34264514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 34274514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 34284514f5e3Sopenharmony_ci SAVE_PC(); 34294514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByIndex(thread, receiver, index, value); 34304514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 34314514f5e3Sopenharmony_ci RESTORE_ACC(); 34324514f5e3Sopenharmony_ci DISPATCH(WIDE_STOWNBYINDEX_PREF_V8_IMM32); 34334514f5e3Sopenharmony_ci} 34344514f5e3Sopenharmony_ci 34354514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideStobjbyindexPrefV8Imm32( 34364514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 34374514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 34384514f5e3Sopenharmony_ci{ 34394514f5e3Sopenharmony_ci uint8_t v0 = READ_INST_8_1(); 34404514f5e3Sopenharmony_ci uint32_t index = READ_INST_32_2(); 34414514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyindex" 34424514f5e3Sopenharmony_ci << " v" << v0 << " imm" << index; 34434514f5e3Sopenharmony_ci 34444514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 34454514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 34464514f5e3Sopenharmony_ci SAVE_ACC(); 34474514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 34484514f5e3Sopenharmony_ci // fast path 34494514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByIndex(thread, receiver, index, value); 34504514f5e3Sopenharmony_ci if (!res.IsHole()) { 34514514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 34524514f5e3Sopenharmony_ci RESTORE_ACC(); 34534514f5e3Sopenharmony_ci DISPATCH(WIDE_STOBJBYINDEX_PREF_V8_IMM32); 34544514f5e3Sopenharmony_ci } 34554514f5e3Sopenharmony_ci RESTORE_ACC(); 34564514f5e3Sopenharmony_ci } 34574514f5e3Sopenharmony_ci // slow path 34584514f5e3Sopenharmony_ci SAVE_ACC(); 34594514f5e3Sopenharmony_ci SAVE_PC(); 34604514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 34614514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 34624514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByIndex(thread, receiver, index, value); 34634514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 34644514f5e3Sopenharmony_ci RESTORE_ACC(); 34654514f5e3Sopenharmony_ci DISPATCH(WIDE_STOBJBYINDEX_PREF_V8_IMM32); 34664514f5e3Sopenharmony_ci} 34674514f5e3Sopenharmony_ci 34684514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideLdobjbyindexPrefImm32( 34694514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 34704514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 34714514f5e3Sopenharmony_ci{ 34724514f5e3Sopenharmony_ci uint32_t idx = READ_INST_32_1(); 34734514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyindex" 34744514f5e3Sopenharmony_ci << " imm" << idx; 34754514f5e3Sopenharmony_ci 34764514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 34774514f5e3Sopenharmony_ci // fast path 34784514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 34794514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByIndex(thread, receiver, idx); 34804514f5e3Sopenharmony_ci if (!res.IsHole()) { 34814514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 34824514f5e3Sopenharmony_ci SET_ACC(res); 34834514f5e3Sopenharmony_ci DISPATCH(WIDE_LDOBJBYINDEX_PREF_IMM32); 34844514f5e3Sopenharmony_ci } 34854514f5e3Sopenharmony_ci } 34864514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 34874514f5e3Sopenharmony_ci // slow stub not need receiver 34884514f5e3Sopenharmony_ci SAVE_PC(); 34894514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByIndex(thread, receiver, idx, false, JSTaggedValue::Undefined()); 34904514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 34914514f5e3Sopenharmony_ci SET_ACC(res); 34924514f5e3Sopenharmony_ci DISPATCH(WIDE_LDOBJBYINDEX_PREF_IMM32); 34934514f5e3Sopenharmony_ci} 34944514f5e3Sopenharmony_ci 34954514f5e3Sopenharmony_cibool InterpreterAssembly::AssemblyIsFastNewFrameEnter(JSFunction *ctor, JSHandle<Method> method) 34964514f5e3Sopenharmony_ci{ 34974514f5e3Sopenharmony_ci if (method->IsNativeWithCallField()) { 34984514f5e3Sopenharmony_ci return false; 34994514f5e3Sopenharmony_ci } 35004514f5e3Sopenharmony_ci 35014514f5e3Sopenharmony_ci if (ctor->IsBase()) { 35024514f5e3Sopenharmony_ci return method->OnlyHaveThisWithCallField(); 35034514f5e3Sopenharmony_ci } 35044514f5e3Sopenharmony_ci 35054514f5e3Sopenharmony_ci if (ctor->IsDerivedConstructor()) { 35064514f5e3Sopenharmony_ci return method->OnlyHaveNewTagetAndThisWithCallField(); 35074514f5e3Sopenharmony_ci } 35084514f5e3Sopenharmony_ci 35094514f5e3Sopenharmony_ci return false; 35104514f5e3Sopenharmony_ci} 35114514f5e3Sopenharmony_ci 35124514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideSupercallarrowrangePrefImm16V8( 35134514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 35144514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 35154514f5e3Sopenharmony_ci{ 35164514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 35174514f5e3Sopenharmony_ci uint16_t range = READ_INST_16_1(); 35184514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_3(); 35194514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::supercall" 35204514f5e3Sopenharmony_ci << " range: " << range << " v" << v0; 35214514f5e3Sopenharmony_ci 35224514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GET_ACC(); 35234514f5e3Sopenharmony_ci JSTaggedValue newTarget = GetNewTarget(sp); 35244514f5e3Sopenharmony_ci 35254514f5e3Sopenharmony_ci SAVE_PC(); 35264514f5e3Sopenharmony_ci JSTaggedValue superCtor = SlowRuntimeStub::GetSuperConstructor(thread, thisFunc); 35274514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(superCtor); 35284514f5e3Sopenharmony_ci 35294514f5e3Sopenharmony_ci if (superCtor.IsJSFunction() && superCtor.IsConstructor() && !newTarget.IsUndefined()) { 35304514f5e3Sopenharmony_ci JSFunction *superCtorFunc = JSFunction::Cast(superCtor.GetTaggedObject()); 35314514f5e3Sopenharmony_ci methodHandle.Update(superCtorFunc->GetMethod()); 35324514f5e3Sopenharmony_ci if (superCtorFunc->IsBuiltinConstructor()) { 35334514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 35344514f5e3Sopenharmony_ci size_t frameSize = 35354514f5e3Sopenharmony_ci InterpretedFrame::NumOfMembers() + range + NUM_MANDATORY_JSFUNC_ARGS + 2; // 2:thread & numArgs 35364514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35374514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 35384514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 35394514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 35404514f5e3Sopenharmony_ci } 35414514f5e3Sopenharmony_ci // copy args 35424514f5e3Sopenharmony_ci uint32_t index = 0; 35434514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35444514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo *>(newSp); 35454514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 35464514f5e3Sopenharmony_ci newSp[index++] = range + NUM_MANDATORY_JSFUNC_ARGS; 35474514f5e3Sopenharmony_ci // func 35484514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35494514f5e3Sopenharmony_ci newSp[index++] = superCtor.GetRawData(); 35504514f5e3Sopenharmony_ci // newTarget 35514514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35524514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 35534514f5e3Sopenharmony_ci // this 35544514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35554514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 35564514f5e3Sopenharmony_ci for (size_t i = 0; i < range; ++i) { 35574514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35584514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 35594514f5e3Sopenharmony_ci } 35604514f5e3Sopenharmony_ci 35614514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 35624514f5e3Sopenharmony_ci state->base.prev = sp; 35634514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 35644514f5e3Sopenharmony_ci state->pc = nullptr; 35654514f5e3Sopenharmony_ci state->function = superCtor; 35664514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 35674514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall "; 35684514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 35694514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 35704514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 35714514f5e3Sopenharmony_ci 35724514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 35734514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 35744514f5e3Sopenharmony_ci } 35754514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime SuperCall "; 35764514f5e3Sopenharmony_ci SET_ACC(retValue); 35774514f5e3Sopenharmony_ci DISPATCH(WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8); 35784514f5e3Sopenharmony_ci } 35794514f5e3Sopenharmony_ci 35804514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(superCtorFunc, methodHandle)) { 35814514f5e3Sopenharmony_ci SAVE_PC(); 35824514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 35834514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = superCtorFunc->IsBase() ? 35844514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 35854514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 35864514f5e3Sopenharmony_ci // +1 for hidden this, explicit this may be overwritten after bc optimizer 35874514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs + 1; 35884514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 35894514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 35904514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(newSp) - 1; 35914514f5e3Sopenharmony_ci 35924514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 35934514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 35944514f5e3Sopenharmony_ci } 35954514f5e3Sopenharmony_ci 35964514f5e3Sopenharmony_ci uint32_t index = 0; 35974514f5e3Sopenharmony_ci // initialize vregs value 35984514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 35994514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 36004514f5e3Sopenharmony_ci } 36014514f5e3Sopenharmony_ci 36024514f5e3Sopenharmony_ci // this 36034514f5e3Sopenharmony_ci JSTaggedValue thisObj; 36044514f5e3Sopenharmony_ci if (superCtorFunc->IsBase()) { 36054514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, superCtor, newTarget, state); 36064514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 36074514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36084514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 36094514f5e3Sopenharmony_ci } else { 36104514f5e3Sopenharmony_ci ASSERT(superCtorFunc->IsDerivedConstructor()); 36114514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 36124514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 36134514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36144514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 36154514f5e3Sopenharmony_ci 36164514f5e3Sopenharmony_ci state->function = superCtor; 36174514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 36184514f5e3Sopenharmony_ci state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo(); 36194514f5e3Sopenharmony_ci state->env = superCtorFunc->GetLexicalEnv(); 36204514f5e3Sopenharmony_ci } 36214514f5e3Sopenharmony_ci 36224514f5e3Sopenharmony_ci // the second condition ensure not push extra args 36234514f5e3Sopenharmony_ci for (size_t i = 0; i < range && index < numVregs + numDeclaredArgs; ++i) { 36244514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36254514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 36264514f5e3Sopenharmony_ci } 36274514f5e3Sopenharmony_ci 36284514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 36294514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 36304514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36314514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 36324514f5e3Sopenharmony_ci } 36334514f5e3Sopenharmony_ci 36344514f5e3Sopenharmony_ci state->base.prev = sp; 36354514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 36364514f5e3Sopenharmony_ci state->thisObj = thisObj; 36374514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 36384514f5e3Sopenharmony_ci sp = newSp; 36394514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 36404514f5e3Sopenharmony_ci 36414514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 36424514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall " << std::hex << reinterpret_cast<uintptr_t>(sp) 36434514f5e3Sopenharmony_ci << " " << std::hex << reinterpret_cast<uintptr_t>(pc); 36444514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 36454514f5e3Sopenharmony_ci } 36464514f5e3Sopenharmony_ci } 36474514f5e3Sopenharmony_ci 36484514f5e3Sopenharmony_ci SAVE_PC(); 36494514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuperCall(thread, thisFunc, newTarget, v0, range); 36504514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 36514514f5e3Sopenharmony_ci SET_ACC(res); 36524514f5e3Sopenharmony_ci DISPATCH(WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8); 36534514f5e3Sopenharmony_ci} 36544514f5e3Sopenharmony_ci 36554514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideSupercallthisrangePrefImm16V8( 36564514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 36574514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 36584514f5e3Sopenharmony_ci{ 36594514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 36604514f5e3Sopenharmony_ci uint16_t range = READ_INST_16_1(); 36614514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_3(); 36624514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::supercall" 36634514f5e3Sopenharmony_ci << " range: " << range << " v" << v0; 36644514f5e3Sopenharmony_ci 36654514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 36664514f5e3Sopenharmony_ci JSTaggedValue newTarget = GetNewTarget(sp); 36674514f5e3Sopenharmony_ci 36684514f5e3Sopenharmony_ci SAVE_PC(); 36694514f5e3Sopenharmony_ci JSTaggedValue superCtor = SlowRuntimeStub::GetSuperConstructor(thread, thisFunc); 36704514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(superCtor); 36714514f5e3Sopenharmony_ci 36724514f5e3Sopenharmony_ci if (superCtor.IsJSFunction() && superCtor.IsConstructor() && !newTarget.IsUndefined()) { 36734514f5e3Sopenharmony_ci JSFunction *superCtorFunc = JSFunction::Cast(superCtor.GetTaggedObject()); 36744514f5e3Sopenharmony_ci methodHandle.Update(superCtorFunc->GetMethod()); 36754514f5e3Sopenharmony_ci if (superCtorFunc->IsBuiltinConstructor()) { 36764514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 36774514f5e3Sopenharmony_ci size_t frameSize = 36784514f5e3Sopenharmony_ci InterpretedFrame::NumOfMembers() + range + NUM_MANDATORY_JSFUNC_ARGS + 2; // 2:thread & numArgs 36794514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36804514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 36814514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 36824514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 36834514f5e3Sopenharmony_ci } 36844514f5e3Sopenharmony_ci // copy args 36854514f5e3Sopenharmony_ci uint32_t index = 0; 36864514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36874514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo *>(newSp); 36884514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 36894514f5e3Sopenharmony_ci newSp[index++] = range + NUM_MANDATORY_JSFUNC_ARGS; 36904514f5e3Sopenharmony_ci // func 36914514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36924514f5e3Sopenharmony_ci newSp[index++] = superCtor.GetRawData(); 36934514f5e3Sopenharmony_ci // newTarget 36944514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36954514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 36964514f5e3Sopenharmony_ci // this 36974514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 36984514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 36994514f5e3Sopenharmony_ci for (size_t i = 0; i < range; ++i) { 37004514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 37014514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 37024514f5e3Sopenharmony_ci } 37034514f5e3Sopenharmony_ci 37044514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 37054514f5e3Sopenharmony_ci state->base.prev = sp; 37064514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 37074514f5e3Sopenharmony_ci state->pc = nullptr; 37084514f5e3Sopenharmony_ci state->function = superCtor; 37094514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 37104514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall "; 37114514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 37124514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 37134514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 37144514f5e3Sopenharmony_ci 37154514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 37164514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 37174514f5e3Sopenharmony_ci } 37184514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime SuperCall "; 37194514f5e3Sopenharmony_ci SET_ACC(retValue); 37204514f5e3Sopenharmony_ci DISPATCH(WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8); 37214514f5e3Sopenharmony_ci } 37224514f5e3Sopenharmony_ci 37234514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(superCtorFunc, methodHandle)) { 37244514f5e3Sopenharmony_ci SAVE_PC(); 37254514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 37264514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = superCtorFunc->IsBase() ? 37274514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 37284514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 37294514f5e3Sopenharmony_ci // +1 for hidden this, explicit this may be overwritten after bc optimizer 37304514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs + 1; 37314514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 37324514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 37334514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(newSp) - 1; 37344514f5e3Sopenharmony_ci 37354514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 37364514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 37374514f5e3Sopenharmony_ci } 37384514f5e3Sopenharmony_ci 37394514f5e3Sopenharmony_ci uint32_t index = 0; 37404514f5e3Sopenharmony_ci // initialize vregs value 37414514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 37424514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 37434514f5e3Sopenharmony_ci } 37444514f5e3Sopenharmony_ci 37454514f5e3Sopenharmony_ci // this 37464514f5e3Sopenharmony_ci JSTaggedValue thisObj; 37474514f5e3Sopenharmony_ci if (superCtorFunc->IsBase()) { 37484514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, superCtor, newTarget, state); 37494514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 37504514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 37514514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 37524514f5e3Sopenharmony_ci } else { 37534514f5e3Sopenharmony_ci ASSERT(superCtorFunc->IsDerivedConstructor()); 37544514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 37554514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 37564514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 37574514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 37584514f5e3Sopenharmony_ci 37594514f5e3Sopenharmony_ci state->function = superCtor; 37604514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 37614514f5e3Sopenharmony_ci state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo(); 37624514f5e3Sopenharmony_ci state->env = superCtorFunc->GetLexicalEnv(); 37634514f5e3Sopenharmony_ci } 37644514f5e3Sopenharmony_ci 37654514f5e3Sopenharmony_ci // the second condition ensure not push extra args 37664514f5e3Sopenharmony_ci for (size_t i = 0; i < range && index < numVregs + numDeclaredArgs; ++i) { 37674514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 37684514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 37694514f5e3Sopenharmony_ci } 37704514f5e3Sopenharmony_ci 37714514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 37724514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 37734514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 37744514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 37754514f5e3Sopenharmony_ci } 37764514f5e3Sopenharmony_ci 37774514f5e3Sopenharmony_ci state->base.prev = sp; 37784514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 37794514f5e3Sopenharmony_ci state->thisObj = thisObj; 37804514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 37814514f5e3Sopenharmony_ci sp = newSp; 37824514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 37834514f5e3Sopenharmony_ci 37844514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 37854514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall " << std::hex << reinterpret_cast<uintptr_t>(sp) 37864514f5e3Sopenharmony_ci << " " << std::hex << reinterpret_cast<uintptr_t>(pc); 37874514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 37884514f5e3Sopenharmony_ci } 37894514f5e3Sopenharmony_ci } 37904514f5e3Sopenharmony_ci 37914514f5e3Sopenharmony_ci SAVE_PC(); 37924514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuperCall(thread, thisFunc, newTarget, v0, range); 37934514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 37944514f5e3Sopenharmony_ci SET_ACC(res); 37954514f5e3Sopenharmony_ci DISPATCH(WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8); 37964514f5e3Sopenharmony_ci} 37974514f5e3Sopenharmony_ci 37984514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideCallthisrangePrefImm16V8( 37994514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 38004514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 38014514f5e3Sopenharmony_ci{ 38024514f5e3Sopenharmony_ci DISPATCH(WIDE_CALLTHISRANGE_PREF_IMM16_V8); 38034514f5e3Sopenharmony_ci} 38044514f5e3Sopenharmony_ci 38054514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideCallrangePrefImm16V8( 38064514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 38074514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 38084514f5e3Sopenharmony_ci{ 38094514f5e3Sopenharmony_ci DISPATCH(WIDE_CALLRANGE_PREF_IMM16_V8); 38104514f5e3Sopenharmony_ci} 38114514f5e3Sopenharmony_ci 38124514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideNewlexenvwithnamePrefImm16Id16( 38134514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 38144514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 38154514f5e3Sopenharmony_ci{ 38164514f5e3Sopenharmony_ci uint16_t numVars = READ_INST_16_1(); 38174514f5e3Sopenharmony_ci uint16_t scopeId = READ_INST_16_3(); 38184514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newlexenvwithname" 38194514f5e3Sopenharmony_ci << " numVars " << numVars << " scopeId " << scopeId; 38204514f5e3Sopenharmony_ci 38214514f5e3Sopenharmony_ci SAVE_PC(); 38224514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewLexicalEnvWithName(thread, numVars, scopeId); 38234514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 38244514f5e3Sopenharmony_ci 38254514f5e3Sopenharmony_ci SET_ACC(res); 38264514f5e3Sopenharmony_ci (reinterpret_cast<InterpretedFrame *>(sp) - 1)->env = res; 38274514f5e3Sopenharmony_ci DISPATCH(WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16); 38284514f5e3Sopenharmony_ci} 38294514f5e3Sopenharmony_ci 38304514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideNewlexenvPrefImm16( 38314514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 38324514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 38334514f5e3Sopenharmony_ci{ 38344514f5e3Sopenharmony_ci uint16_t numVars = READ_INST_16_1(); 38354514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newlexenv" 38364514f5e3Sopenharmony_ci << " imm " << numVars; 38374514f5e3Sopenharmony_ci 38384514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 38394514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 38404514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::NewLexicalEnv(thread, factory, numVars); 38414514f5e3Sopenharmony_ci if (res.IsHole()) { 38424514f5e3Sopenharmony_ci SAVE_PC(); 38434514f5e3Sopenharmony_ci res = SlowRuntimeStub::NewLexicalEnv(thread, numVars); 38444514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 38454514f5e3Sopenharmony_ci } 38464514f5e3Sopenharmony_ci SET_ACC(res); 38474514f5e3Sopenharmony_ci (reinterpret_cast<InterpretedFrame *>(sp) - 1)->env = res; 38484514f5e3Sopenharmony_ci DISPATCH(WIDE_NEWLEXENV_PREF_IMM16); 38494514f5e3Sopenharmony_ci} 38504514f5e3Sopenharmony_ci 38514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideNewobjrangePrefImm16V8( 38524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 38534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 38544514f5e3Sopenharmony_ci{ 38554514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 38564514f5e3Sopenharmony_ci uint16_t numArgs = READ_INST_16_1(); 38574514f5e3Sopenharmony_ci uint16_t firstArgRegIdx = READ_INST_8_3(); 38584514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newobjRange " << numArgs << " v" << firstArgRegIdx; 38594514f5e3Sopenharmony_ci JSTaggedValue ctor = GET_VREG_VALUE(firstArgRegIdx); 38604514f5e3Sopenharmony_ci if (ctor.IsJSFunction() && ctor.IsConstructor()) { 38614514f5e3Sopenharmony_ci JSFunction *ctorFunc = JSFunction::Cast(ctor.GetTaggedObject()); 38624514f5e3Sopenharmony_ci methodHandle.Update(ctorFunc->GetMethod()); 38634514f5e3Sopenharmony_ci if (ctorFunc->IsBuiltinConstructor()) { 38644514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 38654514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numArgs + 4; // 3: this & numArgs & thread 38664514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 38674514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 38684514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 38694514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 38704514f5e3Sopenharmony_ci } 38714514f5e3Sopenharmony_ci // copy args 38724514f5e3Sopenharmony_ci uint32_t index = 0; 38734514f5e3Sopenharmony_ci // numArgs 38744514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 38754514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo*>(newSp); 38764514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 38774514f5e3Sopenharmony_ci newSp[index++] = numArgs + 2; // 2 : for newtarget / this 38784514f5e3Sopenharmony_ci // func 38794514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 38804514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 38814514f5e3Sopenharmony_ci // newTarget 38824514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 38834514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 38844514f5e3Sopenharmony_ci // this 38854514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 38864514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 38874514f5e3Sopenharmony_ci for (size_t i = 1; i < numArgs; ++i) { 38884514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 38894514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(firstArgRegIdx + i); 38904514f5e3Sopenharmony_ci } 38914514f5e3Sopenharmony_ci 38924514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 38934514f5e3Sopenharmony_ci state->base.prev = sp; 38944514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 38954514f5e3Sopenharmony_ci state->pc = nullptr; 38964514f5e3Sopenharmony_ci state->function = ctor; 38974514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 38984514f5e3Sopenharmony_ci 38994514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime New."; 39004514f5e3Sopenharmony_ci SAVE_PC(); 39014514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 39024514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 39034514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 39044514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 39054514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 39064514f5e3Sopenharmony_ci } 39074514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime New."; 39084514f5e3Sopenharmony_ci SET_ACC(retValue); 39094514f5e3Sopenharmony_ci DISPATCH(WIDE_NEWOBJRANGE_PREF_IMM16_V8); 39104514f5e3Sopenharmony_ci } 39114514f5e3Sopenharmony_ci 39124514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(ctorFunc, methodHandle)) { 39134514f5e3Sopenharmony_ci SAVE_PC(); 39144514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 39154514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = ctorFunc->IsBase() ? 39164514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 39174514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 39184514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs; 39194514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 39204514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 39214514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(newSp) - 1); 39224514f5e3Sopenharmony_ci 39234514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 39244514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 39254514f5e3Sopenharmony_ci } 39264514f5e3Sopenharmony_ci 39274514f5e3Sopenharmony_ci uint32_t index = 0; 39284514f5e3Sopenharmony_ci // initialize vregs value 39294514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 39304514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 39314514f5e3Sopenharmony_ci } 39324514f5e3Sopenharmony_ci 39334514f5e3Sopenharmony_ci // this 39344514f5e3Sopenharmony_ci JSTaggedValue thisObj; 39354514f5e3Sopenharmony_ci if (ctorFunc->IsBase()) { 39364514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, ctor, ctor, state); 39374514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 39384514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 39394514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 39404514f5e3Sopenharmony_ci } else { 39414514f5e3Sopenharmony_ci ASSERT(ctorFunc->IsDerivedConstructor()); 39424514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 39434514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 39444514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 39454514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 39464514f5e3Sopenharmony_ci 39474514f5e3Sopenharmony_ci state->function = ctor; 39484514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 39494514f5e3Sopenharmony_ci state->profileTypeInfo = ctorFunc->GetProfileTypeInfo(); 39504514f5e3Sopenharmony_ci state->env = ctorFunc->GetLexicalEnv(); 39514514f5e3Sopenharmony_ci } 39524514f5e3Sopenharmony_ci 39534514f5e3Sopenharmony_ci // the second condition ensure not push extra args 39544514f5e3Sopenharmony_ci for (size_t i = 1; i < numArgs && index < numVregs + numDeclaredArgs; ++i) { 39554514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 39564514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(firstArgRegIdx + i); 39574514f5e3Sopenharmony_ci } 39584514f5e3Sopenharmony_ci 39594514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 39604514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 39614514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 39624514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 39634514f5e3Sopenharmony_ci } 39644514f5e3Sopenharmony_ci 39654514f5e3Sopenharmony_ci state->base.prev = sp; 39664514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 39674514f5e3Sopenharmony_ci state->thisObj = thisObj; 39684514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 39694514f5e3Sopenharmony_ci sp = newSp; 39704514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 39714514f5e3Sopenharmony_ci 39724514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 39734514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime New " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 39744514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(pc); 39754514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 39764514f5e3Sopenharmony_ci } 39774514f5e3Sopenharmony_ci } 39784514f5e3Sopenharmony_ci 39794514f5e3Sopenharmony_ci // bound function, proxy, other call types, enter slow path 39804514f5e3Sopenharmony_ci constexpr uint16_t firstArgOffset = 1; 39814514f5e3Sopenharmony_ci // Exclude func and newTarget 39824514f5e3Sopenharmony_ci uint16_t firstArgIdx = firstArgRegIdx + firstArgOffset; 39834514f5e3Sopenharmony_ci uint16_t length = numArgs - firstArgOffset; 39844514f5e3Sopenharmony_ci 39854514f5e3Sopenharmony_ci SAVE_PC(); 39864514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewObjRange(thread, ctor, ctor, firstArgIdx, length); 39874514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 39884514f5e3Sopenharmony_ci SET_ACC(res); 39894514f5e3Sopenharmony_ci DISPATCH(WIDE_NEWOBJRANGE_PREF_IMM16_V8); 39904514f5e3Sopenharmony_ci} 39914514f5e3Sopenharmony_ci 39924514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideCreateobjectwithexcludedkeysPrefImm16V8V8( 39934514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 39944514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 39954514f5e3Sopenharmony_ci{ 39964514f5e3Sopenharmony_ci uint16_t numKeys = READ_INST_16_1(); 39974514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_3(); 39984514f5e3Sopenharmony_ci uint16_t firstArgRegIdx = READ_INST_8_4(); 39994514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createobjectwithexcludedkeys " << numKeys << " v" << firstArgRegIdx; 40004514f5e3Sopenharmony_ci 40014514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 40024514f5e3Sopenharmony_ci 40034514f5e3Sopenharmony_ci SAVE_PC(); 40044514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateObjectWithExcludedKeys(thread, numKeys, obj, firstArgRegIdx); 40054514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 40064514f5e3Sopenharmony_ci SET_ACC(res); 40074514f5e3Sopenharmony_ci DISPATCH(WIDE_CREATEOBJECTWITHEXCLUDEDKEYS_PREF_IMM16_V8_V8); 40084514f5e3Sopenharmony_ci} 40094514f5e3Sopenharmony_ci 40104514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCreateobjecthavingmethodPrefImm16( 40114514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 40124514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 40134514f5e3Sopenharmony_ci{ 40144514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_1(); 40154514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createobjecthavingmethod" 40164514f5e3Sopenharmony_ci << " imm:" << imm; 40174514f5e3Sopenharmony_ci SAVE_ACC(); 40184514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 40194514f5e3Sopenharmony_ci JSObject *result = 40204514f5e3Sopenharmony_ci JSObject::Cast(ConstantPool::GetMethodFromCache(thread, constpool, imm).GetTaggedObject()); 40214514f5e3Sopenharmony_ci RESTORE_ACC(); 40224514f5e3Sopenharmony_ci JSTaggedValue env = GET_ACC(); 40234514f5e3Sopenharmony_ci 40244514f5e3Sopenharmony_ci SAVE_PC(); 40254514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 40264514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 40274514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateObjectHavingMethod(thread, factory, result, env); 40284514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 40294514f5e3Sopenharmony_ci SET_ACC(res); 40304514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CREATEOBJECTHAVINGMETHOD_PREF_IMM16); 40314514f5e3Sopenharmony_ci} 40324514f5e3Sopenharmony_ci 40334514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdhomeobjectPrefNone( 40344514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 40354514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 40364514f5e3Sopenharmony_ci{ 40374514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldhomeobject"; 40384514f5e3Sopenharmony_ci 40394514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 40404514f5e3Sopenharmony_ci JSTaggedValue homeObject = JSFunction::Cast(thisFunc.GetTaggedObject())->GetHomeObject(); 40414514f5e3Sopenharmony_ci 40424514f5e3Sopenharmony_ci SET_ACC(homeObject); 40434514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDHOMEOBJECT_PREF_NONE); 40444514f5e3Sopenharmony_ci} 40454514f5e3Sopenharmony_ci 40464514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStclasstoglobalrecordPrefId32( 40474514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 40484514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 40494514f5e3Sopenharmony_ci{ 40504514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_32_1(); 40514514f5e3Sopenharmony_ci SAVE_ACC(); 40524514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 40534514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 40544514f5e3Sopenharmony_ci RESTORE_ACC(); 40554514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stclasstoglobalrecord" 40564514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 40574514f5e3Sopenharmony_ci 40584514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 40594514f5e3Sopenharmony_ci SAVE_PC(); 40604514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalRecord(thread, propKey, value, false); 40614514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 40624514f5e3Sopenharmony_ci RESTORE_ACC(); 40634514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STCLASSTOGLOBALRECORD_PREF_ID32); 40644514f5e3Sopenharmony_ci} 40654514f5e3Sopenharmony_ci 40664514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStlettoglobalrecordPrefId32( 40674514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 40684514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 40694514f5e3Sopenharmony_ci{ 40704514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_32_1(); 40714514f5e3Sopenharmony_ci SAVE_ACC(); 40724514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 40734514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 40744514f5e3Sopenharmony_ci RESTORE_ACC(); 40754514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlettoglobalrecord" 40764514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 40774514f5e3Sopenharmony_ci 40784514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 40794514f5e3Sopenharmony_ci SAVE_PC(); 40804514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalRecord(thread, propKey, value, false); 40814514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 40824514f5e3Sopenharmony_ci RESTORE_ACC(); 40834514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STLETTOGLOBALRECORD_PREF_ID32); 40844514f5e3Sopenharmony_ci} 40854514f5e3Sopenharmony_ci 40864514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStconsttoglobalrecordPrefId32( 40874514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 40884514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 40894514f5e3Sopenharmony_ci{ 40904514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_32_1(); 40914514f5e3Sopenharmony_ci SAVE_ACC(); 40924514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 40934514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 40944514f5e3Sopenharmony_ci RESTORE_ACC(); 40954514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stconsttoglobalrecord" 40964514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 40974514f5e3Sopenharmony_ci 40984514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 40994514f5e3Sopenharmony_ci SAVE_PC(); 41004514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalRecord(thread, propKey, value, true); 41014514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 41024514f5e3Sopenharmony_ci RESTORE_ACC(); 41034514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STCONSTTOGLOBALRECORD_PREF_ID32); 41044514f5e3Sopenharmony_ci} 41054514f5e3Sopenharmony_ci 41064514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdmodulevarPrefId32Imm8( 41074514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 41084514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 41094514f5e3Sopenharmony_ci{ 41104514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 41114514f5e3Sopenharmony_ci uint8_t innerFlag = READ_INST_8_5(); 41124514f5e3Sopenharmony_ci 41134514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 41144514f5e3Sopenharmony_ci JSTaggedValue key = ConstantPool::GetStringFromCache(thread, constpool, stringId); 41154514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldmodulevar " 41164514f5e3Sopenharmony_ci << "string_id:" << stringId << ", " 41174514f5e3Sopenharmony_ci << "key: " << ConvertToString(EcmaString::Cast(key.GetTaggedObject())); 41184514f5e3Sopenharmony_ci 41194514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdModuleVar(thread, key, innerFlag != 0); 41204514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 41214514f5e3Sopenharmony_ci SET_ACC(moduleVar); 41224514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDMODULEVAR_PREF_ID32_IMM8); 41234514f5e3Sopenharmony_ci} 41244514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdsuperbynamePrefId32V8( 41254514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 41264514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 41274514f5e3Sopenharmony_ci{ 41284514f5e3Sopenharmony_ci uint32_t stringId = READ_INST_32_1(); 41294514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_5(); 41304514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 41314514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 41324514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 41334514f5e3Sopenharmony_ci 41344514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsuperbyname" 41354514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId << ", " 41364514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << obj.GetRawData(); 41374514f5e3Sopenharmony_ci 41384514f5e3Sopenharmony_ci SAVE_PC(); 41394514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 41404514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdSuperByValue(thread, obj, propKey, thisFunc); 41414514f5e3Sopenharmony_ci 41424514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 41434514f5e3Sopenharmony_ci SET_ACC(res); 41444514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDSUPERBYNAME_PREF_ID32_V8); 41454514f5e3Sopenharmony_ci} 41464514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdobjbynamePrefId32V8( 41474514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 41484514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 41494514f5e3Sopenharmony_ci{ 41504514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_5(); 41514514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 41524514f5e3Sopenharmony_ci 41534514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_32_1(); 41544514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 41554514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 41564514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyname " 41574514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId << ", " 41584514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << receiver.GetRawData(); 41594514f5e3Sopenharmony_ci 41604514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 41614514f5e3Sopenharmony_ci // fast path 41624514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByName(thread, receiver, propKey); 41634514f5e3Sopenharmony_ci if (!res.IsHole()) { 41644514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 41654514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 41664514f5e3Sopenharmony_ci SET_ACC(res); 41674514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDOBJBYNAME_PREF_ID32_V8); 41684514f5e3Sopenharmony_ci } 41694514f5e3Sopenharmony_ci } 41704514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 41714514f5e3Sopenharmony_ci // slow stub not need receiver 41724514f5e3Sopenharmony_ci SAVE_PC(); 41734514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByName(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 41744514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 41754514f5e3Sopenharmony_ci SET_ACC(res); 41764514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDOBJBYNAME_PREF_ID32_V8); 41774514f5e3Sopenharmony_ci} 41784514f5e3Sopenharmony_ci 41794514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStmodulevarPrefId32( 41804514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 41814514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 41824514f5e3Sopenharmony_ci{ 41834514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_32_1(); 41844514f5e3Sopenharmony_ci SAVE_ACC(); 41854514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 41864514f5e3Sopenharmony_ci auto key = ConstantPool::GetStringFromCache(thread, constpool, stringId); 41874514f5e3Sopenharmony_ci RESTORE_ACC(); 41884514f5e3Sopenharmony_ci 41894514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stmodulevar " 41904514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(key.GetTaggedObject())); 41914514f5e3Sopenharmony_ci 41924514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 41934514f5e3Sopenharmony_ci 41944514f5e3Sopenharmony_ci SlowRuntimeStub::StModuleVar(thread, key, value); 41954514f5e3Sopenharmony_ci RESTORE_ACC(); 41964514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STMODULEVAR_PREF_ID32); 41974514f5e3Sopenharmony_ci} 41984514f5e3Sopenharmony_ci 41994514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedGetmodulenamespacePrefId32( 42004514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 42014514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 42024514f5e3Sopenharmony_ci{ 42034514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_32_1(); 42044514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 42054514f5e3Sopenharmony_ci auto localName = ConstantPool::GetStringFromCache(thread, constpool, stringId); 42064514f5e3Sopenharmony_ci 42074514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getmodulenamespace " 42084514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(localName.GetTaggedObject())); 42094514f5e3Sopenharmony_ci 42104514f5e3Sopenharmony_ci JSTaggedValue moduleNamespace = SlowRuntimeStub::GetModuleNamespace(thread, localName); 42114514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleNamespace); 42124514f5e3Sopenharmony_ci SET_ACC(moduleNamespace); 42134514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_GETMODULENAMESPACE_PREF_ID32); 42144514f5e3Sopenharmony_ci} 42154514f5e3Sopenharmony_ci 42164514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStlexvarPrefImm16Imm16V8( 42174514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 42184514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 42194514f5e3Sopenharmony_ci{ 42204514f5e3Sopenharmony_ci uint16_t level = READ_INST_16_1(); 42214514f5e3Sopenharmony_ci uint16_t slot = READ_INST_16_3(); 42224514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_5(); 42234514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlexvar" 42244514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot << " v" << v0; 42254514f5e3Sopenharmony_ci 42264514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 42274514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 42284514f5e3Sopenharmony_ci JSTaggedValue env = state->env; 42294514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 42304514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 42314514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 42324514f5e3Sopenharmony_ci env = taggedParentEnv; 42334514f5e3Sopenharmony_ci } 42344514f5e3Sopenharmony_ci LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 42354514f5e3Sopenharmony_ci 42364514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STLEXVAR_PREF_IMM16_IMM16_V8); 42374514f5e3Sopenharmony_ci} 42384514f5e3Sopenharmony_ci 42394514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStlexvarPrefImm8Imm8V8( 42404514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 42414514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 42424514f5e3Sopenharmony_ci{ 42434514f5e3Sopenharmony_ci uint16_t level = READ_INST_8_1(); 42444514f5e3Sopenharmony_ci uint16_t slot = READ_INST_8_2(); 42454514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_3(); 42464514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlexvar" 42474514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot << " v" << v0; 42484514f5e3Sopenharmony_ci 42494514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 42504514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 42514514f5e3Sopenharmony_ci JSTaggedValue env = state->env; 42524514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 42534514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 42544514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 42554514f5e3Sopenharmony_ci env = taggedParentEnv; 42564514f5e3Sopenharmony_ci } 42574514f5e3Sopenharmony_ci LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 42584514f5e3Sopenharmony_ci 42594514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STLEXVAR_PREF_IMM8_IMM8_V8); 42604514f5e3Sopenharmony_ci} 42614514f5e3Sopenharmony_ci 42624514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedStlexvarPrefImm4Imm4V8( 42634514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 42644514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 42654514f5e3Sopenharmony_ci{ 42664514f5e3Sopenharmony_ci uint16_t level = READ_INST_4_2(); 42674514f5e3Sopenharmony_ci uint16_t slot = READ_INST_4_3(); 42684514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_2(); 42694514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stlexvar" 42704514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot << " v" << v0; 42714514f5e3Sopenharmony_ci 42724514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 42734514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 42744514f5e3Sopenharmony_ci JSTaggedValue env = state->env; 42754514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 42764514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 42774514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 42784514f5e3Sopenharmony_ci env = taggedParentEnv; 42794514f5e3Sopenharmony_ci } 42804514f5e3Sopenharmony_ci LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 42814514f5e3Sopenharmony_ci 42824514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_STLEXVAR_PREF_IMM4_IMM4_V8); 42834514f5e3Sopenharmony_ci} 42844514f5e3Sopenharmony_ci 42854514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedAsyncfunctionrejectPrefV8V8V8( 42864514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 42874514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 42884514f5e3Sopenharmony_ci{ 42894514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 42904514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 42914514f5e3Sopenharmony_ci uint16_t v2 = READ_INST_8_3(); 42924514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionreject" 42934514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1 << " v" << v2; 42944514f5e3Sopenharmony_ci 42954514f5e3Sopenharmony_ci JSTaggedValue asyncFuncObj = GET_VREG_VALUE(v0); 42964514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v2); 42974514f5e3Sopenharmony_ci SAVE_PC(); 42984514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionResolveOrReject(thread, asyncFuncObj, value, false); 42994514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43004514f5e3Sopenharmony_ci SET_ACC(res); 43014514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_ASYNCFUNCTIONREJECT_PREF_V8_V8_V8); 43024514f5e3Sopenharmony_ci} 43034514f5e3Sopenharmony_ci 43044514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedAsyncfunctionresolvePrefV8V8V8( 43054514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 43064514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 43074514f5e3Sopenharmony_ci{ 43084514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 43094514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 43104514f5e3Sopenharmony_ci uint16_t v2 = READ_INST_8_3(); 43114514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionresolve" 43124514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1 << " v" << v2; 43134514f5e3Sopenharmony_ci 43144514f5e3Sopenharmony_ci JSTaggedValue asyncFuncObj = GET_VREG_VALUE(v0); 43154514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v2); 43164514f5e3Sopenharmony_ci SAVE_PC(); 43174514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionResolveOrReject(thread, asyncFuncObj, value, true); 43184514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43194514f5e3Sopenharmony_ci SET_ACC(res); 43204514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_ASYNCFUNCTIONRESOLVE_PREF_V8_V8_V8); 43214514f5e3Sopenharmony_ci} 43224514f5e3Sopenharmony_ci 43234514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdobjbyindexPrefV8Imm32( 43244514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 43254514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 43264514f5e3Sopenharmony_ci{ 43274514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 43284514f5e3Sopenharmony_ci uint32_t idx = READ_INST_32_2(); 43294514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyindex" 43304514f5e3Sopenharmony_ci << " v" << v0 << " imm" << idx; 43314514f5e3Sopenharmony_ci 43324514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 43334514f5e3Sopenharmony_ci // fast path 43344514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 43354514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByIndex(thread, receiver, idx); 43364514f5e3Sopenharmony_ci if (!res.IsHole()) { 43374514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43384514f5e3Sopenharmony_ci SET_ACC(res); 43394514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDOBJBYINDEX_PREF_V8_IMM32); 43404514f5e3Sopenharmony_ci } 43414514f5e3Sopenharmony_ci } 43424514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 43434514f5e3Sopenharmony_ci // slow stub not need receiver 43444514f5e3Sopenharmony_ci SAVE_PC(); 43454514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByIndex(thread, receiver, idx, false, JSTaggedValue::Undefined()); 43464514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43474514f5e3Sopenharmony_ci SET_ACC(res); 43484514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDOBJBYINDEX_PREF_V8_IMM32); 43494514f5e3Sopenharmony_ci} 43504514f5e3Sopenharmony_ci 43514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdsuperbyvaluePrefV8V8( 43524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 43534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 43544514f5e3Sopenharmony_ci{ 43554514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 43564514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_2(); 43574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldsuperbyvalue" 43584514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 43594514f5e3Sopenharmony_ci 43604514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 43614514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 43624514f5e3Sopenharmony_ci 43634514f5e3Sopenharmony_ci // slow path 43644514f5e3Sopenharmony_ci SAVE_PC(); 43654514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 43664514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdSuperByValue(thread, receiver, propKey, thisFunc); 43674514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43684514f5e3Sopenharmony_ci SET_ACC(res); 43694514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDSUPERBYVALUE_PREF_V8_V8); 43704514f5e3Sopenharmony_ci} 43714514f5e3Sopenharmony_ci 43724514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdobjbyvaluePrefV8V8( 43734514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 43744514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 43754514f5e3Sopenharmony_ci{ 43764514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 43774514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_2(); 43784514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldobjbyvalue" 43794514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 43804514f5e3Sopenharmony_ci 43814514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 43824514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 43834514f5e3Sopenharmony_ci 43844514f5e3Sopenharmony_ci // fast path 43854514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 43864514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByValue(thread, receiver, propKey); 43874514f5e3Sopenharmony_ci if (!res.IsHole()) { 43884514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 43894514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43904514f5e3Sopenharmony_ci SET_ACC(res); 43914514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDOBJBYVALUE_PREF_V8_V8); 43924514f5e3Sopenharmony_ci } 43934514f5e3Sopenharmony_ci } 43944514f5e3Sopenharmony_ci // slow path 43954514f5e3Sopenharmony_ci SAVE_PC(); 43964514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByValue(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 43974514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 43984514f5e3Sopenharmony_ci SET_ACC(res); 43994514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDOBJBYVALUE_PREF_V8_V8); 44004514f5e3Sopenharmony_ci} 44014514f5e3Sopenharmony_ci 44024514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedSetobjectwithprotoPrefV8V8( 44034514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 44044514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 44054514f5e3Sopenharmony_ci{ 44064514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 44074514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 44084514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::setobjectwithproto" 44094514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 44104514f5e3Sopenharmony_ci JSTaggedValue proto = GET_VREG_VALUE(v0); 44114514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v1); 44124514f5e3Sopenharmony_ci SAVE_ACC(); 44134514f5e3Sopenharmony_ci SAVE_PC(); 44144514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SetObjectWithProto(thread, proto, obj); 44154514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 44164514f5e3Sopenharmony_ci RESTORE_ACC(); 44174514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_SETOBJECTWITHPROTO_PREF_V8_V8); 44184514f5e3Sopenharmony_ci} 44194514f5e3Sopenharmony_ci 44204514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCopydatapropertiesPrefV8V8( 44214514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 44224514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 44234514f5e3Sopenharmony_ci{ 44244514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 44254514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 44264514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::copydataproperties" 44274514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 44284514f5e3Sopenharmony_ci JSTaggedValue dst = GET_VREG_VALUE(v0); 44294514f5e3Sopenharmony_ci JSTaggedValue src = GET_VREG_VALUE(v1); 44304514f5e3Sopenharmony_ci SAVE_PC(); 44314514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CopyDataProperties(thread, dst, src); 44324514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 44334514f5e3Sopenharmony_ci SET_ACC(res); 44344514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_COPYDATAPROPERTIES_PREF_V8_V8); 44354514f5e3Sopenharmony_ci} 44364514f5e3Sopenharmony_ci 44374514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedAsyncfunctionawaituncaughtPrefV8V8( 44384514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 44394514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 44404514f5e3Sopenharmony_ci{ 44414514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 44424514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 44434514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::asyncfunctionawaituncaught" 44444514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 44454514f5e3Sopenharmony_ci JSTaggedValue asyncFuncObj = GET_VREG_VALUE(v0); 44464514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v1); 44474514f5e3Sopenharmony_ci SAVE_PC(); 44484514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::AsyncFunctionAwaitUncaught(thread, asyncFuncObj, value); 44494514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 44504514f5e3Sopenharmony_ci SET_ACC(res); 44514514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_ASYNCFUNCTIONAWAITUNCAUGHT_PREF_V8_V8); 44524514f5e3Sopenharmony_ci} 44534514f5e3Sopenharmony_ci 44544514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedSuspendgeneratorPrefV8V8( 44554514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 44564514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 44574514f5e3Sopenharmony_ci{ 44584514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 44594514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 44604514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::suspendgenerator" 44614514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 44624514f5e3Sopenharmony_ci JSTaggedValue genObj = GET_VREG_VALUE(v0); 44634514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v1); 44644514f5e3Sopenharmony_ci // suspend will record bytecode offset 44654514f5e3Sopenharmony_ci SAVE_PC(); 44664514f5e3Sopenharmony_ci SAVE_ACC(); 44674514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuspendGenerator(thread, genObj, value); 44684514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 44694514f5e3Sopenharmony_ci SET_ACC(res); 44704514f5e3Sopenharmony_ci 44714514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 44724514f5e3Sopenharmony_ci Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget(); 44734514f5e3Sopenharmony_ci [[maybe_unused]] auto fistPC = method->GetBytecodeArray(); 44744514f5e3Sopenharmony_ci UPDATE_HOTNESS_COUNTER(-(pc - fistPC)); 44754514f5e3Sopenharmony_ci LOG_INST() << "Exit: SuspendGenerator " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 44764514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(state->pc); 44774514f5e3Sopenharmony_ci sp = state->base.prev; 44784514f5e3Sopenharmony_ci ASSERT(sp != nullptr); 44794514f5e3Sopenharmony_ci InterpretedFrame *prevState = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 44804514f5e3Sopenharmony_ci pc = prevState->pc; 44814514f5e3Sopenharmony_ci // entry frame 44824514f5e3Sopenharmony_ci if (FrameHandler::IsEntryFrame(pc)) { 44834514f5e3Sopenharmony_ci state->acc = acc; 44844514f5e3Sopenharmony_ci return; 44854514f5e3Sopenharmony_ci } 44864514f5e3Sopenharmony_ci 44874514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 44884514f5e3Sopenharmony_ci 44894514f5e3Sopenharmony_ci size_t jumpSize = GetJumpSizeAfterCall(pc); 44904514f5e3Sopenharmony_ci DISPATCH_OFFSET(jumpSize); 44914514f5e3Sopenharmony_ci} 44924514f5e3Sopenharmony_ci 44934514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedDelobjpropPrefV8V8( 44944514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 44954514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 44964514f5e3Sopenharmony_ci{ 44974514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 44984514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 44994514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::delobjprop" 45004514f5e3Sopenharmony_ci << " v0" << v0 << " v1" << v1; 45014514f5e3Sopenharmony_ci 45024514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 45034514f5e3Sopenharmony_ci JSTaggedValue prop = GET_VREG_VALUE(v1); 45044514f5e3Sopenharmony_ci SAVE_PC(); 45054514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::DelObjProp(thread, obj, prop); 45064514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 45074514f5e3Sopenharmony_ci SET_ACC(res); 45084514f5e3Sopenharmony_ci 45094514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_DELOBJPROP_PREF_V8_V8); 45104514f5e3Sopenharmony_ci} 45114514f5e3Sopenharmony_ci 45124514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedGettemplateobjectPrefV8( 45134514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 45144514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 45154514f5e3Sopenharmony_ci{ 45164514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 45174514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::gettemplateobject" 45184514f5e3Sopenharmony_ci << " v" << v0; 45194514f5e3Sopenharmony_ci 45204514f5e3Sopenharmony_ci JSTaggedValue literal = GET_VREG_VALUE(v0); 45214514f5e3Sopenharmony_ci SAVE_PC(); 45224514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetTemplateObject(thread, literal); 45234514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 45244514f5e3Sopenharmony_ci SET_ACC(res); 45254514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_GETTEMPLATEOBJECT_PREF_V8); 45264514f5e3Sopenharmony_ci} 45274514f5e3Sopenharmony_ci 45284514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedGetresumemodePrefV8( 45294514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 45304514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 45314514f5e3Sopenharmony_ci{ 45324514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getresumemode"; 45334514f5e3Sopenharmony_ci uint16_t vs = READ_INST_8_1(); 45344514f5e3Sopenharmony_ci JSTaggedValue objVal = GET_VREG_VALUE(vs); 45354514f5e3Sopenharmony_ci if (objVal.IsAsyncGeneratorObject()) { 45364514f5e3Sopenharmony_ci JSAsyncGeneratorObject *obj = JSAsyncGeneratorObject::Cast(objVal.GetTaggedObject()); 45374514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int>(obj->GetResumeMode()))); 45384514f5e3Sopenharmony_ci } else { 45394514f5e3Sopenharmony_ci JSGeneratorObject *obj = JSGeneratorObject::Cast(objVal.GetTaggedObject()); 45404514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(static_cast<int>(obj->GetResumeMode()))); 45414514f5e3Sopenharmony_ci } 45424514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_GETRESUMEMODE_PREF_V8); 45434514f5e3Sopenharmony_ci} 45444514f5e3Sopenharmony_ci 45454514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedResumegeneratorPrefV8( 45464514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 45474514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 45484514f5e3Sopenharmony_ci{ 45494514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::resumegenerator"; 45504514f5e3Sopenharmony_ci uint16_t vs = READ_INST_8_1(); 45514514f5e3Sopenharmony_ci JSTaggedValue objVal = GET_VREG_VALUE(vs); 45524514f5e3Sopenharmony_ci if (objVal.IsAsyncGeneratorObject()) { 45534514f5e3Sopenharmony_ci JSAsyncGeneratorObject *obj = JSAsyncGeneratorObject::Cast(objVal.GetTaggedObject()); 45544514f5e3Sopenharmony_ci SET_ACC(obj->GetResumeResult()); 45554514f5e3Sopenharmony_ci } else { 45564514f5e3Sopenharmony_ci JSGeneratorObject *obj = JSGeneratorObject::Cast(objVal.GetTaggedObject()); 45574514f5e3Sopenharmony_ci SET_ACC(obj->GetResumeResult()); 45584514f5e3Sopenharmony_ci } 45594514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_RESUMEGENERATOR_PREF_V8); 45604514f5e3Sopenharmony_ci} 45614514f5e3Sopenharmony_ci 45624514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8( 45634514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 45644514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 45654514f5e3Sopenharmony_ci{ 45664514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_1(); 45674514f5e3Sopenharmony_ci uint16_t length = READ_INST_16_5(); 45684514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_7(); 45694514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_8(); 45704514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::defineclasswithbuffer" 45714514f5e3Sopenharmony_ci << " method id:" << methodId << " lexenv: v" << v0 << " parent: v" << v1; 45724514f5e3Sopenharmony_ci 45734514f5e3Sopenharmony_ci JSTaggedValue lexenv = GET_VREG_VALUE(v0); 45744514f5e3Sopenharmony_ci JSTaggedValue proto = GET_VREG_VALUE(v1); 45754514f5e3Sopenharmony_ci 45764514f5e3Sopenharmony_ci SAVE_PC(); 45774514f5e3Sopenharmony_ci JSTaggedValue res = 45784514f5e3Sopenharmony_ci SlowRuntimeStub::CreateClassWithBuffer(thread, proto, lexenv, GetConstantPool(sp), 45794514f5e3Sopenharmony_ci methodId, methodId + 1, GetModule(sp), 45804514f5e3Sopenharmony_ci JSTaggedValue(length)); 45814514f5e3Sopenharmony_ci 45824514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 45834514f5e3Sopenharmony_ci ASSERT(res.IsClassConstructor()); 45844514f5e3Sopenharmony_ci 45854514f5e3Sopenharmony_ci SET_ACC(res); 45864514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_DEFINECLASSWITHBUFFER_PREF_ID16_IMM16_IMM16_V8_V8); 45874514f5e3Sopenharmony_ci} 45884514f5e3Sopenharmony_ci 45894514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallspreadPrefV8V8V8( 45904514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 45914514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 45924514f5e3Sopenharmony_ci{ 45934514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 45944514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 45954514f5e3Sopenharmony_ci uint16_t v2 = READ_INST_8_3(); 45964514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::callspread" 45974514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1 << " v" << v2; 45984514f5e3Sopenharmony_ci JSTaggedValue func = GET_VREG_VALUE(v0); 45994514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v1); 46004514f5e3Sopenharmony_ci JSTaggedValue array = GET_VREG_VALUE(v2); 46014514f5e3Sopenharmony_ci 46024514f5e3Sopenharmony_ci SAVE_PC(); 46034514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CallSpread(thread, func, obj, array); 46044514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 46054514f5e3Sopenharmony_ci SET_ACC(res); 46064514f5e3Sopenharmony_ci 46074514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLSPREAD_PREF_V8_V8_V8); 46084514f5e3Sopenharmony_ci} 46094514f5e3Sopenharmony_ci 46104514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallargs3PrefV8V8V8V8( 46114514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 46124514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 46134514f5e3Sopenharmony_ci{ 46144514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLARGS3_PREF_V8_V8_V8_V8); 46154514f5e3Sopenharmony_ci} 46164514f5e3Sopenharmony_ci 46174514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallargs2PrefV8V8V8( 46184514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 46194514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 46204514f5e3Sopenharmony_ci{ 46214514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLARGS2_PREF_V8_V8_V8); 46224514f5e3Sopenharmony_ci} 46234514f5e3Sopenharmony_ci 46244514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallarg1PrefV8V8( 46254514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 46264514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 46274514f5e3Sopenharmony_ci{ 46284514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLARG1_PREF_V8_V8); 46294514f5e3Sopenharmony_ci} 46304514f5e3Sopenharmony_ci 46314514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallarg0PrefV8( 46324514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 46334514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 46344514f5e3Sopenharmony_ci{ 46354514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLARG0_PREF_V8); 46364514f5e3Sopenharmony_ci} 46374514f5e3Sopenharmony_ci 46384514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedDecPrefV8( 46394514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 46404514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 46414514f5e3Sopenharmony_ci{ 46424514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 46434514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::dec" 46444514f5e3Sopenharmony_ci << " v" << v0; 46454514f5e3Sopenharmony_ci 46464514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 46474514f5e3Sopenharmony_ci // number, fast path 46484514f5e3Sopenharmony_ci if (value.IsInt()) { 46494514f5e3Sopenharmony_ci int32_t a0 = value.GetInt(); 46504514f5e3Sopenharmony_ci if (UNLIKELY(a0 == INT32_MIN)) { 46514514f5e3Sopenharmony_ci auto ret = static_cast<double>(a0) - 1.0; 46524514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 46534514f5e3Sopenharmony_ci } else { 46544514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(a0 - 1)); 46554514f5e3Sopenharmony_ci } 46564514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 46574514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(value.GetDouble() - 1.0)); 46584514f5e3Sopenharmony_ci } else { 46594514f5e3Sopenharmony_ci // slow path 46604514f5e3Sopenharmony_ci SAVE_PC(); 46614514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Dec(thread, value); 46624514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 46634514f5e3Sopenharmony_ci SET_ACC(res); 46644514f5e3Sopenharmony_ci } 46654514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_DEC_PREF_V8); 46664514f5e3Sopenharmony_ci} 46674514f5e3Sopenharmony_ci 46684514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedIncPrefV8( 46694514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 46704514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 46714514f5e3Sopenharmony_ci{ 46724514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 46734514f5e3Sopenharmony_ci 46744514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::inc" 46754514f5e3Sopenharmony_ci << " v" << v0; 46764514f5e3Sopenharmony_ci 46774514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 46784514f5e3Sopenharmony_ci // number fast path 46794514f5e3Sopenharmony_ci if (value.IsInt()) { 46804514f5e3Sopenharmony_ci int32_t a0 = value.GetInt(); 46814514f5e3Sopenharmony_ci if (UNLIKELY(a0 == INT32_MAX)) { 46824514f5e3Sopenharmony_ci auto ret = static_cast<double>(a0) + 1.0; 46834514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(ret)); 46844514f5e3Sopenharmony_ci } else { 46854514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(a0 + 1)); 46864514f5e3Sopenharmony_ci } 46874514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 46884514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(value.GetDouble() + 1.0)); 46894514f5e3Sopenharmony_ci } else { 46904514f5e3Sopenharmony_ci // slow path 46914514f5e3Sopenharmony_ci SAVE_PC(); 46924514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Inc(thread, value); 46934514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 46944514f5e3Sopenharmony_ci SET_ACC(res); 46954514f5e3Sopenharmony_ci } 46964514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_INC_PREF_V8); 46974514f5e3Sopenharmony_ci} 46984514f5e3Sopenharmony_ci 46994514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedNotPrefV8( 47004514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 47014514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 47024514f5e3Sopenharmony_ci{ 47034514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 47044514f5e3Sopenharmony_ci 47054514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::not" 47064514f5e3Sopenharmony_ci << " v" << v0; 47074514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 47084514f5e3Sopenharmony_ci int32_t number; 47094514f5e3Sopenharmony_ci // number, fast path 47104514f5e3Sopenharmony_ci if (value.IsInt()) { 47114514f5e3Sopenharmony_ci number = static_cast<int32_t>(value.GetInt()); 47124514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(~number)); // NOLINT(hicpp-signed-bitwise); 47134514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 47144514f5e3Sopenharmony_ci number = base::NumberHelper::DoubleToInt(value.GetDouble(), base::INT32_BITS); 47154514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(~number)); // NOLINT(hicpp-signed-bitwise); 47164514f5e3Sopenharmony_ci } else { 47174514f5e3Sopenharmony_ci // slow path 47184514f5e3Sopenharmony_ci SAVE_PC(); 47194514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Not(thread, value); 47204514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 47214514f5e3Sopenharmony_ci SET_ACC(res); 47224514f5e3Sopenharmony_ci } 47234514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_NOT_PREF_V8); 47244514f5e3Sopenharmony_ci} 47254514f5e3Sopenharmony_ci 47264514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedNegPrefV8( 47274514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 47284514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 47294514f5e3Sopenharmony_ci{ 47304514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 47314514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::neg" 47324514f5e3Sopenharmony_ci << " v" << v0; 47334514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 47344514f5e3Sopenharmony_ci // fast path 47354514f5e3Sopenharmony_ci if (value.IsInt()) { 47364514f5e3Sopenharmony_ci if (value.GetInt() == 0) { 47374514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-0.0)); 47384514f5e3Sopenharmony_ci } else { 47394514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-value.GetInt())); 47404514f5e3Sopenharmony_ci } 47414514f5e3Sopenharmony_ci } else if (value.IsDouble()) { 47424514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(-value.GetDouble())); 47434514f5e3Sopenharmony_ci } else { // slow path 47444514f5e3Sopenharmony_ci SAVE_PC(); 47454514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::Neg(thread, value); 47464514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 47474514f5e3Sopenharmony_ci SET_ACC(res); 47484514f5e3Sopenharmony_ci } 47494514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_NEG_PREF_V8); 47504514f5e3Sopenharmony_ci} 47514514f5e3Sopenharmony_ci 47524514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedTonumericPrefV8( 47534514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 47544514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 47554514f5e3Sopenharmony_ci{ 47564514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 47574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::tonumeric" 47584514f5e3Sopenharmony_ci << " v" << v0; 47594514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 47604514f5e3Sopenharmony_ci if (value.IsNumber() || value.IsBigInt()) { 47614514f5e3Sopenharmony_ci // fast path 47624514f5e3Sopenharmony_ci SET_ACC(value); 47634514f5e3Sopenharmony_ci } else { 47644514f5e3Sopenharmony_ci // slow path 47654514f5e3Sopenharmony_ci SAVE_PC(); 47664514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::ToNumeric(thread, value); 47674514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 47684514f5e3Sopenharmony_ci SET_ACC(res); 47694514f5e3Sopenharmony_ci } 47704514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_TONUMERIC_PREF_V8); 47714514f5e3Sopenharmony_ci} 47724514f5e3Sopenharmony_ci 47734514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallthisrangePrefImm16V8( 47744514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 47754514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 47764514f5e3Sopenharmony_ci{ 47774514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLTHISRANGE_PREF_IMM16_V8); 47784514f5e3Sopenharmony_ci} 47794514f5e3Sopenharmony_ci 47804514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedTonumberPrefV8( 47814514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 47824514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 47834514f5e3Sopenharmony_ci{ 47844514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 47854514f5e3Sopenharmony_ci 47864514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::tonumber" 47874514f5e3Sopenharmony_ci << " v" << v0; 47884514f5e3Sopenharmony_ci JSTaggedValue value = GET_VREG_VALUE(v0); 47894514f5e3Sopenharmony_ci if (value.IsNumber()) { 47904514f5e3Sopenharmony_ci // fast path 47914514f5e3Sopenharmony_ci SET_ACC(value); 47924514f5e3Sopenharmony_ci } else { 47934514f5e3Sopenharmony_ci // slow path 47944514f5e3Sopenharmony_ci SAVE_PC(); 47954514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::ToNumber(thread, value); 47964514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 47974514f5e3Sopenharmony_ci SET_ACC(res); 47984514f5e3Sopenharmony_ci } 47994514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_TONUMBER_PREF_V8); 48004514f5e3Sopenharmony_ci} 48014514f5e3Sopenharmony_ci 48024514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCreateobjectwithbufferPrefImm16( 48034514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48044514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48054514f5e3Sopenharmony_ci{ 48064514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_1(); 48074514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createobjectwithbuffer" 48084514f5e3Sopenharmony_ci << " imm:" << imm; 48094514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 48104514f5e3Sopenharmony_ci JSObject *result = 48114514f5e3Sopenharmony_ci JSObject::Cast(ConstantPool::GetMethodFromCache(thread, constpool, imm).GetTaggedObject()); 48124514f5e3Sopenharmony_ci 48134514f5e3Sopenharmony_ci SAVE_PC(); 48144514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 48154514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 48164514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateObjectWithBuffer(thread, factory, result); 48174514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 48184514f5e3Sopenharmony_ci SET_ACC(res); 48194514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CREATEOBJECTWITHBUFFER_PREF_IMM16); 48204514f5e3Sopenharmony_ci} 48214514f5e3Sopenharmony_ci 48224514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCreatearraywithbufferPrefImm16( 48234514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48244514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48254514f5e3Sopenharmony_ci{ 48264514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_1(); 48274514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createarraywithbuffer" 48284514f5e3Sopenharmony_ci << " imm:" << imm; 48294514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 48304514f5e3Sopenharmony_ci JSArray *result = 48314514f5e3Sopenharmony_ci JSArray::Cast(ConstantPool::GetMethodFromCache(thread, constpool, imm).GetTaggedObject()); 48324514f5e3Sopenharmony_ci SAVE_PC(); 48334514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 48344514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 48354514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateArrayWithBuffer(thread, factory, result); 48364514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 48374514f5e3Sopenharmony_ci SET_ACC(res); 48384514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CREATEARRAYWITHBUFFER_PREF_IMM16); 48394514f5e3Sopenharmony_ci} 48404514f5e3Sopenharmony_ci 48414514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedGetiteratornextPrefV8V8( 48424514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48434514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48444514f5e3Sopenharmony_ci{ 48454514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 48464514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_2(); 48474514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::getiteratornext" 48484514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 48494514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 48504514f5e3Sopenharmony_ci JSTaggedValue method = GET_VREG_VALUE(v1); 48514514f5e3Sopenharmony_ci SAVE_PC(); 48524514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::GetIteratorNext(thread, obj, method); 48534514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 48544514f5e3Sopenharmony_ci SET_ACC(res); 48554514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_GETITERATORNEXT_PREF_V8_V8); 48564514f5e3Sopenharmony_ci} 48574514f5e3Sopenharmony_ci 48584514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedPoplexenvPrefNone( 48594514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48604514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48614514f5e3Sopenharmony_ci{ 48624514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 48634514f5e3Sopenharmony_ci JSTaggedValue currentLexenv = state->env; 48644514f5e3Sopenharmony_ci JSTaggedValue parentLexenv = LexicalEnv::Cast(currentLexenv.GetTaggedObject())->GetParentEnv(); 48654514f5e3Sopenharmony_ci (reinterpret_cast<InterpretedFrame *>(sp) - 1)->env = parentLexenv; 48664514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_POPLEXENV_PREF_NONE); 48674514f5e3Sopenharmony_ci} 48684514f5e3Sopenharmony_ci 48694514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedLdlexenvPrefNone( 48704514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48714514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48724514f5e3Sopenharmony_ci{ 48734514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlexenv "; 48744514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 48754514f5e3Sopenharmony_ci JSTaggedValue currentLexenv = state->env; 48764514f5e3Sopenharmony_ci SET_ACC(currentLexenv); 48774514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_LDLEXENV_PREF_NONE); 48784514f5e3Sopenharmony_ci} 48794514f5e3Sopenharmony_ci 48804514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntime( 48814514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48824514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48834514f5e3Sopenharmony_ci{ 48844514f5e3Sopenharmony_ci} 48854514f5e3Sopenharmony_ci 48864514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWide( 48874514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48884514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48894514f5e3Sopenharmony_ci{ 48904514f5e3Sopenharmony_ci} 48914514f5e3Sopenharmony_ci 48924514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecated( 48934514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 48944514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 48954514f5e3Sopenharmony_ci{ 48964514f5e3Sopenharmony_ci} 48974514f5e3Sopenharmony_ci 48984514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstricteqV8Imm16( 48994514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49004514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49014514f5e3Sopenharmony_ci{ 49024514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQ_V8_IMM16); 49034514f5e3Sopenharmony_ci} 49044514f5e3Sopenharmony_ci 49054514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstricteqV8Imm8( 49064514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49074514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49084514f5e3Sopenharmony_ci{ 49094514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQ_V8_IMM8); 49104514f5e3Sopenharmony_ci} 49114514f5e3Sopenharmony_ci 49124514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstricteqV8Imm16( 49134514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49144514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49154514f5e3Sopenharmony_ci{ 49164514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQ_V8_IMM16); 49174514f5e3Sopenharmony_ci} 49184514f5e3Sopenharmony_ci 49194514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstricteqV8Imm8( 49204514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49214514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49224514f5e3Sopenharmony_ci{ 49234514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQ_V8_IMM8); 49244514f5e3Sopenharmony_ci} 49254514f5e3Sopenharmony_ci 49264514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJneV8Imm16( 49274514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49284514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49294514f5e3Sopenharmony_ci{ 49304514f5e3Sopenharmony_ci DISPATCH(JNE_V8_IMM16); 49314514f5e3Sopenharmony_ci} 49324514f5e3Sopenharmony_ci 49334514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJneV8Imm8( 49344514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49354514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49364514f5e3Sopenharmony_ci{ 49374514f5e3Sopenharmony_ci DISPATCH(JNE_V8_IMM8); 49384514f5e3Sopenharmony_ci} 49394514f5e3Sopenharmony_ci 49404514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqV8Imm16( 49414514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49424514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49434514f5e3Sopenharmony_ci{ 49444514f5e3Sopenharmony_ci DISPATCH(JEQ_V8_IMM16); 49454514f5e3Sopenharmony_ci} 49464514f5e3Sopenharmony_ci 49474514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqV8Imm8( 49484514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49494514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49504514f5e3Sopenharmony_ci{ 49514514f5e3Sopenharmony_ci DISPATCH(JNE_V8_IMM8); 49524514f5e3Sopenharmony_ci} 49534514f5e3Sopenharmony_ci 49544514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstrictequndefinedImm16( 49554514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49564514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49574514f5e3Sopenharmony_ci{ 49584514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQUNDEFINED_IMM16); 49594514f5e3Sopenharmony_ci} 49604514f5e3Sopenharmony_ci 49614514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstrictequndefinedImm8( 49624514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49634514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49644514f5e3Sopenharmony_ci{ 49654514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQUNDEFINED_IMM8); 49664514f5e3Sopenharmony_ci} 49674514f5e3Sopenharmony_ci 49684514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstrictequndefinedImm16( 49694514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49704514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49714514f5e3Sopenharmony_ci{ 49724514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQUNDEFINED_IMM16); 49734514f5e3Sopenharmony_ci} 49744514f5e3Sopenharmony_ci 49754514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstrictequndefinedImm8( 49764514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49774514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49784514f5e3Sopenharmony_ci{ 49794514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQUNDEFINED_IMM8); 49804514f5e3Sopenharmony_ci} 49814514f5e3Sopenharmony_ci 49824514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJneundefinedImm16( 49834514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49844514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49854514f5e3Sopenharmony_ci{ 49864514f5e3Sopenharmony_ci DISPATCH(JNEUNDEFINED_IMM16); 49874514f5e3Sopenharmony_ci} 49884514f5e3Sopenharmony_ci 49894514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJneundefinedImm8( 49904514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49914514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49924514f5e3Sopenharmony_ci{ 49934514f5e3Sopenharmony_ci DISPATCH(JNEUNDEFINED_IMM8); 49944514f5e3Sopenharmony_ci} 49954514f5e3Sopenharmony_ci 49964514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJequndefinedImm16( 49974514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 49984514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 49994514f5e3Sopenharmony_ci{ 50004514f5e3Sopenharmony_ci DISPATCH(JEQUNDEFINED_IMM16); 50014514f5e3Sopenharmony_ci} 50024514f5e3Sopenharmony_ci 50034514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJequndefinedImm8( 50044514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50054514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50064514f5e3Sopenharmony_ci{ 50074514f5e3Sopenharmony_ci DISPATCH(JEQUNDEFINED_IMM8); 50084514f5e3Sopenharmony_ci} 50094514f5e3Sopenharmony_ci 50104514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstricteqnullImm16( 50114514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50124514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50134514f5e3Sopenharmony_ci{ 50144514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQNULL_IMM16); 50154514f5e3Sopenharmony_ci} 50164514f5e3Sopenharmony_ci 50174514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstricteqnullImm8( 50184514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50194514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50204514f5e3Sopenharmony_ci{ 50214514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQNULL_IMM8); 50224514f5e3Sopenharmony_ci} 50234514f5e3Sopenharmony_ci 50244514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallarg1Imm8V8( 50254514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50264514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50274514f5e3Sopenharmony_ci{ 50284514f5e3Sopenharmony_ci DISPATCH(CALLARG1_IMM8_V8); 50294514f5e3Sopenharmony_ci} 50304514f5e3Sopenharmony_ci 50314514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstricteqnullImm16( 50324514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50334514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50344514f5e3Sopenharmony_ci{ 50354514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQNULL_IMM16); 50364514f5e3Sopenharmony_ci} 50374514f5e3Sopenharmony_ci 50384514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstricteqnullImm8( 50394514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50404514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50414514f5e3Sopenharmony_ci{ 50424514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQNULL_IMM8); 50434514f5e3Sopenharmony_ci} 50444514f5e3Sopenharmony_ci 50454514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnenullImm16( 50464514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50474514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50484514f5e3Sopenharmony_ci{ 50494514f5e3Sopenharmony_ci DISPATCH(JNENULL_IMM16); 50504514f5e3Sopenharmony_ci} 50514514f5e3Sopenharmony_ci 50524514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnenullImm8( 50534514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50544514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50554514f5e3Sopenharmony_ci{ 50564514f5e3Sopenharmony_ci DISPATCH(JNENULL_IMM8); 50574514f5e3Sopenharmony_ci} 50584514f5e3Sopenharmony_ci 50594514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbynamewithnamesetImm16Id16V8( 50604514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50614514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 50624514f5e3Sopenharmony_ci{ 50634514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 50644514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_4(); 50654514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 50664514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbynamewithnameset " 50674514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId; 50684514f5e3Sopenharmony_ci 50694514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 50704514f5e3Sopenharmony_ci if (receiver.IsJSObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 50714514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 50724514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 50734514f5e3Sopenharmony_ci // fast path 50744514f5e3Sopenharmony_ci SAVE_ACC(); 50754514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName<ObjectFastOperator::Status::UseOwn> 50764514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 50774514f5e3Sopenharmony_ci if (!res.IsHole()) { 50784514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 50794514f5e3Sopenharmony_ci JSFunction::SetFunctionNameNoPrefix(thread, JSFunction::Cast(value.GetTaggedObject()), propKey); 50804514f5e3Sopenharmony_ci RESTORE_ACC(); 50814514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8); 50824514f5e3Sopenharmony_ci } 50834514f5e3Sopenharmony_ci RESTORE_ACC(); 50844514f5e3Sopenharmony_ci } 50854514f5e3Sopenharmony_ci 50864514f5e3Sopenharmony_ci SAVE_ACC(); 50874514f5e3Sopenharmony_ci SAVE_PC(); 50884514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 50894514f5e3Sopenharmony_ci auto propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); // Maybe moved by GC 50904514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 50914514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByNameWithNameSet(thread, receiver, propKey, value); 50924514f5e3Sopenharmony_ci RESTORE_ACC(); 50934514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 50944514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAMEWITHNAMESET_IMM16_ID16_V8); 50954514f5e3Sopenharmony_ci} 50964514f5e3Sopenharmony_ci 50974514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbyvaluewithnamesetImm16V8V8( 50984514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 50994514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51004514f5e3Sopenharmony_ci{ 51014514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 51024514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_3(); 51034514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyvaluewithnameset" 51044514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 51054514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 51064514f5e3Sopenharmony_ci if (receiver.IsHeapObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 51074514f5e3Sopenharmony_ci SAVE_ACC(); 51084514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 51094514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 51104514f5e3Sopenharmony_ci // fast path 51114514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue<ObjectFastOperator::Status::UseOwn> 51124514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 51134514f5e3Sopenharmony_ci 51144514f5e3Sopenharmony_ci // SetPropertyByValue maybe gc need update the value 51154514f5e3Sopenharmony_ci RESTORE_ACC(); 51164514f5e3Sopenharmony_ci propKey = GET_VREG_VALUE(v1); 51174514f5e3Sopenharmony_ci value = GET_ACC(); 51184514f5e3Sopenharmony_ci if (!res.IsHole()) { 51194514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 51204514f5e3Sopenharmony_ci JSFunction::SetFunctionNameNoPrefix(thread, JSFunction::Cast(value.GetTaggedObject()), propKey); 51214514f5e3Sopenharmony_ci RESTORE_ACC(); 51224514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUEWITHNAMESET_IMM16_V8_V8); 51234514f5e3Sopenharmony_ci } 51244514f5e3Sopenharmony_ci } 51254514f5e3Sopenharmony_ci 51264514f5e3Sopenharmony_ci // slow path 51274514f5e3Sopenharmony_ci SAVE_ACC(); 51284514f5e3Sopenharmony_ci SAVE_PC(); 51294514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 51304514f5e3Sopenharmony_ci auto propKey = GET_VREG_VALUE(v1); // Maybe moved by GC 51314514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 51324514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByValueWithNameSet(thread, receiver, propKey, value); 51334514f5e3Sopenharmony_ci RESTORE_ACC(); 51344514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 51354514f5e3Sopenharmony_ci DISPATCH(STOWNBYVALUEWITHNAMESET_IMM16_V8_V8); 51364514f5e3Sopenharmony_ci} 51374514f5e3Sopenharmony_ci 51384514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqnullImm16( 51394514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 51404514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51414514f5e3Sopenharmony_ci{ 51424514f5e3Sopenharmony_ci DISPATCH(JEQNULL_IMM16); 51434514f5e3Sopenharmony_ci} 51444514f5e3Sopenharmony_ci 51454514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJeqnullImm8( 51464514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 51474514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51484514f5e3Sopenharmony_ci{ 51494514f5e3Sopenharmony_ci DISPATCH(JEQNULL_IMM8); 51504514f5e3Sopenharmony_ci} 51514514f5e3Sopenharmony_ci 51524514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstricteqzImm16( 51534514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 51544514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51554514f5e3Sopenharmony_ci{ 51564514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQZ_IMM16); 51574514f5e3Sopenharmony_ci} 51584514f5e3Sopenharmony_ci 51594514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJnstricteqzImm8( 51604514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 51614514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51624514f5e3Sopenharmony_ci{ 51634514f5e3Sopenharmony_ci DISPATCH(JNSTRICTEQZ_IMM8); 51644514f5e3Sopenharmony_ci} 51654514f5e3Sopenharmony_ci 51664514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSttoglobalrecordImm16Id16( 51674514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 51684514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51694514f5e3Sopenharmony_ci{ 51704514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 51714514f5e3Sopenharmony_ci SAVE_ACC(); 51724514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 51734514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 51744514f5e3Sopenharmony_ci RESTORE_ACC(); 51754514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stconsttoglobalrecord" 51764514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 51774514f5e3Sopenharmony_ci 51784514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 51794514f5e3Sopenharmony_ci SAVE_PC(); 51804514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalRecord(thread, propKey, value, true); 51814514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 51824514f5e3Sopenharmony_ci RESTORE_ACC(); 51834514f5e3Sopenharmony_ci DISPATCH(STCONSTTOGLOBALRECORD_IMM16_ID16); 51844514f5e3Sopenharmony_ci} 51854514f5e3Sopenharmony_ci 51864514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStconsttoglobalrecordImm16Id16( 51874514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 51884514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 51894514f5e3Sopenharmony_ci{ 51904514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 51914514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 51924514f5e3Sopenharmony_ci JSTaggedValue constantPool = state->constpool; 51934514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constantPool.GetTaggedObject()) 51944514f5e3Sopenharmony_ci ->GetObjectFromCache(stringId); 51954514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stconsttoglobalrecord" 51964514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 51974514f5e3Sopenharmony_ci 51984514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 51994514f5e3Sopenharmony_ci SAVE_ACC(); 52004514f5e3Sopenharmony_ci SAVE_PC(); 52014514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalRecord(thread, propKey, value, true); 52024514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 52034514f5e3Sopenharmony_ci RESTORE_ACC(); 52044514f5e3Sopenharmony_ci DISPATCH(STCONSTTOGLOBALRECORD_IMM16_ID16); 52054514f5e3Sopenharmony_ci} 52064514f5e3Sopenharmony_ci 52074514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdlocalmodulevarImm8( 52084514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 52094514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 52104514f5e3Sopenharmony_ci{ 52114514f5e3Sopenharmony_ci int32_t index = READ_INST_8_0(); 52124514f5e3Sopenharmony_ci 52134514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldmodulevar index:" << index; 52144514f5e3Sopenharmony_ci 52154514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdLocalModuleVar(thread, index); 52164514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 52174514f5e3Sopenharmony_ci SET_ACC(moduleVar); 52184514f5e3Sopenharmony_ci DISPATCH(LDLOCALMODULEVAR_IMM8); 52194514f5e3Sopenharmony_ci} 52204514f5e3Sopenharmony_ci 52214514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStsuperbynameImm16Id16V8( 52224514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 52234514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 52244514f5e3Sopenharmony_ci{ 52254514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 52264514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_4(); 52274514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 52284514f5e3Sopenharmony_ci 52294514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 52304514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 52314514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 52324514f5e3Sopenharmony_ci 52334514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsuperbyname" 52344514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId << ", " 52354514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << obj.GetRawData() 52364514f5e3Sopenharmony_ci << ", value:" << value.GetRawData(); 52374514f5e3Sopenharmony_ci 52384514f5e3Sopenharmony_ci // slow path 52394514f5e3Sopenharmony_ci SAVE_ACC(); 52404514f5e3Sopenharmony_ci SAVE_PC(); 52414514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 52424514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StSuperByValue(thread, obj, propKey, value, thisFunc); 52434514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 52444514f5e3Sopenharmony_ci RESTORE_ACC(); 52454514f5e3Sopenharmony_ci DISPATCH(STSUPERBYNAME_IMM16_ID16_V8); 52464514f5e3Sopenharmony_ci} 52474514f5e3Sopenharmony_ci 52484514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdsuperbynameImm16Id16( 52494514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 52504514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 52514514f5e3Sopenharmony_ci{ 52524514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 52534514f5e3Sopenharmony_ci SAVE_ACC(); 52544514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 52554514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 52564514f5e3Sopenharmony_ci RESTORE_ACC(); 52574514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 52584514f5e3Sopenharmony_ci 52594514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsuperbyname stringId:" << stringId << ", " 52604514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << obj.GetRawData(); 52614514f5e3Sopenharmony_ci 52624514f5e3Sopenharmony_ci SAVE_PC(); 52634514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 52644514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdSuperByValue(thread, obj, propKey, thisFunc); 52654514f5e3Sopenharmony_ci 52664514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 52674514f5e3Sopenharmony_ci SET_ACC(res); 52684514f5e3Sopenharmony_ci DISPATCH(LDSUPERBYNAME_IMM16_ID16); 52694514f5e3Sopenharmony_ci} 52704514f5e3Sopenharmony_ci 52714514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdsuperbynameImm8Id16( 52724514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 52734514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 52744514f5e3Sopenharmony_ci{ 52754514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 52764514f5e3Sopenharmony_ci SAVE_ACC(); 52774514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 52784514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 52794514f5e3Sopenharmony_ci RESTORE_ACC(); 52804514f5e3Sopenharmony_ci 52814514f5e3Sopenharmony_ci JSTaggedValue obj = GET_ACC(); 52824514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsuperbyname stringId:" << stringId << ", " 52834514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << obj.GetRawData(); 52844514f5e3Sopenharmony_ci 52854514f5e3Sopenharmony_ci SAVE_PC(); 52864514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 52874514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdSuperByValue(thread, obj, propKey, thisFunc); 52884514f5e3Sopenharmony_ci 52894514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 52904514f5e3Sopenharmony_ci SET_ACC(res); 52914514f5e3Sopenharmony_ci DISPATCH(LDSUPERBYNAME_IMM8_ID16); 52924514f5e3Sopenharmony_ci} 52934514f5e3Sopenharmony_ci 52944514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStownbynameImm16Id16V8( 52954514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 52964514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 52974514f5e3Sopenharmony_ci{ 52984514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 52994514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_4(); 53004514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stownbyname " 53014514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId; 53024514f5e3Sopenharmony_ci 53034514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 53044514f5e3Sopenharmony_ci if (receiver.IsJSObject() && !receiver.IsClassConstructor() && !receiver.IsClassPrototype()) { 53054514f5e3Sopenharmony_ci SAVE_ACC(); 53064514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 53074514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 53084514f5e3Sopenharmony_ci RESTORE_ACC(); 53094514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 53104514f5e3Sopenharmony_ci // fast path 53114514f5e3Sopenharmony_ci SAVE_ACC(); 53124514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 53134514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName<ObjectFastOperator::Status::UseOwn> 53144514f5e3Sopenharmony_ci (thread, receiver, propKey, value); 53154514f5e3Sopenharmony_ci if (!res.IsHole()) { 53164514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 53174514f5e3Sopenharmony_ci RESTORE_ACC(); 53184514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAME_IMM16_ID16_V8); 53194514f5e3Sopenharmony_ci } 53204514f5e3Sopenharmony_ci RESTORE_ACC(); 53214514f5e3Sopenharmony_ci } 53224514f5e3Sopenharmony_ci 53234514f5e3Sopenharmony_ci SAVE_ACC(); 53244514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 53254514f5e3Sopenharmony_ci auto propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); // Maybe moved by GC 53264514f5e3Sopenharmony_ci RESTORE_ACC(); 53274514f5e3Sopenharmony_ci auto value = GET_ACC(); // Maybe moved by GC 53284514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); // Maybe moved by GC 53294514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StOwnByName(thread, receiver, propKey, value); 53304514f5e3Sopenharmony_ci RESTORE_ACC(); 53314514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 53324514f5e3Sopenharmony_ci DISPATCH(STOWNBYNAME_IMM16_ID16_V8); 53334514f5e3Sopenharmony_ci} 53344514f5e3Sopenharmony_ci 53354514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStobjbynameImm16Id16V8( 53364514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 53374514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 53384514f5e3Sopenharmony_ci{ 53394514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 53404514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_4(); 53414514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 53424514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 53434514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 53444514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 53454514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 53464514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 53474514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 53484514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 53494514f5e3Sopenharmony_ci SAVE_ACC(); 53504514f5e3Sopenharmony_ci 53514514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 53524514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 53534514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 53544514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 53554514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByName(thread, receiver, firstValue, secondValue, value); 53564514f5e3Sopenharmony_ci } 53574514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 53584514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 53594514f5e3Sopenharmony_ci RESTORE_ACC(); 53604514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM16_ID16_V8); 53614514f5e3Sopenharmony_ci } else if (!firstValue.IsHole()) { // IC miss and not enter the megamorphic state, store as polymorphic 53624514f5e3Sopenharmony_ci SAVE_ACC(); 53634514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 53644514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 53654514f5e3Sopenharmony_ci RESTORE_ACC(); 53664514f5e3Sopenharmony_ci value = GET_ACC(); 53674514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 53684514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 53694514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByName(thread, 53704514f5e3Sopenharmony_ci profileTypeArray, 53714514f5e3Sopenharmony_ci receiver, propKey, value, slotId); 53724514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 53734514f5e3Sopenharmony_ci RESTORE_ACC(); 53744514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM16_ID16_V8); 53754514f5e3Sopenharmony_ci } 53764514f5e3Sopenharmony_ci } 53774514f5e3Sopenharmony_ci#endif 53784514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stobjbyname " 53794514f5e3Sopenharmony_ci << "v" << v0 << " stringId:" << stringId; 53804514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 53814514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 53824514f5e3Sopenharmony_ci SAVE_ACC(); 53834514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 53844514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 53854514f5e3Sopenharmony_ci RESTORE_ACC(); 53864514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 53874514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 53884514f5e3Sopenharmony_ci // fast path 53894514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName(thread, receiver, propKey, value); 53904514f5e3Sopenharmony_ci if (!res.IsHole()) { 53914514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 53924514f5e3Sopenharmony_ci RESTORE_ACC(); 53934514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM16_ID16_V8); 53944514f5e3Sopenharmony_ci } 53954514f5e3Sopenharmony_ci RESTORE_ACC(); 53964514f5e3Sopenharmony_ci } 53974514f5e3Sopenharmony_ci // slow path 53984514f5e3Sopenharmony_ci SAVE_ACC(); 53994514f5e3Sopenharmony_ci SAVE_PC(); 54004514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); // Maybe moved by GC 54014514f5e3Sopenharmony_ci auto propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); // Maybe moved by GC 54024514f5e3Sopenharmony_ci RESTORE_ACC(); 54034514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 54044514f5e3Sopenharmony_ci receiver = GET_VREG_VALUE(v0); 54054514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByName(thread, receiver, propKey, value); 54064514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 54074514f5e3Sopenharmony_ci RESTORE_ACC(); 54084514f5e3Sopenharmony_ci DISPATCH(STOBJBYNAME_IMM16_ID16_V8); 54094514f5e3Sopenharmony_ci} 54104514f5e3Sopenharmony_ci 54114514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdobjbynameImm16Id16( 54124514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 54134514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 54144514f5e3Sopenharmony_ci{ 54154514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 54164514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 54174514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 54184514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 54194514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 54204514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 54214514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 54224514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 54234514f5e3Sopenharmony_ci 54244514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 54254514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 54264514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 54274514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByName(thread, receiver, firstValue, secondValue); 54284514f5e3Sopenharmony_ci } 54294514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 54304514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 54314514f5e3Sopenharmony_ci SET_ACC(res); 54324514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM16_ID16); 54334514f5e3Sopenharmony_ci } else if (!firstValue.IsHole()) { // IC miss and not enter the megamorphic state, store as polymorphic 54344514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 54354514f5e3Sopenharmony_ci SAVE_ACC(); 54364514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 54374514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 54384514f5e3Sopenharmony_ci RESTORE_ACC(); 54394514f5e3Sopenharmony_ci receiver = GET_ACC(); 54404514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 54414514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByName(thread, 54424514f5e3Sopenharmony_ci profileTypeArray, 54434514f5e3Sopenharmony_ci receiver, propKey, slotId); 54444514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 54454514f5e3Sopenharmony_ci SET_ACC(res); 54464514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM16_ID16); 54474514f5e3Sopenharmony_ci } 54484514f5e3Sopenharmony_ci } 54494514f5e3Sopenharmony_ci#endif 54504514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 54514514f5e3Sopenharmony_ci SAVE_ACC(); 54524514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 54534514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 54544514f5e3Sopenharmony_ci RESTORE_ACC(); 54554514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 54564514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyname stringId:" << stringId << ", " 54574514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << receiver.GetRawData(); 54584514f5e3Sopenharmony_ci 54594514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 54604514f5e3Sopenharmony_ci // fast path 54614514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByName(thread, receiver, propKey); 54624514f5e3Sopenharmony_ci if (!res.IsHole()) { 54634514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 54644514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 54654514f5e3Sopenharmony_ci SET_ACC(res); 54664514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM16_ID16); 54674514f5e3Sopenharmony_ci } 54684514f5e3Sopenharmony_ci } 54694514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 54704514f5e3Sopenharmony_ci // slow stub not need receiver 54714514f5e3Sopenharmony_ci SAVE_PC(); 54724514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByName(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 54734514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 54744514f5e3Sopenharmony_ci SET_ACC(res); 54754514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM16_ID16); 54764514f5e3Sopenharmony_ci} 54774514f5e3Sopenharmony_ci 54784514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdobjbynameImm8Id16( 54794514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 54804514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 54814514f5e3Sopenharmony_ci{ 54824514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 54834514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 54844514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 54854514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 54864514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 54874514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 54884514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 54894514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 54904514f5e3Sopenharmony_ci 54914514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 54924514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 54934514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 54944514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByName(thread, receiver, firstValue, secondValue); 54954514f5e3Sopenharmony_ci } 54964514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 54974514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 54984514f5e3Sopenharmony_ci SET_ACC(res); 54994514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM8_ID16); 55004514f5e3Sopenharmony_ci } else if (!firstValue.IsHole()) { // IC miss and not enter the megamorphic state, store as polymorphic 55014514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 55024514f5e3Sopenharmony_ci SAVE_ACC(); 55034514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 55044514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 55054514f5e3Sopenharmony_ci RESTORE_ACC(); 55064514f5e3Sopenharmony_ci receiver = GET_ACC(); 55074514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 55084514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByName(thread, 55094514f5e3Sopenharmony_ci profileTypeArray, 55104514f5e3Sopenharmony_ci receiver, propKey, slotId); 55114514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 55124514f5e3Sopenharmony_ci SET_ACC(res); 55134514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM8_ID16); 55144514f5e3Sopenharmony_ci } 55154514f5e3Sopenharmony_ci } 55164514f5e3Sopenharmony_ci#endif 55174514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 55184514f5e3Sopenharmony_ci SAVE_ACC(); 55194514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 55204514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 55214514f5e3Sopenharmony_ci RESTORE_ACC(); 55224514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 55234514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyname stringId:" << stringId << ", " 55244514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << receiver.GetRawData(); 55254514f5e3Sopenharmony_ci 55264514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 55274514f5e3Sopenharmony_ci // fast path 55284514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByName(thread, receiver, propKey); 55294514f5e3Sopenharmony_ci if (!res.IsHole()) { 55304514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 55314514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 55324514f5e3Sopenharmony_ci SET_ACC(res); 55334514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM8_ID16); 55344514f5e3Sopenharmony_ci } 55354514f5e3Sopenharmony_ci } 55364514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 55374514f5e3Sopenharmony_ci // slow stub not need receiver 55384514f5e3Sopenharmony_ci SAVE_PC(); 55394514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByName(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 55404514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 55414514f5e3Sopenharmony_ci SET_ACC(res); 55424514f5e3Sopenharmony_ci DISPATCH(LDOBJBYNAME_IMM8_ID16); 55434514f5e3Sopenharmony_ci} 55444514f5e3Sopenharmony_ci 55454514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTrystglobalbynameImm16Id16( 55464514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 55474514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 55484514f5e3Sopenharmony_ci{ 55494514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 55504514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 55514514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::GetStringFromCache(thread, constpool, stringId); 55524514f5e3Sopenharmony_ci 55534514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 55544514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 55554514f5e3Sopenharmony_ci JSTaggedValue globalObj = globalEnv->GetGlobalObject(); 55564514f5e3Sopenharmony_ci 55574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::trystglobalbyname" 55584514f5e3Sopenharmony_ci << " stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())); 55594514f5e3Sopenharmony_ci 55604514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 55614514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 55624514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 55634514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 55644514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 55654514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 55664514f5e3Sopenharmony_ci SAVE_ACC(); 55674514f5e3Sopenharmony_ci JSTaggedValue res = ICRuntimeStub::StoreGlobalICByName(thread, 55684514f5e3Sopenharmony_ci ProfileTypeInfo::Cast( 55694514f5e3Sopenharmony_ci tmpProfileTypeInfo.GetTaggedObject()), 55704514f5e3Sopenharmony_ci globalObj, propKey, value, slotId, true); 55714514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 55724514f5e3Sopenharmony_ci RESTORE_ACC(); 55734514f5e3Sopenharmony_ci DISPATCH(TRYSTGLOBALBYNAME_IMM16_ID16); 55744514f5e3Sopenharmony_ci } 55754514f5e3Sopenharmony_ci#endif 55764514f5e3Sopenharmony_ci 55774514f5e3Sopenharmony_ci auto recordResult = SlowRuntimeStub::LdGlobalRecord(thread, propKey); 55784514f5e3Sopenharmony_ci SAVE_PC(); 55794514f5e3Sopenharmony_ci // 1. find from global record 55804514f5e3Sopenharmony_ci if (!recordResult.IsUndefined()) { 55814514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 55824514f5e3Sopenharmony_ci SAVE_ACC(); 55834514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::TryUpdateGlobalRecord(thread, propKey, value); 55844514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 55854514f5e3Sopenharmony_ci RESTORE_ACC(); 55864514f5e3Sopenharmony_ci } else { 55874514f5e3Sopenharmony_ci // 2. find from global object 55884514f5e3Sopenharmony_ci auto globalResult = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj, propKey); 55894514f5e3Sopenharmony_ci if (globalResult.IsHole()) { 55904514f5e3Sopenharmony_ci auto result = SlowRuntimeStub::ThrowReferenceError(thread, propKey, " is not defined"); 55914514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(result); 55924514f5e3Sopenharmony_ci } 55934514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 55944514f5e3Sopenharmony_ci SAVE_ACC(); 55954514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StGlobalVar(thread, propKey, value); 55964514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 55974514f5e3Sopenharmony_ci RESTORE_ACC(); 55984514f5e3Sopenharmony_ci } 55994514f5e3Sopenharmony_ci DISPATCH(TRYSTGLOBALBYNAME_IMM16_ID16); 56004514f5e3Sopenharmony_ci} 56014514f5e3Sopenharmony_ci 56024514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTryldglobalbynameImm16Id16( 56034514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 56044514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 56054514f5e3Sopenharmony_ci{ 56064514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 56074514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 56084514f5e3Sopenharmony_ci auto prop = ConstantPool::GetStringFromCache(thread, constpool, stringId); 56094514f5e3Sopenharmony_ci 56104514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 56114514f5e3Sopenharmony_ci JSHandle<GlobalEnv> globalEnv = ecmaVm->GetGlobalEnv(); 56124514f5e3Sopenharmony_ci JSTaggedValue globalObj = globalEnv->GetGlobalObject(); 56134514f5e3Sopenharmony_ci 56144514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::tryldglobalbyname " 56154514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(prop.GetTaggedObject())); 56164514f5e3Sopenharmony_ci 56174514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 56184514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 56194514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 56204514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 56214514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 56224514f5e3Sopenharmony_ci JSTaggedValue res = ICRuntimeStub::LoadGlobalICByName(thread, 56234514f5e3Sopenharmony_ci ProfileTypeInfo::Cast( 56244514f5e3Sopenharmony_ci tmpProfileTypeInfo.GetTaggedObject()), 56254514f5e3Sopenharmony_ci globalObj, prop, slotId, true); 56264514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 56274514f5e3Sopenharmony_ci SET_ACC(res); 56284514f5e3Sopenharmony_ci DISPATCH(TRYLDGLOBALBYNAME_IMM16_ID16); 56294514f5e3Sopenharmony_ci } 56304514f5e3Sopenharmony_ci#endif 56314514f5e3Sopenharmony_ci 56324514f5e3Sopenharmony_ci // order: 1. global record 2. global object 56334514f5e3Sopenharmony_ci JSTaggedValue result = SlowRuntimeStub::LdGlobalRecord(thread, prop); 56344514f5e3Sopenharmony_ci if (!result.IsUndefined()) { 56354514f5e3Sopenharmony_ci SET_ACC(PropertyBox::Cast(result.GetTaggedObject())->GetValue()); 56364514f5e3Sopenharmony_ci } else { 56374514f5e3Sopenharmony_ci JSTaggedValue globalResult = FastRuntimeStub::GetGlobalOwnProperty(thread, globalObj, prop); 56384514f5e3Sopenharmony_ci if (!globalResult.IsHole()) { 56394514f5e3Sopenharmony_ci SET_ACC(globalResult); 56404514f5e3Sopenharmony_ci } else { 56414514f5e3Sopenharmony_ci // slow path 56424514f5e3Sopenharmony_ci SAVE_PC(); 56434514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::TryLdGlobalByNameFromGlobalProto(thread, globalObj, prop); 56444514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 56454514f5e3Sopenharmony_ci SET_ACC(res); 56464514f5e3Sopenharmony_ci } 56474514f5e3Sopenharmony_ci } 56484514f5e3Sopenharmony_ci 56494514f5e3Sopenharmony_ci DISPATCH(TRYLDGLOBALBYNAME_IMM16_ID16); 56504514f5e3Sopenharmony_ci} 56514514f5e3Sopenharmony_ci 56524514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStmodulevarImm8( 56534514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 56544514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 56554514f5e3Sopenharmony_ci{ 56564514f5e3Sopenharmony_ci int32_t index = READ_INST_8_0(); 56574514f5e3Sopenharmony_ci 56584514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stmodulevar index:" << index; 56594514f5e3Sopenharmony_ci 56604514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 56614514f5e3Sopenharmony_ci 56624514f5e3Sopenharmony_ci SlowRuntimeStub::StModuleVar(thread, index, value); 56634514f5e3Sopenharmony_ci RESTORE_ACC(); 56644514f5e3Sopenharmony_ci DISPATCH(STMODULEVAR_IMM8); 56654514f5e3Sopenharmony_ci} 56664514f5e3Sopenharmony_ci 56674514f5e3Sopenharmony_civoid InterpreterAssembly::HandleGetmodulenamespaceImm8( 56684514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 56694514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 56704514f5e3Sopenharmony_ci{ 56714514f5e3Sopenharmony_ci int32_t index = READ_INST_8_0(); 56724514f5e3Sopenharmony_ci 56734514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::getmodulenamespace index:" << index; 56744514f5e3Sopenharmony_ci 56754514f5e3Sopenharmony_ci JSTaggedValue moduleNamespace = SlowRuntimeStub::GetModuleNamespace(thread, index); 56764514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleNamespace); 56774514f5e3Sopenharmony_ci SET_ACC(moduleNamespace); 56784514f5e3Sopenharmony_ci DISPATCH(GETMODULENAMESPACE_IMM8); 56794514f5e3Sopenharmony_ci} 56804514f5e3Sopenharmony_ci 56814514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdobjbyindexImm16Imm16( 56824514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 56834514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 56844514f5e3Sopenharmony_ci{ 56854514f5e3Sopenharmony_ci uint32_t idx = READ_INST_32_1(); 56864514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyindex" 56874514f5e3Sopenharmony_ci << " imm" << idx; 56884514f5e3Sopenharmony_ci 56894514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 56904514f5e3Sopenharmony_ci // fast path 56914514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 56924514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByIndex(thread, receiver, idx); 56934514f5e3Sopenharmony_ci if (!res.IsHole()) { 56944514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 56954514f5e3Sopenharmony_ci SET_ACC(res); 56964514f5e3Sopenharmony_ci DISPATCH(LDOBJBYINDEX_IMM16_IMM16); 56974514f5e3Sopenharmony_ci } 56984514f5e3Sopenharmony_ci } 56994514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 57004514f5e3Sopenharmony_ci // slow stub not need receiver 57014514f5e3Sopenharmony_ci SAVE_PC(); 57024514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByIndex(thread, receiver, idx, false, JSTaggedValue::Undefined()); 57034514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 57044514f5e3Sopenharmony_ci SET_ACC(res); 57054514f5e3Sopenharmony_ci DISPATCH(LDOBJBYINDEX_IMM16_IMM16); 57064514f5e3Sopenharmony_ci} 57074514f5e3Sopenharmony_ci 57084514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdobjbyindexImm8Imm16( 57094514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 57104514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 57114514f5e3Sopenharmony_ci{ 57124514f5e3Sopenharmony_ci uint32_t idx = READ_INST_16_1(); 57134514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldobjbyindex" 57144514f5e3Sopenharmony_ci << " imm" << idx; 57154514f5e3Sopenharmony_ci 57164514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_ACC(); 57174514f5e3Sopenharmony_ci // fast path 57184514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 57194514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByIndex(thread, receiver, idx); 57204514f5e3Sopenharmony_ci if (!res.IsHole()) { 57214514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 57224514f5e3Sopenharmony_ci SET_ACC(res); 57234514f5e3Sopenharmony_ci DISPATCH(LDOBJBYINDEX_IMM8_IMM16); 57244514f5e3Sopenharmony_ci } 57254514f5e3Sopenharmony_ci } 57264514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 57274514f5e3Sopenharmony_ci // slow stub not need receiver 57284514f5e3Sopenharmony_ci SAVE_PC(); 57294514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByIndex(thread, receiver, idx, false, JSTaggedValue::Undefined()); 57304514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 57314514f5e3Sopenharmony_ci SET_ACC(res); 57324514f5e3Sopenharmony_ci DISPATCH(LDOBJBYINDEX_IMM8_IMM16); 57334514f5e3Sopenharmony_ci} 57344514f5e3Sopenharmony_ci 57354514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStsuperbyvalueImm16V8V8( 57364514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 57374514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 57384514f5e3Sopenharmony_ci{ 57394514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 57404514f5e3Sopenharmony_ci uint32_t v1 = READ_INST_8_3(); 57414514f5e3Sopenharmony_ci 57424514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsuperbyvalue" 57434514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 57444514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 57454514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v1); 57464514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 57474514f5e3Sopenharmony_ci 57484514f5e3Sopenharmony_ci // slow path 57494514f5e3Sopenharmony_ci SAVE_ACC(); 57504514f5e3Sopenharmony_ci SAVE_PC(); 57514514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 57524514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StSuperByValue(thread, receiver, propKey, value, thisFunc); 57534514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 57544514f5e3Sopenharmony_ci RESTORE_ACC(); 57554514f5e3Sopenharmony_ci DISPATCH(STSUPERBYVALUE_IMM16_V8_V8); 57564514f5e3Sopenharmony_ci} 57574514f5e3Sopenharmony_ci 57584514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdsuperbyvalueImm16V8( 57594514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 57604514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 57614514f5e3Sopenharmony_ci{ 57624514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 57634514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldsuperbyvalue" 57644514f5e3Sopenharmony_ci << " v" << v0; 57654514f5e3Sopenharmony_ci 57664514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 57674514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_ACC(); 57684514f5e3Sopenharmony_ci 57694514f5e3Sopenharmony_ci // slow path 57704514f5e3Sopenharmony_ci SAVE_PC(); 57714514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 57724514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdSuperByValue(thread, receiver, propKey, thisFunc); 57734514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 57744514f5e3Sopenharmony_ci SET_ACC(res); 57754514f5e3Sopenharmony_ci DISPATCH(LDSUPERBYVALUE_IMM16_V8); 57764514f5e3Sopenharmony_ci} 57774514f5e3Sopenharmony_ci 57784514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdsuperbyvalueImm8V8( 57794514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 57804514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 57814514f5e3Sopenharmony_ci{ 57824514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 57834514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldsuperbyvalue" 57844514f5e3Sopenharmony_ci << " v" << v0; 57854514f5e3Sopenharmony_ci 57864514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 57874514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_ACC(); 57884514f5e3Sopenharmony_ci 57894514f5e3Sopenharmony_ci // slow path 57904514f5e3Sopenharmony_ci SAVE_PC(); 57914514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 57924514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdSuperByValue(thread, receiver, propKey, thisFunc); 57934514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 57944514f5e3Sopenharmony_ci SET_ACC(res); 57954514f5e3Sopenharmony_ci DISPATCH(LDSUPERBYVALUE_IMM8_V8); 57964514f5e3Sopenharmony_ci} 57974514f5e3Sopenharmony_ci 57984514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdobjbyvalueImm16V8( 57994514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 58004514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 58014514f5e3Sopenharmony_ci{ 58024514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 58034514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldobjbyvalue" 58044514f5e3Sopenharmony_ci << " v" << v0; 58054514f5e3Sopenharmony_ci 58064514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 58074514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_ACC(); 58084514f5e3Sopenharmony_ci 58094514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 58104514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 58114514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 58124514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 58134514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 58144514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profiltmpProfileTypeInfoeTypeInfo.GetTaggedObject()); 58154514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 58164514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 58174514f5e3Sopenharmony_ci 58184514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 58194514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 58204514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByValue(thread, receiver, propKey, firstValue, secondValue); 58214514f5e3Sopenharmony_ci } 58224514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 58234514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 58244514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByValue(thread, 58254514f5e3Sopenharmony_ci profileTypeArray, 58264514f5e3Sopenharmony_ci receiver, propKey, slotId); 58274514f5e3Sopenharmony_ci } 58284514f5e3Sopenharmony_ci 58294514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 58304514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 58314514f5e3Sopenharmony_ci SET_ACC(res); 58324514f5e3Sopenharmony_ci DISPATCH(LDOBJBYVALUE_IMM16_V8); 58334514f5e3Sopenharmony_ci } 58344514f5e3Sopenharmony_ci } 58354514f5e3Sopenharmony_ci#endif 58364514f5e3Sopenharmony_ci // fast path 58374514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 58384514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByValue(thread, receiver, propKey); 58394514f5e3Sopenharmony_ci if (!res.IsHole()) { 58404514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 58414514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 58424514f5e3Sopenharmony_ci SET_ACC(res); 58434514f5e3Sopenharmony_ci DISPATCH(LDOBJBYVALUE_IMM16_V8); 58444514f5e3Sopenharmony_ci } 58454514f5e3Sopenharmony_ci } 58464514f5e3Sopenharmony_ci // slow path 58474514f5e3Sopenharmony_ci SAVE_PC(); 58484514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByValue(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 58494514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 58504514f5e3Sopenharmony_ci SET_ACC(res); 58514514f5e3Sopenharmony_ci DISPATCH(LDOBJBYVALUE_IMM16_V8); 58524514f5e3Sopenharmony_ci} 58534514f5e3Sopenharmony_ci 58544514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdobjbyvalueImm8V8( 58554514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 58564514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 58574514f5e3Sopenharmony_ci{ 58584514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 58594514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldobjbyvalue" 58604514f5e3Sopenharmony_ci << " v" << v0; 58614514f5e3Sopenharmony_ci 58624514f5e3Sopenharmony_ci JSTaggedValue receiver = GET_VREG_VALUE(v0); 58634514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_ACC(); 58644514f5e3Sopenharmony_ci 58654514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 58664514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 58674514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 58684514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 58694514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 58704514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 58714514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 58724514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 58734514f5e3Sopenharmony_ci 58744514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 58754514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 58764514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByValue(thread, receiver, propKey, firstValue, secondValue); 58774514f5e3Sopenharmony_ci } 58784514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 58794514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 58804514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByValue(thread, 58814514f5e3Sopenharmony_ci profileTypeArray, 58824514f5e3Sopenharmony_ci receiver, propKey, slotId); 58834514f5e3Sopenharmony_ci } 58844514f5e3Sopenharmony_ci 58854514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 58864514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 58874514f5e3Sopenharmony_ci SET_ACC(res); 58884514f5e3Sopenharmony_ci DISPATCH(LDOBJBYVALUE_IMM8_V8); 58894514f5e3Sopenharmony_ci } 58904514f5e3Sopenharmony_ci } 58914514f5e3Sopenharmony_ci#endif 58924514f5e3Sopenharmony_ci // fast path 58934514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 58944514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByValue(thread, receiver, propKey); 58954514f5e3Sopenharmony_ci if (!res.IsHole()) { 58964514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 58974514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 58984514f5e3Sopenharmony_ci SET_ACC(res); 58994514f5e3Sopenharmony_ci DISPATCH(LDOBJBYVALUE_IMM8_V8); 59004514f5e3Sopenharmony_ci } 59014514f5e3Sopenharmony_ci } 59024514f5e3Sopenharmony_ci // slow path 59034514f5e3Sopenharmony_ci SAVE_PC(); 59044514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByValue(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 59054514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 59064514f5e3Sopenharmony_ci SET_ACC(res); 59074514f5e3Sopenharmony_ci DISPATCH(LDOBJBYVALUE_IMM8_V8); 59084514f5e3Sopenharmony_ci} 59094514f5e3Sopenharmony_ci 59104514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstricteqzImm16( 59114514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 59124514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 59134514f5e3Sopenharmony_ci{ 59144514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQZ_IMM16); 59154514f5e3Sopenharmony_ci} 59164514f5e3Sopenharmony_ci 59174514f5e3Sopenharmony_civoid InterpreterAssembly::HandleJstricteqzImm8( 59184514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 59194514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 59204514f5e3Sopenharmony_ci{ 59214514f5e3Sopenharmony_ci DISPATCH(JSTRICTEQZ_IMM8); 59224514f5e3Sopenharmony_ci} 59234514f5e3Sopenharmony_ci 59244514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefineclasswithbufferImm16Id16Id16Imm16V8( 59254514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 59264514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 59274514f5e3Sopenharmony_ci{ 59284514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_2(); 59294514f5e3Sopenharmony_ci uint16_t literaId = READ_INST_16(6); 59304514f5e3Sopenharmony_ci uint16_t length = READ_INST_16(8); 59314514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_8(); 59324514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::defineclasswithbuffer" 59334514f5e3Sopenharmony_ci << " method id:" << methodId << " lexenv: v" << v0; 59344514f5e3Sopenharmony_ci 59354514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 59364514f5e3Sopenharmony_ci JSTaggedValue proto = GET_VREG_VALUE(v0); 59374514f5e3Sopenharmony_ci 59384514f5e3Sopenharmony_ci SAVE_PC(); 59394514f5e3Sopenharmony_ci JSTaggedValue res = 59404514f5e3Sopenharmony_ci SlowRuntimeStub::CreateClassWithBuffer(thread, proto, state->env, GetConstantPool(sp), 59414514f5e3Sopenharmony_ci methodId, literaId, GetModule(sp), JSTaggedValue(length)); 59424514f5e3Sopenharmony_ci 59434514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 59444514f5e3Sopenharmony_ci ASSERT(res.IsClassConstructor()); 59454514f5e3Sopenharmony_ci 59464514f5e3Sopenharmony_ci SET_ACC(res); 59474514f5e3Sopenharmony_ci DISPATCH(DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8); 59484514f5e3Sopenharmony_ci} 59494514f5e3Sopenharmony_ci 59504514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefineclasswithbufferImm8Id16Id16Imm16V8( 59514514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 59524514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 59534514f5e3Sopenharmony_ci{ 59544514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_1(); 59554514f5e3Sopenharmony_ci uint16_t literaId = READ_INST_16_3(); 59564514f5e3Sopenharmony_ci uint16_t length = READ_INST_16_5(); 59574514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_7(); 59584514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::defineclasswithbuffer" 59594514f5e3Sopenharmony_ci << " method id:" << methodId << " lexenv: v" << v0; 59604514f5e3Sopenharmony_ci 59614514f5e3Sopenharmony_ci JSTaggedValue proto = GET_VREG_VALUE(v0); 59624514f5e3Sopenharmony_ci 59634514f5e3Sopenharmony_ci SAVE_PC(); 59644514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 59654514f5e3Sopenharmony_ci JSTaggedValue res = 59664514f5e3Sopenharmony_ci SlowRuntimeStub::CreateClassWithBuffer(thread, proto, state->env, GetConstantPool(sp), 59674514f5e3Sopenharmony_ci methodId, literaId, GetModule(sp), JSTaggedValue(length)); 59684514f5e3Sopenharmony_ci 59694514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 59704514f5e3Sopenharmony_ci ASSERT(res.IsClassConstructor()); 59714514f5e3Sopenharmony_ci 59724514f5e3Sopenharmony_ci SET_ACC(res); 59734514f5e3Sopenharmony_ci DISPATCH(DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8); 59744514f5e3Sopenharmony_ci} 59754514f5e3Sopenharmony_ci 59764514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideLdpatchvarPrefImm16( 59774514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 59784514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 59794514f5e3Sopenharmony_ci{ 59804514f5e3Sopenharmony_ci uint32_t index = READ_INST_16_1(); 59814514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldpatchvar" << " imm: " << index; 59824514f5e3Sopenharmony_ci 59834514f5e3Sopenharmony_ci SAVE_PC(); 59844514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdPatchVar(thread, index); 59854514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 59864514f5e3Sopenharmony_ci SET_ACC(res); 59874514f5e3Sopenharmony_ci DISPATCH(WIDE_LDPATCHVAR_PREF_IMM16); 59884514f5e3Sopenharmony_ci} 59894514f5e3Sopenharmony_ci 59904514f5e3Sopenharmony_civoid InterpreterAssembly::HandleWideStpatchvarPrefImm16( 59914514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 59924514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 59934514f5e3Sopenharmony_ci{ 59944514f5e3Sopenharmony_ci uint32_t index = READ_INST_16_1(); 59954514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stpatchvar" << " imm: " << index; 59964514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 59974514f5e3Sopenharmony_ci 59984514f5e3Sopenharmony_ci SAVE_ACC(); 59994514f5e3Sopenharmony_ci SAVE_PC(); 60004514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StPatchVar(thread, index, value); 60014514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 60024514f5e3Sopenharmony_ci RESTORE_ACC(); 60034514f5e3Sopenharmony_ci DISPATCH(WIDE_STPATCHVAR_PREF_IMM16); 60044514f5e3Sopenharmony_ci} 60054514f5e3Sopenharmony_ci 60064514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdPrivatePropertyImm8Imm16Imm16( 60074514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60084514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60094514f5e3Sopenharmony_ci{ 60104514f5e3Sopenharmony_ci DISPATCH(LDPRIVATEPROPERTY_IMM8_IMM16_IMM16); 60114514f5e3Sopenharmony_ci} 60124514f5e3Sopenharmony_ci 60134514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStPrivatePropertyImm8Imm16Imm16V8( 60144514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60154514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60164514f5e3Sopenharmony_ci{ 60174514f5e3Sopenharmony_ci DISPATCH(STPRIVATEPROPERTY_IMM8_IMM16_IMM16_V8); 60184514f5e3Sopenharmony_ci} 60194514f5e3Sopenharmony_ci 60204514f5e3Sopenharmony_civoid InterpreterAssembly::HandleTestInImm8Imm16Imm16( 60214514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60224514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60234514f5e3Sopenharmony_ci{ 60244514f5e3Sopenharmony_ci DISPATCH(TESTIN_IMM8_IMM16_IMM16); 60254514f5e3Sopenharmony_ci} 60264514f5e3Sopenharmony_ci 60274514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeNotifyConcurrentResultPrefNone( 60284514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60294514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60304514f5e3Sopenharmony_ci{ 60314514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE); 60324514f5e3Sopenharmony_ci} 60334514f5e3Sopenharmony_ci 60344514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefineFieldByNameImm8Id16V8( 60354514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60364514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60374514f5e3Sopenharmony_ci{ 60384514f5e3Sopenharmony_ci DISPATCH(DEFINEFIELDBYNAME_IMM8_ID16_V8); 60394514f5e3Sopenharmony_ci} 60404514f5e3Sopenharmony_ci 60414514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefinePropertyByNameImm8Id16V8( 60424514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60434514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60444514f5e3Sopenharmony_ci{ 60454514f5e3Sopenharmony_ci DISPATCH(DEFINEPROPERTYBYNAME_IMM8_ID16_V8); 60464514f5e3Sopenharmony_ci} 60474514f5e3Sopenharmony_ci 60484514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeDefineFieldByValuePrefImm8V8V8( 60494514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60504514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60514514f5e3Sopenharmony_ci{ 60524514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_DEFINEFIELDBYVALUE_PREF_IMM8_V8_V8); 60534514f5e3Sopenharmony_ci} 60544514f5e3Sopenharmony_ci 60554514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeDefineFieldByIndexPrefImm8Imm32V8( 60564514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60574514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60584514f5e3Sopenharmony_ci{ 60594514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_DEFINEFIELDBYINDEX_PREF_IMM8_IMM32_V8); 60604514f5e3Sopenharmony_ci} 60614514f5e3Sopenharmony_ci 60624514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeToPropertyKeyPrefNone( 60634514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60644514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60654514f5e3Sopenharmony_ci{ 60664514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_TOPROPERTYKEY_PREF_NONE); 60674514f5e3Sopenharmony_ci} 60684514f5e3Sopenharmony_ci 60694514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeCreatePrivatePropertyPrefImm16Id16( 60704514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60714514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60724514f5e3Sopenharmony_ci{ 60734514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_CREATEPRIVATEPROPERTY_PREF_IMM16_ID16); 60744514f5e3Sopenharmony_ci} 60754514f5e3Sopenharmony_ci 60764514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeDefinePrivatePropertyPrefImm8Imm16Imm16V8( 60774514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60784514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60794514f5e3Sopenharmony_ci{ 60804514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_DEFINEPRIVATEPROPERTY_PREF_IMM8_IMM16_IMM16_V8); 60814514f5e3Sopenharmony_ci} 60824514f5e3Sopenharmony_ci 60834514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeCallInitPrefImm8V8( 60844514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60854514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60864514f5e3Sopenharmony_ci{ 60874514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_CALLINIT_PREF_IMM8_V8); 60884514f5e3Sopenharmony_ci} 60894514f5e3Sopenharmony_ci 60904514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeDefineSendableClassPrefImm16Id16Id16Imm16V8( 60914514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 60924514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 60934514f5e3Sopenharmony_ci{ 60944514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_3(); 60954514f5e3Sopenharmony_ci uint16_t literaId = READ_INST_16_5(); 60964514f5e3Sopenharmony_ci uint16_t length = READ_INST_16_7(); 60974514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_9(); 60984514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::definesendableclass" 60994514f5e3Sopenharmony_ci << " method id:" << methodId << " base: v" << v0; 61004514f5e3Sopenharmony_ci 61014514f5e3Sopenharmony_ci JSTaggedValue base = GET_VREG_VALUE(v0); 61024514f5e3Sopenharmony_ci 61034514f5e3Sopenharmony_ci SAVE_PC(); 61044514f5e3Sopenharmony_ci JSTaggedValue res = 61054514f5e3Sopenharmony_ci SlowRuntimeStub::CreateSharedClass(thread, base, GetConstantPool(sp), methodId, literaId, 61064514f5e3Sopenharmony_ci length, GetModule(sp)); 61074514f5e3Sopenharmony_ci 61084514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 61094514f5e3Sopenharmony_ci ASSERT(res.IsClassConstructor()); 61104514f5e3Sopenharmony_ci ASSERT(res.IsJSSharedFunction()); 61114514f5e3Sopenharmony_ci SET_ACC(res); 61124514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_DEFINESENDABLECLASS_PREF_IMM16_ID16_ID16_IMM16_V8); 61134514f5e3Sopenharmony_ci} 61144514f5e3Sopenharmony_ci 61154514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdSendableClassPrefImm16( 61164514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 61174514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 61184514f5e3Sopenharmony_ci{ 61194514f5e3Sopenharmony_ci uint16_t level = READ_INST_16_1(); 61204514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::LdSendableClass level: " << level; 61214514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 61224514f5e3Sopenharmony_ci auto res = SlowRuntimeStub::LdSendableClass(thread, state->env, level); 61234514f5e3Sopenharmony_ci ASSERT(res.IsJSSharedFunction()); 61244514f5e3Sopenharmony_ci SET_ACC(res); 61254514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_LDSENDABLECLASS_PREF_IMM16); 61264514f5e3Sopenharmony_ci} 61274514f5e3Sopenharmony_ci 61284514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStthisbyvalueImm16V8( 61294514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 61304514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 61314514f5e3Sopenharmony_ci{ 61324514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_2(); 61334514f5e3Sopenharmony_ci 61344514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stthisbyvalue" 61354514f5e3Sopenharmony_ci << " v" << v0; 61364514f5e3Sopenharmony_ci 61374514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 61384514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 61394514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 61404514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 61414514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 61424514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 61434514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v0); 61444514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 61454514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 61464514f5e3Sopenharmony_ci SAVE_ACC(); 61474514f5e3Sopenharmony_ci 61484514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 61494514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 61504514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByValue(thread, receiver, propKey, firstValue, secondValue, value); 61514514f5e3Sopenharmony_ci } 61524514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 61534514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 61544514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByValue(thread, 61554514f5e3Sopenharmony_ci profileTypeArray, 61564514f5e3Sopenharmony_ci receiver, propKey, value, slotId); 61574514f5e3Sopenharmony_ci } 61584514f5e3Sopenharmony_ci 61594514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 61604514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 61614514f5e3Sopenharmony_ci RESTORE_ACC(); 61624514f5e3Sopenharmony_ci DISPATCH(STTHISBYVALUE_IMM16_V8); 61634514f5e3Sopenharmony_ci } 61644514f5e3Sopenharmony_ci } 61654514f5e3Sopenharmony_ci#endif 61664514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 61674514f5e3Sopenharmony_ci SAVE_ACC(); 61684514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v0); 61694514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 61704514f5e3Sopenharmony_ci // fast path 61714514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue(thread, receiver, propKey, value); 61724514f5e3Sopenharmony_ci if (!res.IsHole()) { 61734514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 61744514f5e3Sopenharmony_ci RESTORE_ACC(); 61754514f5e3Sopenharmony_ci DISPATCH(STTHISBYVALUE_IMM16_V8); 61764514f5e3Sopenharmony_ci } 61774514f5e3Sopenharmony_ci RESTORE_ACC(); 61784514f5e3Sopenharmony_ci } 61794514f5e3Sopenharmony_ci { 61804514f5e3Sopenharmony_ci // slow path 61814514f5e3Sopenharmony_ci SAVE_ACC(); 61824514f5e3Sopenharmony_ci receiver = GetThis(sp); // Maybe moved by GC 61834514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v0); // Maybe moved by GC 61844514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 61854514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByValue(thread, receiver, propKey, value); 61864514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 61874514f5e3Sopenharmony_ci RESTORE_ACC(); 61884514f5e3Sopenharmony_ci } 61894514f5e3Sopenharmony_ci DISPATCH(STTHISBYVALUE_IMM16_V8); 61904514f5e3Sopenharmony_ci} 61914514f5e3Sopenharmony_ci 61924514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStthisbyvalueImm8V8( 61934514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 61944514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 61954514f5e3Sopenharmony_ci{ 61964514f5e3Sopenharmony_ci uint32_t v0 = READ_INST_8_1(); 61974514f5e3Sopenharmony_ci 61984514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stthisbyvalue" 61994514f5e3Sopenharmony_ci << " v" << v0; 62004514f5e3Sopenharmony_ci 62014514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 62024514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 62034514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 62044514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 62054514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 62064514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 62074514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v0); 62084514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 62094514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 62104514f5e3Sopenharmony_ci SAVE_ACC(); 62114514f5e3Sopenharmony_ci 62124514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 62134514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 62144514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByValue(thread, receiver, propKey, firstValue, secondValue, value); 62154514f5e3Sopenharmony_ci } 62164514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 62174514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 62184514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByValue(thread, 62194514f5e3Sopenharmony_ci profileTypeArray, 62204514f5e3Sopenharmony_ci receiver, propKey, value, slotId); 62214514f5e3Sopenharmony_ci } 62224514f5e3Sopenharmony_ci 62234514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 62244514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 62254514f5e3Sopenharmony_ci RESTORE_ACC(); 62264514f5e3Sopenharmony_ci DISPATCH(STTHISBYVALUE_IMM8_V8); 62274514f5e3Sopenharmony_ci } 62284514f5e3Sopenharmony_ci } 62294514f5e3Sopenharmony_ci#endif 62304514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 62314514f5e3Sopenharmony_ci SAVE_ACC(); 62324514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v0); 62334514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 62344514f5e3Sopenharmony_ci // fast path 62354514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByValue(thread, receiver, propKey, value); 62364514f5e3Sopenharmony_ci if (!res.IsHole()) { 62374514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 62384514f5e3Sopenharmony_ci RESTORE_ACC(); 62394514f5e3Sopenharmony_ci DISPATCH(STTHISBYVALUE_IMM8_V8); 62404514f5e3Sopenharmony_ci } 62414514f5e3Sopenharmony_ci RESTORE_ACC(); 62424514f5e3Sopenharmony_ci } 62434514f5e3Sopenharmony_ci { 62444514f5e3Sopenharmony_ci // slow path 62454514f5e3Sopenharmony_ci SAVE_ACC(); 62464514f5e3Sopenharmony_ci receiver = GetThis(sp); // Maybe moved by GC 62474514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_VREG_VALUE(v0); // Maybe moved by GC 62484514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 62494514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByValue(thread, receiver, propKey, value); 62504514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 62514514f5e3Sopenharmony_ci RESTORE_ACC(); 62524514f5e3Sopenharmony_ci } 62534514f5e3Sopenharmony_ci DISPATCH(STTHISBYVALUE_IMM8_V8); 62544514f5e3Sopenharmony_ci} 62554514f5e3Sopenharmony_ci 62564514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdthisbyvalueImm16( 62574514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 62584514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 62594514f5e3Sopenharmony_ci{ 62604514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldthisbyvalue"; 62614514f5e3Sopenharmony_ci 62624514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 62634514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_ACC(); 62644514f5e3Sopenharmony_ci 62654514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 62664514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 62674514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 62684514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 62694514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 62704514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 62714514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 62724514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 62734514f5e3Sopenharmony_ci 62744514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 62754514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 62764514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByValue(thread, receiver, propKey, firstValue, secondValue); 62774514f5e3Sopenharmony_ci } 62784514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 62794514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 62804514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByValue(thread, 62814514f5e3Sopenharmony_ci profileTypeArray, 62824514f5e3Sopenharmony_ci receiver, propKey, slotId); 62834514f5e3Sopenharmony_ci } 62844514f5e3Sopenharmony_ci 62854514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 62864514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 62874514f5e3Sopenharmony_ci SET_ACC(res); 62884514f5e3Sopenharmony_ci DISPATCH(LDTHISBYVALUE_IMM16); 62894514f5e3Sopenharmony_ci } 62904514f5e3Sopenharmony_ci } 62914514f5e3Sopenharmony_ci#endif 62924514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 62934514f5e3Sopenharmony_ci // fast path 62944514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByValue(thread, receiver, propKey); 62954514f5e3Sopenharmony_ci if (!res.IsHole()) { 62964514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 62974514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 62984514f5e3Sopenharmony_ci SET_ACC(res); 62994514f5e3Sopenharmony_ci DISPATCH(LDTHISBYVALUE_IMM16); 63004514f5e3Sopenharmony_ci } 63014514f5e3Sopenharmony_ci } 63024514f5e3Sopenharmony_ci // slow path 63034514f5e3Sopenharmony_ci SAVE_PC(); 63044514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByValue(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 63054514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 63064514f5e3Sopenharmony_ci SET_ACC(res); 63074514f5e3Sopenharmony_ci DISPATCH(LDTHISBYVALUE_IMM16); 63084514f5e3Sopenharmony_ci} 63094514f5e3Sopenharmony_ci 63104514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdthisbyvalueImm8( 63114514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 63124514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 63134514f5e3Sopenharmony_ci{ 63144514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::Ldthisbyvalue"; 63154514f5e3Sopenharmony_ci 63164514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 63174514f5e3Sopenharmony_ci JSTaggedValue propKey = GET_ACC(); 63184514f5e3Sopenharmony_ci 63194514f5e3Sopenharmony_ci#if ECMSCRIPT_ENABLE_IC 63204514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 63214514f5e3Sopenharmony_ci auto tmpProfileTypeInfo = state->profileTypeInfo; 63224514f5e3Sopenharmony_ci if (!tmpProfileTypeInfo.IsUndefined()) { 63234514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 63244514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(tmpProfileTypeInfo.GetTaggedObject()); 63254514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 63264514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 63274514f5e3Sopenharmony_ci 63284514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 63294514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 63304514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByValue(thread, receiver, propKey, firstValue, secondValue); 63314514f5e3Sopenharmony_ci } 63324514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 63334514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 63344514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByValue(thread, 63354514f5e3Sopenharmony_ci profileTypeArray, 63364514f5e3Sopenharmony_ci receiver, propKey, slotId); 63374514f5e3Sopenharmony_ci } 63384514f5e3Sopenharmony_ci 63394514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 63404514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 63414514f5e3Sopenharmony_ci SET_ACC(res); 63424514f5e3Sopenharmony_ci DISPATCH(LDTHISBYVALUE_IMM8); 63434514f5e3Sopenharmony_ci } 63444514f5e3Sopenharmony_ci } 63454514f5e3Sopenharmony_ci#endif 63464514f5e3Sopenharmony_ci // fast path 63474514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 63484514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByValue(thread, receiver, propKey); 63494514f5e3Sopenharmony_ci if (!res.IsHole()) { 63504514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 63514514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 63524514f5e3Sopenharmony_ci SET_ACC(res); 63534514f5e3Sopenharmony_ci DISPATCH(LDTHISBYVALUE_IMM8); 63544514f5e3Sopenharmony_ci } 63554514f5e3Sopenharmony_ci } 63564514f5e3Sopenharmony_ci // slow path 63574514f5e3Sopenharmony_ci SAVE_PC(); 63584514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByValue(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 63594514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 63604514f5e3Sopenharmony_ci SET_ACC(res); 63614514f5e3Sopenharmony_ci DISPATCH(LDTHISBYVALUE_IMM8); 63624514f5e3Sopenharmony_ci} 63634514f5e3Sopenharmony_ci 63644514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStthisbynameImm16Id16( 63654514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 63664514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 63674514f5e3Sopenharmony_ci{ 63684514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 63694514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 63704514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 63714514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 63724514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 63734514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 63744514f5e3Sopenharmony_ci SAVE_ACC(); 63754514f5e3Sopenharmony_ci 63764514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 63774514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 63784514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 63794514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 63804514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByName(thread, receiver, firstValue, secondValue, value); 63814514f5e3Sopenharmony_ci } 63824514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 63834514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 63844514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 63854514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 63864514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 63874514f5e3Sopenharmony_ci RESTORE_ACC(); 63884514f5e3Sopenharmony_ci value = GET_ACC(); 63894514f5e3Sopenharmony_ci receiver = GetThis(sp); 63904514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(GetProfileTypeInfo(sp).GetTaggedObject()); 63914514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByName(thread, profileTypeArray, receiver, propKey, value, slotId); 63924514f5e3Sopenharmony_ci } 63934514f5e3Sopenharmony_ci 63944514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 63954514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 63964514f5e3Sopenharmony_ci RESTORE_ACC(); 63974514f5e3Sopenharmony_ci DISPATCH(STTHISBYNAME_IMM16_ID16); 63984514f5e3Sopenharmony_ci } 63994514f5e3Sopenharmony_ci RESTORE_ACC(); 64004514f5e3Sopenharmony_ci } 64014514f5e3Sopenharmony_ci#endif 64024514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 64034514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stthisbyname " 64044514f5e3Sopenharmony_ci << " stringId:" << stringId; 64054514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 64064514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 64074514f5e3Sopenharmony_ci SAVE_ACC(); 64084514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 64094514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 64104514f5e3Sopenharmony_ci RESTORE_ACC(); 64114514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 64124514f5e3Sopenharmony_ci receiver = GetThis(sp); 64134514f5e3Sopenharmony_ci // fast path 64144514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName(thread, receiver, propKey, value); 64154514f5e3Sopenharmony_ci if (!res.IsHole()) { 64164514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 64174514f5e3Sopenharmony_ci RESTORE_ACC(); 64184514f5e3Sopenharmony_ci DISPATCH(STTHISBYNAME_IMM16_ID16); 64194514f5e3Sopenharmony_ci } 64204514f5e3Sopenharmony_ci RESTORE_ACC(); 64214514f5e3Sopenharmony_ci } 64224514f5e3Sopenharmony_ci // slow path 64234514f5e3Sopenharmony_ci SAVE_ACC(); 64244514f5e3Sopenharmony_ci SAVE_PC(); 64254514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 64264514f5e3Sopenharmony_ci auto propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); // Maybe moved by GC 64274514f5e3Sopenharmony_ci RESTORE_ACC(); 64284514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 64294514f5e3Sopenharmony_ci receiver = GetThis(sp); // Maybe moved by GC 64304514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByName(thread, receiver, propKey, value); 64314514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 64324514f5e3Sopenharmony_ci RESTORE_ACC(); 64334514f5e3Sopenharmony_ci DISPATCH(STTHISBYNAME_IMM16_ID16); 64344514f5e3Sopenharmony_ci} 64354514f5e3Sopenharmony_ci 64364514f5e3Sopenharmony_civoid InterpreterAssembly::HandleStthisbynameImm8Id16( 64374514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 64384514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 64394514f5e3Sopenharmony_ci{ 64404514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 64414514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 64424514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 64434514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 64444514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 64454514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 64464514f5e3Sopenharmony_ci SAVE_ACC(); 64474514f5e3Sopenharmony_ci 64484514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 64494514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 64504514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 64514514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 64524514f5e3Sopenharmony_ci res = ICRuntimeStub::TryStoreICByName(thread, receiver, firstValue, secondValue, value); 64534514f5e3Sopenharmony_ci } 64544514f5e3Sopenharmony_ci // IC miss and not enter the megamorphic state, store as polymorphic 64554514f5e3Sopenharmony_ci if (res.IsHole() && !firstValue.IsHole()) { 64564514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 64574514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 64584514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 64594514f5e3Sopenharmony_ci RESTORE_ACC(); 64604514f5e3Sopenharmony_ci value = GET_ACC(); 64614514f5e3Sopenharmony_ci receiver = GetThis(sp); 64624514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(GetProfileTypeInfo(sp).GetTaggedObject()); 64634514f5e3Sopenharmony_ci res = ICRuntimeStub::StoreICByName(thread, profileTypeArray, receiver, propKey, value, slotId); 64644514f5e3Sopenharmony_ci } 64654514f5e3Sopenharmony_ci 64664514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 64674514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 64684514f5e3Sopenharmony_ci RESTORE_ACC(); 64694514f5e3Sopenharmony_ci DISPATCH(STTHISBYNAME_IMM8_ID16); 64704514f5e3Sopenharmony_ci } 64714514f5e3Sopenharmony_ci RESTORE_ACC(); 64724514f5e3Sopenharmony_ci } 64734514f5e3Sopenharmony_ci#endif 64744514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 64754514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stthisbyname " 64764514f5e3Sopenharmony_ci << " stringId:" << stringId; 64774514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 64784514f5e3Sopenharmony_ci if (receiver.IsHeapObject()) { 64794514f5e3Sopenharmony_ci SAVE_ACC(); 64804514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 64814514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 64824514f5e3Sopenharmony_ci RESTORE_ACC(); 64834514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 64844514f5e3Sopenharmony_ci receiver = GetThis(sp); 64854514f5e3Sopenharmony_ci // fast path 64864514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::SetPropertyByName(thread, receiver, propKey, value); 64874514f5e3Sopenharmony_ci if (!res.IsHole()) { 64884514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 64894514f5e3Sopenharmony_ci RESTORE_ACC(); 64904514f5e3Sopenharmony_ci DISPATCH(STTHISBYNAME_IMM8_ID16); 64914514f5e3Sopenharmony_ci } 64924514f5e3Sopenharmony_ci RESTORE_ACC(); 64934514f5e3Sopenharmony_ci } 64944514f5e3Sopenharmony_ci // slow path 64954514f5e3Sopenharmony_ci SAVE_ACC(); 64964514f5e3Sopenharmony_ci SAVE_PC(); 64974514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 64984514f5e3Sopenharmony_ci auto propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); // Maybe moved by GC 64994514f5e3Sopenharmony_ci RESTORE_ACC(); 65004514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); // Maybe moved by GC 65014514f5e3Sopenharmony_ci receiver = GetThis(sp); // Maybe moved by GC 65024514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::StObjByName(thread, receiver, propKey, value); 65034514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65044514f5e3Sopenharmony_ci RESTORE_ACC(); 65054514f5e3Sopenharmony_ci DISPATCH(STTHISBYNAME_IMM8_ID16); 65064514f5e3Sopenharmony_ci} 65074514f5e3Sopenharmony_ci 65084514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdthisbynameImm16Id16( 65094514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 65104514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 65114514f5e3Sopenharmony_ci{ 65124514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 65134514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 65144514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_16_0(); 65154514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 65164514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 65174514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 65184514f5e3Sopenharmony_ci 65194514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 65204514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 65214514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 65224514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByName(thread, receiver, firstValue, secondValue); 65234514f5e3Sopenharmony_ci } 65244514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 65254514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65264514f5e3Sopenharmony_ci SET_ACC(res); 65274514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM16_ID16); 65284514f5e3Sopenharmony_ci } else if (!firstValue.IsHole()) { // IC miss and not enter the megamorphic state, store as polymorphic 65294514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 65304514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 65314514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 65324514f5e3Sopenharmony_ci receiver = GetThis(sp); 65334514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(GetProfileTypeInfo(sp).GetTaggedObject()); 65344514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByName(thread, 65354514f5e3Sopenharmony_ci profileTypeArray, 65364514f5e3Sopenharmony_ci receiver, propKey, slotId); 65374514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65384514f5e3Sopenharmony_ci SET_ACC(res); 65394514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM16_ID16); 65404514f5e3Sopenharmony_ci } 65414514f5e3Sopenharmony_ci } 65424514f5e3Sopenharmony_ci#endif 65434514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 65444514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 65454514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 65464514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 65474514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldthisbyname stringId:" << stringId << ", " 65484514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << receiver.GetRawData(); 65494514f5e3Sopenharmony_ci 65504514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 65514514f5e3Sopenharmony_ci // fast path 65524514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByName(thread, receiver, propKey); 65534514f5e3Sopenharmony_ci if (!res.IsHole()) { 65544514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 65554514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65564514f5e3Sopenharmony_ci SET_ACC(res); 65574514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM16_ID16); 65584514f5e3Sopenharmony_ci } 65594514f5e3Sopenharmony_ci } 65604514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 65614514f5e3Sopenharmony_ci // slow stub not need receiver 65624514f5e3Sopenharmony_ci SAVE_PC(); 65634514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByName(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 65644514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65654514f5e3Sopenharmony_ci SET_ACC(res); 65664514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM16_ID16); 65674514f5e3Sopenharmony_ci} 65684514f5e3Sopenharmony_ci 65694514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdthisbynameImm8Id16( 65704514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 65714514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 65724514f5e3Sopenharmony_ci{ 65734514f5e3Sopenharmony_ci#if ECMASCRIPT_ENABLE_IC 65744514f5e3Sopenharmony_ci if (!profileTypeInfo.IsUndefined()) { 65754514f5e3Sopenharmony_ci uint16_t slotId = READ_INST_8_0(); 65764514f5e3Sopenharmony_ci auto profileTypeArray = ProfileTypeInfo::Cast(profileTypeInfo.GetTaggedObject()); 65774514f5e3Sopenharmony_ci JSTaggedValue firstValue = profileTypeArray->Get(slotId); 65784514f5e3Sopenharmony_ci JSTaggedValue res = JSTaggedValue::Hole(); 65794514f5e3Sopenharmony_ci 65804514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 65814514f5e3Sopenharmony_ci if (LIKELY(firstValue.IsHeapObject())) { 65824514f5e3Sopenharmony_ci JSTaggedValue secondValue = profileTypeArray->Get(slotId + 1); 65834514f5e3Sopenharmony_ci res = ICRuntimeStub::TryLoadICByName(thread, receiver, firstValue, secondValue); 65844514f5e3Sopenharmony_ci } 65854514f5e3Sopenharmony_ci if (LIKELY(!res.IsHole())) { 65864514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65874514f5e3Sopenharmony_ci SET_ACC(res); 65884514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM8_ID16); 65894514f5e3Sopenharmony_ci } else if (!firstValue.IsHole()) { // IC miss and not enter the megamorphic state, store as polymorphic 65904514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 65914514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 65924514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 65934514f5e3Sopenharmony_ci receiver = GetThis(sp); 65944514f5e3Sopenharmony_ci profileTypeArray = ProfileTypeInfo::Cast(GetProfileTypeInfo(sp).GetTaggedObject()); 65954514f5e3Sopenharmony_ci res = ICRuntimeStub::LoadICByName(thread, 65964514f5e3Sopenharmony_ci profileTypeArray, 65974514f5e3Sopenharmony_ci receiver, propKey, slotId); 65984514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 65994514f5e3Sopenharmony_ci SET_ACC(res); 66004514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM8_ID16); 66014514f5e3Sopenharmony_ci } 66024514f5e3Sopenharmony_ci } 66034514f5e3Sopenharmony_ci#endif 66044514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_1(); 66054514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 66064514f5e3Sopenharmony_ci JSTaggedValue propKey = ConstantPool::Cast(constpool.GetTaggedObject())->GetObjectFromCache(stringId); 66074514f5e3Sopenharmony_ci JSTaggedValue receiver = GetThis(sp); 66084514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldthisbyname stringId:" << stringId << ", " 66094514f5e3Sopenharmony_ci << ConvertToString(EcmaString::Cast(propKey.GetTaggedObject())) << ", obj:" << receiver.GetRawData(); 66104514f5e3Sopenharmony_ci 66114514f5e3Sopenharmony_ci if (LIKELY(receiver.IsHeapObject())) { 66124514f5e3Sopenharmony_ci // fast path 66134514f5e3Sopenharmony_ci JSTaggedValue res = FastRuntimeStub::GetPropertyByName(thread, receiver, propKey); 66144514f5e3Sopenharmony_ci if (!res.IsHole()) { 66154514f5e3Sopenharmony_ci ASSERT(!res.IsAccessor()); 66164514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 66174514f5e3Sopenharmony_ci SET_ACC(res); 66184514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM8_ID16); 66194514f5e3Sopenharmony_ci } 66204514f5e3Sopenharmony_ci } 66214514f5e3Sopenharmony_ci // not meet fast condition or fast path return hole, walk slow path 66224514f5e3Sopenharmony_ci // slow stub not need receiver 66234514f5e3Sopenharmony_ci SAVE_PC(); 66244514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::LdObjByName(thread, receiver, propKey, false, JSTaggedValue::Undefined()); 66254514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 66264514f5e3Sopenharmony_ci SET_ACC(res); 66274514f5e3Sopenharmony_ci DISPATCH(LDTHISBYNAME_IMM8_ID16); 66284514f5e3Sopenharmony_ci} 66294514f5e3Sopenharmony_ci 66304514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdexternalmodulevarImm8( 66314514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 66324514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 66334514f5e3Sopenharmony_ci{ 66344514f5e3Sopenharmony_ci int32_t index = READ_INST_8_0(); 66354514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldmodulevar index:" << index; 66364514f5e3Sopenharmony_ci 66374514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdExternalModuleVar(thread, index); 66384514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 66394514f5e3Sopenharmony_ci SET_ACC(moduleVar); 66404514f5e3Sopenharmony_ci DISPATCH(LDEXTERNALMODULEVAR_IMM8); 66414514f5e3Sopenharmony_ci} 66424514f5e3Sopenharmony_ci 66434514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdsendableexternalmodulevarImm8( 66444514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 66454514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 66464514f5e3Sopenharmony_ci{ 66474514f5e3Sopenharmony_ci int32_t index = READ_INST_8_1(); 66484514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 66494514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsendableexternalmodulevar index:" << index; 66504514f5e3Sopenharmony_ci 66514514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdSendableExternalModuleVar(thread, index, thisFunc); 66524514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 66534514f5e3Sopenharmony_ci SET_ACC(moduleVar); 66544514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_LDSENDABLEEXTERNALMODULEVAR_PREF_IMM8); 66554514f5e3Sopenharmony_ci} 66564514f5e3Sopenharmony_ci 66574514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeNewSendableEnvImm8( 66584514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 66594514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 66604514f5e3Sopenharmony_ci{ 66614514f5e3Sopenharmony_ci uint8_t numVars = READ_INST_8_1(); 66624514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newsendableenv" 66634514f5e3Sopenharmony_ci << " imm " << numVars; 66644514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewSendableEnv(thread, numVars); 66654514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 66664514f5e3Sopenharmony_ci SET_ACC(res); 66674514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 66684514f5e3Sopenharmony_ci moduleRecord->SetSendableEnv(thread, res); 66694514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_NEWSENDABLEENV_PREF_IMM8); 66704514f5e3Sopenharmony_ci} 66714514f5e3Sopenharmony_ci 66724514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeNewSendableEnvImm16( 66734514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 66744514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 66754514f5e3Sopenharmony_ci{ 66764514f5e3Sopenharmony_ci uint16_t numVars = READ_INST_16_1(); 66774514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newsendableenv" 66784514f5e3Sopenharmony_ci << " imm " << numVars; 66794514f5e3Sopenharmony_ci 66804514f5e3Sopenharmony_ci SAVE_PC(); 66814514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewSendableEnv(thread, numVars); 66824514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 66834514f5e3Sopenharmony_ci SET_ACC(res); 66844514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 66854514f5e3Sopenharmony_ci moduleRecord->SetSendableEnv(thread, res); 66864514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_WIDENEWSENDABLEENV_PREF_IMM16); 66874514f5e3Sopenharmony_ci} 66884514f5e3Sopenharmony_ci 66894514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeStSendableVarImm4Imm4( 66904514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 66914514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 66924514f5e3Sopenharmony_ci{ 66934514f5e3Sopenharmony_ci uint16_t level = READ_INST_4_2(); 66944514f5e3Sopenharmony_ci uint16_t slot = READ_INST_4_3(); 66954514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsendablevar" 66964514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 66974514f5e3Sopenharmony_ci 66984514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 66994514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 67004514f5e3Sopenharmony_ci JSTaggedValue env = moduleRecord->GetSendableEnv(); 67014514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 67024514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 67034514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 67044514f5e3Sopenharmony_ci env = taggedParentEnv; 67054514f5e3Sopenharmony_ci } 67064514f5e3Sopenharmony_ci SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 67074514f5e3Sopenharmony_ci 67084514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM4_IMM4); 67094514f5e3Sopenharmony_ci} 67104514f5e3Sopenharmony_ci 67114514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeStSendableVarImm8Imm8( 67124514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 67134514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 67144514f5e3Sopenharmony_ci{ 67154514f5e3Sopenharmony_ci uint16_t level = READ_INST_8_1(); 67164514f5e3Sopenharmony_ci uint16_t slot = READ_INST_8_2(); 67174514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsendablevar" 67184514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 67194514f5e3Sopenharmony_ci 67204514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 67214514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 67224514f5e3Sopenharmony_ci JSTaggedValue env = moduleRecord->GetSendableEnv(); 67234514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 67244514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 67254514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 67264514f5e3Sopenharmony_ci env = taggedParentEnv; 67274514f5e3Sopenharmony_ci } 67284514f5e3Sopenharmony_ci SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 67294514f5e3Sopenharmony_ci 67304514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_STSENDABLEVAR_PREF_IMM8_IMM8); 67314514f5e3Sopenharmony_ci} 67324514f5e3Sopenharmony_ci 67334514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeStSendableVarImm16Imm16( 67344514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 67354514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 67364514f5e3Sopenharmony_ci{ 67374514f5e3Sopenharmony_ci uint16_t level = READ_INST_16_1(); 67384514f5e3Sopenharmony_ci uint16_t slot = READ_INST_16_3(); 67394514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::stsendablevar" 67404514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 67414514f5e3Sopenharmony_ci 67424514f5e3Sopenharmony_ci JSTaggedValue value = GET_ACC(); 67434514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 67444514f5e3Sopenharmony_ci JSTaggedValue env = moduleRecord->GetSendableEnv(); 67454514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 67464514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 67474514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 67484514f5e3Sopenharmony_ci env = taggedParentEnv; 67494514f5e3Sopenharmony_ci } 67504514f5e3Sopenharmony_ci SendableEnv::Cast(env.GetTaggedObject())->SetProperties(thread, slot, value); 67514514f5e3Sopenharmony_ci 67524514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_WIDESTSENDABLEVAR_PREF_IMM16_IMM16); 67534514f5e3Sopenharmony_ci} 67544514f5e3Sopenharmony_ci 67554514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdSendableVarImm4Imm4( 67564514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 67574514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 67584514f5e3Sopenharmony_ci{ 67594514f5e3Sopenharmony_ci uint16_t level = READ_INST_4_2(); 67604514f5e3Sopenharmony_ci uint16_t slot = READ_INST_4_3(); 67614514f5e3Sopenharmony_ci 67624514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsendablevar" 67634514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 67644514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 67654514f5e3Sopenharmony_ci JSTaggedValue env = moduleRecord->GetSendableEnv(); 67664514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 67674514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 67684514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 67694514f5e3Sopenharmony_ci env = taggedParentEnv; 67704514f5e3Sopenharmony_ci } 67714514f5e3Sopenharmony_ci SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot)); 67724514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM4_IMM4); 67734514f5e3Sopenharmony_ci} 67744514f5e3Sopenharmony_ci 67754514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdSendableVarImm8Imm8( 67764514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 67774514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 67784514f5e3Sopenharmony_ci{ 67794514f5e3Sopenharmony_ci uint16_t level = READ_INST_8_1(); 67804514f5e3Sopenharmony_ci uint16_t slot = READ_INST_8_2(); 67814514f5e3Sopenharmony_ci 67824514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsendablevar" 67834514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 67844514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 67854514f5e3Sopenharmony_ci JSTaggedValue env = moduleRecord->GetSendableEnv(); 67864514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 67874514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 67884514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 67894514f5e3Sopenharmony_ci env = taggedParentEnv; 67904514f5e3Sopenharmony_ci } 67914514f5e3Sopenharmony_ci SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot)); 67924514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_LDSENDABLEVAR_PREF_IMM8_IMM8); 67934514f5e3Sopenharmony_ci} 67944514f5e3Sopenharmony_ci 67954514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdSendableVarImm16Imm16( 67964514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 67974514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 67984514f5e3Sopenharmony_ci{ 67994514f5e3Sopenharmony_ci uint16_t level = READ_INST_16_1(); 68004514f5e3Sopenharmony_ci uint16_t slot = READ_INST_16_3(); 68014514f5e3Sopenharmony_ci 68024514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldsendablevar" 68034514f5e3Sopenharmony_ci << " level:" << level << " slot:" << slot; 68044514f5e3Sopenharmony_ci SourceTextModule *moduleRecord = SourceTextModule::Cast(GetModule(sp)); 68054514f5e3Sopenharmony_ci JSTaggedValue env = moduleRecord->GetSendableEnv(); 68064514f5e3Sopenharmony_ci for (uint32_t i = 0; i < level; i++) { 68074514f5e3Sopenharmony_ci JSTaggedValue taggedParentEnv = SendableEnv::Cast(env.GetTaggedObject())->GetParentEnv(); 68084514f5e3Sopenharmony_ci ASSERT(!taggedParentEnv.IsUndefined()); 68094514f5e3Sopenharmony_ci env = taggedParentEnv; 68104514f5e3Sopenharmony_ci } 68114514f5e3Sopenharmony_ci SET_ACC(SendableEnv::Cast(env.GetTaggedObject())->GetProperties(slot)); 68124514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_WIDELDSENDABLEVAR_PREF_IMM16_IMM16); 68134514f5e3Sopenharmony_ci} 68144514f5e3Sopenharmony_ci 68154514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefinemethodImm16Id16Imm8( 68164514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68174514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68184514f5e3Sopenharmony_ci{ 68194514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_2(); 68204514f5e3Sopenharmony_ci uint16_t length = READ_INST_8_4(); 68214514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::definemethod length: " << length; 68224514f5e3Sopenharmony_ci SAVE_ACC(); 68234514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 68244514f5e3Sopenharmony_ci Method *method = 68254514f5e3Sopenharmony_ci Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, methodId).GetTaggedObject()); 68264514f5e3Sopenharmony_ci ASSERT(method != nullptr); 68274514f5e3Sopenharmony_ci RESTORE_ACC(); 68284514f5e3Sopenharmony_ci 68294514f5e3Sopenharmony_ci SAVE_PC(); 68304514f5e3Sopenharmony_ci JSTaggedValue homeObject = GET_ACC(); 68314514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 68324514f5e3Sopenharmony_ci JSTaggedValue taggedCurEnv = state->env; 68334514f5e3Sopenharmony_ci 68344514f5e3Sopenharmony_ci auto res = SlowRuntimeStub::DefineMethod(thread, method, homeObject, length, taggedCurEnv, GetModule(sp)); 68354514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 68364514f5e3Sopenharmony_ci JSFunction *result = JSFunction::Cast(res.GetTaggedObject()); 68374514f5e3Sopenharmony_ci 68384514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(result)); 68394514f5e3Sopenharmony_ci DISPATCH(DEFINEMETHOD_IMM16_ID16_IMM8); 68404514f5e3Sopenharmony_ci} 68414514f5e3Sopenharmony_ci 68424514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedCallrangePrefImm16V8( 68434514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68444514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68454514f5e3Sopenharmony_ci{ 68464514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_CALLRANGE_PREF_IMM16_V8); 68474514f5e3Sopenharmony_ci} 68484514f5e3Sopenharmony_ci 68494514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallrangeImm8Imm8V8( 68504514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68514514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68524514f5e3Sopenharmony_ci{ 68534514f5e3Sopenharmony_ci DISPATCH(CALLRANGE_IMM8_IMM8_V8); 68544514f5e3Sopenharmony_ci} 68554514f5e3Sopenharmony_ci 68564514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDynamicimport( 68574514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68584514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68594514f5e3Sopenharmony_ci{ 68604514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::dynamicimport"; 68614514f5e3Sopenharmony_ci JSTaggedValue specifier = GET_ACC(); 68624514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 68634514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::DynamicImport(thread, specifier, thisFunc); 68644514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 68654514f5e3Sopenharmony_ci SET_ACC(res); 68664514f5e3Sopenharmony_ci DISPATCH(DYNAMICIMPORT); 68674514f5e3Sopenharmony_ci} 68684514f5e3Sopenharmony_ci 68694514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDeprecatedDynamicimportPrefV8( 68704514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68714514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68724514f5e3Sopenharmony_ci{ 68734514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_1(); 68744514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::dynamicimport" 68754514f5e3Sopenharmony_ci << " v" << v0; 68764514f5e3Sopenharmony_ci JSTaggedValue specifier = GET_VREG_VALUE(v0); 68774514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 68784514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::DynamicImport(thread, specifier, thisFunc); 68794514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 68804514f5e3Sopenharmony_ci SET_ACC(res); 68814514f5e3Sopenharmony_ci DISPATCH(DEPRECATED_DYNAMICIMPORT_PREF_V8); 68824514f5e3Sopenharmony_ci} 68834514f5e3Sopenharmony_ci 68844514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallargs3Imm8V8V8V8( 68854514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68864514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68874514f5e3Sopenharmony_ci{ 68884514f5e3Sopenharmony_ci DISPATCH(CALLARGS3_IMM8_V8_V8_V8); 68894514f5e3Sopenharmony_ci} 68904514f5e3Sopenharmony_ci 68914514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallargs2Imm8V8V8( 68924514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 68934514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 68944514f5e3Sopenharmony_ci{ 68954514f5e3Sopenharmony_ci DISPATCH(CALLARGS2_IMM8_V8_V8); 68964514f5e3Sopenharmony_ci} 68974514f5e3Sopenharmony_ci 68984514f5e3Sopenharmony_civoid InterpreterAssembly::HandleApplyImm8V8V8( 68994514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 69004514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 69014514f5e3Sopenharmony_ci{ 69024514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_0(); 69034514f5e3Sopenharmony_ci uint16_t v1 = READ_INST_8_1(); 69044514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::callspread" 69054514f5e3Sopenharmony_ci << " v" << v0 << " v" << v1; 69064514f5e3Sopenharmony_ci JSTaggedValue func = GET_ACC(); 69074514f5e3Sopenharmony_ci JSTaggedValue obj = GET_VREG_VALUE(v0); 69084514f5e3Sopenharmony_ci JSTaggedValue array = GET_VREG_VALUE(v1); 69094514f5e3Sopenharmony_ci 69104514f5e3Sopenharmony_ci SAVE_PC(); 69114514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CallSpread(thread, func, obj, array); 69124514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 69134514f5e3Sopenharmony_ci SET_ACC(res); 69144514f5e3Sopenharmony_ci 69154514f5e3Sopenharmony_ci DISPATCH(APPLY_IMM8_V8_V8); 69164514f5e3Sopenharmony_ci} 69174514f5e3Sopenharmony_ci 69184514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallarg0Imm8( 69194514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 69204514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 69214514f5e3Sopenharmony_ci{ 69224514f5e3Sopenharmony_ci DISPATCH(CALLARG0_IMM8); 69234514f5e3Sopenharmony_ci} 69244514f5e3Sopenharmony_ci 69254514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefinemethodImm8Id16Imm8( 69264514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 69274514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 69284514f5e3Sopenharmony_ci{ 69294514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_1(); 69304514f5e3Sopenharmony_ci uint16_t length = READ_INST_8_3(); 69314514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::definemethod length: " << length; 69324514f5e3Sopenharmony_ci SAVE_ACC(); 69334514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 69344514f5e3Sopenharmony_ci Method *method = 69354514f5e3Sopenharmony_ci Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, methodId).GetTaggedObject()); 69364514f5e3Sopenharmony_ci ASSERT(method != nullptr); 69374514f5e3Sopenharmony_ci RESTORE_ACC(); 69384514f5e3Sopenharmony_ci 69394514f5e3Sopenharmony_ci SAVE_PC(); 69404514f5e3Sopenharmony_ci JSTaggedValue homeObject = GET_ACC(); 69414514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 69424514f5e3Sopenharmony_ci JSTaggedValue taggedCurEnv = state->env; 69434514f5e3Sopenharmony_ci auto res = SlowRuntimeStub::DefineMethod(thread, method, homeObject, length, taggedCurEnv, GetModule(sp)); 69444514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 69454514f5e3Sopenharmony_ci JSFunction *result = JSFunction::Cast(res.GetTaggedObject()); 69464514f5e3Sopenharmony_ci 69474514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(result)); 69484514f5e3Sopenharmony_ci DISPATCH(DEFINEMETHOD_IMM8_ID16_IMM8); 69494514f5e3Sopenharmony_ci} 69504514f5e3Sopenharmony_ci 69514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefinefuncImm16Id16Imm8( 69524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 69534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 69544514f5e3Sopenharmony_ci{ 69554514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_2(); 69564514f5e3Sopenharmony_ci uint16_t length = READ_INST_8_4(); 69574514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::definefunc length: " << length; 69584514f5e3Sopenharmony_ci 69594514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 69604514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 69614514f5e3Sopenharmony_ci JSTaggedValue envHandle = state->env; 69624514f5e3Sopenharmony_ci JSFunction *currentFunc = 69634514f5e3Sopenharmony_ci JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject()); 69644514f5e3Sopenharmony_ci 69654514f5e3Sopenharmony_ci auto res = SlowRuntimeStub::DefineFunc(thread, constpool, methodId, GetModule(sp), 69664514f5e3Sopenharmony_ci length, envHandle, currentFunc->GetHomeObject()); 69674514f5e3Sopenharmony_ci JSFunction *jsFunc = JSFunction::Cast(res.GetTaggedObject()); 69684514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(jsFunc)); 69694514f5e3Sopenharmony_ci 69704514f5e3Sopenharmony_ci DISPATCH(DEFINEFUNC_IMM16_ID16_IMM8); 69714514f5e3Sopenharmony_ci} 69724514f5e3Sopenharmony_ci 69734514f5e3Sopenharmony_civoid InterpreterAssembly::HandleDefinefuncImm8Id16Imm8( 69744514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 69754514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 69764514f5e3Sopenharmony_ci{ 69774514f5e3Sopenharmony_ci uint16_t methodId = READ_INST_16_1(); 69784514f5e3Sopenharmony_ci uint16_t length = READ_INST_8_3(); 69794514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::definefunc length: " << length; 69804514f5e3Sopenharmony_ci 69814514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 69824514f5e3Sopenharmony_ci AsmInterpretedFrame *state = (reinterpret_cast<AsmInterpretedFrame *>(sp) - 1); 69834514f5e3Sopenharmony_ci JSTaggedValue envHandle = state->env; 69844514f5e3Sopenharmony_ci JSFunction *currentFunc = 69854514f5e3Sopenharmony_ci JSFunction::Cast(((reinterpret_cast<AsmInterpretedFrame *>(sp) - 1)->function).GetTaggedObject()); 69864514f5e3Sopenharmony_ci 69874514f5e3Sopenharmony_ci auto res = SlowRuntimeStub::DefineFunc(thread, constpool, methodId, GetModule(sp), 69884514f5e3Sopenharmony_ci length, envHandle, currentFunc->GetHomeObject()); 69894514f5e3Sopenharmony_ci JSFunction *jsFunc = JSFunction::Cast(res.GetTaggedObject()); 69904514f5e3Sopenharmony_ci 69914514f5e3Sopenharmony_ci SET_ACC(JSTaggedValue(jsFunc)); 69924514f5e3Sopenharmony_ci DISPATCH(DEFINEFUNC_IMM8_ID16_IMM8); 69934514f5e3Sopenharmony_ci} 69944514f5e3Sopenharmony_ci 69954514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSupercallarrowrangeImm8Imm8V8( 69964514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 69974514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 69984514f5e3Sopenharmony_ci{ 69994514f5e3Sopenharmony_ci uint16_t range = READ_INST_8_1(); 70004514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_2(); 70014514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::supercall" 70024514f5e3Sopenharmony_ci << " range: " << range << " v" << v0; 70034514f5e3Sopenharmony_ci 70044514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GET_ACC(); 70054514f5e3Sopenharmony_ci JSTaggedValue newTarget = GetNewTarget(sp); 70064514f5e3Sopenharmony_ci 70074514f5e3Sopenharmony_ci SAVE_PC(); 70084514f5e3Sopenharmony_ci JSTaggedValue superCtor = SlowRuntimeStub::GetSuperConstructor(thread, thisFunc); 70094514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(superCtor); 70104514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 70114514f5e3Sopenharmony_ci 70124514f5e3Sopenharmony_ci if (superCtor.IsJSFunction() && superCtor.IsConstructor() && !newTarget.IsUndefined()) { 70134514f5e3Sopenharmony_ci JSFunction *superCtorFunc = JSFunction::Cast(superCtor.GetTaggedObject()); 70144514f5e3Sopenharmony_ci methodHandle.Update(superCtorFunc->GetMethod()); 70154514f5e3Sopenharmony_ci if (superCtorFunc->IsBuiltinConstructor()) { 70164514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 70174514f5e3Sopenharmony_ci size_t frameSize = 70184514f5e3Sopenharmony_ci InterpretedFrame::NumOfMembers() + range + NUM_MANDATORY_JSFUNC_ARGS + 2; // 2:thread & numArgs 70194514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70204514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 70214514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 70224514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 70234514f5e3Sopenharmony_ci } 70244514f5e3Sopenharmony_ci // copy args 70254514f5e3Sopenharmony_ci uint32_t index = 0; 70264514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70274514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo *>(newSp); 70284514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 70294514f5e3Sopenharmony_ci newSp[index++] = range + NUM_MANDATORY_JSFUNC_ARGS; 70304514f5e3Sopenharmony_ci // func 70314514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70324514f5e3Sopenharmony_ci newSp[index++] = superCtor.GetRawData(); 70334514f5e3Sopenharmony_ci // newTarget 70344514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70354514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 70364514f5e3Sopenharmony_ci // this 70374514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70384514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 70394514f5e3Sopenharmony_ci for (size_t i = 0; i < range; ++i) { 70404514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70414514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 70424514f5e3Sopenharmony_ci } 70434514f5e3Sopenharmony_ci 70444514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 70454514f5e3Sopenharmony_ci state->base.prev = sp; 70464514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 70474514f5e3Sopenharmony_ci state->pc = nullptr; 70484514f5e3Sopenharmony_ci state->function = superCtor; 70494514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 70504514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall "; 70514514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 70524514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 70534514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 70544514f5e3Sopenharmony_ci 70554514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 70564514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 70574514f5e3Sopenharmony_ci } 70584514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime SuperCall "; 70594514f5e3Sopenharmony_ci SET_ACC(retValue); 70604514f5e3Sopenharmony_ci DISPATCH(SUPERCALLARROWRANGE_IMM8_IMM8_V8); 70614514f5e3Sopenharmony_ci } 70624514f5e3Sopenharmony_ci 70634514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(superCtorFunc, methodHandle)) { 70644514f5e3Sopenharmony_ci SAVE_PC(); 70654514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 70664514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = superCtorFunc->IsBase() ? 70674514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 70684514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 70694514f5e3Sopenharmony_ci // +1 for hidden this, explicit this may be overwritten after bc optimizer 70704514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs + 1; 70714514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70724514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 70734514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(newSp) - 1; 70744514f5e3Sopenharmony_ci 70754514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 70764514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 70774514f5e3Sopenharmony_ci } 70784514f5e3Sopenharmony_ci 70794514f5e3Sopenharmony_ci uint32_t index = 0; 70804514f5e3Sopenharmony_ci // initialize vregs value 70814514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 70824514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 70834514f5e3Sopenharmony_ci } 70844514f5e3Sopenharmony_ci 70854514f5e3Sopenharmony_ci // this 70864514f5e3Sopenharmony_ci JSTaggedValue thisObj; 70874514f5e3Sopenharmony_ci if (superCtorFunc->IsBase()) { 70884514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, superCtor, newTarget, state); 70894514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 70904514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70914514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 70924514f5e3Sopenharmony_ci } else { 70934514f5e3Sopenharmony_ci ASSERT(superCtorFunc->IsDerivedConstructor()); 70944514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 70954514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 70964514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 70974514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 70984514f5e3Sopenharmony_ci 70994514f5e3Sopenharmony_ci state->function = superCtor; 71004514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 71014514f5e3Sopenharmony_ci state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo(); 71024514f5e3Sopenharmony_ci state->env = superCtorFunc->GetLexicalEnv(); 71034514f5e3Sopenharmony_ci } 71044514f5e3Sopenharmony_ci 71054514f5e3Sopenharmony_ci // the second condition ensure not push extra args 71064514f5e3Sopenharmony_ci for (size_t i = 0; i < range && index < numVregs + numDeclaredArgs; ++i) { 71074514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71084514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 71094514f5e3Sopenharmony_ci } 71104514f5e3Sopenharmony_ci 71114514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 71124514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 71134514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71144514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 71154514f5e3Sopenharmony_ci } 71164514f5e3Sopenharmony_ci 71174514f5e3Sopenharmony_ci state->base.prev = sp; 71184514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 71194514f5e3Sopenharmony_ci state->thisObj = thisObj; 71204514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 71214514f5e3Sopenharmony_ci sp = newSp; 71224514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 71234514f5e3Sopenharmony_ci 71244514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 71254514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall " << std::hex << reinterpret_cast<uintptr_t>(sp) 71264514f5e3Sopenharmony_ci << " " << std::hex << reinterpret_cast<uintptr_t>(pc); 71274514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 71284514f5e3Sopenharmony_ci } 71294514f5e3Sopenharmony_ci } 71304514f5e3Sopenharmony_ci 71314514f5e3Sopenharmony_ci SAVE_PC(); 71324514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuperCall(thread, thisFunc, newTarget, v0, range); 71334514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 71344514f5e3Sopenharmony_ci SET_ACC(res); 71354514f5e3Sopenharmony_ci DISPATCH(SUPERCALLARROWRANGE_IMM8_IMM8_V8); 71364514f5e3Sopenharmony_ci} 71374514f5e3Sopenharmony_ci 71384514f5e3Sopenharmony_civoid InterpreterAssembly::HandleSupercallthisrangeImm8Imm8V8( 71394514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 71404514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 71414514f5e3Sopenharmony_ci{ 71424514f5e3Sopenharmony_ci uint16_t range = READ_INST_8_1(); 71434514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_2(); 71444514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::supercall" 71454514f5e3Sopenharmony_ci << " range: " << range << " v" << v0; 71464514f5e3Sopenharmony_ci 71474514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 71484514f5e3Sopenharmony_ci JSTaggedValue newTarget = GetNewTarget(sp); 71494514f5e3Sopenharmony_ci 71504514f5e3Sopenharmony_ci SAVE_PC(); 71514514f5e3Sopenharmony_ci JSTaggedValue superCtor = SlowRuntimeStub::GetSuperConstructor(thread, thisFunc); 71524514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(superCtor); 71534514f5e3Sopenharmony_ci 71544514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 71554514f5e3Sopenharmony_ci if (superCtor.IsJSFunction() && superCtor.IsConstructor() && !newTarget.IsUndefined()) { 71564514f5e3Sopenharmony_ci JSFunction *superCtorFunc = JSFunction::Cast(superCtor.GetTaggedObject()); 71574514f5e3Sopenharmony_ci methodHandle.Update(superCtorFunc->GetMethod()); 71584514f5e3Sopenharmony_ci if (superCtorFunc->IsBuiltinConstructor()) { 71594514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 71604514f5e3Sopenharmony_ci size_t frameSize = 71614514f5e3Sopenharmony_ci InterpretedFrame::NumOfMembers() + range + NUM_MANDATORY_JSFUNC_ARGS + 2; // 2:thread & numArgs 71624514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71634514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 71644514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 71654514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 71664514f5e3Sopenharmony_ci } 71674514f5e3Sopenharmony_ci // copy args 71684514f5e3Sopenharmony_ci uint32_t index = 0; 71694514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71704514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo *>(newSp); 71714514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 71724514f5e3Sopenharmony_ci newSp[index++] = range + NUM_MANDATORY_JSFUNC_ARGS; 71734514f5e3Sopenharmony_ci // func 71744514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71754514f5e3Sopenharmony_ci newSp[index++] = superCtor.GetRawData(); 71764514f5e3Sopenharmony_ci // newTarget 71774514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71784514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 71794514f5e3Sopenharmony_ci // this 71804514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71814514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 71824514f5e3Sopenharmony_ci for (size_t i = 0; i < range; ++i) { 71834514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 71844514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 71854514f5e3Sopenharmony_ci } 71864514f5e3Sopenharmony_ci 71874514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 71884514f5e3Sopenharmony_ci state->base.prev = sp; 71894514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 71904514f5e3Sopenharmony_ci state->pc = nullptr; 71914514f5e3Sopenharmony_ci state->function = superCtor; 71924514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 71934514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall "; 71944514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 71954514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 71964514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 71974514f5e3Sopenharmony_ci 71984514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 71994514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 72004514f5e3Sopenharmony_ci } 72014514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime SuperCall "; 72024514f5e3Sopenharmony_ci SET_ACC(retValue); 72034514f5e3Sopenharmony_ci DISPATCH(SUPERCALLTHISRANGE_IMM8_IMM8_V8); 72044514f5e3Sopenharmony_ci } 72054514f5e3Sopenharmony_ci 72064514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(superCtorFunc, methodHandle)) { 72074514f5e3Sopenharmony_ci SAVE_PC(); 72084514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 72094514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = superCtorFunc->IsBase() ? 72104514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 72114514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 72124514f5e3Sopenharmony_ci // +1 for hidden this, explicit this may be overwritten after bc optimizer 72134514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs + 1; 72144514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 72154514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 72164514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(newSp) - 1; 72174514f5e3Sopenharmony_ci 72184514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 72194514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 72204514f5e3Sopenharmony_ci } 72214514f5e3Sopenharmony_ci 72224514f5e3Sopenharmony_ci uint32_t index = 0; 72234514f5e3Sopenharmony_ci // initialize vregs value 72244514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 72254514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 72264514f5e3Sopenharmony_ci } 72274514f5e3Sopenharmony_ci 72284514f5e3Sopenharmony_ci // this 72294514f5e3Sopenharmony_ci JSTaggedValue thisObj; 72304514f5e3Sopenharmony_ci if (superCtorFunc->IsBase()) { 72314514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, superCtor, newTarget, state); 72324514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 72334514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 72344514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 72354514f5e3Sopenharmony_ci } else { 72364514f5e3Sopenharmony_ci ASSERT(superCtorFunc->IsDerivedConstructor()); 72374514f5e3Sopenharmony_ci newSp[index++] = newTarget.GetRawData(); 72384514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 72394514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 72404514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 72414514f5e3Sopenharmony_ci 72424514f5e3Sopenharmony_ci state->function = superCtor; 72434514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 72444514f5e3Sopenharmony_ci state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo(); 72454514f5e3Sopenharmony_ci state->env = superCtorFunc->GetLexicalEnv(); 72464514f5e3Sopenharmony_ci } 72474514f5e3Sopenharmony_ci 72484514f5e3Sopenharmony_ci // the second condition ensure not push extra args 72494514f5e3Sopenharmony_ci for (size_t i = 0; i < range && index < numVregs + numDeclaredArgs; ++i) { 72504514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 72514514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(v0 + i); 72524514f5e3Sopenharmony_ci } 72534514f5e3Sopenharmony_ci 72544514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 72554514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 72564514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 72574514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 72584514f5e3Sopenharmony_ci } 72594514f5e3Sopenharmony_ci 72604514f5e3Sopenharmony_ci state->base.prev = sp; 72614514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 72624514f5e3Sopenharmony_ci state->thisObj = thisObj; 72634514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 72644514f5e3Sopenharmony_ci sp = newSp; 72654514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 72664514f5e3Sopenharmony_ci 72674514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 72684514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime SuperCall " << std::hex << reinterpret_cast<uintptr_t>(sp) 72694514f5e3Sopenharmony_ci << " " << std::hex << reinterpret_cast<uintptr_t>(pc); 72704514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 72714514f5e3Sopenharmony_ci } 72724514f5e3Sopenharmony_ci } 72734514f5e3Sopenharmony_ci 72744514f5e3Sopenharmony_ci SAVE_PC(); 72754514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::SuperCall(thread, thisFunc, newTarget, v0, range); 72764514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 72774514f5e3Sopenharmony_ci SET_ACC(res); 72784514f5e3Sopenharmony_ci DISPATCH(SUPERCALLTHISRANGE_IMM8_IMM8_V8); 72794514f5e3Sopenharmony_ci} 72804514f5e3Sopenharmony_ci 72814514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallthisrangeImm8Imm8V8( 72824514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 72834514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 72844514f5e3Sopenharmony_ci{ 72854514f5e3Sopenharmony_ci DISPATCH(CALLTHISRANGE_IMM8_IMM8_V8); 72864514f5e3Sopenharmony_ci} 72874514f5e3Sopenharmony_ci 72884514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallthis3Imm8V8V8V8V8( 72894514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 72904514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 72914514f5e3Sopenharmony_ci{ 72924514f5e3Sopenharmony_ci DISPATCH(CALLTHIS3_IMM8_V8_V8_V8_V8); 72934514f5e3Sopenharmony_ci} 72944514f5e3Sopenharmony_ci 72954514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallthis2Imm8V8V8V8( 72964514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 72974514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 72984514f5e3Sopenharmony_ci{ 72994514f5e3Sopenharmony_ci DISPATCH(CALLTHIS2_IMM8_V8_V8_V8); 73004514f5e3Sopenharmony_ci} 73014514f5e3Sopenharmony_ci 73024514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNewlexenvwithnameImm8Id16( 73034514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 73044514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 73054514f5e3Sopenharmony_ci{ 73064514f5e3Sopenharmony_ci uint16_t numVars = READ_INST_8_0(); 73074514f5e3Sopenharmony_ci uint16_t scopeId = READ_INST_16_1(); 73084514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newlexenvwithname" 73094514f5e3Sopenharmony_ci << " numVars " << numVars << " scopeId " << scopeId; 73104514f5e3Sopenharmony_ci 73114514f5e3Sopenharmony_ci SAVE_PC(); 73124514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewLexicalEnvWithName(thread, numVars, scopeId); 73134514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 73144514f5e3Sopenharmony_ci 73154514f5e3Sopenharmony_ci SET_ACC(res); 73164514f5e3Sopenharmony_ci (reinterpret_cast<InterpretedFrame *>(sp) - 1)->env = res; 73174514f5e3Sopenharmony_ci DISPATCH(NEWLEXENVWITHNAME_IMM8_ID16); 73184514f5e3Sopenharmony_ci} 73194514f5e3Sopenharmony_ci 73204514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNewobjrangeImm16Imm8V8( 73214514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 73224514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 73234514f5e3Sopenharmony_ci{ 73244514f5e3Sopenharmony_ci uint16_t numArgs = READ_INST_8_2(); 73254514f5e3Sopenharmony_ci uint16_t firstArgRegIdx = READ_INST_8_3(); 73264514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newobjRange " << numArgs << " v" << firstArgRegIdx; 73274514f5e3Sopenharmony_ci JSTaggedValue ctor = GET_VREG_VALUE(firstArgRegIdx); 73284514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 73294514f5e3Sopenharmony_ci 73304514f5e3Sopenharmony_ci if (ctor.IsJSFunction() && ctor.IsConstructor()) { 73314514f5e3Sopenharmony_ci JSFunction *ctorFunc = JSFunction::Cast(ctor.GetTaggedObject()); 73324514f5e3Sopenharmony_ci methodHandle.Update(ctorFunc->GetMethod()); 73334514f5e3Sopenharmony_ci if (ctorFunc->IsBuiltinConstructor()) { 73344514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 73354514f5e3Sopenharmony_ci size_t frameSize = 73364514f5e3Sopenharmony_ci InterpretedFrame::NumOfMembers() + numArgs + 4; // 4: newtarget/this & numArgs & thread 73374514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73384514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 73394514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 73404514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 73414514f5e3Sopenharmony_ci } 73424514f5e3Sopenharmony_ci // copy args 73434514f5e3Sopenharmony_ci uint32_t index = 0; 73444514f5e3Sopenharmony_ci // numArgs 73454514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73464514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo*>(newSp); 73474514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 73484514f5e3Sopenharmony_ci newSp[index++] = numArgs + 2; // 2: for newtarget/this 73494514f5e3Sopenharmony_ci // func 73504514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73514514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 73524514f5e3Sopenharmony_ci // newTarget 73534514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73544514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 73554514f5e3Sopenharmony_ci // this 73564514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73574514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 73584514f5e3Sopenharmony_ci for (size_t i = 1; i < numArgs; ++i) { // 1: func 73594514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73604514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(firstArgRegIdx + i); 73614514f5e3Sopenharmony_ci } 73624514f5e3Sopenharmony_ci 73634514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 73644514f5e3Sopenharmony_ci state->base.prev = sp; 73654514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 73664514f5e3Sopenharmony_ci state->pc = nullptr; 73674514f5e3Sopenharmony_ci state->function = ctor; 73684514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 73694514f5e3Sopenharmony_ci 73704514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime New."; 73714514f5e3Sopenharmony_ci SAVE_PC(); 73724514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 73734514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 73744514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 73754514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 73764514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 73774514f5e3Sopenharmony_ci } 73784514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime New."; 73794514f5e3Sopenharmony_ci SET_ACC(retValue); 73804514f5e3Sopenharmony_ci DISPATCH(NEWOBJRANGE_IMM16_IMM8_V8); 73814514f5e3Sopenharmony_ci } 73824514f5e3Sopenharmony_ci 73834514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(ctorFunc, methodHandle)) { 73844514f5e3Sopenharmony_ci SAVE_PC(); 73854514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 73864514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = ctorFunc->IsBase() ? 73874514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 73884514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 73894514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs; 73904514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 73914514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 73924514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(newSp) - 1); 73934514f5e3Sopenharmony_ci 73944514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 73954514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 73964514f5e3Sopenharmony_ci } 73974514f5e3Sopenharmony_ci 73984514f5e3Sopenharmony_ci uint32_t index = 0; 73994514f5e3Sopenharmony_ci // initialize vregs value 74004514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 74014514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 74024514f5e3Sopenharmony_ci } 74034514f5e3Sopenharmony_ci 74044514f5e3Sopenharmony_ci // this 74054514f5e3Sopenharmony_ci JSTaggedValue thisObj; 74064514f5e3Sopenharmony_ci if (ctorFunc->IsBase()) { 74074514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, ctor, ctor, state); 74084514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 74094514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74104514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 74114514f5e3Sopenharmony_ci } else { 74124514f5e3Sopenharmony_ci ASSERT(ctorFunc->IsDerivedConstructor()); 74134514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 74144514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 74154514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74164514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 74174514f5e3Sopenharmony_ci 74184514f5e3Sopenharmony_ci state->function = ctor; 74194514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 74204514f5e3Sopenharmony_ci state->profileTypeInfo = ctorFunc->GetProfileTypeInfo(); 74214514f5e3Sopenharmony_ci state->env = ctorFunc->GetLexicalEnv(); 74224514f5e3Sopenharmony_ci } 74234514f5e3Sopenharmony_ci 74244514f5e3Sopenharmony_ci // the second condition ensure not push extra args 74254514f5e3Sopenharmony_ci for (size_t i = 1; i < numArgs && index < numVregs + numDeclaredArgs; ++i) { // 2: func and newTarget 74264514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74274514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(firstArgRegIdx + i); 74284514f5e3Sopenharmony_ci } 74294514f5e3Sopenharmony_ci 74304514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 74314514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 74324514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74334514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 74344514f5e3Sopenharmony_ci } 74354514f5e3Sopenharmony_ci 74364514f5e3Sopenharmony_ci state->base.prev = sp; 74374514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 74384514f5e3Sopenharmony_ci state->thisObj = thisObj; 74394514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 74404514f5e3Sopenharmony_ci sp = newSp; 74414514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 74424514f5e3Sopenharmony_ci 74434514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 74444514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime New " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 74454514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(pc); 74464514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 74474514f5e3Sopenharmony_ci } 74484514f5e3Sopenharmony_ci } 74494514f5e3Sopenharmony_ci 74504514f5e3Sopenharmony_ci // bound function, proxy, other call types, enter slow path 74514514f5e3Sopenharmony_ci constexpr uint16_t firstArgOffset = 1; 74524514f5e3Sopenharmony_ci // Exclude func and newTarget 74534514f5e3Sopenharmony_ci uint16_t firstArgIdx = firstArgRegIdx + firstArgOffset; 74544514f5e3Sopenharmony_ci uint16_t length = numArgs - firstArgOffset; 74554514f5e3Sopenharmony_ci 74564514f5e3Sopenharmony_ci SAVE_PC(); 74574514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewObjRange(thread, ctor, ctor, firstArgIdx, length); 74584514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 74594514f5e3Sopenharmony_ci SET_ACC(res); 74604514f5e3Sopenharmony_ci DISPATCH(NEWOBJRANGE_IMM16_IMM8_V8); 74614514f5e3Sopenharmony_ci} 74624514f5e3Sopenharmony_ci 74634514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNewobjrangeImm8Imm8V8( 74644514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 74654514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 74664514f5e3Sopenharmony_ci{ 74674514f5e3Sopenharmony_ci uint16_t numArgs = READ_INST_8_1(); 74684514f5e3Sopenharmony_ci uint16_t firstArgRegIdx = READ_INST_8_2(); 74694514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::newobjRange " << numArgs << " v" << firstArgRegIdx; 74704514f5e3Sopenharmony_ci JSTaggedValue ctor = GET_VREG_VALUE(firstArgRegIdx); 74714514f5e3Sopenharmony_ci JSMutableHandle<Method> methodHandle(thread, JSTaggedValue::Undefined()); 74724514f5e3Sopenharmony_ci 74734514f5e3Sopenharmony_ci if (ctor.IsJSFunction() && ctor.IsConstructor()) { 74744514f5e3Sopenharmony_ci JSFunction *ctorFunc = JSFunction::Cast(ctor.GetTaggedObject()); 74754514f5e3Sopenharmony_ci methodHandle.Update(ctorFunc->GetMethod()); 74764514f5e3Sopenharmony_ci if (ctorFunc->IsBuiltinConstructor()) { 74774514f5e3Sopenharmony_ci ASSERT(methodHandle->GetNumVregsWithCallField() == 0); 74784514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numArgs + 4; // 2: numArgs & thread 74794514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74804514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 74814514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 74824514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 74834514f5e3Sopenharmony_ci } 74844514f5e3Sopenharmony_ci // copy args 74854514f5e3Sopenharmony_ci uint32_t index = 0; 74864514f5e3Sopenharmony_ci // numArgs 74874514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74884514f5e3Sopenharmony_ci EcmaRuntimeCallInfo *ecmaRuntimeCallInfo = reinterpret_cast<EcmaRuntimeCallInfo*>(newSp); 74894514f5e3Sopenharmony_ci newSp[index++] = ToUintPtr(thread); 74904514f5e3Sopenharmony_ci newSp[index++] = numArgs + 2; // 2: for newtarget / this 74914514f5e3Sopenharmony_ci // func 74924514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74934514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 74944514f5e3Sopenharmony_ci // newTarget 74954514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74964514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 74974514f5e3Sopenharmony_ci // this 74984514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 74994514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 75004514f5e3Sopenharmony_ci for (size_t i = 1; i < numArgs; ++i) { 75014514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 75024514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(firstArgRegIdx + i); 75034514f5e3Sopenharmony_ci } 75044514f5e3Sopenharmony_ci 75054514f5e3Sopenharmony_ci InterpretedBuiltinFrame *state = GET_BUILTIN_FRAME(newSp); 75064514f5e3Sopenharmony_ci state->base.prev = sp; 75074514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_BUILTIN_FRAME; 75084514f5e3Sopenharmony_ci state->pc = nullptr; 75094514f5e3Sopenharmony_ci state->function = ctor; 75104514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 75114514f5e3Sopenharmony_ci 75124514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime New."; 75134514f5e3Sopenharmony_ci SAVE_PC(); 75144514f5e3Sopenharmony_ci JSTaggedValue retValue = reinterpret_cast<EcmaEntrypoint>( 75154514f5e3Sopenharmony_ci const_cast<void *>(methodHandle->GetNativePointer()))(ecmaRuntimeCallInfo); 75164514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(sp); 75174514f5e3Sopenharmony_ci if (UNLIKELY(thread->HasPendingException())) { 75184514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 75194514f5e3Sopenharmony_ci } 75204514f5e3Sopenharmony_ci LOG_INST() << "Exit: Runtime New."; 75214514f5e3Sopenharmony_ci SET_ACC(retValue); 75224514f5e3Sopenharmony_ci DISPATCH(NEWOBJRANGE_IMM8_IMM8_V8); 75234514f5e3Sopenharmony_ci } 75244514f5e3Sopenharmony_ci 75254514f5e3Sopenharmony_ci if (AssemblyIsFastNewFrameEnter(ctorFunc, methodHandle)) { 75264514f5e3Sopenharmony_ci SAVE_PC(); 75274514f5e3Sopenharmony_ci uint32_t numVregs = methodHandle->GetNumVregsWithCallField(); 75284514f5e3Sopenharmony_ci uint32_t numDeclaredArgs = ctorFunc->IsBase() ? 75294514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 1 : // +1 for this 75304514f5e3Sopenharmony_ci methodHandle->GetNumArgsWithCallField() + 2; // +2 for newTarget and this 75314514f5e3Sopenharmony_ci size_t frameSize = InterpretedFrame::NumOfMembers() + numVregs + numDeclaredArgs; 75324514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 75334514f5e3Sopenharmony_ci JSTaggedType *newSp = sp - frameSize; 75344514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(newSp) - 1); 75354514f5e3Sopenharmony_ci 75364514f5e3Sopenharmony_ci if (UNLIKELY(thread->DoStackOverflowCheck(newSp))) { 75374514f5e3Sopenharmony_ci INTERPRETER_GOTO_EXCEPTION_HANDLER(); 75384514f5e3Sopenharmony_ci } 75394514f5e3Sopenharmony_ci 75404514f5e3Sopenharmony_ci uint32_t index = 0; 75414514f5e3Sopenharmony_ci // initialize vregs value 75424514f5e3Sopenharmony_ci for (size_t i = 0; i < numVregs; ++i) { 75434514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 75444514f5e3Sopenharmony_ci } 75454514f5e3Sopenharmony_ci 75464514f5e3Sopenharmony_ci // this 75474514f5e3Sopenharmony_ci JSTaggedValue thisObj; 75484514f5e3Sopenharmony_ci if (ctorFunc->IsBase()) { 75494514f5e3Sopenharmony_ci thisObj = FastRuntimeStub::NewThisObject(thread, ctor, ctor, state); 75504514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(thisObj); 75514514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 75524514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 75534514f5e3Sopenharmony_ci } else { 75544514f5e3Sopenharmony_ci ASSERT(ctorFunc->IsDerivedConstructor()); 75554514f5e3Sopenharmony_ci newSp[index++] = ctor.GetRawData(); 75564514f5e3Sopenharmony_ci thisObj = JSTaggedValue::Undefined(); 75574514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 75584514f5e3Sopenharmony_ci newSp[index++] = thisObj.GetRawData(); 75594514f5e3Sopenharmony_ci 75604514f5e3Sopenharmony_ci state->function = ctor; 75614514f5e3Sopenharmony_ci state->constpool = methodHandle->GetConstantPool(); 75624514f5e3Sopenharmony_ci state->profileTypeInfo = ctorFunc->GetProfileTypeInfo(); 75634514f5e3Sopenharmony_ci state->env = ctorFunc->GetLexicalEnv(); 75644514f5e3Sopenharmony_ci } 75654514f5e3Sopenharmony_ci 75664514f5e3Sopenharmony_ci // the second condition ensure not push extra args 75674514f5e3Sopenharmony_ci for (size_t i = 1; i < numArgs && index < numVregs + numDeclaredArgs; ++i) { 75684514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 75694514f5e3Sopenharmony_ci newSp[index++] = GET_VREG(firstArgRegIdx + i); 75704514f5e3Sopenharmony_ci } 75714514f5e3Sopenharmony_ci 75724514f5e3Sopenharmony_ci // set undefined to the extra prats of declare 75734514f5e3Sopenharmony_ci for (size_t i = index; i < numVregs + numDeclaredArgs; ++i) { 75744514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 75754514f5e3Sopenharmony_ci newSp[index++] = JSTaggedValue::VALUE_UNDEFINED; 75764514f5e3Sopenharmony_ci } 75774514f5e3Sopenharmony_ci 75784514f5e3Sopenharmony_ci state->base.prev = sp; 75794514f5e3Sopenharmony_ci state->base.type = FrameType::INTERPRETER_FAST_NEW_FRAME; 75804514f5e3Sopenharmony_ci state->thisObj = thisObj; 75814514f5e3Sopenharmony_ci state->pc = pc = methodHandle->GetBytecodeArray(); 75824514f5e3Sopenharmony_ci sp = newSp; 75834514f5e3Sopenharmony_ci state->acc = JSTaggedValue::Hole(); 75844514f5e3Sopenharmony_ci 75854514f5e3Sopenharmony_ci thread->SetCurrentSPFrame(newSp); 75864514f5e3Sopenharmony_ci LOG_INST() << "Entry: Runtime New " << std::hex << reinterpret_cast<uintptr_t>(sp) << " " 75874514f5e3Sopenharmony_ci << std::hex << reinterpret_cast<uintptr_t>(pc); 75884514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 75894514f5e3Sopenharmony_ci } 75904514f5e3Sopenharmony_ci } 75914514f5e3Sopenharmony_ci 75924514f5e3Sopenharmony_ci // bound function, proxy, other call types, enter slow path 75934514f5e3Sopenharmony_ci constexpr uint16_t firstArgOffset = 1; 75944514f5e3Sopenharmony_ci // Exclude func and newTarget 75954514f5e3Sopenharmony_ci uint16_t firstArgIdx = firstArgRegIdx + firstArgOffset; 75964514f5e3Sopenharmony_ci uint16_t length = numArgs - firstArgOffset; 75974514f5e3Sopenharmony_ci 75984514f5e3Sopenharmony_ci SAVE_PC(); 75994514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewObjRange(thread, ctor, ctor, firstArgIdx, length); 76004514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 76014514f5e3Sopenharmony_ci SET_ACC(res); 76024514f5e3Sopenharmony_ci DISPATCH(NEWOBJRANGE_IMM8_IMM8_V8); 76034514f5e3Sopenharmony_ci} 76044514f5e3Sopenharmony_ci 76054514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNewobjapplyImm16V8( 76064514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76074514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 76084514f5e3Sopenharmony_ci{ 76094514f5e3Sopenharmony_ci uint16_t v0 = READ_INST_8_2(); 76104514f5e3Sopenharmony_ci LOG_INST() << "intrinsic::newobjspeard" 76114514f5e3Sopenharmony_ci << " v" << v0; 76124514f5e3Sopenharmony_ci JSTaggedValue func = GET_VREG_VALUE(v0); 76134514f5e3Sopenharmony_ci JSTaggedValue array = GET_ACC(); 76144514f5e3Sopenharmony_ci SAVE_PC(); 76154514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::NewObjApply(thread, func, array); 76164514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 76174514f5e3Sopenharmony_ci SET_ACC(res); 76184514f5e3Sopenharmony_ci DISPATCH(NEWOBJAPPLY_IMM16_V8); 76194514f5e3Sopenharmony_ci} 76204514f5e3Sopenharmony_ci 76214514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateregexpwithliteralImm16Id16Imm8( 76224514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76234514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 76244514f5e3Sopenharmony_ci{ 76254514f5e3Sopenharmony_ci uint16_t stringId = READ_INST_16_2(); 76264514f5e3Sopenharmony_ci SAVE_ACC(); 76274514f5e3Sopenharmony_ci constpool = GetConstantPool(sp); 76284514f5e3Sopenharmony_ci JSTaggedValue pattern = ConstantPool::GetStringFromCache(thread, constpool, stringId); 76294514f5e3Sopenharmony_ci uint8_t flags = READ_INST_8_4(); 76304514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createregexpwithliteral " 76314514f5e3Sopenharmony_ci << "stringId:" << stringId << ", " << ConvertToString(EcmaString::Cast(pattern.GetTaggedObject())) 76324514f5e3Sopenharmony_ci << ", flags:" << flags; 76334514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateRegExpWithLiteral(thread, pattern, flags); 76344514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 76354514f5e3Sopenharmony_ci SET_ACC(res); 76364514f5e3Sopenharmony_ci DISPATCH(CREATEREGEXPWITHLITERAL_IMM16_ID16_IMM8); 76374514f5e3Sopenharmony_ci} 76384514f5e3Sopenharmony_ci 76394514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateobjectwithbufferImm16Id16( 76404514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76414514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 76424514f5e3Sopenharmony_ci{ 76434514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_2(); 76444514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createobjectwithbuffer" 76454514f5e3Sopenharmony_ci << " imm:" << imm; 76464514f5e3Sopenharmony_ci constpool = GetUnsharedConstpool(thread, sp); 76474514f5e3Sopenharmony_ci JSObject *result = JSObject::Cast( 76484514f5e3Sopenharmony_ci ConstantPool::GetLiteralFromCache<ConstPoolType::OBJECT_LITERAL>( 76494514f5e3Sopenharmony_ci thread, constpool, imm, GetModule(sp)).GetTaggedObject()); 76504514f5e3Sopenharmony_ci SAVE_PC(); 76514514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 76524514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 76534514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 76544514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateObjectHavingMethod(thread, factory, result, state->env); 76554514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 76564514f5e3Sopenharmony_ci SET_ACC(res); 76574514f5e3Sopenharmony_ci DISPATCH(CREATEOBJECTWITHBUFFER_IMM16_ID16); 76584514f5e3Sopenharmony_ci} 76594514f5e3Sopenharmony_ci 76604514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreateobjectwithbufferImm8Id16( 76614514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76624514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 76634514f5e3Sopenharmony_ci{ 76644514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_1(); 76654514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createobjectwithbuffer" 76664514f5e3Sopenharmony_ci << " imm:" << imm; 76674514f5e3Sopenharmony_ci constpool = GetUnsharedConstpool(thread, sp); 76684514f5e3Sopenharmony_ci JSObject *result = JSObject::Cast( 76694514f5e3Sopenharmony_ci ConstantPool::GetLiteralFromCache<ConstPoolType::OBJECT_LITERAL>( 76704514f5e3Sopenharmony_ci thread, constpool, imm, GetModule(sp)).GetTaggedObject()); 76714514f5e3Sopenharmony_ci SAVE_PC(); 76724514f5e3Sopenharmony_ci InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1); 76734514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 76744514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 76754514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateObjectHavingMethod(thread, factory, result, state->env); 76764514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 76774514f5e3Sopenharmony_ci SET_ACC(res); 76784514f5e3Sopenharmony_ci DISPATCH(CREATEOBJECTWITHBUFFER_IMM8_ID16); 76794514f5e3Sopenharmony_ci} 76804514f5e3Sopenharmony_ci 76814514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdnewtarget( 76824514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76834514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 76844514f5e3Sopenharmony_ci{ 76854514f5e3Sopenharmony_ci DISPATCH(LDNEWTARGET); 76864514f5e3Sopenharmony_ci} 76874514f5e3Sopenharmony_ci 76884514f5e3Sopenharmony_civoid InterpreterAssembly::HandleLdthis( 76894514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76904514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 76914514f5e3Sopenharmony_ci{ 76924514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldthis"; 76934514f5e3Sopenharmony_ci SET_ACC(GetThis(sp)); 76944514f5e3Sopenharmony_ci DISPATCH(LDTHIS); 76954514f5e3Sopenharmony_ci} 76964514f5e3Sopenharmony_ci 76974514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreatearraywithbufferImm8Id16( 76984514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 76994514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77004514f5e3Sopenharmony_ci{ 77014514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_1(); 77024514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createarraywithbuffer" 77034514f5e3Sopenharmony_ci << " imm:" << imm; 77044514f5e3Sopenharmony_ci constpool = GetUnsharedConstpool(thread, sp); 77054514f5e3Sopenharmony_ci JSArray *result = JSArray::Cast( 77064514f5e3Sopenharmony_ci ConstantPool::GetLiteralFromCache<ConstPoolType::ARRAY_LITERAL>( 77074514f5e3Sopenharmony_ci thread, constpool, imm, GetModule(sp)).GetTaggedObject()); 77084514f5e3Sopenharmony_ci SAVE_PC(); 77094514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 77104514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 77114514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateArrayWithBuffer(thread, factory, result); 77124514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 77134514f5e3Sopenharmony_ci SET_ACC(res); 77144514f5e3Sopenharmony_ci DISPATCH(CREATEARRAYWITHBUFFER_IMM8_ID16); 77154514f5e3Sopenharmony_ci} 77164514f5e3Sopenharmony_ci 77174514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCreatearraywithbufferImm16Id16( 77184514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 77194514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77204514f5e3Sopenharmony_ci{ 77214514f5e3Sopenharmony_ci uint16_t imm = READ_INST_16_2(); 77224514f5e3Sopenharmony_ci EcmaVM *ecmaVm = thread->GetEcmaVM(); 77234514f5e3Sopenharmony_ci ObjectFactory *factory = ecmaVm->GetFactory(); 77244514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::createarraywithbuffer" 77254514f5e3Sopenharmony_ci << " imm:" << imm; 77264514f5e3Sopenharmony_ci InterpretedFrame *state = reinterpret_cast<InterpretedFrame *>(sp) - 1; 77274514f5e3Sopenharmony_ci JSTaggedValue constantPool = state->constpool; 77284514f5e3Sopenharmony_ci JSArray *result = JSArray::Cast(ConstantPool::Cast(constantPool.GetTaggedObject()) 77294514f5e3Sopenharmony_ci ->GetObjectFromCache(imm).GetTaggedObject()); 77304514f5e3Sopenharmony_ci SAVE_PC(); 77314514f5e3Sopenharmony_ci JSTaggedValue res = SlowRuntimeStub::CreateArrayWithBuffer(thread, factory, result); 77324514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(res); 77334514f5e3Sopenharmony_ci SET_ACC(res); 77344514f5e3Sopenharmony_ci DISPATCH(CREATEARRAYWITHBUFFER_IMM16_ID16); 77354514f5e3Sopenharmony_ci} 77364514f5e3Sopenharmony_ci 77374514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallthis0Imm8V8( 77384514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 77394514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77404514f5e3Sopenharmony_ci{ 77414514f5e3Sopenharmony_ci DISPATCH(CALLTHIS0_IMM8_V8); 77424514f5e3Sopenharmony_ci} 77434514f5e3Sopenharmony_ci 77444514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallthis1Imm8V8V8( 77454514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 77464514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77474514f5e3Sopenharmony_ci{ 77484514f5e3Sopenharmony_ci DISPATCH(CALLTHIS1_IMM8_V8_V8); 77494514f5e3Sopenharmony_ci} 77504514f5e3Sopenharmony_ci 77514514f5e3Sopenharmony_civoid InterpreterAssembly::HandleNop( 77524514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 77534514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77544514f5e3Sopenharmony_ci{ 77554514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::nop"; 77564514f5e3Sopenharmony_ci DISPATCH(NOP); 77574514f5e3Sopenharmony_ci} 77584514f5e3Sopenharmony_ci 77594514f5e3Sopenharmony_civoid InterpreterAssembly::ExceptionHandler( 77604514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 77614514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77624514f5e3Sopenharmony_ci{ 77634514f5e3Sopenharmony_ci FrameHandler frameHandler(thread); 77644514f5e3Sopenharmony_ci uint32_t pcOffset = panda_file::INVALID_OFFSET; 77654514f5e3Sopenharmony_ci for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) { 77664514f5e3Sopenharmony_ci if (frameHandler.IsEntryFrame() || frameHandler.IsBuiltinFrame()) { 77674514f5e3Sopenharmony_ci thread->SetLastFp(frameHandler.GetFp()); 77684514f5e3Sopenharmony_ci return; 77694514f5e3Sopenharmony_ci } 77704514f5e3Sopenharmony_ci auto method = frameHandler.GetMethod(); 77714514f5e3Sopenharmony_ci pcOffset = method->FindCatchBlock(frameHandler.GetBytecodeOffset()); 77724514f5e3Sopenharmony_ci if (pcOffset != INVALID_INDEX) { 77734514f5e3Sopenharmony_ci thread->SetCurrentFrame(frameHandler.GetSp()); 77744514f5e3Sopenharmony_ci thread->SetLastFp(frameHandler.GetFp()); 77754514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 77764514f5e3Sopenharmony_ci pc = method->GetBytecodeArray() + pcOffset; 77774514f5e3Sopenharmony_ci break; 77784514f5e3Sopenharmony_ci } 77794514f5e3Sopenharmony_ci } 77804514f5e3Sopenharmony_ci if (pcOffset == INVALID_INDEX) { 77814514f5e3Sopenharmony_ci return; 77824514f5e3Sopenharmony_ci } 77834514f5e3Sopenharmony_ci 77844514f5e3Sopenharmony_ci auto exception = thread->GetException(); 77854514f5e3Sopenharmony_ci SET_ACC(exception); 77864514f5e3Sopenharmony_ci thread->ClearException(); 77874514f5e3Sopenharmony_ci DISPATCH_OFFSET(0); 77884514f5e3Sopenharmony_ci} 77894514f5e3Sopenharmony_ci 77904514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdLazyModuleVarPrefImm8( 77914514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 77924514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 77934514f5e3Sopenharmony_ci{ 77944514f5e3Sopenharmony_ci int32_t index = READ_INST_8_1(); 77954514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 77964514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlazyexternalmodulevar index:" << index; 77974514f5e3Sopenharmony_ci 77984514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdLazyExternalModuleVar(thread, index, thisFunc); 77994514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 78004514f5e3Sopenharmony_ci SET_ACC(moduleVar); 78014514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_LDLAZYMODULEVAR_PREF_IMM8); 78024514f5e3Sopenharmony_ci} 78034514f5e3Sopenharmony_ci 78044514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeWideLdLazyModuleVarPrefImm16( 78054514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 78064514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 78074514f5e3Sopenharmony_ci{ 78084514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 78094514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 78104514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlazyexternalmodulevar index:" << index; 78114514f5e3Sopenharmony_ci 78124514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdLazyExternalModuleVar(thread, index, thisFunc); 78134514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 78144514f5e3Sopenharmony_ci SET_ACC(moduleVar); 78154514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_WIDELDLAZYMODULEVAR_PREF_IMM16); 78164514f5e3Sopenharmony_ci} 78174514f5e3Sopenharmony_ci 78184514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeLdLazySendableModuleVarPrefImm8( 78194514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 78204514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 78214514f5e3Sopenharmony_ci{ 78224514f5e3Sopenharmony_ci int32_t index = READ_INST_8_1(); 78234514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 78244514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlazysendableexternalmodulevar index:" << index; 78254514f5e3Sopenharmony_ci 78264514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdLazySendableExternalModuleVar(thread, index, thisFunc); 78274514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 78284514f5e3Sopenharmony_ci SET_ACC(moduleVar); 78294514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_LDLAZYSENDABLEMODULEVAR_PREF_IMM8); 78304514f5e3Sopenharmony_ci} 78314514f5e3Sopenharmony_ci 78324514f5e3Sopenharmony_civoid InterpreterAssembly::HandleCallRuntimeWideLdLazySendableModuleVarPrefImm16( 78334514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, JSTaggedValue profileTypeInfo, 78344514f5e3Sopenharmony_ci JSTaggedValue acc, int16_t hotnessCounter) 78354514f5e3Sopenharmony_ci{ 78364514f5e3Sopenharmony_ci int32_t index = READ_INST_16_1(); 78374514f5e3Sopenharmony_ci JSTaggedValue thisFunc = GetFunction(sp); 78384514f5e3Sopenharmony_ci LOG_INST() << "intrinsics::ldlazysendableexternalmodulevar index:" << index; 78394514f5e3Sopenharmony_ci 78404514f5e3Sopenharmony_ci JSTaggedValue moduleVar = SlowRuntimeStub::LdLazySendableExternalModuleVar(thread, index, thisFunc); 78414514f5e3Sopenharmony_ci INTERPRETER_RETURN_IF_ABRUPT(moduleVar); 78424514f5e3Sopenharmony_ci SET_ACC(moduleVar); 78434514f5e3Sopenharmony_ci DISPATCH(CALLRUNTIME_WIDELDLAZYSENDABLEMODULEVAR_PREF_IMM16); 78444514f5e3Sopenharmony_ci} 78454514f5e3Sopenharmony_ci 78464514f5e3Sopenharmony_ci#define DECLARE_UNUSED_ASM_HANDLE(name) \ 78474514f5e3Sopenharmony_ci void InterpreterAssembly::name( \ 78484514f5e3Sopenharmony_ci JSThread *thread, const uint8_t *pc, JSTaggedType *sp, JSTaggedValue constpool, \ 78494514f5e3Sopenharmony_ci JSTaggedValue profileTypeInfo, JSTaggedValue acc, int16_t hotnessCounter) \ 78504514f5e3Sopenharmony_ci { \ 78514514f5e3Sopenharmony_ci LOG_INTERPRETER(FATAL) << #name; \ 78524514f5e3Sopenharmony_ci } 78534514f5e3Sopenharmony_ciASM_UNUSED_BC_STUB_LIST(DECLARE_UNUSED_ASM_HANDLE) 78544514f5e3Sopenharmony_ci#undef DECLARE_UNUSED_ASM_HANDLE 78554514f5e3Sopenharmony_ci#endif 78564514f5e3Sopenharmony_ci 78574514f5e3Sopenharmony_ciinline void InterpreterAssembly::InterpreterFrameCopyArgs( 78584514f5e3Sopenharmony_ci JSTaggedType *newSp, uint32_t numVregs, uint32_t numActualArgs, uint32_t numDeclaredArgs, bool haveExtraArgs) 78594514f5e3Sopenharmony_ci{ 78604514f5e3Sopenharmony_ci size_t i = 0; 78614514f5e3Sopenharmony_ci for (; i < numVregs; i++) { 78624514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 78634514f5e3Sopenharmony_ci newSp[i] = JSTaggedValue::VALUE_UNDEFINED; 78644514f5e3Sopenharmony_ci } 78654514f5e3Sopenharmony_ci for (i = numActualArgs; i < numDeclaredArgs; i++) { 78664514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 78674514f5e3Sopenharmony_ci newSp[numVregs + i] = JSTaggedValue::VALUE_UNDEFINED; 78684514f5e3Sopenharmony_ci } 78694514f5e3Sopenharmony_ci if (haveExtraArgs) { 78704514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 78714514f5e3Sopenharmony_ci newSp[numVregs + i] = JSTaggedValue(numActualArgs).GetRawData(); // numActualArgs is stored at the end 78724514f5e3Sopenharmony_ci } 78734514f5e3Sopenharmony_ci} 78744514f5e3Sopenharmony_ci 78754514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetFunction(JSTaggedType *sp) 78764514f5e3Sopenharmony_ci{ 78774514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 78784514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 78794514f5e3Sopenharmony_ci return JSTaggedValue(state->function); 78804514f5e3Sopenharmony_ci} 78814514f5e3Sopenharmony_ci 78824514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetThis(JSTaggedType *sp) 78834514f5e3Sopenharmony_ci{ 78844514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 78854514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 78864514f5e3Sopenharmony_ci return JSTaggedValue(state->thisObj); 78874514f5e3Sopenharmony_ci} 78884514f5e3Sopenharmony_ci 78894514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetNewTarget(JSTaggedType *sp) 78904514f5e3Sopenharmony_ci{ 78914514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 78924514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 78934514f5e3Sopenharmony_ci Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget(); 78944514f5e3Sopenharmony_ci ASSERT(method->HaveNewTargetWithCallField()); 78954514f5e3Sopenharmony_ci uint32_t numVregs = method->GetNumVregsWithCallField(); 78964514f5e3Sopenharmony_ci bool haveFunc = method->HaveFuncWithCallField(); 78974514f5e3Sopenharmony_ci return JSTaggedValue(sp[numVregs + haveFunc]); 78984514f5e3Sopenharmony_ci} 78994514f5e3Sopenharmony_ci 79004514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetConstantPool(JSTaggedType *sp) 79014514f5e3Sopenharmony_ci{ 79024514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 79034514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 79044514f5e3Sopenharmony_ci Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget(); 79054514f5e3Sopenharmony_ci return method->GetConstantPool(); 79064514f5e3Sopenharmony_ci} 79074514f5e3Sopenharmony_ci 79084514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetUnsharedConstpool(JSThread* thread, JSTaggedType *sp) 79094514f5e3Sopenharmony_ci{ 79104514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 79114514f5e3Sopenharmony_ci Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget(); 79124514f5e3Sopenharmony_ci return thread->GetCurrentEcmaContext()->FindOrCreateUnsharedConstpool(method->GetConstantPool()); 79134514f5e3Sopenharmony_ci} 79144514f5e3Sopenharmony_ci 79154514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetModule(JSTaggedType *sp) 79164514f5e3Sopenharmony_ci{ 79174514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 79184514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 79194514f5e3Sopenharmony_ci return JSFunction::Cast(state->function.GetTaggedObject())->GetModule(); 79204514f5e3Sopenharmony_ci} 79214514f5e3Sopenharmony_ci 79224514f5e3Sopenharmony_ciJSTaggedValue InterpreterAssembly::GetProfileTypeInfo(JSTaggedType *sp) 79234514f5e3Sopenharmony_ci{ 79244514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 79254514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 79264514f5e3Sopenharmony_ci JSFunction *function = JSFunction::Cast(state->function.GetTaggedObject()); 79274514f5e3Sopenharmony_ci return function->GetProfileTypeInfo(); 79284514f5e3Sopenharmony_ci} 79294514f5e3Sopenharmony_ci 79304514f5e3Sopenharmony_ciJSTaggedType *InterpreterAssembly::GetAsmInterpreterFramePointer(AsmInterpretedFrame *state) 79314514f5e3Sopenharmony_ci{ 79324514f5e3Sopenharmony_ci return state->GetCurrentFramePointer(); 79334514f5e3Sopenharmony_ci} 79344514f5e3Sopenharmony_ci 79354514f5e3Sopenharmony_ciuint32_t InterpreterAssembly::GetNumArgs(JSTaggedType *sp, uint32_t restIdx, uint32_t &startIdx) 79364514f5e3Sopenharmony_ci{ 79374514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 79384514f5e3Sopenharmony_ci AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1; 79394514f5e3Sopenharmony_ci Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget(); 79404514f5e3Sopenharmony_ci ASSERT(method->HaveExtraWithCallField()); 79414514f5e3Sopenharmony_ci 79424514f5e3Sopenharmony_ci uint32_t numVregs = method->GetNumVregsWithCallField(); 79434514f5e3Sopenharmony_ci bool haveFunc = method->HaveFuncWithCallField(); 79444514f5e3Sopenharmony_ci bool haveNewTarget = method->HaveNewTargetWithCallField(); 79454514f5e3Sopenharmony_ci bool haveThis = method->HaveThisWithCallField(); 79464514f5e3Sopenharmony_ci uint32_t copyArgs = haveFunc + haveNewTarget + haveThis; 79474514f5e3Sopenharmony_ci uint32_t numArgs = method->GetNumArgsWithCallField(); 79484514f5e3Sopenharmony_ci 79494514f5e3Sopenharmony_ci JSTaggedType *fp = GetAsmInterpreterFramePointer(state); 79504514f5e3Sopenharmony_ci if (static_cast<uint32_t>(fp - sp) > numVregs + copyArgs + numArgs) { 79514514f5e3Sopenharmony_ci // In this case, actualNumArgs is in the end 79524514f5e3Sopenharmony_ci // If not, then actualNumArgs == declaredNumArgs, therefore do nothing 79534514f5e3Sopenharmony_ci // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) 79544514f5e3Sopenharmony_ci numArgs = static_cast<uint32_t>(JSTaggedValue(*(fp - 1)).GetInt()); 79554514f5e3Sopenharmony_ci } 79564514f5e3Sopenharmony_ci startIdx = numVregs + copyArgs + restIdx; 79574514f5e3Sopenharmony_ci return ((numArgs > restIdx) ? (numArgs - restIdx) : 0); 79584514f5e3Sopenharmony_ci} 79594514f5e3Sopenharmony_ci 79604514f5e3Sopenharmony_ciinline size_t InterpreterAssembly::GetJumpSizeAfterCall(const uint8_t *prevPc) 79614514f5e3Sopenharmony_ci{ 79624514f5e3Sopenharmony_ci auto op = BytecodeInstruction(prevPc).GetOpcode(); 79634514f5e3Sopenharmony_ci size_t jumpSize = BytecodeInstruction::Size(op); 79644514f5e3Sopenharmony_ci return jumpSize; 79654514f5e3Sopenharmony_ci} 79664514f5e3Sopenharmony_ci 79674514f5e3Sopenharmony_ciinline JSTaggedValue InterpreterAssembly::UpdateHotnessCounter(JSThread* thread, JSTaggedType *sp) 79684514f5e3Sopenharmony_ci{ 79694514f5e3Sopenharmony_ci AsmInterpretedFrame *state = GET_ASM_FRAME(sp); 79704514f5e3Sopenharmony_ci thread->CheckSafepoint(); 79714514f5e3Sopenharmony_ci JSFunction* function = JSFunction::Cast(state->function.GetTaggedObject()); 79724514f5e3Sopenharmony_ci JSTaggedValue profileTypeInfo = function->GetProfileTypeInfo(); 79734514f5e3Sopenharmony_ci if (profileTypeInfo.IsUndefined()) { 79744514f5e3Sopenharmony_ci return SlowRuntimeStub::NotifyInlineCache(thread, function); 79754514f5e3Sopenharmony_ci } 79764514f5e3Sopenharmony_ci return profileTypeInfo; 79774514f5e3Sopenharmony_ci} 79784514f5e3Sopenharmony_ci#undef LOG_INST 79794514f5e3Sopenharmony_ci#undef ADVANCE_PC 79804514f5e3Sopenharmony_ci#undef GOTO_NEXT 79814514f5e3Sopenharmony_ci#undef DISPATCH_OFFSET 79824514f5e3Sopenharmony_ci#undef GET_ASM_FRAME 79834514f5e3Sopenharmony_ci#undef GET_ENTRY_FRAME 79844514f5e3Sopenharmony_ci#undef SAVE_PC 79854514f5e3Sopenharmony_ci#undef SAVE_ACC 79864514f5e3Sopenharmony_ci#undef RESTORE_ACC 79874514f5e3Sopenharmony_ci#undef INTERPRETER_GOTO_EXCEPTION_HANDLER 79884514f5e3Sopenharmony_ci#undef INTERPRETER_HANDLE_RETURN 79894514f5e3Sopenharmony_ci#undef UPDATE_HOTNESS_COUNTER 79904514f5e3Sopenharmony_ci#undef GET_VREG 79914514f5e3Sopenharmony_ci#undef GET_VREG_VALUE 79924514f5e3Sopenharmony_ci#undef SET_VREG 79934514f5e3Sopenharmony_ci#undef GET_ACC 79944514f5e3Sopenharmony_ci#undef SET_ACC 79954514f5e3Sopenharmony_ci#if defined(__clang__) 79964514f5e3Sopenharmony_ci#pragma clang diagnostic pop 79974514f5e3Sopenharmony_ci#elif defined(__GNUC__) 79984514f5e3Sopenharmony_ci#pragma GCC diagnostic pop 79994514f5e3Sopenharmony_ci#endif 80004514f5e3Sopenharmony_ci} // namespace panda::ecmascript 8001