!6758 Change ThreadState to native during calling native method inside ArkNativeFunctionCallBack

Merge pull request !6758 from Aleksandr Emelenko/panda-add-native-scope-interfaces-for-internalnativemethod
This commit is contained in:
openharmony_ci 2024-04-02 11:33:26 +00:00 committed by Gitee
commit 6e3eb5f249
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 27 additions and 0 deletions

View File

@ -1033,6 +1033,18 @@ private:
bool isRevert_ = false;
};
class ECMA_PUBLIC_API JsiNativeScope {
public:
explicit JsiNativeScope(const EcmaVM *vm);
~JsiNativeScope();
ECMA_DISALLOW_COPY(JsiNativeScope);
ECMA_DISALLOW_MOVE(JsiNativeScope);
private:
JSThread *thread_;
uint16_t oldThreadState_;
};
/**
* JsiRuntimeCallInfo is used for ace_engine and napi, is same to ark EcamRuntimeCallInfo except data.
*/

View File

@ -2728,6 +2728,20 @@ JSExecutionScope::~JSExecutionScope()
isRevert_ = false;
}
// ------------------------------------ JsiNativeScope -----------------------------------------------
JsiNativeScope::JsiNativeScope(const EcmaVM *vm)
{
thread_ = vm->GetAssociatedJSThread();
oldThreadState_ = static_cast<uint16_t>(thread_->GetState());
thread_->UpdateState(ecmascript::ThreadState::NATIVE);
}
JsiNativeScope::~JsiNativeScope()
{
thread_->UpdateState(static_cast<ecmascript::ThreadState>(oldThreadState_));
}
// ------------------------------------ JsiRuntimeCallInfo -----------------------------------------------
void *JsiRuntimeCallInfo::GetData()
{

View File

@ -69,6 +69,7 @@
panda::Exception::*;
panda::JSON::*;
panda::JsiRuntimeCallInfo::*;
panda::JsiNativeScope::*;
panda::JSExecutionScope::*;
panda::ecmascript::Log::*;