Lines Matching refs:vm
57 void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] const std::string &path,
62 DumpHeapSnapshot(vm, &stream, dumpOption);
69 void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] Stream *stream,
75 const_cast<EcmaVM *>(vm));
84 void DFXJSNApi::DumpCpuProfile([[maybe_unused]] const EcmaVM *vm)
90 if (DFXJSNApi::StopCpuProfilerForColdStart(vm)) {
95 if (DFXJSNApi::CpuProfilerSamplingAnyTime(vm)) {
105 void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] const EcmaVM *vm,
111 auto &options = const_cast<EcmaVM *>(vm)->GetJSOptions();
118 vm->GetJSThread()->SetStackTraceFd(stackTraceFd);
135 const_cast<EcmaVM *>(vm));
145 // tid = 0: dump all vm; tid != 0: dump tid vm, hidumper.
146 void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] const EcmaVM *vm,
150 if (vm->IsWorkerThread()) {
155 uint32_t curTid = vm->GetTid();
157 DumpHeapSnapshotWithVm(vm, dumpOption, tid);
160 void DFXJSNApi::DumpHeapSnapshotWithVm([[maybe_unused]] const EcmaVM *vm,
166 uv_loop_t *loop = reinterpret_cast<uv_loop_t *>(vm->GetLoop());
172 dumpStruct->vm = vm;
182 uint32_t curTid = vm->GetTid();
187 DFXJSNApi::GetHeapPrepare(dump->vm);
189 DumpHeapSnapshot(dump->vm, dumpOption);
198 // dump worker vm
199 const_cast<EcmaVM *>(vm)->EnumerateWorkerVm([&](const EcmaVM *workerVm) -> void {
215 void DFXJSNApi::GenerateHeapSnapshotByBinFile([[maybe_unused]] const EcmaVM *vm,
220 auto *heapProfile = ecmascript::HeapProfilerInterface::GetInstance(const_cast<EcmaVM *>(vm));
227 // tid = 0: TriggerGC all vm; tid != 0: TriggerGC tid vm
228 void DFXJSNApi::TriggerGC([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] uint32_t tid)
230 if (vm->IsWorkerThread()) {
234 // triggerGC host vm
235 uint32_t curTid = vm->GetTid();
238 TriggerGCWithVm(vm);
240 // triggerGC worker vm
241 const_cast<EcmaVM *>(vm)->EnumerateWorkerVm([&](const EcmaVM *workerVm) -> void {
250 TriggerSharedGCWithVm(vm);
253 void DFXJSNApi::TriggerSharedGCWithVm([[maybe_unused]] const EcmaVM *vm)
257 uv_loop_t *loop = reinterpret_cast<uv_loop_t *>(vm->GetLoop());
271 work->data = static_cast<void *>(const_cast<EcmaVM *>(vm));
273 EcmaVM *vm = static_cast<EcmaVM *>(work->data);
275 JSThread *thread = vm->GetJSThread();
289 void DFXJSNApi::TriggerGCWithVm([[maybe_unused]] const EcmaVM *vm)
293 uv_loop_t *loop = reinterpret_cast<uv_loop_t *>(vm->GetLoop());
307 work->data = static_cast<void *>(const_cast<EcmaVM *>(vm));
309 EcmaVM *vm = static_cast<EcmaVM *>(work->data);
310 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
311 vm->CollectGarbage(ecmascript::TriggerGCType::FULL_GC, ecmascript::GCReason::TRIGGER_BY_MEM_TOOLS);
322 void DFXJSNApi::DestroyHeapProfiler([[maybe_unused]] const EcmaVM *vm)
325 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
326 ecmascript::HeapProfilerInterface::Destroy(const_cast<EcmaVM *>(vm));
332 bool DFXJSNApi::BuildNativeAndJsStackTrace(const EcmaVM *vm, std::string &stackTraceStr)
334 stackTraceStr = ecmascript::JsStackInfo::BuildJsStackTrace(vm->GetAssociatedJSThread(), true);
341 bool DFXJSNApi::BuildJsStackTrace(const EcmaVM *vm, std::string &stackTraceStr)
343 stackTraceStr = ecmascript::JsStackInfo::BuildJsStackTrace(vm->GetAssociatedJSThread(), false);
350 bool DFXJSNApi::StartHeapTracking([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] double timeInterval,
356 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
358 const_cast<EcmaVM *>(vm));
366 bool DFXJSNApi::UpdateHeapTracking([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] Stream *stream)
370 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
372 const_cast<EcmaVM *>(vm));
380 bool DFXJSNApi::StopHeapTracking([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] const std::string &filePath,
385 return StopHeapTracking(vm, &stream, nullptr, newThread);
392 bool DFXJSNApi::StopHeapTracking([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] Stream* stream,
397 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
400 const_cast<EcmaVM *>(vm));
402 ecmascript::HeapProfilerInterface::Destroy(const_cast<EcmaVM *>(vm));
410 void DFXJSNApi::PrintStatisticResult(const EcmaVM *vm)
412 ecmascript::GCStats gcstats(vm->GetHeap());
416 void DFXJSNApi::StartRuntimeStat(EcmaVM *vm)
418 vm->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(true);
421 void DFXJSNApi::StopRuntimeStat(EcmaVM *vm)
423 vm->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(false);
426 size_t DFXJSNApi::GetArrayBufferSize(const EcmaVM *vm)
428 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
429 return vm->GetHeap()->GetArrayBufferSize();
432 size_t DFXJSNApi::GetHeapTotalSize(const EcmaVM *vm)
434 return vm->GetHeap()->GetCommittedSize();
437 size_t DFXJSNApi::GetHeapUsedSize(const EcmaVM *vm)
439 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
440 return vm->GetHeap()->GetLiveObjectSize();
443 size_t DFXJSNApi::GetHeapObjectSize(const EcmaVM *vm)
445 return vm->GetHeap()->GetHeapObjectSize();
448 size_t DFXJSNApi::GetHeapLimitSize(const EcmaVM *vm)
450 return vm->GetHeap()->GetHeapLimitSize();
458 size_t DFXJSNApi::GetGCCount(const EcmaVM *vm)
460 if (vm->IsWorkerThread()) {
461 return vm->GetEcmaGCStats()->GetGCCount();
463 return vm->GetEcmaGCStats()->GetGCCount() +
467 size_t DFXJSNApi::GetGCDuration(const EcmaVM *vm)
469 if (vm->IsWorkerThread()) {
470 return vm->GetEcmaGCStats()->GetGCDuration();
472 return vm->GetEcmaGCStats()->GetGCDuration() +
476 size_t DFXJSNApi::GetAccumulatedAllocateSize(const EcmaVM *vm)
478 if (vm->IsWorkerThread()) {
479 return vm->GetEcmaGCStats()->GetAccumulatedAllocateSize();
481 return vm->GetEcmaGCStats()->GetAccumulatedAllocateSize() +
485 size_t DFXJSNApi::GetAccumulatedFreeSize(const EcmaVM *vm)
487 if (vm->IsWorkerThread()) {
488 return vm->GetEcmaGCStats()->GetAccumulatedFreeSize();
490 return vm->GetEcmaGCStats()->GetAccumulatedFreeSize() +
494 size_t DFXJSNApi::GetFullGCLongTimeCount(const EcmaVM *vm)
496 return vm->GetEcmaGCStats()->GetFullGCLongTimeCount();
499 void DFXJSNApi::GetHeapPrepare(const EcmaVM *vm)
501 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
502 const_cast<ecmascript::Heap *>(vm->GetHeap())->GetHeapPrepare();
505 void DFXJSNApi::SetJsDumpThresholds([[maybe_unused]] EcmaVM *vm, [[maybe_unused]] size_t thresholds)
508 vm->GetHeap()->SetJsDumpThresholds(thresholds);
514 void DFXJSNApi::SetAppFreezeFilterCallback(const EcmaVM *vm, AppFreezeFilterCallback cb)
516 const_cast<ecmascript::Heap *>(vm->GetHeap())->SetAppFreezeFilterCallback(cb);
521 void DFXJSNApi::NotifyApplicationState(EcmaVM *vm, bool inBackground)
523 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
524 const_cast<ecmascript::Heap *>(vm->GetHeap())->ChangeGCParams(inBackground);
528 void DFXJSNApi::NotifyIdleStatusControl(const EcmaVM *vm, std::function<void(bool)> callback)
530 const_cast<ecmascript::Heap *>(vm->GetHeap())->InitializeIdleStatusControl(callback);
533 void DFXJSNApi::NotifyIdleTime(const EcmaVM *vm, int idleMicroSec)
535 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
536 const_cast<ecmascript::Heap *>(vm->GetHeap())->TriggerIdleCollection(idleMicroSec);
539 void DFXJSNApi::NotifyMemoryPressure(EcmaVM *vm, bool inHighMemoryPressure)
541 const_cast<ecmascript::Heap *>(vm->GetHeap())->NotifyMemoryPressure(inHighMemoryPressure);
544 void DFXJSNApi::NotifyFinishColdStart(EcmaVM *vm, bool isConvinced)
546 ecmascript::ThreadManagedScope managedScope(vm->GetJSThread());
548 const_cast<ecmascript::Heap *>(vm->GetHeap())->NotifyFinishColdStart();
550 const_cast<ecmascript::Heap *>(vm->GetHeap())->NotifyFinishColdStartSoon();
554 void DFXJSNApi::NotifyHighSensitive(EcmaVM *vm, bool isStart)
556 const_cast<ecmascript::Heap *>(vm->GetHeap())->NotifyHighSensitive(isStart);
559 bool DFXJSNApi::StopCpuProfilerForColdStart([[maybe_unused]] const EcmaVM *vm)
563 auto &options = const_cast<EcmaVM *>(vm)->GetJSOptions();
566 DFXJSNApi::StopCpuProfilerForFile(vm);
571 const_cast<EcmaVM *>(vm)->EnumerateWorkerVm([&](const EcmaVM *workerVm) -> void {
586 void DFXJSNApi::CpuProfilerAnyTimeMainThread(const EcmaVM *vm)
592 std::string fileName = ConvertToStdString(const_cast<EcmaVM *>(vm)->GetBundleName())
597 DFXJSNApi::StartCpuProfilerForFile(vm, fileName, CpuProfiler::INTERVAL_OF_INNER_START);
601 if (vm->GetJSThread()->GetIsProfiling()) {
602 DFXJSNApi::StopCpuProfilerForFile(vm);
608 bool DFXJSNApi::CpuProfilerSamplingAnyTime([[maybe_unused]] const EcmaVM *vm)
614 auto &options = const_cast<EcmaVM *>(vm)->GetJSOptions();
617 CpuProfilerAnyTimeMainThread(vm);
625 const_cast<EcmaVM *>(vm)->EnumerateWorkerVm([&](const EcmaVM *workerVm) -> void {
639 const_cast<EcmaVM *>(vm)->EnumerateWorkerVm([&](const EcmaVM *workerVm) -> void {
656 bool DFXJSNApi::StartCpuProfilerForFile([[maybe_unused]] const EcmaVM *vm,
661 LOG_ECMA(INFO) << "DFXJSNApi::StartCpuProfilerForFile, vm = " << vm;
666 if (vm == nullptr) {
667 LOG_ECMA(ERROR) << "DFXJSNApi::StartCpuProfilerForFile, vm == nullptr";
670 CpuProfiler *profiler = vm->GetProfiler();
672 profiler = new CpuProfiler(vm, interval);
673 const_cast<EcmaVM *>(vm)->SetProfiler(profiler);
682 void DFXJSNApi::StopCpuProfilerForFile([[maybe_unused]] const EcmaVM *vm)
685 LOG_ECMA(INFO) << "DFXJSNApi::StopCpuProfilerForFile, vm = " << vm;
686 if (vm == nullptr) {
687 LOG_ECMA(ERROR) << "DFXJSNApi::StopCpuProfilerForFile, vm == nullptr";
690 CpuProfiler *profiler = vm->GetProfiler();
702 const_cast<EcmaVM *>(vm)->SetProfiler(nullptr);
708 bool DFXJSNApi::StartCpuProfilerForInfo([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] int interval)
711 LOG_ECMA(INFO) << "DFXJSNApi::StartCpuProfilerForInfo, vm = " << vm;
716 if (vm == nullptr) {
717 LOG_ECMA(ERROR) << "DFXJSNApi::StartCpuProfilerForInfo, vm == nullptr";
720 CpuProfiler *profiler = vm->GetProfiler();
722 profiler = new CpuProfiler(vm, interval);
723 const_cast<EcmaVM *>(vm)->SetProfiler(profiler);
732 std::unique_ptr<ProfileInfo> DFXJSNApi::StopCpuProfilerForInfo([[maybe_unused]] const EcmaVM *vm)
735 LOG_ECMA(INFO) << "DFXJSNApi::StopCpuProfilerForInfo, vm = " << vm;
736 if (vm == nullptr) {
737 LOG_ECMA(ERROR) << "DFXJSNApi::StopCpuProfilerForInfo, vm == nullptr";
740 CpuProfiler *profiler = vm->GetProfiler();
753 const_cast<EcmaVM *>(vm)->SetProfiler(nullptr);
761 void DFXJSNApi::SetCpuSamplingInterval([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] int interval)
769 if (vm == nullptr) {
772 CpuProfiler *profiler = vm->GetProfiler();
774 profiler = new CpuProfiler(vm, interval);
775 const_cast<EcmaVM *>(vm)->SetProfiler(profiler);
795 bool DFXJSNApi::SuspendVM([[maybe_unused]] const EcmaVM *vm)
798 ecmascript::VmThreadControl* vmThreadControl = vm->GetAssociatedJSThread()->GetVmThreadControl();
806 void DFXJSNApi::ResumeVM([[maybe_unused]] const EcmaVM *vm)
809 ecmascript::VmThreadControl* vmThreadControl = vm->GetAssociatedJSThread()->GetVmThreadControl();
816 bool DFXJSNApi::IsSuspended([[maybe_unused]] const EcmaVM *vm)
819 ecmascript::VmThreadControl* vmThreadControl = vm->GetAssociatedJSThread()->GetVmThreadControl();
827 void DFXJSNApi::TerminateExecution(const EcmaVM *vm)
829 ecmascript::VmThreadControl* vmThreadControl = vm->GetAssociatedJSThread()->GetVmThreadControl();
833 bool DFXJSNApi::CheckSafepoint([[maybe_unused]] const EcmaVM *vm)
836 ecmascript::JSThread* thread = vm->GetJSThread();
846 EcmaVM *vm;
848 vm = const_cast<EcmaVM*>(hostVm);
850 vm = const_cast<EcmaVM*>(hostVm)->GetWorkerVm(tid);
851 if (vm == nullptr) {
855 jsFrames = ecmascript::JsStackInfo::BuildJsStackInfo(vm->GetAssociatedJSThread());
862 int32_t DFXJSNApi::GetObjectHash(const EcmaVM *vm, Local<JSValueRef> nativeObject)
865 return ecmascript::tooling::DebuggerApi::GetObjectHash(vm, obj);
868 bool DFXJSNApi::StartSampling([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] uint64_t samplingInterval)
872 const_cast<EcmaVM *>(vm));
880 const SamplingInfo *DFXJSNApi::GetAllocationProfile([[maybe_unused]] const EcmaVM *vm)
884 const_cast<EcmaVM *>(vm));
892 void DFXJSNApi::StopSampling([[maybe_unused]] const EcmaVM *vm)
896 const_cast<EcmaVM *>(vm));
905 bool DFXJSNApi::StartProfiler(EcmaVM *vm, const ProfilerOption &option, int tid,
914 if (JSNApi::NotifyDebugMode(tid, vm, debugOption, instanceId, debuggerPostTask, isDebugApp)) {
915 return StartCpuProfilerForInfo(vm, option.interval);
922 return JSNApi::NotifyDebugMode(tid, vm, debugOption, instanceId, debuggerPostTask, isDebugApp);
949 bool DFXJSNApi::StartTracing([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] std::string &categories)
952 if (vm == nullptr) {
955 Tracing *tracing = vm->GetTracing();
957 tracing = new Tracing(vm);
958 const_cast<EcmaVM *>(vm)->SetTracing(tracing);
968 std::unique_ptr<std::vector<TraceEvent>> DFXJSNApi::StopTracing([[maybe_unused]] const EcmaVM *vm)
971 if (vm == nullptr) {
974 Tracing *tracing = vm->GetTracing();
985 const_cast<EcmaVM *>(vm)->SetTracing(nullptr);
993 void DFXJSNApi::GetTracingBufferUseage([[maybe_unused]] const EcmaVM *vm, [[maybe_unused]] double &percentFull,
997 if (vm == nullptr) {
1000 ecmascript::Tracing *tracing = vm->GetTracing();
1011 void DFXJSNApi::TranslateJSStackInfo(const EcmaVM *vm, std::string &url, int32_t &line, int32_t &column)
1013 auto cb = vm->GetSourceMapTranslateCallback();