jvm関連の最近の出来事〜graalとopenj9〜
TRANSCRIPT
Graal
• HotSpotでの新しいJITコンパイラ
• Java 9でexperimental
• Javaで記述されている
• 他言語のサポート– http://www.oracle.com/technetwork/oracle-labs/program-languages/overview/index.html
$ graalvm-0.28.2/bin/polyglot –shell
GraalVM MultiLanguage Shell 0.28.2
Copyright (c) 2013-7, Oracle and/or its affiliates
JavaScript version 0.9
Ruby version 2.3.3
Usage:
Use Ctrl+L to switch language and Ctrl+D to exit.
Enter -usage to get a list of available commands.
JavaScript>
Ruby> Truffle::Interop.eval('application/javascript', '14 + 6')
20
JavaScript> Interop.eval('ruby', '"100".to_i')
100
Truffleで言語実装してみた
• https://github.com/jyukutyo/JVM-Math-Language
Graal & Truffle
• Graalは言語実装そのものは知らない– Truffleを間に挟んでいる(JVM言語以外)
• JITコンパイルでは(結果として)複数言語にまたがったコンパイルができる
OpenJ9
• IBMがJVM“J9”をEclipse ファウンデーションに寄贈した–つまりオープンソース化した
– https://www.eclipse.org/openj9/
• Apache 2.0/Eclipse Public License 2.0
–デュアルライセンス
J9の特徴
• 適応型コンパイル(6レベル) 1999
• スタック割り当て 2001
• クラス共有 2005
• Metronome ソフトリアルタイムGC (GCポーズが1msから) 2006
• 動的事前コンパイル 2007
• 圧縮参照 2007
J9の特徴
• アイドル時間最適化 2007
• リージョンベースの安定したGC 2011
• JITコンパイラでのハードウェアトランザクショナルメモリサポート 2013
• JITコンパイラでの自動ベクタ化と自動並列化 2014
• ポーズレスGCサポート(z14) 2017
https://www.slideshare.net/MarkStoodley/javaone-2017-mark-stoodley-open-sourcing-ibm-j9-jvm
https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
J9ROMClass at 0x7f19b1a2a498 {
Fields for J9ROMClass:
0x0: U32 romSize = 0x0000E510 (58640)
0x4: U32 singleScalarStaticCount = 0x00000007 (7)
0x8: J9SRP(struct J9UTF8) className = !j9utf8
0x00007F19B1A266F6
0xc: J9SRP(struct J9UTF8) superclassName
= !j9utf8 0x00007F19B1A26608
0x10: U32 modifiers = 0x00000031 (49)
0x14: U32 extraModifiers = 0x0C800000
(209715200)
0x18: U32 interfaceCount = 0x00000003 (3)
https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
J9Class at 0x87ca00 {
Fields for J9Class:
0x0: UDATA eyecatcher = 0x0000000099669966
(2573637990)
0x8: struct J9ROMClass * romClass = !j9romclass
0x00007F19B1A2A498
0x10: struct J9Class ** superclasses = !j9x
0x000000000087C738
0x18: UDATA classDepthAndFlags =
0x00000000008E0001 (9306113)
0x20: U32 classDepthWithFlags = 0x00000000 (0)
0x24: U32 classFlags = 0x00000000 (0)
0x28: struct J9ClassLoader * classLoader
= !j9classloader 0x00007F19C80821D8
https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
https://www.slideshare.net/MarkStoodley/javaone-2017-mark-stoodley-open-sourcing-ibm-j9-jvm
https://www.slideshare.net/DanHeidinga/j9-under-the-hood-of-the-next-open-source-jvm
Ahead-Of-Time (AOT)コンパイル
• OpenJDK/OracleJDK 9にexperimentalで含まれる
• Linuxのみ
– Libelfへの依存があるため
• jaotcコマンド
https://github.com/eclipse/openj9-website/blob/master/benchmark/daytrader3.md
Ahead-Of-Time (AOT) enabled
• -Xshareclasses–クラス共有を使用可能にする
• -Xscmx60M –キャッシュ・サイズを指定
• -Xscmaxaot8M– AOT データに使用できるクラス・キャッシュでの最大バイト数
https://www.slideshare.net/Dev_Events/secrets-of-building-a-debuggable-runtime-learn-how-language-implementors-solve-your-runtime-issues
$ cd ibm-java-x86_64-80/jre/lib/ddr
$ java -cp j9ddr.jar:../ext/dtfj.jar
com.ibm.j9ddr.tools.ddrinteractive.DDRInteractive
core.2999
*0 : PID: 2999; !j9javavm
0x7f19c80127c0Run !j9help to see a list of
commands
> j9help
<struct> <address> Format <struct> at <address>
ac <address> [ xrefs | ownedRegions ]
Dump allocation context details
acforobject <address> Find allocation
context which owns the specified object
> j9object 0xe0003260
J9VMJavaLangString at 0x00000000E0003260 {
struct J9Class* clazz = !j9class 0x881B00 //
java/lang/String
Object flags = 0x00000020;
[C value = !fj9object 0xe0003270 (offset=0)
(java/lang/String)
I count = 0x00000004 (offset=4) (java/lang/String)
I hashCode = 0x003305B9 (offset=8)
(java/lang/String)
"main”
}
DDRが提供すること
• そのアドレスの構造を出力する
– j9object/j9method
• その他情報を出力する
– stackslots
• ユーティリティ
– classforname/findpattern/whatis
• データ解析
– gccheck/デッドロック