实例分享CompileCommand如何查看jit编译(mac环境)!
反汇编命令:
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly -Xcomp
-XX:CompileCommand=print,*AtomicInteger.incrementAndGet
把这些参数设置到jvm启动参数,但一般首次执行会报错:
Java HotSpot(TM) 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
这是因为缺少hsdis-amd64.dylib导致的,把hsdis-amd64.dylib放到$JAVA_PATH/jre/lib/server/目录下即可:
再次运行代码,即可以看到汇编代码输出:
关于CompileCommand参数,其格式是这样的:
-XX:CompileCommand=command,method[,option]
该参数用于定制编译需求,比如过滤某个方法不做JIT编译,或者打印某个方法汇编代码等。
command选项有如下:
如上文截图中,-XX:CompileCommand=print,*AtomicInteger.incrementAndGet 即表示把AtomicInteger.incrementAndGet方法生成的汇编代码打印出来。
【我是tin,来自@看点代码再上班,如果觉得文章有用,欢迎关注我呀!】
我是tin
欢迎关注公众号【看点代码再上班】。我是tin,司职后端开发,在这里分享Java相关知识、我的工作经验和工作思考。坚持原创,持续原创,感谢关注。
我是tin
欢迎关注公众号【看点代码再上班】。我是tin,司职后端开发,在这里分享Java相关知识、我的工作经验和工作思考。坚持原创,持续原创,感谢关注。
宣传栏
目录
反汇编命令:
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly -Xcomp
-XX:CompileCommand=print,*AtomicInteger.incrementAndGet
把这些参数设置到jvm启动参数,但一般首次执行会报错:
Java HotSpot(TM) 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
这是因为缺少hsdis-amd64.dylib导致的,把hsdis-amd64.dylib放到$JAVA_PATH/jre/lib/server/目录下即可:
再次运行代码,即可以看到汇编代码输出:
关于CompileCommand参数,其格式是这样的:
-XX:CompileCommand=command,method[,option]
该参数用于定制编译需求,比如过滤某个方法不做JIT编译,或者打印某个方法汇编代码等。
command选项有如下:
如上文截图中,-XX:CompileCommand=print,*AtomicInteger.incrementAndGet 即表示把AtomicInteger.incrementAndGet方法生成的汇编代码打印出来。
【我是tin,来自@看点代码再上班,如果觉得文章有用,欢迎关注我呀!】