mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-17 10:18:13 +00:00
Link and update JSfunction and constpool info in aot execution phase.
Remove unnecessary jsruntime option setting in CreateEcmaVMWithScope. Tweak llvm lib path in ecmascript/compiler/tests/BUILD.gn. Issue: https://gitee.com/openharmony/ark_js_runtime/issues/I563DZ Signed-off-by: luochuhao <luochuhao@huawei.com> Change-Id: I740db8d7dd6d406adda05333edfff50bbc505cc6
This commit is contained in:
parent
bd06132c1f
commit
fd4e8bb803
@ -2586,8 +2586,7 @@ void SlowPathLowering::LowerDefineFuncDyn(GateRef gate, GateRef glue, GateRef js
|
||||
builder_.Branch(builder_.FunctionIsResolved(*result), &isResolved, ¬Resolved);
|
||||
builder_.Bind(&isResolved);
|
||||
{
|
||||
result = builder_.CallRuntime(glue, RTSTUB_ID(DefinefuncDynWithMethodId),
|
||||
{ builder_.TaggedNGC(builder_.ZExtInt16ToInt64(methodId)) });
|
||||
result = builder_.CallRuntime(glue, RTSTUB_ID(DefinefuncDyn), { *result });
|
||||
Label isException(&builder_);
|
||||
Label notException(&builder_);
|
||||
builder_.Branch(builder_.TaggedIsException(*result), &isException, ¬Exception);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "ecmascript/global_env_constants.h"
|
||||
#include "ecmascript/interpreter/interpreter-inl.h"
|
||||
#include "ecmascript/jobs/micro_job_queue.h"
|
||||
#include "ecmascript/jspandafile/constpool_value.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile_manager.h"
|
||||
#include "ecmascript/jspandafile/module_data_extractor.h"
|
||||
@ -347,11 +348,47 @@ JSMethod *EcmaVM::GetMethodForNativeFunction(const void *func)
|
||||
return nativeMethods_.back();
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaVM::InvokeEcmaAotEntrypoint()
|
||||
JSMethod *EcmaVM::GenerateMethodForAOTFunction(const void *func, size_t numArgs)
|
||||
{
|
||||
auto method = chunk_.New<JSMethod>(nullptr, panda_file::File::EntityId(0)); // 0 : temporary file id
|
||||
method->SetNativePointer(const_cast<void *>(func));
|
||||
method->SetAotCodeBit(true);
|
||||
method->SetNativeBit(false);
|
||||
method->SetNumArgsWithCallField(numArgs);
|
||||
nativeMethods_.push_back(method);
|
||||
return nativeMethods_.back();
|
||||
}
|
||||
|
||||
void EcmaVM::UpdateMethodInFunc(JSHandle<JSFunction> mainFunc, const JSPandaFile *jsPandaFile)
|
||||
{
|
||||
const std::string funcName = "func_main_0";
|
||||
auto ptr = static_cast<uintptr_t>(aotInfo_->GetAOTFuncEntry(funcName));
|
||||
JSHandle<JSFunction> mainFunc = factory_->NewAotFunction(0, ptr);
|
||||
auto mainEntry = static_cast<uintptr_t>(aotInfo_->GetAOTFuncEntry(funcName));
|
||||
JSMethod *mainMethod = GenerateMethodForAOTFunction(reinterpret_cast<void *>(mainEntry), 1); // 1 : default paras
|
||||
mainFunc->SetCallTarget(thread_, mainMethod);
|
||||
mainFunc->SetCodeEntry(reinterpret_cast<uintptr_t>(mainEntry));
|
||||
JSHandle<JSTaggedValue> constPool(thread_, mainFunc->GetConstantPool());
|
||||
ConstantPool *curPool = ConstantPool::Cast(constPool->GetTaggedObject());
|
||||
const CUnorderedMap<uint32_t, uint64_t> &constpoolMap = jsPandaFile->GetConstpoolMap();
|
||||
for (const auto &it : constpoolMap) {
|
||||
ConstPoolValue value(it.second);
|
||||
if (value.GetConstpoolType() == ConstPoolType::BASE_FUNCTION ||
|
||||
value.GetConstpoolType() == ConstPoolType::NC_FUNCTION ||
|
||||
value.GetConstpoolType() == ConstPoolType::GENERATOR_FUNCTION ||
|
||||
value.GetConstpoolType() == ConstPoolType::ASYNC_FUNCTION ||
|
||||
value.GetConstpoolType() == ConstPoolType::METHOD) {
|
||||
auto id = value.GetConstpoolIndex();
|
||||
auto codeEntry = static_cast<uintptr_t>(aotInfo_->GetAOTFuncEntry(id));
|
||||
JSMethod *curMethod = GenerateMethodForAOTFunction(reinterpret_cast<void *>(codeEntry), 1);
|
||||
auto curFunction = JSFunction::Cast(curPool->GetObjectFromCache(id).GetTaggedObject());
|
||||
curFunction->SetCallTarget(thread_, curMethod);
|
||||
curFunction->SetCodeEntry(reinterpret_cast<uintptr_t>(codeEntry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaVM::InvokeEcmaAotEntrypoint(JSHandle<JSFunction> mainFunc, const JSPandaFile *jsPandaFile)
|
||||
{
|
||||
UpdateMethodInFunc(mainFunc, jsPandaFile);
|
||||
std::vector<JSTaggedType> args(6, JSTaggedValue::Undefined().GetRawData()); // 6: number of para
|
||||
args[0] = mainFunc.GetTaggedValue().GetRawData();
|
||||
auto res = JSFunctionEntry(thread_->GetGlueAddr(),
|
||||
@ -359,7 +396,7 @@ JSTaggedValue EcmaVM::InvokeEcmaAotEntrypoint()
|
||||
static_cast<uint32_t>(args.size()),
|
||||
static_cast<uint32_t>(args.size()),
|
||||
args.data(),
|
||||
ptr);
|
||||
mainFunc->GetCodeEntry());
|
||||
return JSTaggedValue(res);
|
||||
}
|
||||
|
||||
@ -391,7 +428,7 @@ Expected<JSTaggedValue, bool> EcmaVM::InvokeEcmaEntrypoint(const JSPandaFile *js
|
||||
|
||||
auto options = GetJSOptions();
|
||||
if (options.EnableTSAot()) {
|
||||
result = InvokeEcmaAotEntrypoint();
|
||||
result = InvokeEcmaAotEntrypoint(func, jsPandaFile);
|
||||
} else {
|
||||
JSHandle<JSTaggedValue> undefined = thread_->GlobalConstants()->GetHandledUndefined();
|
||||
EcmaRuntimeCallInfo info =
|
||||
|
@ -136,6 +136,8 @@ public:
|
||||
}
|
||||
|
||||
JSMethod *GetMethodForNativeFunction(const void *func);
|
||||
JSMethod *GenerateMethodForAOTFunction(const void *func, size_t numArgs);
|
||||
void UpdateMethodInFunc(JSHandle<JSFunction> mainFunc, const JSPandaFile *jsPandaFile);
|
||||
|
||||
EcmaStringTable *GetEcmaStringTable() const
|
||||
{
|
||||
@ -317,7 +319,7 @@ private:
|
||||
|
||||
Expected<JSTaggedValue, bool> InvokeEcmaEntrypoint(const JSPandaFile *jsPandaFile);
|
||||
|
||||
JSTaggedValue InvokeEcmaAotEntrypoint();
|
||||
JSTaggedValue InvokeEcmaAotEntrypoint(JSHandle<JSFunction> mainFunc, const JSPandaFile *jsPandaFile);
|
||||
|
||||
void InitializeEcmaScriptRunStat();
|
||||
|
||||
|
@ -1298,21 +1298,7 @@ JSTaggedValue RuntimeStubs::RuntimeDefinefuncDyn(JSThread *thread, JSFunction *f
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSHClass> dynclass = JSHandle<JSHClass>::Cast(env->GetFunctionClassWithProto());
|
||||
JSHandle<JSFunction> jsFunc = factory->NewJSFunctionByDynClass(method, dynclass, FunctionKind::BASE_CONSTRUCTOR);
|
||||
ASSERT_NO_ABRUPT_COMPLETION(thread);
|
||||
return jsFunc.GetTaggedValue();
|
||||
}
|
||||
|
||||
JSTaggedValue RuntimeStubs::RuntimeDefinefuncDynWithMethodId(JSThread *thread, JSTaggedValue methodId)
|
||||
{
|
||||
auto aotCodeInfo = thread->GetEcmaVM()->GetAotCodeInfo();
|
||||
auto entry = aotCodeInfo->GetAOTFuncEntry(methodId.GetInt());
|
||||
auto method = thread->GetEcmaVM()->GetMethodForNativeFunction(reinterpret_cast<void *>(entry));
|
||||
method->SetAotCodeBit(true);
|
||||
method->SetNativeBit(false);
|
||||
JSHandle<GlobalEnv> env = thread->GetEcmaVM()->GetGlobalEnv();
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSFunction> jsFunc = factory->NewJSFunction(env, method, FunctionKind::NORMAL_FUNCTION);
|
||||
jsFunc->SetCodeEntry(entry);
|
||||
jsFunc->SetCodeEntry(func->GetCodeEntry());
|
||||
ASSERT_NO_ABRUPT_COMPLETION(thread);
|
||||
return jsFunc.GetTaggedValue();
|
||||
}
|
||||
|
@ -1458,13 +1458,6 @@ DEF_RUNTIME_STUBS(DefinefuncDyn)
|
||||
return RuntimeDefinefuncDyn(thread, reinterpret_cast<JSFunction*>(func)).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(DefinefuncDynWithMethodId)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(DefinefuncDynWithMethodId);
|
||||
CONVERT_ARG_TAGGED_CHECKED(methodId, 0);
|
||||
return RuntimeDefinefuncDynWithMethodId(thread, methodId).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(CreateRegExpWithLiteral)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(CreateRegExpWithLiteral);
|
||||
|
@ -253,7 +253,6 @@ extern "C" void ResumeRspAndReturn(uintptr_t glue, uintptr_t sp);
|
||||
V(NewLexicalEnvDyn) \
|
||||
V(NewObjDynRange) \
|
||||
V(DefinefuncDyn) \
|
||||
V(DefinefuncDynWithMethodId) \
|
||||
V(CreateRegExpWithLiteral) \
|
||||
V(ThrowIfSuperNotCorrectCall) \
|
||||
V(CreateObjectHavingMethod) \
|
||||
@ -466,7 +465,6 @@ private:
|
||||
const JSHandle<JSTaggedValue> &newTarget, uint16_t firstArgIdx,
|
||||
uint16_t length);
|
||||
static inline JSTaggedValue RuntimeDefinefuncDyn(JSThread *thread, JSFunction *func);
|
||||
static inline JSTaggedValue RuntimeDefinefuncDynWithMethodId(JSThread *thread, JSTaggedValue methodId);
|
||||
static inline JSTaggedValue RuntimeCreateRegExpWithLiteral(JSThread *thread, const JSHandle<JSTaggedValue> &pattern,
|
||||
uint8_t flags);
|
||||
static inline JSTaggedValue RuntimeThrowIfSuperNotCorrectCall(JSThread *thread, uint16_t index,
|
||||
|
Loading…
x
Reference in New Issue
Block a user