Google NaCl v.s. Microsoft Xax ?

NaCl (Native Client) by Google

GoogleがリリースしたNaClがはやっているみたい。
一言で言えば、ブラウザの中で安全かつ高速にx86のネイティブコードを実行する技術。ただし安全性の保証のため、専用のtoolchainに変更が必要。
すぐ動くものを出してきたのがさすがはGoogle。さっそく動かしている人も。(私もさっそくマネしてみました。)

NaClのVMに関しては、以下が詳しく、とても興味深い。

Xax by Microsoft

偶然か必然か、MicrosoftもNaClと似たような技術をOSDIで発表しており、タイミング的にも非常に興味深い。
Microsoftのは、レガシーなコード(過去のC/C++などで書かれたコード資産)を安全にブラウザ内で実行するXaxという技術。


Xax is a browser plugin model that enables developers to leverage existing tools, libraries, and entire programs to deliver feature-rich applications on the web. Xax employs a novel combination of mechanisms that collectively provide security, OS-independence, performance, and support for legacy code. These mechanisms include memory-isolated native code execution behind a narrow syscall interface, an abstraction layer that provides a consistent binary interface across operating systems, system services via hooks to existing browser mechanisms, and lightweight modifications to existing tool chains and code bases. We demonstrate a variety of applications and libraries from existing code bases, in several languages, produced with various tool chains, running in multiple browsers on multiple operating systems. With roughly two person-weeks of effort, we ported 3.3 million lines of code to Xax, including a PDF viewer, a Python interpreter, a speech synthesizer, and an OpenGL pipeline.

XaxAnalogClock-PPC.pngWinLorem.pngxp-donut.pngvista-tiger.pngIMDB-graphviz.png
(Figure2:実行画面の例)


こちらはコード資産を活かしつつ、Webブラウザ中心の環境に移行することが目的なので、Toolchainは選ばないという点でNaClとは少しアプローチが違う。


安全性の保護は、プロセス(pico-process)による隔離 + メモリ保護 + PAL(Platform Abstruction Layer)によるシステムコール等のABIのエミュレーション、という感じ。アプリケーションはバイナリをそのまま実行する。ライブラリ(zlibとかlibcとか)もそのまま(アプリの一部として)載せてしまう!
これによってLinuxのコードがWindowsで動いたり、その逆ができてしまう。さらにはx86だけでなく、Linux/PowerPCでも動いているらしい。すげえ。


論文にはPythonとかgraphvizとかPDF viewerとか…を移行した例がある。さすがにX(pangoとか)依存部分は動かないので除外、stdio/stdout等の入出力も調整が必要だし、pthreadもサポートしていないが、33行の変更でPythonが動いたというのはなかなかでは。OpenGLまで使えるとか。


Microsoftは元々ActiveXのようなNative Code Execution in Browserを頑張ってやってたのだが、VMとしてより汎用的に利用できるようにしていくという方向性なのだろうか。

いずれにせよ

どちらも目が離せないな、と。