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