Mac 安装 hsdis 查看 汇编指令

2020-09-21

先安装下hg

1
brew install mercurial

官网地址: https://www.chrisnewland.com/updated-instructions-for-building-hsdis-on-osx-417

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u

# 官网上少了这一步
sh get_source.sh

cd jdk8u/hotspot/src/share/tools/hsdis/

wget http://ftp.heanet.ie/mirrors/ftp.gnu.org/gnu/binutils/binutils-2.30.tar.gz

tar -xzf binutils-2.30.tar.gz

make BINUTILS=binutils-2.30 ARCH=amd64

#java8
sudo cp build/macosx-amd64/hsdis-amd64.dylib /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre/lib/server/

Vm参数

1
2
3
4
5
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
-XX:CompileCommand=print,*Test.main
-XX:+LogCompilation
-XX:LogFile=jit.log

运行程序就可以看到汇编输出了:

image-20200922101601840

使用支付宝打赏
使用微信打赏

若你觉得我的文章对你有帮助,欢迎点击上方按钮对我打赏

扫描二维码,分享此文章