mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!10336 Set TaskInfo to the ConcurrentFunction
Merge pull request !10336 from huangfeijie/fix_taskInfo_nullptr
This commit is contained in:
commit
383d69dbd1
@ -788,6 +788,15 @@ void EcmaVM::TriggerConcurrentCallback(JSTaggedValue result, JSTaggedValue hint)
|
||||
}
|
||||
|
||||
void *taskInfo = reinterpret_cast<void*>(thread_->GetTaskInfo());
|
||||
if (UNLIKELY(taskInfo == nullptr)) {
|
||||
JSTaggedValue extraInfoValue = functionInfo->GetFunctionExtraInfo();
|
||||
if (!extraInfoValue.IsJSNativePointer()) {
|
||||
LOG_ECMA(INFO) << "FunctionExtraInfo is not JSNativePointer";
|
||||
return;
|
||||
}
|
||||
JSHandle<JSNativePointer> extraInfo(thread_, extraInfoValue);
|
||||
taskInfo = extraInfo->GetData();
|
||||
}
|
||||
// clear the taskInfo when return, which can prevent the callback to get it
|
||||
thread_->SetTaskInfo(reinterpret_cast<uintptr_t>(nullptr));
|
||||
auto localResultRef = JSNApiHelper::ToLocal<JSValueRef>(JSHandle<JSTaggedValue>(thread_, result));
|
||||
|
@ -4184,6 +4184,7 @@ bool JSNApi::InitForConcurrentFunction(EcmaVM *vm, Local<JSValueRef> function, v
|
||||
LOG_ECMA(ERROR) << "Function is not concurrent";
|
||||
return false;
|
||||
}
|
||||
JSFunction::SetFunctionExtraInfo(thread, transFunc, nullptr, nullptr, taskInfo);
|
||||
transFunc->SetTaskConcurrentFuncFlag(1); // 1 : concurrent function flag
|
||||
thread->SetTaskInfo(reinterpret_cast<uintptr_t>(taskInfo));
|
||||
thread->SetIsInConcurrentScope(true);
|
||||
|
Loading…
Reference in New Issue
Block a user