问题
学习volatile时,想看底层源码,只能查看汇编代码。
因此在启动参数加上:
-XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -Xcomp
如图:
但是启动就会报错:
报错信息:
Connected to the target VM, address: '127.0.0.1:58499', transport: 'socket'
Could not load hsdis-amd64.dll; library not loadable; PrintAssembly is disabled
睡眠线程main
B修改flag
Bfalse
maintrue
A调出循环,i=-169078805
Java HotSpot(TM) 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
Disconnected from the target VM, address: '127.0.0.1:58499', transport: 'socket'
Process finished with exit code 0
解决办法:
首先:
http://vorboss.dl.sourceforge.net/project/fcml/fcml-1.1.1/
下载hsdis-1.1.1-win32-amd64.zip。
然后将压缩包中的hsdis-amd64.dll放到*\jdk1.8\jre\bin\server下。
然后启动参数中加上:
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
-Xcomp
然后启动即可。
注意
提示汇编代码在控制台的量会比较大,如果需要全部的输出日志,可以在idea上的File —》Settings —》 Editor —》 General —》 Console去设置调大控制台打印缓存,就可以全部打印日志到控制台了。
修改如图: