!7802 修改process的getStartRealtime实现【runtime】

Merge pull request !7802 from yuqing_han/master
This commit is contained in:
openharmony_ci 2024-06-14 14:09:48 +00:00 committed by Gitee
commit 9cb166a520
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 41 additions and 1 deletions

View File

@ -234,7 +234,7 @@ void EcmaVM::PostFork()
ResetPGOProfiler();
options_.SetEnableJitFrame(ohos::JitTools::GetJitFrameEnable());
processStartRealtime_ = InitializeStartRealTime();
bool jitEscapeDisable = ohos::JitTools::GetJitEscapeDisable();
if (jitEscapeDisable || !JSNApi::IsJitEscape()) {
if (ohos::EnableAotListHelper::GetJitInstance()->IsEnableJit(bundleName)) {
@ -269,6 +269,7 @@ EcmaVM::EcmaVM(JSRuntimeOptions options, EcmaParamConfiguration config)
optionalLogEnabled_ = options_.EnableOptionalLog();
options_.ParseAsmInterOption();
SetEnableOsr(options_.IsEnableOSR() && options_.IsEnableJIT() && options_.GetEnableAsmInterpreter());
processStartRealtime_ = InitializeStartRealTime();
}
// for jit
@ -1123,4 +1124,25 @@ void EcmaVM::InitializeIcuData(const JSRuntimeOptions &options)
}
}
}
// Initialize Process StartRealTime
int EcmaVM::InitializeStartRealTime()
{
int startRealTime = 0;
struct timespec timespro = {0, 0};
struct timespec timessys = {0, 0};
auto res = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &timespro);
if (res) {
return startRealTime;
}
auto res1 = clock_gettime(CLOCK_MONOTONIC, &timessys);
if (res1) {
return startRealTime;
}
int whenpro = int(timespro.tv_sec * 1000) + int(timespro.tv_nsec / 1000000);
int whensys = int(timessys.tv_sec * 1000) + int(timessys.tv_nsec / 1000000);
startRealTime = (whensys - whenpro);
return startRealTime;
}
} // namespace panda::ecmascript

View File

@ -666,6 +666,11 @@ public:
return workerList_;
}
int GetProcessStartRealtime() const
{
return processStartRealtime_;
}
Jit *GetJit() const;
bool PUBLIC_API IsEnableFastJit() const;
bool PUBLIC_API IsEnableBaselineJit() const;
@ -723,6 +728,8 @@ public:
static void InitializeIcuData(const JSRuntimeOptions &options);
static int InitializeStartRealTime();
std::vector<std::pair<NativePointerCallback, std::pair<void *, void *>>> &GetSharedNativePointerCallbacks()
{
return sharedNativePointerCallbacks_;
@ -925,6 +932,9 @@ private:
bool isEnableOsr_ {false};
bool isJitCompileVM_ {false};
// process StartRealTime
int processStartRealtime_ = 0;
#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT
// Stats for Thread-State-Transition and String-Table Locks
bool isCollectingScopeLockStats_ = false;

View File

@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <map>
#include <sys/time.h>
#include "ecmascript/base/aligned_struct.h"
#include "ecmascript/base/config.h"

View File

@ -1557,6 +1557,7 @@ public:
static bool IsJitEscape();
static bool IsAotEscape(const std::string &pgoRealPath = "");
static int GetStartRealTime(const EcmaVM *vm);
private:
static int vmCount_;
static bool initialize_;

View File

@ -4805,6 +4805,12 @@ uintptr_t JSNApi::GetGlobalHandleAddr(const EcmaVM *vm, uintptr_t localAddress)
return thread->NewGlobalHandle(value);
}
int JSNApi::GetStartRealTime(const EcmaVM *vm)
{
ecmascript::ThreadManagedScope scope(vm->GetJSThread());
return vm->GetProcessStartRealtime();
}
uintptr_t JSNApi::SetWeak(const EcmaVM *vm, uintptr_t localAddress)
{
if (localAddress == 0) {