Fixed bug for aot jsfunction not updated callfield

For new ISA, the defined functions should check if they have been
resolved to AOTC code.

issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I5U0FR?from=project-issue

Signed-off-by: wuzhefeng <wuzhefeng1@huawei.com>
Change-Id: I9bd611e51906d1df1cfb0e2208a1fe2ce8f3a058
This commit is contained in:
wuzhefeng 2022-09-30 18:23:47 -07:00
parent c2390da886
commit 1142e5da23
4 changed files with 29 additions and 8 deletions

View File

@ -42,13 +42,13 @@ DominatorTreeInfo Scheduler::CalculateDominatorTree(const Circuit *circuit)
pendingList.pop_back();
bbGatesList.push_back(curGate);
if (acc.GetOpCode(curGate) != OpCode::LOOP_BACK) {
std::vector<GateRef> succGates;
acc.GetOutStateVector(curGate, succGates);
for (const auto &succGate : succGates) {
if (acc.GetOpCode(succGate).IsState() && acc.GetMark(succGate) == MarkCode::NO_MARK) {
acc.SetMark(succGate, MarkCode::VISITED);
pendingList.push_back(succGate);
dfsFatherIdx[succGate] = dfsTimestamp[curGate];
auto uses = acc.Uses(curGate);
for (auto useIt = uses.begin(); useIt != uses.end(); useIt++) {
if (useIt.GetIndex() < acc.GetStateCount(*useIt) &&
acc.IsState(*useIt) && acc.GetMark(*useIt) == MarkCode::NO_MARK) {
acc.SetMark(*useIt, MarkCode::VISITED);
pendingList.push_back(*useIt);
dfsFatherIdx[*useIt] = dfsTimestamp[curGate];
}
}
}

View File

@ -726,6 +726,20 @@ JSTaggedValue RuntimeStubs::RuntimeCloneClassFromTemplate(JSThread *thread, cons
return cloneClass.GetTaggedValue();
}
void RuntimeStubs::RuntimeUpdateAotStatus(JSThread *thread,
const JSTaggedValue constpoolValue,
const JSTaggedValue methodValue)
{
auto constpool = ConstantPool::Cast(constpoolValue.GetTaggedObject());
auto method = Method::Cast(methodValue.GetTaggedObject());
// JSPandaFile is in the first index of constpool.
auto jsPandaFile = constpool->GetJSPandaFile();
FileLoader *fileLoader = thread->GetEcmaVM()->GetFileLoader();
if (jsPandaFile->IsLoadedAOT()) {
fileLoader->SetAOTFuncEntry(jsPandaFile, method);
}
}
// clone class may need re-set inheritance relationship due to extends may be a variable.
JSTaggedValue RuntimeStubs::RuntimeCreateClassWithBuffer(JSThread *thread,
const JSHandle<JSTaggedValue> &base,
@ -747,6 +761,7 @@ JSTaggedValue RuntimeStubs::RuntimeCreateClassWithBuffer(JSThread *thread,
JSHandle<JSFunction> cls = ClassHelper::DefineClassFromExtractor(thread, base, extractor, constpool, lexenv);
RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(cls), base);
RuntimeUpdateAotStatus(thread, constpool.GetTaggedValue(), method.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return cls.GetTaggedValue();
@ -777,6 +792,7 @@ JSTaggedValue RuntimeStubs::RuntimeCreateClassWithIHClass(JSThread *thread,
JSHandle<JSFunction> cls = ClassHelper::DefineClassWithIHClass(thread, base, extractor, constpool, lexenv, ihclass);
RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(cls), base);
RuntimeUpdateAotStatus(thread, constpool.GetTaggedValue(), method.GetTaggedValue());
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
return cls.GetTaggedValue();
@ -1798,7 +1814,7 @@ JSTaggedValue RuntimeStubs::RuntimeDefinefunc(JSThread *thread, const JSHandle<M
default:
UNREACHABLE();
}
RuntimeUpdateAotStatus(thread, methodHandle->GetConstantPool(), methodHandle.GetTaggedValue());
ASSERT_NO_ABRUPT_COMPLETION(thread);
return jsFunc.GetTaggedValue();
}
@ -1895,6 +1911,7 @@ JSTaggedValue RuntimeStubs::RuntimeDefineMethod(JSThread *thread, const JSHandle
JSHandle<JSHClass> hclass = JSHandle<JSHClass>::Cast(env->GetFunctionClassWithoutProto());
JSHandle<JSFunction> jsFunc = factory->NewJSFunctionByHClass(methodHandle, hclass);
jsFunc->SetHomeObject(thread, homeObject);
RuntimeUpdateAotStatus(thread, methodHandle->GetConstantPool(), methodHandle.GetTaggedValue());
ASSERT_NO_ABRUPT_COMPLETION(thread);
return jsFunc.GetTaggedValue();
}

View File

@ -612,6 +612,9 @@ private:
static inline JSTaggedValue RuntimeOptGenerateScopeInfo(JSThread *thread, uint16_t scopeId, JSTaggedValue func);
static inline JSTaggedType *GetActualArgv(JSThread *thread);
static inline OptimizedJSFunctionFrame *GetOptimizedJSFunctionFrame(JSThread *thread);
static inline void RuntimeUpdateAotStatus(JSThread *thread,
const JSTaggedValue constpool,
const JSTaggedValue method);
static JSTaggedValue NewObject(EcmaRuntimeCallInfo *info);
static void SaveFrameToContext(JSThread *thread, JSHandle<GeneratorContext> context);

View File

@ -12,4 +12,5 @@
# limitations under the License.
SyntaxError: Unexpected Array in JSON
Exception at function foo: 8
Exception at function func_main_0: 10