From 420a6fd1ed3c89d4b9c300e10715f178a3b03de6 Mon Sep 17 00:00:00 2001 From: zhao1d Date: Wed, 6 Nov 2024 21:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=96=E9=9F=B3aot?= =?UTF-8?q?=E5=90=8Ecppcrash=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB2KCZ Signed-off-by: zhao1d Change-Id: I4e3587e2ba0275a7c736f4293cddf52f34746da7 --- ecmascript/object_factory.cpp | 8 ++++++++ ecmascript/object_factory.h | 2 ++ ecmascript/shared_object_factory.cpp | 2 ++ 3 files changed, 12 insertions(+) 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; }