diff --git a/ecmascript/compiler/builtins/builtins_call_signature.cpp b/ecmascript/compiler/builtins/builtins_call_signature.cpp index 9b148fa854d60447158840be0d15dc90a7d57bc7..d83048739d16ef080c2a9093dde6fef3f5f14714 100644 --- a/ecmascript/compiler/builtins/builtins_call_signature.cpp +++ b/ecmascript/compiler/builtins/builtins_call_signature.cpp @@ -24,46 +24,45 @@ CallSignature BuiltinsStubCSigns::builtinsWithArgvCSign_; void BuiltinsStubCSigns::Initialize() { -#define COMMON_INIT(name) \ - callSigns_[SubID::name].SetID(SubID::name); \ - callSigns_[SubID::name].SetName(std::string("BuiltinStub_") + #name); \ - callSigns_[SubID::name].SetConstructor( \ - [](void* env) { \ - return static_cast( \ - new name##StubBuilder(&callSigns_[SubID::name], \ - static_cast(env), Gate::InvalidGateRef)); \ +#define COMMON_INIT(name) \ + callSigns_[ID_##name].SetID(ID_##name); \ + callSigns_[ID_##name].SetName(std::string("BuiltinStub_") + #name); \ + callSigns_[ID_##name].SetConstructor( \ + [](void* env) { \ + return static_cast( \ + new name##StubBuilder(&callSigns_[ID_##name], \ + static_cast(env), Gate::InvalidGateRef)); \ }); -#define INIT_BUILTINS_METHOD(name) \ - BuiltinsCallSignature::Initialize(&callSigns_[SubID::name]); \ +#define INIT_BUILTINS_METHOD(name) \ + BuiltinsCallSignature::Initialize(&callSigns_[ID_##name]); \ COMMON_INIT(name) -#define INIT_BUILTINS_METHOD_DYN(name, type, ...) \ - BuiltinsCallSignature::Initialize(&callSigns_[SubID::type##name]); \ +#define INIT_BUILTINS_METHOD_DYN(name, type, ...) \ + BuiltinsCallSignature::Initialize(&callSigns_[ID_##type##name]); \ COMMON_INIT(type##name) -#define INIT_BUILTINS_CONSTRUCTOR_METHOD(name) \ - BuiltinsWithArgvCallSignature::Initialize(&callSigns_[SubID::name]); \ +#define INIT_BUILTINS_CONSTRUCTOR_METHOD(name) \ + BuiltinsWithArgvCallSignature::Initialize(&callSigns_[ID_##name]); \ COMMON_INIT(name) - BUILTINS_STUB_LIST(INIT_BUILTINS_METHOD, INIT_BUILTINS_METHOD_DYN, INIT_BUILTINS_CONSTRUCTOR_METHOD) - -#define STW_COPY_INIT(name) \ - callSigns_[SubID::name].SetStwCopyStub(true); \ - callSigns_[SubID::name].SetTargetKind(CallSignature::TargetKind::BUILTINS_STW_COPY_STUB); +#define STW_COPY_INIT(name) \ + callSigns_[ID_##name].SetStwCopyStub(true); \ + callSigns_[ID_##name].SetTargetKind(CallSignature::TargetKind::BUILTINS_STW_COPY_STUB); -#define INIT_BUILTINS_METHOD_STW_COPY(name) \ - INIT_BUILTINS_METHOD(name##StwCopy) \ +#define INIT_BUILTINS_METHOD_STW_COPY(name) \ + INIT_BUILTINS_METHOD(name##StwCopy) \ STW_COPY_INIT(name##StwCopy) -#define INIT_BUILTINS_METHOD_DYN_STW_COPY(name, type, ...) \ - INIT_BUILTINS_METHOD_DYN(name##StwCopy, type) \ +#define INIT_BUILTINS_METHOD_DYN_STW_COPY(name, type, ...) \ + INIT_BUILTINS_METHOD_DYN(name##StwCopy, type) \ STW_COPY_INIT(type##name##StwCopy) -#define INIT_BUILTINS_CONSTRUCTOR_METHOD_STW_COPY(name) \ - INIT_BUILTINS_CONSTRUCTOR_METHOD(name##StwCopy) \ +#define INIT_BUILTINS_CONSTRUCTOR_METHOD_STW_COPY(name) \ + INIT_BUILTINS_CONSTRUCTOR_METHOD(name##StwCopy) \ STW_COPY_INIT(name##StwCopy) + BUILTINS_STUB_LIST(INIT_BUILTINS_METHOD, INIT_BUILTINS_METHOD_DYN, INIT_BUILTINS_CONSTRUCTOR_METHOD) BUILTINS_STW_COPY_STUB_LIST(INIT_BUILTINS_METHOD_STW_COPY, INIT_BUILTINS_METHOD_DYN_STW_COPY, \ INIT_BUILTINS_CONSTRUCTOR_METHOD_STW_COPY) diff --git a/ecmascript/compiler/builtins/builtins_call_signature.h b/ecmascript/compiler/builtins/builtins_call_signature.h index e33a113eed8062e4ffd1e58e8484593483c0a1ef..e1a8c8b146ffb969e24ed29bc22654e7354580fd 100644 --- a/ecmascript/compiler/builtins/builtins_call_signature.h +++ b/ecmascript/compiler/builtins/builtins_call_signature.h @@ -34,14 +34,27 @@ public: static_assert(ID::NONE == 0); static constexpr int NONE = ID::NONE; static constexpr int NUM_OF_BUILTINS_STUBS = ID::NUM_OF_BUILTINS_STUBS; - using SubID = builtinssubid::SubID; - static constexpr int NUM_OF_BUILTINS_STUBS_EXTEND = SubID::NUM_OF_BUILTINS_STUBS_EXTEND; - static_assert(SubID::NONE == 0); + + enum CALL_SIGNATURE_ID { +#define DEF_STUB_ID(name) ID_##name, +#define DEF_STUB_ID_DYN(name, type, ...) ID_##type##name, + PADDING_BUILTINS_STUB_LIST(DEF_STUB_ID) + BUILTINS_STUB_LIST(DEF_STUB_ID, DEF_STUB_ID_DYN, DEF_STUB_ID) +#undef DEF_STUB_ID_DYN +#undef DEF_STUB_ID +#define DEF_STUB_ID(name) ID_##name##StwCopy, +#define DEF_STUB_ID_DYN(name, type, ...) ID_##type##name##StwCopy, + BUILTINS_STW_COPY_STUB_LIST(DEF_STUB_ID, DEF_STUB_ID_DYN, DEF_STUB_ID) +#undef DEF_STUB_ID_DYN +#undef DEF_STUB_ID + NUM_OF_BUILTINS_STUBS_EXTEND, + }; + static_assert(CALL_SIGNATURE_ID::ID_NONE == 0); #define ASSERT_ID_EQUAL(name) \ - static_assert((static_cast(ID::name)) == (static_cast(SubID::name))); + static_assert(static_cast(ID::name) == static_cast(CALL_SIGNATURE_ID::ID_##name)); #define ASSERT_ID_EQUAL_DYN(name, type, ...) \ - static_assert((static_cast(ID::type##name)) == (static_cast(SubID::type##name))); + static_assert(static_cast(ID::type##name) == static_cast(CALL_SIGNATURE_ID::ID_##type##name)); BUILTINS_STUB_LIST(ASSERT_ID_EQUAL, ASSERT_ID_EQUAL_DYN, ASSERT_ID_EQUAL) #undef ASSERT_ID_EQUAL_DYN diff --git a/ecmascript/compiler/builtins/builtins_call_signature_id_properties.h b/ecmascript/compiler/builtins/builtins_call_signature_id_properties.h index 37e613007a5f625a627b5e0598da968efaea96c6..689806551a03667f676f8c6b511c07fde4d9adb9 100644 --- a/ecmascript/compiler/builtins/builtins_call_signature_id_properties.h +++ b/ecmascript/compiler/builtins/builtins_call_signature_id_properties.h @@ -40,22 +40,4 @@ enum BuiltinsStubCSignsID { }; } // namespace panda::ecmascript::kungfu::stubcsigns -namespace panda::ecmascript::kungfu::builtinssubid { -// SubID indicates the index in callSigns[] for builtins stubs, including the StwCopy version ones -enum SubID { -#define DEF_STUB_ID(name) name, -#define DEF_STUB_ID_DYN(name, type, ...) type##name, - PADDING_BUILTINS_STUB_LIST(DEF_STUB_ID) - BUILTINS_STUB_LIST(DEF_STUB_ID, DEF_STUB_ID_DYN, DEF_STUB_ID) -#undef DEF_STUB_ID_DYN -#undef DEF_STUB_ID -#define DEF_STUB_ID(name) name##StwCopy, -#define DEF_STUB_ID_DYN(name, type, ...) type##name##StwCopy, - BUILTINS_STW_COPY_STUB_LIST(DEF_STUB_ID, DEF_STUB_ID_DYN, DEF_STUB_ID) -#undef DEF_STUB_ID_DYN -#undef DEF_STUB_ID - NUM_OF_BUILTINS_STUBS_EXTEND, -}; -} // namespace panda::ecmascript::kungfu::builtinssubid - #endif // ECMASCRIPT_COMPILER_BUILTINS_CALL_SIGNATURE_ID_PROPERTIES_H diff --git a/ecmascript/compiler/stub_builder.cpp b/ecmascript/compiler/stub_builder.cpp index fc3618c2996397701b52ef86b9bf617f2bed6078..048c22a6ca8a76c9b535932cf7fe7d834d53eb00 100644 --- a/ecmascript/compiler/stub_builder.cpp +++ b/ecmascript/compiler/stub_builder.cpp @@ -4012,9 +4012,8 @@ GateRef StubBuilder::GetPropertyByName(GateRef glue, Label notString(env); Label notJsPrimitiveRef(env); auto holderValue = *holder; - BRANCH( - LogicAndBuilder(env).And(TaggedIsString(glue, holderValue)).And(TaggedIsString(glue, propKey)).Done(), - &isString, ¬String); + BRANCH(LogicAndBuilder(env).And(TaggedIsString(glue, holderValue)).And(TaggedIsString(glue, propKey)) + .Done(), &isString, ¬String); Bind(&isString); { Label getStringLength(env); @@ -12578,7 +12577,7 @@ void StubBuilder::TryToJitReuseCompiledFunc(GateRef glue, GateRef jsFunc, GateRe Bind(&machineCodeIsNotUndefine); { GateRef machineCode = TaggedCastToIntPtr(RemoveTaggedWeakTag(weakMachineCode)); - GateRef codeAddr = LoadPrimitive(VariableType::NATIVE_POINTER(), machineCode, + GateRef codeAddr = Load(VariableType::NATIVE_POINTER(), glue, machineCode, IntPtr(MachineCode::FUNCADDR_OFFSET)); ASSERT(IntPtrNotEqual(codeAddr, IntPtr(0))); GateRef isFastCall = GetIsFastCall(machineCode); diff --git a/ecmascript/js_thread.cpp b/ecmascript/js_thread.cpp index a71ec4afff2c343d827d1e5dd61d3333332f6e9d..dddf0df12dd051d8e53ea0049998cca32bf062a4 100644 --- a/ecmascript/js_thread.cpp +++ b/ecmascript/js_thread.cpp @@ -950,10 +950,10 @@ void JSThread::SwitchStwCopyBuiltinsStubs(bool isStwCopy) if (isSwitch) { Address curAddress; #define SWITCH_STW_COPY_STUB_ENTRY(base) \ - curAddress = GetBuiltinStubEntry(BuiltinsStubCSigns::SubID::base); \ - SetBuiltinStubEntry(BuiltinsStubCSigns::SubID::base, \ - GetBuiltinStubEntry(BuiltinsStubCSigns::SubID::base##StwCopy)); \ - SetBuiltinStubEntry(BuiltinsStubCSigns::SubID::base##StwCopy, curAddress); + curAddress = GetBuiltinStubEntry(BuiltinsStubCSigns::ID_##base); \ + SetBuiltinStubEntry(BuiltinsStubCSigns::ID_##base, \ + GetBuiltinStubEntry(BuiltinsStubCSigns::ID_##base##StwCopy)); \ + SetBuiltinStubEntry(BuiltinsStubCSigns::ID_##base##StwCopy, curAddress); #define SWITCH_STW_COPY_STUB_ENTRY_DYN(base, type, ...) \ SWITCH_STW_COPY_STUB_ENTRY(type##base) diff --git a/ecmascript/pgo_profiler/pgo_state.cpp b/ecmascript/pgo_profiler/pgo_state.cpp index 61c02dff5d480c754eb35282334e4fb31915d606..5d08ffb6b20825e1c8741639bc1e35d4f3600ac8 100644 --- a/ecmascript/pgo_profiler/pgo_state.cpp +++ b/ecmascript/pgo_profiler/pgo_state.cpp @@ -191,13 +191,12 @@ void PGOState::SetSaveAndNotify() NotifyAllDumpWaiters(); } -void PGOState::StartDumpBeforeDestroy(JSThread *thread) +void PGOState::StartDumpBeforeDestroy([[maybe_unused]] JSThread *thread) { LockHolder lock(stateMutex_); // possible state: STOP, SAVE, START // may notify after change to STOP and SAVE, we need to make sure state is STOP while (!StateIsStop()) { - ThreadNativeScope scope(thread); WaitDump(); } // possible gc state: STOP, WAITING, RUNNING