代码图片来自:https://blog.csdn.net/qq_31865983/article/details/103788358
VM_Thread 就是大家平时说的 JVM线程,只有一个实例,也就是虚拟机创建过程中只会被创建一次(C++层面),并且在虚拟机销毁的时候被销毁
具体的作用是 开启一个无限循环(while (true)), 然后不断地从一个 VM_Operation 队列中取出 VM_Operation 并且执行,如果没有 VM_Operation 就等待一会
VM_Operation 是通过其他线程 放入到队列中的,所以类似 生产者-消费者 模式。VM_Operation 有许多种,大概有四类
从注释上看,应该都是一些堆内存的分配操作?
细分的话,具体操作如下:
#define VM_OP_ENUM(type) VMOp_##type, // Note: When new VM_XXX comes up, add 'XXX' to the template table. #define VM_OPS_DO(template) \ template(Dummy) \ template(ThreadStop) \ template(ThreadDump) \ template(PrintThreads) \ template(FindDeadlocks) \ template(ForceSafepoint) \ template(ForceAsyncSafepoint) \ template(Deoptimize) \ template(DeoptimizeFrame) \ template(DeoptimizeAll) \ template(ZombieAll) \ template(UnlinkSymbols) \ template(Verify) \ template(PrintJNI) \ template(HeapDumper) \ template(DeoptimizeTheWorld) \ template(CollectForMetadataAllocation) \ template(GC_HeapInspection) \ template(GenCollectFull) \ template(GenCollectFullConcurrent) \ template(GenCollectForAllocation) \ template(ParallelGCFailedAllocation) \ template(ParallelGCSystemGC) \ template(CGC_Operation) \ template(CMS_Initial_Mark) \ template(CMS_Final_Remark) \ template(G1CollectFull) \ template(G1CollectForAllocation) \ template(G1IncCollectionPause) \ template(DestroyAllocationContext) \ template(EnableBiasedLocking) \ template(RevokeBias) \ template(BulkRevokeBias) \ template(PopulateDumpSharedSpace) \ template(JNIFunctionTableCopier) \ template(RedefineClasses) \ template(GetOwnedMonitorInfo) \ template(GetObjectMonitorUsage) \ template(GetCurrentContendedMonitor) \ template(GetStackTrace) \ template(GetMultipleStackTraces) \ template(GetAllStackTraces) \ template(GetThreadListStackTraces) \ template(GetFrameCount) \ template(GetFrameLocation) \ template(ChangeBreakpoints) \ template(GetOrSetLocal) \ template(GetCurrentLocation) \ template(EnterInterpOnlyMode) \ template(ChangeSingleStep) \ template(HeapWalkOperation) \ template(HeapIterateOperation) \ template(ReportJavaOutOfMemory) \ template(JFRCheckpoint) \ template(Exit) \ template(LinuxDllLoad) \ template(RotateGCLog) \ template(WhiteBoxOperation) \ template(ClassLoaderStatsOperation) \