Maxine VM

Java Language Summit のセッションの一つに Maxine というのがあったので、調べてみるとリサーチ用の VM らしい。昔 ExactVM というのがあったが、Maxine VM では機能の多くが Java 実装となっている。以前 bytecode -> native compile を Java 実装した研究はあったが、Maxine ではほかの部分も Java 実装でいろいろと実験できるようにするベースとしたいらしい。

https://maxine.dev.java.net/
http://labs.oracle.com/projects/maxine/
抄訳
多くのソフトウェアは managed language で作られるようになり、ハイパフォーマンスでスケーラブルな VM が求められている。実装技術、言語機能、代替デザインの研究においては柔軟で、拡張可能な VM が求められている。既存の VM はパフォーマンス、機能において進歩したが専属のエンジニア以外には手に負えないぐらい複雑になってきた。

Javaプログラミング言語、ツールとしてはアプリケーション開発の生産性向上に寄与したが、システムプログラミング、特に VM 開発という点では十分ではない。Managed Runtime 研究開発、システムプログラミング全般における Java language の使用を推進したい。Maxine project はソフトウェアデザイン、手法、ツールを探求し、VM 開発をより生産性の高いものにしたい。

Maxine VM は meta-circularity, コンポーネント化デザイン、アカデミック、インダストリアルの VM 研究者に、柔軟性、configurability, code 再利用を提供することを強調した、Java に向け、Java で書かれた VM である。


http://wikis.sun.com/display/MaxineVM/Home

Download, build, platform 要件などが説明されている。

OS X Snow Leopard 10.6 で、ダウンロードは Mercurial を使うが、まだインストールしていなかったので、次のサイトから入手。

http://mercurial.berkwood.com/

OS X のインストールパッケージ形式のファイルが入手できる。最新の 1.6 をダウンロード&インストール。

hg clone https://kenai.com/hg/maxine~maxine maxine

junit4.5 が必要とのことだが、最新のものにしてみる。

環境変数 JUNIT4_CP が junit-4.8.2.jar をさすように設定する。

$MAXINE_HOME/bin/max を使って多くの作業を行うことになるが、Mercurial でダウンロードされていない便利なラッパスクリプトがあるので、パスの通ったところにおいておくと便利。

http://wikis.sun.com/download/attachments/172494752/max?version=1&modificationDate=1252967968000

maxine を落としたディレクトリに移動。Assembler や、C1X、bin といったディレクトリがあるはず。

max と単にうつと使用方法が出てくる。
max help vm と打つと


$ max help vm
max vm [options] [class | -jar jarfile] [args...]

launch the Maxine VM

Run the Maxine VM with the given options and arguments.
The expansion of the MAXVM_OPTIONS environment variable is inserted
before any other VM options specified on the command line.

Use "max vm -help" to see what other options this command accepts.

コンパイル Maxine 本体を作る

max build

Compiling C sources in /Users/yoshi/Documents/local/maxine/Native...
Could not find a GNU make executable on the current path.
Please fix the path or use the -make option.

gcc というか、XCode を入れてなかった。
developer.apple.com でダウンロード。2GB もある。

XCode をインストールして max build. 特に問題なく終了。Linux の場合には 64-bit kernel でないと失敗する。mac の場合も確かに -m64 オプションが指定されている。

さらに boot image を作る

max image

コンパイルより少し時間がかかった。といっても数分。

max helloworld

残念ながら mac ではエラーになる。


FATAL VM ERROR[1]: Error re-initializingLjava/lang/ProcessEnvironment;
Faulting thread: main[id=1]
------ Stack dump for thread main[id=1] ------
-> com.sun.max.vm.runtime.FatalError.dumpStackAndThreadLocals(Lcom/sun/max/unsafe/Pointer;Z)V [0x1048ea6f0+101]
-> com.sun.max.vm.runtime.FatalError.unexpected(Ljava/lang/String;ZLjava/lang/Throwable;Lcom/sun/max/unsafe/Pointer;)Lcom/sun/max/vm/runtime/FatalError; [0x104896680+412]
-> com.sun.max.vm.runtime.FatalError.unexpected(Ljava/lang/String;Ljava/lang/Throwable;)Lcom/sun/max/vm/runtime/FatalError; [0x1048f1b30+54]
-> com.sun.max.vm.jdk.JDK.callInitializer(Lcom/sun/max/vm/actor/holder/ClassActor;)V [0x1048e0a08+238]
-> java.lang.System.initProperties(Ljava/util/Properties;)Ljava/util/Properties; [0x10484c8d0+696]

Ubuntu 64-bit で試したところ、helloworld は動いた。しかし、SwingSet2 や Java2Demo はエラーで動かない。
システムプロパティを表示されると java.vm.name=Maxine VM, java.vm.version=0.2 だった。たいていのものは動くというレベルに達するまではまだ時間がかかりそう。