diff --git a/ecmascript/object_factory.cpp b/ecmascript/object_factory.cpp index 4ccaaf5624..9929a888b5 100644 --- a/ecmascript/object_factory.cpp +++ b/ecmascript/object_factory.cpp @@ -1942,6 +1942,12 @@ JSHandle ObjectFactory::CreateDefaultClassConstructorHClass(JSHClass * return defaultHclass; } +void ObjectFactory::SetCodeEntryToFunctionFromMethod(const JSHandle &func, const JSHandle &mothed) +{ + uintptr_t entry = mothed->GetCodeEntryOrLiteral(); + func->SetCodeEntry(entry); +} + JSHandle ObjectFactory::NewJSFunctionByHClass(const JSHandle &method, const JSHandle &clazz, MemSpaceType type) @@ -1969,6 +1975,8 @@ JSHandle ObjectFactory::NewJSFunctionByHClass(const JSHandle if (method->IsAotWithCallField()) { thread_->GetEcmaVM()->GetAOTFileManager()-> SetAOTFuncEntry(method->GetJSPandaFile(), *function, *method); + } else { + SetCodeEntryToFunctionFromMethod(function, method); } return function; } diff --git a/ecmascript/object_factory.h b/ecmascript/object_factory.h index cc196ba753..3d833dbabf 100644 --- a/ecmascript/object_factory.h +++ b/ecmascript/object_factory.h @@ -892,6 +892,8 @@ public: JSHandle NewSendableEnv(int numSlots); JSHandle NewJSSendableFunction(const JSHandle &methodHandle); + void SetCodeEntryToFunctionFromMethod(const JSHandle &func, const JSHandle &mothed); + private: friend class GlobalEnv; friend class GlobalEnvConstants; diff --git a/ecmascript/shared_object_factory.cpp b/ecmascript/shared_object_factory.cpp index 8a3b30681e..7c4b3b672d 100644 --- a/ecmascript/shared_object_factory.cpp +++ b/ecmascript/shared_object_factory.cpp @@ -245,6 +245,8 @@ JSHandle ObjectFactory::NewSFunctionByHClass(const JSHandle if (method->IsAotWithCallField()) { thread_->GetEcmaVM()->GetAOTFileManager()-> SetAOTFuncEntry(method->GetJSPandaFile(), *function, *method); + } else { + SetCodeEntryToFunctionFromMethod(function, method); } return function; }