!8227 Fix typo for debugger

Merge pull request !8227 from 杨阳/fixtypo112
This commit is contained in:
openharmony_ci 2024-07-18 20:34:14 +00:00 committed by Gitee
commit 5ef2ec2577
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 63 additions and 72 deletions

View File

@ -129,7 +129,7 @@ public:
return debuggerLibraryHandle_;
}
bool GetSignalState()
bool GetSignalState() const
{
return isSignalInterrupt_;
}

View File

@ -366,13 +366,6 @@ bool CpuProfiler::GetStackCallNapi(JSThread *thread, bool beforeCallNapi)
void CpuProfiler::GetStackSignalHandler(int signal, [[maybe_unused]] siginfo_t *siginfo, void *context)
{
pthread_t tid = static_cast<pthread_t>(syscall(SYS_gettid));
const EcmaVM *vm = profilerMap_[tid];
if (vm == nullptr) {
LOG_ECMA(ERROR) << "CpuProfiler GetStackSignalHandler vm is nullptr";
return;
}
[[maybe_unused]] SignalStateScope scope(vm->GetJsDebuggerManager());
if (signal != SIGPROF) {
return;
}
@ -380,6 +373,12 @@ void CpuProfiler::GetStackSignalHandler(int signal, [[maybe_unused]] siginfo_t *
JSThread *thread = nullptr;
{
LockHolder lock(synchronizationMutex_);
pthread_t tid = static_cast<pthread_t>(syscall(SYS_gettid));
const EcmaVM *vm = profilerMap_[tid];
if (vm == nullptr) {
LOG_ECMA(ERROR) << "CpuProfiler GetStackSignalHandler vm is nullptr";
return;
}
profiler = vm->GetProfiler();
thread = vm->GetAssociatedJSThread();
if (profiler == nullptr) {
@ -387,6 +386,7 @@ void CpuProfiler::GetStackSignalHandler(int signal, [[maybe_unused]] siginfo_t *
return;
}
}
[[maybe_unused]] SignalStateScope scope(thread->GetEcmaVM()->GetJsDebuggerManager());
if (profiler->GetBuildNapiStack() || thread->GetGcState()) {
if (profiler->generator_->SemPost(0) != 0) {

View File

@ -65,7 +65,6 @@ private:
JsDebuggerManager *jsDebuggerManager_ = nullptr;
};
class RuntimeStateScope {
public:
inline explicit RuntimeStateScope(JSThread *thread)

View File

@ -130,83 +130,70 @@ void EcmaStringTable::InternEmptyString(JSThread *thread, EcmaString *emptyStr)
EcmaString *EcmaStringTable::GetOrInternString(EcmaVM *vm, const JSHandle<EcmaString> &firstString,
const JSHandle<EcmaString> &secondString)
{
auto firstFlat = JSHandle<EcmaString>(vm->GetJSThread(), EcmaStringAccessor::Flatten(vm, firstString));
auto secondFlat = JSHandle<EcmaString>(vm->GetJSThread(), EcmaStringAccessor::Flatten(vm, secondString));
if (vm->GetJsDebuggerManager()->GetSignalState()) {
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
if (vm->IsCollectingScopeLockStats()) {
vm->IncreaseStringTableLockCount();
}
#endif
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(firstFlat, secondFlat);
if (result.first != nullptr) {
return result.first;
}
JSHandle<EcmaString> concatHandle(vm->GetJSThread(),
EcmaStringAccessor::Concat(vm, firstFlat, secondFlat, MemSpaceType::SHARED_OLD_SPACE));
EcmaString *concatString = EcmaStringAccessor::Flatten(vm, concatHandle, MemSpaceType::SHARED_OLD_SPACE);
concatString->SetMixHashcode(result.second);
InternStringThreadUnsafe(concatString);
return concatString;
JSThread *thread = vm->GetJSThreadNoCheck();
return GetOrInternStringWithoutLock(thread, firstString, secondString);
} else {
RuntimeLockHolder locker(vm->GetJSThread(), mutex_);
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
if (vm->IsCollectingScopeLockStats()) {
vm->IncreaseStringTableLockCount();
}
#endif
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(firstFlat, secondFlat);
if (result.first != nullptr) {
return result.first;
}
JSHandle<EcmaString> concatHandle(vm->GetJSThread(),
EcmaStringAccessor::Concat(vm, firstFlat, secondFlat, MemSpaceType::SHARED_OLD_SPACE));
EcmaString *concatString = EcmaStringAccessor::Flatten(vm, concatHandle, MemSpaceType::SHARED_OLD_SPACE);
concatString->SetMixHashcode(result.second);
InternStringThreadUnsafe(concatString);
return concatString;
JSThread *thread = vm->GetJSThread();
return GetOrInternStringWithoutLock(thread, firstString, secondString);
}
}
EcmaString *EcmaStringTable::GetOrInternStringWithoutLock(JSThread *thread, const JSHandle<EcmaString> &firstString,
const JSHandle<EcmaString> &secondString)
{
EcmaVM *vm = thread->GetEcmaVM();
auto firstFlat = JSHandle<EcmaString>(thread, EcmaStringAccessor::Flatten(vm, firstString));
auto secondFlat = JSHandle<EcmaString>(thread, EcmaStringAccessor::Flatten(vm, secondString));
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
if (vm->IsCollectingScopeLockStats()) {
vm->IncreaseStringTableLockCount();
}
#endif
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(firstFlat, secondFlat);
if (result.first != nullptr) {
return result.first;
}
JSHandle<EcmaString> concatHandle(thread,
EcmaStringAccessor::Concat(vm, firstFlat, secondFlat, MemSpaceType::SHARED_OLD_SPACE));
EcmaString *concatString = EcmaStringAccessor::Flatten(vm, concatHandle, MemSpaceType::SHARED_OLD_SPACE);
concatString->SetMixHashcode(result.second);
InternStringThreadUnsafe(concatString);
return concatString;
}
EcmaString *EcmaStringTable::GetOrInternString(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf8Len,
bool canBeCompress)
{
if (vm->GetJsDebuggerManager()->GetSignalState()) {
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
if (vm->IsCollectingScopeLockStats()) {
vm->IncreaseStringTableLockCount();
}
#endif
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(utf8Data, utf8Len, canBeCompress);
if (result.first != nullptr) {
return result.first;
}
EcmaString *str =
EcmaStringAccessor::CreateFromUtf8(vm, utf8Data, utf8Len, canBeCompress, MemSpaceType::SHARED_OLD_SPACE);
str->SetMixHashcode(result.second);
InternStringThreadUnsafe(str);
return str;
return GetOrInternStringWithoutLock(vm, utf8Data, utf8Len, canBeCompress);
} else {
RuntimeLockHolder locker(vm->GetJSThread(), mutex_);
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
if (vm->IsCollectingScopeLockStats()) {
vm->IncreaseStringTableLockCount();
}
#endif
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(utf8Data, utf8Len, canBeCompress);
if (result.first != nullptr) {
return result.first;
}
EcmaString *str =
EcmaStringAccessor::CreateFromUtf8(vm, utf8Data, utf8Len, canBeCompress, MemSpaceType::SHARED_OLD_SPACE);
str->SetMixHashcode(result.second);
InternStringThreadUnsafe(str);
return str;
return GetOrInternStringWithoutLock(vm, utf8Data, utf8Len, canBeCompress);
}
}
EcmaString *EcmaStringTable::GetOrInternStringWithoutLock(EcmaVM *vm, const uint8_t *utf8Data,
uint32_t utf8Len, bool canBeCompress)
{
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
if (vm->IsCollectingScopeLockStats()) {
vm->IncreaseStringTableLockCount();
}
#endif
std::pair<EcmaString *, uint32_t> result = GetStringThreadUnsafe(utf8Data, utf8Len, canBeCompress);
if (result.first != nullptr) {
return result.first;
}
EcmaString *str =
EcmaStringAccessor::CreateFromUtf8(vm, utf8Data, utf8Len, canBeCompress, MemSpaceType::SHARED_OLD_SPACE);
str->SetMixHashcode(result.second);
InternStringThreadUnsafe(str);
return str;
}
EcmaString *EcmaStringTable::GetOrInternCompressedSubString(EcmaVM *vm, const JSHandle<EcmaString> &string,
uint32_t offset, uint32_t utf8Len)
{

View File

@ -41,7 +41,12 @@ public:
EcmaString *GetOrInternString(EcmaVM *vm,
const JSHandle<EcmaString> &firstString,
const JSHandle<EcmaString> &secondString);
EcmaString *GetOrInternStringWithoutLock(JSThread *thread,
const JSHandle<EcmaString> &firstString,
const JSHandle<EcmaString> &secondString);
EcmaString *GetOrInternString(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress);
EcmaString *GetOrInternStringWithoutLock(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf8Len,
bool canBeCompress);
EcmaString *CreateAndInternStringNonMovable(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf8Len);
EcmaString *CreateAndInternStringReadOnly(EcmaVM *vm, const uint8_t *utf8Data, uint32_t utf8Len,
bool canBeCompress);

View File

@ -4461,7 +4461,7 @@ bool JSNApi::StoreDebugInfo([[maybe_unused]] int tid,
JsDebuggerManager *jsDebuggerManager = vm->GetJsDebuggerManager();
const auto &handler = jsDebuggerManager->GetDebugLibraryHandle();
if (handler.IsValid()) {
LOG_ECMA(ERROR) << "[StoreDebugInfo] handler has already loaded";
LOG_ECMA(INFO) << "[StoreDebugInfo] handler has already loaded";
return false;
}