diff --git a/compiler/ecmascript_call_params.h b/compiler/ecmascript_call_params.h index 3f2bc43db466ab4925cdfb50a7fe67a28d751b67..73f7dfb5ea112d43b54b2935dd61263159d73123 100644 --- a/compiler/ecmascript_call_params.h +++ b/compiler/ecmascript_call_params.h @@ -25,13 +25,13 @@ namespace panda::compiler { namespace EcmascriptCallParams { enum : uint8_t { SLOT_FUNCTION = CallConvDynInfo::SLOT_CALLEE, - SLOT_NEWTARGET = ::panda::ecmascript::JSMethodArgs::NEW_TARGET_IDX, - SLOT_THIS = ::panda::ecmascript::JSMethodArgs::THIS_IDX, - SLOT_FIRST_ARG = ::panda::ecmascript::JSMethodArgs::FIRST_ARG_IDX, + SLOT_NEWTARGET = ::panda::ecmascript::js_method_args::NEW_TARGET_IDX, + SLOT_THIS = ::panda::ecmascript::js_method_args::THIS_IDX, + SLOT_FIRST_ARG = ::panda::ecmascript::js_method_args::FIRST_ARG_IDX, }; } // namespace EcmascriptCallParams static_assert(static_cast(EcmascriptCallParams::SLOT_FUNCTION) == - static_cast(::panda::ecmascript::JSMethodArgs::FUNC_IDX)); + static_cast(::panda::ecmascript::js_method_args::FUNC_IDX)); } // namespace panda::compiler diff --git a/runtime/builtins/builtins_array.cpp b/runtime/builtins/builtins_array.cpp index 841f16340ea20de272d78eb692c730935e585d5d..230a4abc1059d50a3fab70f062b49445db0ab3cf 100644 --- a/runtime/builtins/builtins_array.cpp +++ b/runtime/builtins/builtins_array.cpp @@ -2737,7 +2737,7 @@ JSTaggedValue BuiltinsArray::ToString(EcmaRuntimeCallInfo *argv) NewRuntimeCallInfo(thread, callbackFnHandle, thisObjVal, JSTaggedValue::Undefined(), argv->GetArgsNumber()); if (argv->GetArgsNumber() > 0) { info->SetCallArg(argv->GetArgsNumber(), - reinterpret_cast(argv->GetArgAddress(JSMethodArgs::NUM_MANDATORY_ARGS))); + reinterpret_cast(argv->GetArgAddress(js_method_args::NUM_MANDATORY_ARGS))); } return JSFunction::Call(info.get()); } diff --git a/runtime/builtins/builtins_function.cpp b/runtime/builtins/builtins_function.cpp index 7e6fc75f2ac3a7767e3fbfb04d8d45c89c0b1aa2..925ed8ebc10e86b013cd5174951bcc9cb12e03fc 100644 --- a/runtime/builtins/builtins_function.cpp +++ b/runtime/builtins/builtins_function.cpp @@ -248,7 +248,7 @@ JSTaggedValue BuiltinsFunction::FunctionPrototypeCall(EcmaRuntimeCallInfo *argv) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (argsLength > 0) { info->SetCallArg(argsLength, - reinterpret_cast(argv->GetArgAddress(JSMethodArgs::NUM_MANDATORY_ARGS + 1))); + reinterpret_cast(argv->GetArgAddress(js_method_args::NUM_MANDATORY_ARGS + 1))); } return JSFunction::Call(info.get()); } diff --git a/runtime/builtins/builtins_object.cpp b/runtime/builtins/builtins_object.cpp index 0ef7df54645d70875cbebeaa4cfc30e47458c2ae..fde1dcf1d42847e671d58356c9312b6f563822ad 100644 --- a/runtime/builtins/builtins_object.cpp +++ b/runtime/builtins/builtins_object.cpp @@ -833,7 +833,7 @@ JSTaggedValue BuiltinsObject::ToLocaleString(EcmaRuntimeCallInfo *argv) argv->GetArgsNumber()); if (argv->GetArgsNumber() > 0) { info->SetCallArg(argv->GetArgsNumber(), - reinterpret_cast(argv->GetArgAddress(JSMethodArgs::NUM_MANDATORY_ARGS))); + reinterpret_cast(argv->GetArgAddress(js_method_args::NUM_MANDATORY_ARGS))); } return JSFunction::Invoke(info.get(), calleeKey); } diff --git a/runtime/ecma_call_params.h b/runtime/ecma_call_params.h index 71250ab8b7cba5ceeb5cfb64cba33eb85f6d8953..151381fec3dc27e3aeb8bbfd29483e1ac18018e6 100644 --- a/runtime/ecma_call_params.h +++ b/runtime/ecma_call_params.h @@ -18,7 +18,7 @@ #include -namespace panda::ecmascript::JSMethodArgs { +namespace panda::ecmascript::js_method_args { enum : uint8_t { FUNC_IDX = 0, NEW_TARGET_IDX = 1, @@ -28,6 +28,6 @@ enum : uint8_t { FIRST_ARG_IDX = NUM_MANDATORY_ARGS, }; -} // namespace panda::ecmascript::JSMethodArgs +} // namespace panda::ecmascript::js_method_args #endif // PANDA_RUNTIME_ECMASCRIPT_CALL_PARAMS diff --git a/runtime/ecma_runtime_call_info.h b/runtime/ecma_runtime_call_info.h index 7044007c97e31bcf9a673e1190b28db9012615d4..482977ec019d417dd04955ebce1a9b8e4b704fbe 100644 --- a/runtime/ecma_runtime_call_info.h +++ b/runtime/ecma_runtime_call_info.h @@ -32,7 +32,7 @@ public: EcmaRuntimeCallInfo(JSThread *thread, uint32_t num_args, JSTaggedValue *args) : thread_(thread), num_args_(num_args), args_(args) { - ASSERT(num_args >= JSMethodArgs::NUM_MANDATORY_ARGS); + ASSERT(num_args >= js_method_args::NUM_MANDATORY_ARGS); } ~EcmaRuntimeCallInfo() = default; @@ -44,44 +44,44 @@ public: inline void SetNewTarget(JSTaggedValue tagged) { - SetArg(JSMethodArgs::NEW_TARGET_IDX, tagged); + SetArg(js_method_args::NEW_TARGET_IDX, tagged); } inline void SetFunction(JSTaggedValue tagged) { - SetArg(JSMethodArgs::FUNC_IDX, tagged); + SetArg(js_method_args::FUNC_IDX, tagged); } inline void SetThis(JSTaggedValue tagged) { - SetArg(JSMethodArgs::THIS_IDX, tagged); + SetArg(js_method_args::THIS_IDX, tagged); } inline void SetCallArg(uint32_t idx, JSTaggedValue tagged) { ASSERT_PRINT(idx < GetArgsNumber(), "Can not set values out of index range"); - SetArg(idx + JSMethodArgs::FIRST_ARG_IDX, tagged); + SetArg(idx + js_method_args::FIRST_ARG_IDX, tagged); } inline JSHandle GetFunction() const { - return GetArg(JSMethodArgs::FUNC_IDX); + return GetArg(js_method_args::FUNC_IDX); } inline JSHandle GetNewTarget() const { - return GetArg(JSMethodArgs::NEW_TARGET_IDX); + return GetArg(js_method_args::NEW_TARGET_IDX); } inline JSHandle GetThis() const { - return GetArg(JSMethodArgs::THIS_IDX); + return GetArg(js_method_args::THIS_IDX); } inline JSHandle GetCallArg(uint32_t idx) const { ASSERT_PRINT(idx < GetArgsNumber(), "Can not set values out of index range"); - return GetArg(idx + JSMethodArgs::FIRST_ARG_IDX); + return GetArg(idx + js_method_args::FIRST_ARG_IDX); } /* @@ -90,7 +90,7 @@ public: */ inline uint32_t GetArgsNumber() const { - return num_args_ - JSMethodArgs::NUM_MANDATORY_ARGS; + return num_args_ - js_method_args::NUM_MANDATORY_ARGS; } inline uintptr_t GetArgAddress(uint32_t idx) const @@ -168,7 +168,7 @@ public: ScopedCallInfo(JSThread *thread, uint32_t num_args) { - num_args += JSMethodArgs::NUM_MANDATORY_ARGS; + num_args += js_method_args::NUM_MANDATORY_ARGS; auto allocator = thread->GetStackFrameAllocator(); auto *mem = reinterpret_cast( allocator->Alloc(AlignUp(num_args * sizeof(JSTaggedValue), GetAlignmentInBytes(DEFAULT_FRAME_ALIGNMENT)))); diff --git a/runtime/interpreter/ecma-interpreter-inl.h b/runtime/interpreter/ecma-interpreter-inl.h index 7116cbdb028bf1bdf2beb540339ab1623bb618db..915c68f6fcb30a1d90ac5cc115c442bbfb762316 100644 --- a/runtime/interpreter/ecma-interpreter-inl.h +++ b/runtime/interpreter/ecma-interpreter-inl.h @@ -165,21 +165,21 @@ public: { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto num_vregs = this->GetFrame()->GetMethod()->GetNumVregs(); - return GetRegAsTaggedValue(num_vregs + JSMethodArgs::FUNC_IDX); + return GetRegAsTaggedValue(num_vregs + js_method_args::FUNC_IDX); } JSTaggedValue GetCurrentNewTarget() { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto num_vregs = this->GetFrame()->GetMethod()->GetNumVregs(); - return GetRegAsTaggedValue(num_vregs + JSMethodArgs::NEW_TARGET_IDX); + return GetRegAsTaggedValue(num_vregs + js_method_args::NEW_TARGET_IDX); } JSTaggedValue GetCurrentThis() { // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) auto num_vregs = this->GetFrame()->GetMethod()->GetNumVregs(); - return GetRegAsTaggedValue(num_vregs + JSMethodArgs::THIS_IDX); + return GetRegAsTaggedValue(num_vregs + js_method_args::THIS_IDX); } JSTaggedValue GetGlobalObject() @@ -471,7 +471,7 @@ public: return; } this->GetFrame() - ->GetVReg(method->GetNumVregs() + JSMethodArgs::THIS_IDX) + ->GetVReg(method->GetNumVregs() + js_method_args::THIS_IDX) .SetValue(this_obj.GetRawData()); // Init EcmascriptEnvironment @@ -501,7 +501,7 @@ public: JSCopyArgumets(this->GetJSThread(), prev_frame, ctor.GetRawData(), prev_inst, frame, 0, num_actual_args); - frame->GetVReg(0 + JSMethodArgs::THIS_IDX).SetValue(JSTaggedValue::VALUE_UNDEFINED); + frame->GetVReg(0 + js_method_args::THIS_IDX).SetValue(JSTaggedValue::VALUE_UNDEFINED); // Call native method thread->SetCurrentFrame(frame); @@ -788,8 +788,8 @@ public: LOG_INST() << "getunmappedargs"; uint32_t actual_num_args = - this->GetFrame()->GetNumActualArgs() - JSMethodArgs::NUM_MANDATORY_ARGS; // not compile-time - uint32_t start_idx = this->GetFrame()->GetMethod()->GetNumVregs() + JSMethodArgs::NUM_MANDATORY_ARGS; + this->GetFrame()->GetNumActualArgs() - js_method_args::NUM_MANDATORY_ARGS; // not compile-time + uint32_t start_idx = this->GetFrame()->GetMethod()->GetNumVregs() + js_method_args::NUM_MANDATORY_ARGS; auto thread = JSThread::Cast(this->GetThread()); JSTaggedValue res = SlowRuntimeStub::GetUnmappedArgs(thread, actual_num_args, GetStkArgs(start_idx)); @@ -2120,10 +2120,10 @@ public: auto *state = this->GetFrame(); uint32_t num_vregs = state->GetMethod()->GetNumVregs(); // Exclude func, new_target and "this" - int32_t actual_num_args = state->GetNumActualArgs() - JSMethodArgs::NUM_MANDATORY_ARGS; + int32_t actual_num_args = state->GetNumActualArgs() - js_method_args::NUM_MANDATORY_ARGS; int32_t tmp = actual_num_args - rest_idx; uint32_t rest_num_args = (tmp > 0) ? tmp : 0; - uint32_t start_idx = num_vregs + JSMethodArgs::NUM_MANDATORY_ARGS + rest_idx; + uint32_t start_idx = num_vregs + js_method_args::NUM_MANDATORY_ARGS + rest_idx; auto thread = JSThread::Cast(this->GetThread()); JSTaggedValue res = SlowRuntimeStub::CopyRestArgs(thread, rest_num_args, GetStkArgs(start_idx)); diff --git a/runtime/interpreter/js_decode_call_instr.h b/runtime/interpreter/js_decode_call_instr.h index 511e64e1f8e4ebded96f56d34ff13529d9e6f7fc..89f5d02dc33f8fe31fdfc916da429c439b746338 100644 --- a/runtime/interpreter/js_decode_call_instr.h +++ b/runtime/interpreter/js_decode_call_instr.h @@ -18,46 +18,46 @@ ALWAYS_INLINE inline uint32_t JSGetNumberActualArgsDyn([[maybe_unused]] Bytecode constexpr auto OP = R::template Get(); if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 0; + return js_method_args::FIRST_ARG_IDX + 0; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 1; + return js_method_args::FIRST_ARG_IDX + 1; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 2; + return js_method_args::FIRST_ARG_IDX + 2; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 3; + return js_method_args::FIRST_ARG_IDX + 3; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); auto imm = inst.GetImm(); - return JSMethodArgs::FIRST_ARG_IDX + imm; + return js_method_args::FIRST_ARG_IDX + imm; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX; + return js_method_args::FIRST_ARG_IDX; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 1; + return js_method_args::FIRST_ARG_IDX + 1; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 2; + return js_method_args::FIRST_ARG_IDX + 2; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); - return JSMethodArgs::FIRST_ARG_IDX + 3; + return js_method_args::FIRST_ARG_IDX + 3; } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); auto imm = inst.GetImm(); ASSERT(imm >= 1); // magic, 'this' is counted in range, 'func' - not - return JSMethodArgs::FIRST_ARG_IDX + (imm - 1); + return js_method_args::FIRST_ARG_IDX + (imm - 1); } else if constexpr (OP == R::template Get()) { static_assert(FORMAT == R::template Get()); auto imm = inst.GetImm(); ASSERT(imm >= 2); // magic, 'func' and 'new_target' are counted in range - return JSMethodArgs::FIRST_ARG_IDX + (imm - 2); + return js_method_args::FIRST_ARG_IDX + (imm - 2); } else { enum { IMPOSSIBLE_CASE = false }; static_assert(IMPOSSIBLE_CASE, "Impossible case"); @@ -145,10 +145,10 @@ ALWAYS_INLINE inline static void JSCopyArgumets(JSThread *thread, Frame *prev_fr using R = BytecodeInstructionResolver; constexpr auto op = R::template Get(); - ASSERT(num_actual_args >= JSMethodArgs::FIRST_ARG_IDX); - new_frame->GetVReg(num_vregs + JSMethodArgs::FUNC_IDX).SetValue(raw_fn_object); + ASSERT(num_actual_args >= js_method_args::FIRST_ARG_IDX); + new_frame->GetVReg(num_vregs + js_method_args::FUNC_IDX).SetValue(raw_fn_object); if constexpr (op != R::template Get()) { - new_frame->GetVReg(num_vregs + JSMethodArgs::NEW_TARGET_IDX).SetValue(JSTaggedValue::VALUE_UNDEFINED); + new_frame->GetVReg(num_vregs + js_method_args::NEW_TARGET_IDX).SetValue(JSTaggedValue::VALUE_UNDEFINED); } if constexpr (op == R::template Get() || @@ -161,73 +161,79 @@ ALWAYS_INLINE inline static void JSCopyArgumets(JSThread *thread, Frame *prev_fr if (fn_object.IsJSFunction() && !JSFunction::Cast(fn_object.GetHeapObject())->IsStrict()) { this_arg = thread->GetGlobalObject().GetRawData(); } - new_frame->GetVReg(num_vregs + JSMethodArgs::THIS_IDX).SetValue(this_arg); + new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX).SetValue(this_arg); } if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX); // Do nothing } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX + 1); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 0).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX + 1); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 0) + .SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX + 2); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(1)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 1).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX + 2); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(1)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 1) + .SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX + 3); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(1)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 1) = prev_frame->GetVReg(prev_inst.GetVReg(2)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 2).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX + 3); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(1)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 1) = prev_frame->GetVReg(prev_inst.GetVReg(2)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 2) + .SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); uint16_t prev_v0 = JSGetCalleRangeStartDyn(prev_inst); - for (uint16_t i = 0; i < (num_actual_args - JSMethodArgs::FIRST_ARG_IDX); ++i) { - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 1 + i); + for (uint16_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 1 + i); } } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX); - new_frame->GetVReg(num_vregs + JSMethodArgs::THIS_IDX).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX); + new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX).SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX + 1); - new_frame->GetVReg(num_vregs + JSMethodArgs::THIS_IDX) = prev_frame->GetVReg(prev_inst.GetVReg(1)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 0).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX + 1); + new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX) = prev_frame->GetVReg(prev_inst.GetVReg(1)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 0) + .SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX + 2); - new_frame->GetVReg(num_vregs + JSMethodArgs::THIS_IDX) = prev_frame->GetVReg(prev_inst.GetVReg(1)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(2)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 1).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX + 2); + new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX) = prev_frame->GetVReg(prev_inst.GetVReg(1)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(2)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 1) + .SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); - ASSERT(num_actual_args == JSMethodArgs::FIRST_ARG_IDX + 3); - new_frame->GetVReg(num_vregs + JSMethodArgs::THIS_IDX) = prev_frame->GetVReg(prev_inst.GetVReg(1)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(2)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 1) = prev_frame->GetVReg(prev_inst.GetVReg(3)); - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + 2).SetValue(prev_frame->GetAccAsVReg().GetValue()); + ASSERT(num_actual_args == js_method_args::FIRST_ARG_IDX + 3); + new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX) = prev_frame->GetVReg(prev_inst.GetVReg(1)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 0) = prev_frame->GetVReg(prev_inst.GetVReg(2)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 1) = prev_frame->GetVReg(prev_inst.GetVReg(3)); + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + 2) + .SetValue(prev_frame->GetAccAsVReg().GetValue()); } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); uint16_t prev_v0 = JSGetCalleRangeStartDyn(prev_inst); - new_frame->GetVReg(num_vregs + JSMethodArgs::THIS_IDX) = prev_frame->GetVReg(prev_v0 + 1); - for (uint16_t i = 0; i < (num_actual_args - JSMethodArgs::FIRST_ARG_IDX); ++i) { - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 2 + i); + new_frame->GetVReg(num_vregs + js_method_args::THIS_IDX) = prev_frame->GetVReg(prev_v0 + 1); + for (uint16_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 2 + i); } } else if constexpr (op == R::template Get()) { static_assert(FORMAT == R::template Get()); uint16_t prev_v0 = JSGetCalleRangeStartDyn(prev_inst); - new_frame->GetVReg(num_vregs + JSMethodArgs::NEW_TARGET_IDX) = prev_frame->GetVReg(prev_v0 + 1); - for (uint16_t i = 0; i < (num_actual_args - JSMethodArgs::FIRST_ARG_IDX); ++i) { - new_frame->GetVReg(num_vregs + JSMethodArgs::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 2 + i); + new_frame->GetVReg(num_vregs + js_method_args::NEW_TARGET_IDX) = prev_frame->GetVReg(prev_v0 + 1); + for (uint16_t i = 0; i < (num_actual_args - js_method_args::FIRST_ARG_IDX); ++i) { + new_frame->GetVReg(num_vregs + js_method_args::FIRST_ARG_IDX + i) = prev_frame->GetVReg(prev_v0 + 2 + i); } } else { enum { IMPOSSIBLE_CASE = false }; diff --git a/runtime/interpreter/slow_runtime_helper.cpp b/runtime/interpreter/slow_runtime_helper.cpp index cf7b5162880d2b2199dc256576d9e3e1bd2956e5..3a59581658953fcd5d62f43aa09acfa853f87faa 100644 --- a/runtime/interpreter/slow_runtime_helper.cpp +++ b/runtime/interpreter/slow_runtime_helper.cpp @@ -56,7 +56,7 @@ JSTaggedValue SlowRuntimeHelper::CallBoundFunction(EcmaRuntimeCallInfo *info) } if (argsLength != 0) { runtime_info->SetCallArg( - argsLength, reinterpret_cast(info->GetArgAddress(JSMethodArgs::NUM_MANDATORY_ARGS)), + argsLength, reinterpret_cast(info->GetArgAddress(js_method_args::NUM_MANDATORY_ARGS)), boundLength); } return EcmaInterpreter::Execute(runtime_info.get()); diff --git a/runtime/intrinsics-inl.h b/runtime/intrinsics-inl.h index 579899d0de5c2f2550f47b7e7fd2ee2672886b66..542c64435885bfc3f2c817f1015b3137198e8921 100644 --- a/runtime/intrinsics-inl.h +++ b/runtime/intrinsics-inl.h @@ -623,8 +623,8 @@ INLINE_ECMA_INTRINSICS uint64_t GetUnmappedArgs([[maybe_unused]] JSThread *threa INLINE_ECMA_INTRINSICS uint64_t GetUnmappedArgsInterp(JSThread *thread) { ASSERT(!thread->IsCurrentFrameCompiled()); - uint32_t actual_num_args = thread->GetCurrentFrame()->GetNumActualArgs() - JSMethodArgs::NUM_MANDATORY_ARGS; - uint32_t start_idx = thread->GetCurrentFrame()->GetMethod()->GetNumVregs() + JSMethodArgs::NUM_MANDATORY_ARGS; + uint32_t actual_num_args = thread->GetCurrentFrame()->GetNumActualArgs() - js_method_args::NUM_MANDATORY_ARGS; + uint32_t start_idx = thread->GetCurrentFrame()->GetMethod()->GetNumVregs() + js_method_args::NUM_MANDATORY_ARGS; auto args = reinterpret_cast(&thread->GetCurrentFrame()->GetVReg(start_idx)); return SlowRuntimeStub::GetUnmappedArgs(thread, actual_num_args, reinterpret_cast(args)) .GetRawData(); @@ -716,10 +716,10 @@ INLINE_ECMA_INTRINSICS uint64_t CopyrestargsInterp(JSThread *thread, uint16_t in ASSERT(!thread->IsCurrentFrameCompiled()); auto *frame = thread->GetCurrentFrame(); uint32_t num_vregs = frame->GetMethod()->GetNumVregs(); - int32_t actual_num_args = frame->GetNumActualArgs() - JSMethodArgs::NUM_MANDATORY_ARGS; + int32_t actual_num_args = frame->GetNumActualArgs() - js_method_args::NUM_MANDATORY_ARGS; int32_t tmp = actual_num_args - index; uint32_t rest_num_args = (tmp > 0) ? tmp : 0; - uint32_t start_idx = num_vregs + JSMethodArgs::NUM_MANDATORY_ARGS + index; + uint32_t start_idx = num_vregs + js_method_args::NUM_MANDATORY_ARGS + index; auto args = reinterpret_cast(&thread->GetCurrentFrame()->GetVReg(start_idx)); diff --git a/runtime/js_eval.cpp b/runtime/js_eval.cpp index 9db28f3fa4c97ab2c4cfc6d9932a75de9a93d098..9bdc7d4550f226942cf018789335c528934ec199 100644 --- a/runtime/js_eval.cpp +++ b/runtime/js_eval.cpp @@ -79,8 +79,8 @@ JSTaggedValue EvalUtils::DirectEval(JSThread *thread, uint32_t parserStatus, JST RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, argStr.GetTaggedValue()); es2panda::CompilerOptions options; - options.isEval = true; - options.isDirectEval = true; + options.is_eval = true; + options.is_direct_eval = true; JSHandle func(thread, GetEvaluatedScript(thread, argStr, options, parserStatus)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, func.GetTaggedValue()); @@ -91,7 +91,7 @@ JSTaggedValue EvalUtils::DirectEval(JSThread *thread, uint32_t parserStatus, JST JSHandle thisValue = JSArray::FastGetPropertyByValue(thread, evalBindingsHandle, index++); JSHandle lexicalContext = JSArray::FastGetPropertyByValue(thread, evalBindingsHandle, index++); - ASSERT(1 == index - JSMethodArgs::NUM_MANDATORY_ARGS); + ASSERT(1 == index - js_method_args::NUM_MANDATORY_ARGS); auto info = NewRuntimeCallInfo(thread, paramFunc, thisValue, newTarget, 1); info->SetCallArgs(lexicalContext); @@ -108,7 +108,7 @@ JSTaggedValue EvalUtils::Eval(JSThread *thread, const JSHandle &a RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, argStr.GetTaggedValue()); es2panda::CompilerOptions options; - options.isEval = true; + options.is_eval = true; JSHandle func(thread, GetEvaluatedScript(thread, argStr, options)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, func.GetTaggedValue()); @@ -193,8 +193,8 @@ JSTaggedValue EvalUtils::CreateDynamicFunction(EcmaRuntimeCallInfo *argv, Dynami resultStr = factory->ConcatFromString(resultStr, rightBraceRightParen); es2panda::CompilerOptions options; - options.isEval = true; - options.isFunctionEval = true; + options.is_eval = true; + options.is_function_eval = true; JSHandle func(thread, GetEvaluatedScript(thread, resultStr, options)); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, func.GetTaggedValue()); diff --git a/runtime/js_function.cpp b/runtime/js_function.cpp index d9cfaf6f2e98594a3ce8e333ee1668e522e686a5..0e1893ba90a253bbffce432c77d71b604b4f8a4f 100644 --- a/runtime/js_function.cpp +++ b/runtime/js_function.cpp @@ -441,7 +441,7 @@ JSTaggedValue JSBoundFunction::ConstructInternal(EcmaRuntimeCallInfo *info) } if (argsLength != 0) { runtime_info->SetCallArg( - argsLength, reinterpret_cast(info->GetArgAddress(JSMethodArgs::NUM_MANDATORY_ARGS)), + argsLength, reinterpret_cast(info->GetArgAddress(js_method_args::NUM_MANDATORY_ARGS)), boundLength); } return JSFunction::Construct(runtime_info.get()); diff --git a/runtime/js_proxy.cpp b/runtime/js_proxy.cpp index 1356a17ffe9321378a931565ea1134befe8af58d..dff75a2d20c506fd194ef505c15c31f37750b406 100644 --- a/runtime/js_proxy.cpp +++ b/runtime/js_proxy.cpp @@ -865,7 +865,7 @@ JSTaggedValue JSProxy::CallInternal(EcmaRuntimeCallInfo *info) RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); if (argc > 0) { runtimeInfo->SetCallArg( - argc, reinterpret_cast(info->GetArgAddress(JSMethodArgs::NUM_MANDATORY_ARGS))); + argc, reinterpret_cast(info->GetArgAddress(js_method_args::NUM_MANDATORY_ARGS))); } return JSFunction::Call(runtimeInfo.get()); }