1/* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef ECMASCRIPT_ECMA_VM_H 17#define ECMASCRIPT_ECMA_VM_H 18 19#include <mutex> 20 21#include "ecmascript/base/config.h" 22#include "ecmascript/builtins/builtins_method_index.h" 23#include "ecmascript/js_runtime_options.h" 24#include "ecmascript/mem/c_containers.h" 25#include "ecmascript/mem/c_string.h" 26#include "ecmascript/mem/gc_stats.h" 27#include "ecmascript/mem/gc_key_stats.h" 28#include "ecmascript/mem/heap_region_allocator.h" 29#include "ecmascript/napi/include/dfx_jsnapi.h" 30#include "ecmascript/napi/include/jsnapi.h" 31#include "ecmascript/taskpool/taskpool.h" 32 33namespace panda { 34class JSNApi; 35struct HmsMap; 36namespace panda_file { 37class File; 38} // namespace panda_file 39 40namespace ecmascript { 41class GlobalEnv; 42class ObjectFactory; 43class RegExpParserCache; 44class EcmaRuntimeStat; 45class Heap; 46class HeapTracker; 47class JSNativePointer; 48class Program; 49class GCStats; 50class GCKeyStats; 51class CpuProfiler; 52class Tracing; 53class RegExpExecResultCache; 54class JSPromise; 55enum class PromiseRejectionEvent : uint8_t; 56enum class Concurrent { YES, NO }; 57class JSPandaFileManager; 58class JSPandaFile; 59class EcmaStringTable; 60class SnapshotEnv; 61class SnapshotSerialize; 62class SnapshotProcessor; 63class JSThread; 64 65namespace pgo { 66 class PGOProfiler; 67} // namespace pgo 68 69using PGOProfiler = pgo::PGOProfiler; 70#if !WIN_OR_MAC_OR_IOS_PLATFORM 71class HeapProfilerInterface; 72class HeapProfiler; 73#endif 74namespace job { 75class MicroJobQueue; 76} // namespace job 77 78namespace tooling { 79class JsDebuggerManager; 80} // namespace tooling 81 82template<typename T> 83class JSHandle; 84class JSArrayBuffer; 85class JSFunction; 86class SourceTextModule; 87class Program; 88class AOTFileManager; 89class SlowRuntimeStub; 90class RequireManager; 91class QuickFixManager; 92class ConstantPool; 93class FunctionCallTimer; 94class EcmaStringTable; 95class JSObjectResizingStrategy; 96class Jit; 97class JitThread; 98 99using NativePtrGetter = void* (*)(void* info); 100using SourceMapCallback = std::function<std::string(const std::string& rawStack)>; 101using SourceMapTranslateCallback = std::function<bool(std::string& url, int& line, int& column)>; 102using ResolveBufferCallback = 103 std::function<bool(std::string dirPath, uint8_t **buff, size_t *buffSize, std::string &errorMsg)>; 104using UnloadNativeModuleCallback = std::function<bool(const std::string &moduleKey)>; 105using RequestAotCallback = 106 std::function<int32_t(const std::string &bundleName, const std::string &moduleName, int32_t triggerMode)>; 107using SearchHapPathCallBack = std::function<bool(const std::string moduleName, std::string &hapPath)>; 108using DeviceDisconnectCallback = std::function<bool()>; 109using UncatchableErrorHandler = std::function<void(panda::TryCatch&)>; 110 111class EcmaVM { 112public: 113 static EcmaVM *Create(const JSRuntimeOptions &options); 114 115 static bool Destroy(EcmaVM *vm); 116 117 EcmaVM(JSRuntimeOptions options, EcmaParamConfiguration config); 118 119 EcmaVM(); 120 121 ~EcmaVM(); 122 123 void SetLoop(void *loop) 124 { 125 loop_ = loop; 126 } 127 128 void *GetLoop() const 129 { 130 return loop_; 131 } 132 133 bool IsInitialized() const 134 { 135 return initialized_; 136 } 137 138 void SetPostForked(bool isPostForked) 139 { 140 isPostForked_ = isPostForked; 141 } 142 143 bool IsPostForked() const 144 { 145 return isPostForked_; 146 } 147 148 bool IsAsynTranslateClasses() 149 { 150 if (!GetJSOptions().IsAsyncLoadAbcTest()) { 151 return IsPostForked() && GetJSOptions().IsAsyncLoadAbc(); 152 } 153 return GetJSOptions().IsAsyncLoadAbc(); 154 } 155 156 ObjectFactory *GetFactory() const 157 { 158 return factory_; 159 } 160 161 void InitializePGOProfiler(); 162 void ResetPGOProfiler(); 163 void DisablePGOProfilerWithAOTFile(const std::string &aotFileName); 164 165 bool PUBLIC_API IsEnablePGOProfiler() const; 166 bool PUBLIC_API IsEnableElementsKind() const; 167 bool PUBLIC_API IsEnableForceIC() const; 168 169 void SetEnableForceIC(bool isEnableForceIC); 170 171 bool Initialize(); 172 void InitializeForJit(JitThread *thread); 173 174 GCStats *GetEcmaGCStats() const 175 { 176 return gcStats_; 177 } 178 179 GCKeyStats *GetEcmaGCKeyStats() const 180 { 181 return gcKeyStats_; 182 } 183 184 JSThread *GetAssociatedJSThread() const 185 { 186 return thread_; 187 } 188 189 JSRuntimeOptions &GetJSOptions() 190 { 191 return options_; 192 } 193 194 const EcmaParamConfiguration &GetEcmaParamConfiguration() const 195 { 196 return ecmaParamConfiguration_; 197 } 198 199 JSHandle<GlobalEnv> PUBLIC_API GetGlobalEnv() const; 200 201 static EcmaVM *ConstCast(const EcmaVM *vm) 202 { 203 return const_cast<EcmaVM *>(vm); 204 } 205 206 void PUBLIC_API CheckThread() const; 207 JSThread *GetAndFastCheckJSThread() const; 208 bool CheckSingleThread() const; 209 210 ARK_INLINE bool GetThreadCheckStatus() const 211 { 212 return options_.EnableThreadCheck() || EcmaVM::GetMultiThreadCheck(); 213 } 214 215 ARK_INLINE JSThread *GetJSThread() const 216 { 217 // default enable multi-thread check in asan 218#ifdef ECMASCRIPT_ENABLE_ASAN_THREAD_CHECK 219 CheckThread(); 220#else 221 if (GetThreadCheckStatus()) { 222 CheckThread(); 223 } 224#endif 225 return thread_; 226 } 227 228 JSThread *GetJSThreadNoCheck() const 229 { 230 return thread_; 231 } 232 233 bool ICEnabled() const 234 { 235 return icEnabled_; 236 } 237 238 void PushToNativePointerList(JSNativePointer *pointer, Concurrent isConcurrent = Concurrent::NO); 239 void RemoveFromNativePointerList(JSNativePointer *pointer); 240 void PushToDeregisterModuleList(const CString &module); 241 void RemoveFromDeregisterModuleList(CString module); 242 bool ContainInDeregisterModuleList(CString module); 243 JSHandle<ecmascript::JSTaggedValue> GetAndClearEcmaUncaughtException() const; 244 JSHandle<ecmascript::JSTaggedValue> GetEcmaUncaughtException() const; 245 bool IsOptionalLogEnabled() const 246 { 247 return optionalLogEnabled_; 248 } 249 250 void Iterate(const RootVisitor &v, const RootRangeVisitor &rv, VMRootVisitType type); 251 252 const Heap *GetHeap() const 253 { 254 return heap_; 255 } 256 void CollectGarbage(TriggerGCType gcType, GCReason reason = GCReason::OTHER) const; 257 258 NativeAreaAllocator *GetNativeAreaAllocator() const 259 { 260 return nativeAreaAllocator_.get(); 261 } 262 263 HeapRegionAllocator *GetHeapRegionAllocator() const 264 { 265 return heapRegionAllocator_.get(); 266 } 267 268 Chunk *GetChunk() const 269 { 270 return const_cast<Chunk *>(&chunk_); 271 } 272 void ProcessNativeDelete(const WeakRootVisitor &visitor); 273 void ProcessReferences(const WeakRootVisitor &visitor); 274 275 SnapshotEnv *GetSnapshotEnv() const 276 { 277 return snapshotEnv_; 278 } 279 280 tooling::JsDebuggerManager *GetJsDebuggerManager() const 281 { 282 return debuggerManager_; 283 } 284 285 void SetDeviceDisconnectCallback(DeviceDisconnectCallback cb) 286 { 287 deviceDisconnectCallback_ = cb; 288 } 289 290 DeviceDisconnectCallback GetDeviceDisconnectCallback() const 291 { 292 return deviceDisconnectCallback_; 293 } 294 295 void SetEnableForceGC(bool enable) 296 { 297 options_.SetEnableForceGC(enable); 298 } 299 300 void SetNativePtrGetter(NativePtrGetter cb) 301 { 302 nativePtrGetter_ = cb; 303 } 304 305 NativePtrGetter GetNativePtrGetter() const 306 { 307 return nativePtrGetter_; 308 } 309 310 void SetSourceMapCallback(SourceMapCallback cb) 311 { 312 sourceMapCallback_ = cb; 313 } 314 315 SourceMapCallback GetSourceMapCallback() const 316 { 317 return sourceMapCallback_; 318 } 319 320 void SetSourceMapTranslateCallback(SourceMapTranslateCallback cb) 321 { 322 sourceMapTranslateCallback_ = cb; 323 } 324 325 SourceMapTranslateCallback GetSourceMapTranslateCallback() const 326 { 327 return sourceMapTranslateCallback_; 328 } 329 330 void SetResolveBufferCallback(ResolveBufferCallback cb) 331 { 332 resolveBufferCallback_ = cb; 333 } 334 335 ResolveBufferCallback GetResolveBufferCallback() const 336 { 337 return resolveBufferCallback_; 338 } 339 340 void SetSearchHapPathCallBack(SearchHapPathCallBack cb) 341 { 342 SearchHapPathCallBack_ = cb; 343 } 344 345 SearchHapPathCallBack GetSearchHapPathCallBack() const 346 { 347 return SearchHapPathCallBack_; 348 } 349 350 void SetUnloadNativeModuleCallback(const UnloadNativeModuleCallback &cb) 351 { 352 unloadNativeModuleCallback_ = cb; 353 } 354 355 UnloadNativeModuleCallback GetUnloadNativeModuleCallback() const 356 { 357 return unloadNativeModuleCallback_; 358 } 359 360 void SetConcurrentCallback(ConcurrentCallback callback, void *data) 361 { 362 concurrentCallback_ = callback; 363 concurrentData_ = data; 364 } 365 366 void TriggerConcurrentCallback(JSTaggedValue result, JSTaggedValue hint); 367 368 void WorkersetInfo(EcmaVM *workerVm); 369 370 EcmaVM *GetWorkerVm(uint32_t tid); 371 372 bool DeleteWorker(EcmaVM *workerVm); 373 374 bool SuspendWorkerVm(uint32_t tid); 375 376 void ResumeWorkerVm(uint32_t tid); 377 378 template<typename Callback> 379 void EnumerateWorkerVm(Callback cb) 380 { 381 // since there is a lock, so cannot mark function const 382 LockHolder lock(mutex_); 383 for (const auto &item : workerList_) { 384 cb(item.second); 385 } 386 } 387 388 bool IsWorkerThread() const 389 { 390 return options_.IsWorker(); 391 } 392 393 bool IsRestrictedWorkerThread() const 394 { 395 return options_.IsRestrictedWorker(); 396 } 397 398 bool IsBundlePack() const 399 { 400 return isBundlePack_; 401 } 402 403 void SetIsBundlePack(bool value) 404 { 405 isBundlePack_ = value; 406 } 407 408 // UnifiedOhmUrlPack means app compiles ohmurl using old format like "@bundle:", 409 // or new unified rules like "@normalize:" 410 // if pkgContextInfoList is empty, means use old ohmurl packing. 411 bool IsNormalizedOhmUrlPack() const 412 { 413 return !pkgContextInfoList_.empty(); 414 } 415 416 void SetPkgNameList(const CMap<CString, CString> &list) 417 { 418 pkgNameList_ = list; 419 } 420 421 CMap<CString, CString> GetPkgNameList() const 422 { 423 return pkgNameList_; 424 } 425 426 inline CString GetPkgName(const CString &moduleName) const 427 { 428 auto it = pkgNameList_.find(moduleName); 429 if (it == pkgNameList_.end()) { 430 LOG_ECMA(INFO) << " Get Pkg Name failed"; 431 return moduleName; 432 } 433 return it->second; 434 } 435 436 inline CMap<CString, CMap<CString, CVector<CString>>> GetPkgContextInfoLit() const 437 { 438 return pkgContextInfoList_; 439 } 440 441 inline CString GetPkgNameWithAlias(const CString &alias) const 442 { 443 auto it = pkgAliasList_.find(alias); 444 if (it == pkgAliasList_.end()) { 445 return alias; 446 } 447 return it->second; 448 } 449 450 void SetPkgAliasList(const CMap<CString, CString> &list) 451 { 452 pkgAliasList_ = list; 453 } 454 455 CMap<CString, CString> GetPkgAliasList() const 456 { 457 return pkgAliasList_; 458 } 459 460 void SetMockModuleList(const std::map<std::string, std::string> &list) 461 { 462 for (auto it = list.begin(); it != list.end(); ++it) { 463 mockModuleList_.emplace(it->first.c_str(), it->second.c_str()); 464 } 465 } 466 467 inline bool IsMockModule(const CString &moduleStr) const 468 { 469 if (mockModuleList_.empty()) { 470 return false; 471 } 472 auto it = mockModuleList_.find(moduleStr); 473 if (it == mockModuleList_.end()) { 474 return false; 475 } 476 return true; 477 } 478 479 inline CString GetMockModule(const CString &module) const 480 { 481 auto it = mockModuleList_.find(module); 482 if (it == mockModuleList_.end()) { 483 LOG_ECMA(FATAL) << " Get Mock Module failed"; 484 } 485 return it->second; 486 } 487 488#if defined(ECMASCRIPT_SUPPORT_HEAPPROFILER) 489 void DeleteHeapProfile(); 490 HeapProfilerInterface *GetHeapProfile(); 491 void SetHeapProfile(HeapProfilerInterface *heapProfile) { heapProfile_ = heapProfile; } 492 HeapProfilerInterface *GetOrNewHeapProfile(); 493 void StartHeapTracking(); 494 void StopHeapTracking(); 495#endif 496 497 void SetAssetPath(const CString &assetPath) 498 { 499 assetPath_ = assetPath; 500 } 501 502 CString GetAssetPath() const 503 { 504 return assetPath_; 505 } 506 507 void SetBundleName(const CString &bundleName) 508 { 509 bundleName_ = bundleName; 510 } 511 512 CString GetBundleName() const 513 { 514 return bundleName_; 515 } 516 517 void SetModuleName(const CString &moduleName) 518 { 519 moduleName_ = moduleName; 520 } 521 522 CString GetModuleName() const 523 { 524 return moduleName_; 525 } 526 527 std::pair<std::string, std::string> GetCurrentModuleInfo(bool needRecordName = false); 528 529 void SetHmsModuleList(const std::vector<panda::HmsMap> &list); 530 531 bool IsHmsModule(const CString &moduleStr) const; 532 533 CString GetHmsModule(const CString &module) const; 534 535 void SetpkgContextInfoList(const CMap<CString, CMap<CString, CVector<CString>>> &list); 536 537#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER) 538 CpuProfiler *GetProfiler() const 539 { 540 return profiler_; 541 } 542 543 void SetProfiler(CpuProfiler *profiler) 544 { 545 profiler_ = profiler; 546 } 547#endif 548 549#if defined(ECMASCRIPT_SUPPORT_TRACING) 550 Tracing *GetTracing() const 551 { 552 return tracing_; 553 } 554 555 void SetTracing(Tracing *tracing) 556 { 557 tracing_ = tracing; 558 } 559#endif 560 561 std::shared_ptr<PGOProfiler> GetPGOProfiler() const 562 { 563 return pgoProfiler_; 564 } 565 566 void PreFork(); 567 void PostFork(); 568 569 // For Internal Native MethodLiteral. 570 JSTaggedValue GetMethodByIndex(MethodIndex idx); 571 572 QuickFixManager *GetQuickFixManager() const 573 { 574 return quickFixManager_; 575 } 576 577 JSTaggedValue FastCallAot(size_t actualNumArgs, JSTaggedType *args, const JSTaggedType *prevFp); 578 579 void RegisterUncatchableErrorHandler(const UncatchableErrorHandler &uncatchableErrorHandler) 580 { 581 uncatchableErrorHandler_ = uncatchableErrorHandler; 582 } 583 584 // handle uncatchable errors, such as oom 585 void HandleUncatchableError() 586 { 587 if (uncatchableErrorHandler_ != nullptr) { 588 panda::TryCatch trycatch(this); 589 uncatchableErrorHandler_(trycatch); 590 } 591 LOG_ECMA_MEM(FATAL) << "Out of Memory"; 592 } 593 594 void DumpCallTimeInfo(); 595 596 FunctionCallTimer *GetCallTimer() const 597 { 598 return callTimer_; 599 } 600 601 EcmaStringTable *GetEcmaStringTable() const 602 { 603 ASSERT(stringTable_ != nullptr); 604 return stringTable_; 605 } 606 607 void IncreaseCallDepth() 608 { 609 callDepth_++; 610 } 611 612 void DecreaseCallDepth() 613 { 614 ASSERT(callDepth_ > 0); 615 callDepth_--; 616 } 617 618 bool IsTopLevelCallDepth() 619 { 620 return callDepth_ == 0; 621 } 622 623 void SetProfilerState(bool state) 624 { 625 isProfiling_ = state; 626 } 627 628 bool GetProfilerState() 629 { 630 return isProfiling_; 631 } 632 633 JSObjectResizingStrategy *GetJSObjectResizingStrategy() 634 { 635 return strategy_; 636 } 637 638 CMap<uint32_t, EcmaVM *> GetWorkList() const 639 { 640 return workerList_; 641 } 642 643 int GetProcessStartRealtime() const 644 { 645 return processStartRealtime_; 646 } 647 648 void SetProcessStartRealtime(int value) 649 { 650 processStartRealtime_ = value; 651 } 652 653 Jit *GetJit() const; 654 bool PUBLIC_API IsEnableFastJit() const; 655 bool PUBLIC_API IsEnableBaselineJit() const; 656 657 bool IsEnableOsr() const 658 { 659 return isEnableOsr_; 660 } 661 662 void SetEnableOsr(bool state) 663 { 664 isEnableOsr_ = state; 665 } 666 667 AOTFileManager *GetAOTFileManager() const 668 { 669 return aotFileManager_; 670 } 671 672 uint32_t GetTid() const; 673 674 std::vector<NativePointerCallbackData> &GetConcurrentNativePointerCallbacks() 675 { 676 return concurrentNativeCallbacks_; 677 } 678 679 AsyncNativeCallbacksPack &GetAsyncNativePointerCallbacksPack() 680 { 681 return asyncNativeCallbacksPack_; 682 } 683 684 void SetIsJitCompileVM(bool isJitCompileVM) 685 { 686 isJitCompileVM_ = isJitCompileVM; 687 } 688 689 bool IsJitCompileVM() const 690 { 691 return isJitCompileVM_; 692 } 693 694 static void SetMultiThreadCheck(bool multiThreadCheck) 695 { 696 multiThreadCheck_ = multiThreadCheck; 697 } 698 699 PUBLIC_API static bool GetMultiThreadCheck() 700 { 701 return multiThreadCheck_; 702 } 703 704 static void SetErrorInfoEnhance(bool errorInfoEnhance) 705 { 706 errorInfoEnhanced_ = errorInfoEnhance; 707 } 708 709 static bool GetErrorInfoEnhance() 710 { 711 return errorInfoEnhanced_; 712 } 713 714 static void InitializeIcuData(const JSRuntimeOptions &options); 715 716 static int InitializeStartRealTime(); 717 718#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT 719 void ResetScopeLockStats() 720 { 721 enterThreadManagedScopeCount_ = 0; 722 enterJsiNativeScopeCount_ = 0; 723 enterFastNativeScopeCount_ = 0; 724 updateThreadStateTransCount_ = 0; 725 stringTableLockCount_ = 0; 726 } 727 728 bool IsCollectingScopeLockStats() const 729 { 730 return isCollectingScopeLockStats_; 731 } 732 733 void StartCollectingScopeLockStats() 734 { 735 isCollectingScopeLockStats_ = true; 736 } 737 738 void StopCollectingScopeLockStats() 739 { 740 isCollectingScopeLockStats_ = false; 741 } 742 743 int GetEnterThreadManagedScopeCount() const 744 { 745 return enterThreadManagedScopeCount_; 746 } 747 748 void IncreaseEnterThreadManagedScopeCount() 749 { 750 enterThreadManagedScopeCount_++; 751 } 752 753 int GetEnterFastNativeScopeCount() const 754 { 755 return enterFastNativeScopeCount_; 756 } 757 758 void IncreaseEnterFastNativeScopeCount() 759 { 760 enterFastNativeScopeCount_++; 761 } 762 763 int GetEnterJsiNativeScopeCount() const 764 { 765 return enterJsiNativeScopeCount_; 766 } 767 768 void IncreaseEnterJsiNativeScopeCount() 769 { 770 enterJsiNativeScopeCount_++; 771 } 772 773 int GetUpdateThreadStateTransCount() const 774 { 775 return updateThreadStateTransCount_; 776 } 777 778 void IncreaseUpdateThreadStateTransCount() 779 { 780 updateThreadStateTransCount_++; 781 } 782 783 int GetStringTableLockCount() const 784 { 785 return stringTableLockCount_; 786 } 787 788 void IncreaseStringTableLockCount() 789 { 790 stringTableLockCount_++; 791 } 792#endif 793 794 bool GetEnableJitLogSkip() const 795 { 796 return enableJitLogSkip_; 797 } 798 799 void SetEnableJitLogSkip(bool flag) 800 { 801 enableJitLogSkip_ = flag; 802 } 803 804 void AddAOTSnapShotStats(std::string tag, uint32_t count = 1) 805 { 806 aotSnapShotStatsMap_[tag] += count; 807 } 808 809 void PUBLIC_API PrintAOTSnapShotStats(); 810 811protected: 812 813 void PrintJSErrorInfo(const JSHandle<JSTaggedValue> &exceptionInfo) const; 814 815private: 816 void ClearBufferData(); 817 void CheckStartCpuProfiler(); 818 819 // For Internal Native MethodLiteral. 820 void GenerateInternalNativeMethods(); 821 void CacheToGlobalConstants(JSTaggedValue value, ConstantIndex constant); 822 823 NO_MOVE_SEMANTIC(EcmaVM); 824 NO_COPY_SEMANTIC(EcmaVM); 825 826 // VM startup states. 827 JSRuntimeOptions options_; 828 bool icEnabled_ {true}; 829 bool initialized_ {false}; 830 bool isPostForked_ {false}; 831 GCStats *gcStats_ {nullptr}; 832 GCKeyStats *gcKeyStats_ {nullptr}; 833 EcmaStringTable *stringTable_ {nullptr}; 834 PUBLIC_API static bool multiThreadCheck_; 835 static bool errorInfoEnhanced_; 836 837 // VM memory management. 838 std::unique_ptr<NativeAreaAllocator> nativeAreaAllocator_; 839 std::unique_ptr<HeapRegionAllocator> heapRegionAllocator_; 840 Chunk chunk_; 841 Heap *heap_ {nullptr}; 842 ObjectFactory *factory_ {nullptr}; 843 844 std::vector<NativePointerCallbackData> concurrentNativeCallbacks_ {}; 845 AsyncNativeCallbacksPack asyncNativeCallbacksPack_ {}; 846 // VM execution states. 847 JSThread *thread_ {nullptr}; 848 849 CUnorderedMap<std::string, uint32_t> aotSnapShotStatsMap_; 850 851 // VM resources. 852 SnapshotEnv *snapshotEnv_ {nullptr}; 853 bool optionalLogEnabled_ {false}; 854 // Debugger 855 tooling::JsDebuggerManager *debuggerManager_ {nullptr}; 856 // isBundle means app compile mode is JSBundle 857 bool isBundlePack_ {true}; 858#if !WIN_OR_MAC_OR_IOS_PLATFORM 859 HeapProfilerInterface *heapProfile_ {nullptr}; 860#endif 861 CString assetPath_; 862 CString bundleName_; 863 CString moduleName_; 864 CList<CString> deregisterModuleList_; 865 CMap<CString, CString> mockModuleList_; 866 CMap<CString, HmsMap> hmsModuleList_; 867 CMap<CString, CString> pkgNameList_; 868 CMap<CString, CMap<CString, CVector<CString>>> pkgContextInfoList_; 869 CMap<CString, CString> pkgAliasList_; 870 NativePtrGetter nativePtrGetter_ {nullptr}; 871 SourceMapCallback sourceMapCallback_ {nullptr}; 872 SourceMapTranslateCallback sourceMapTranslateCallback_ {nullptr}; 873 void *loop_ {nullptr}; 874 875 // resolve path to get abc's buffer 876 ResolveBufferCallback resolveBufferCallback_ {nullptr}; 877 878 // delete the native module and dlclose so from NativeModuleManager 879 UnloadNativeModuleCallback unloadNativeModuleCallback_ {nullptr}; 880 881 // Concurrent taskpool callback and data 882 ConcurrentCallback concurrentCallback_ {nullptr}; 883 void *concurrentData_ {nullptr}; 884 885 // serch happath callback 886 SearchHapPathCallBack SearchHapPathCallBack_ {nullptr}; 887 888 // vm parameter configurations 889 EcmaParamConfiguration ecmaParamConfiguration_; 890#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER) 891 CpuProfiler *profiler_ {nullptr}; 892#endif 893#if defined(ECMASCRIPT_SUPPORT_TRACING) 894 Tracing *tracing_ {nullptr}; 895#endif 896 FunctionCallTimer *callTimer_ {nullptr}; 897 JSObjectResizingStrategy *strategy_ {nullptr}; 898 899 // For Native MethodLiteral 900 static void *InternalMethodTable[static_cast<uint8_t>(MethodIndex::METHOD_END)]; 901 CVector<JSTaggedValue> internalNativeMethods_; 902 903 // For repair patch. 904 QuickFixManager *quickFixManager_ {nullptr}; 905 906 // PGO Profiler 907 std::shared_ptr<PGOProfiler> pgoProfiler_ {nullptr}; 908 909 //AOT File Manager 910 AOTFileManager *aotFileManager_ {nullptr}; 911 912 // c++ call js 913 size_t callDepth_ {0}; 914 915 bool isProfiling_ {false}; 916 917 DeviceDisconnectCallback deviceDisconnectCallback_ {nullptr}; 918 919 UncatchableErrorHandler uncatchableErrorHandler_ {nullptr}; 920 921 friend class Snapshot; 922 friend class SnapshotProcessor; 923 friend class ObjectFactory; 924 friend class ValueSerializer; 925 friend class panda::JSNApi; 926 friend class JSPandaFileExecutor; 927 friend class EcmaContext; 928 friend class JitVM; 929 CMap<uint32_t, EcmaVM *> workerList_ {}; 930 Mutex mutex_; 931 bool isEnableOsr_ {false}; 932 bool isJitCompileVM_ {false}; 933 934 // process StartRealTime 935 int processStartRealtime_ = 0; 936 937 bool enableJitLogSkip_ = true; 938 939#if ECMASCRIPT_ENABLE_SCOPE_LOCK_STAT 940 // Stats for Thread-State-Transition and String-Table Locks 941 bool isCollectingScopeLockStats_ = false; 942 int enterThreadManagedScopeCount_ = 0; 943 int enterFastNativeScopeCount_ = 0; 944 int enterJsiNativeScopeCount_ = 0; 945 int updateThreadStateTransCount_ = 0; 946 int stringTableLockCount_ = 0; 947#endif 948}; 949} // namespace ecmascript 950} // namespace panda 951 952#endif 953