• クラウド環境では高性能なx86_64、デバイス環境では省電力なARMが普及[1] • アーキテクチャの差異を吸収してソフトウェアをそのまま実行可能な環境が必要 2. 可搬性 • 要件や要求に合わせてソフトウェアの実行先が動的に変化 • 処理状態を維持したまま最適なノードに再配置し 処理途中から再開するライブマイグレーションが必要 • 異種環境間での実現によってアーキテクチャ中立性と両立 [1] J. Shuja, S. Mustafa, R. W. Ahmad, S. A. Madani, A. Gani and M. Khurram Khan, "Analysis of Vector Code Offloading Framework in Heterogeneous Cloud and Edge Architectures," IEEE Access, vol. 5, pp. 24542-24554, 2017.
l l o \n フレームスタック 値スタック 計算時の 数値型を格納 実行中関数の 情報を格納 文字列などの データを格納 線形メモリ プログラム カウンタ Wasm VM Wasmバイトコード H e l l o \n フレーム スタック 値スタック CPUレジスタ・ プログラムカウンタ OSスタック VM外に内部状態が散在
JavaScript関数 内部状態取得関数 呼び出し … local.get $p1 local.get $p2 i32.add call $hoge … … call $analysis local.get $p1 call $analysis local.get $p2 call $analysis i32.add call $analysis call $hoge call $analysis … Pros: ランタイムや最適化に非依存 Cons: アプリケーション性能低下 [2] Daniel Lehmann and Michael Pradel. Wasabi: A framework for dynamically analyzing webassembly. In Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS ’19, p. 1045–1058, New York, NY, USA, 2019. Association for Computing Machinery. • 実行前に内部状態取得コードを挿入 • ランタイムや最適化手法に非依存 • アプリケーション性能が大幅に低下 • JavaScriptで記述し Wasmバイトコードから呼び出し • 任意タイミングのライブマイグレーションでは 大量のJavaScript関数の呼び出し
ヒント情報を与える • 各ランタイムにトレース機構を実装する必要 • 多様なランタイムへの対応が難しい 最適なインタプリタを生成できるが、ホストランタイムに制約 [4]Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, and Armin Rigo. 2009. Tracing the meta-level: PyPy's tracing JIT compiler. In Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems (ICOOOLPS '09). Association for Computing Machinery, New York, NY, USA, 18–25. https://doi.org/10.1145/1565824.1565827 メタトレーシングの概念図 (https://pypy.org/posts/2018/09/the-first-15-years-of-pypy- 3412615975376972020.html)
Graal VM:Truffleが生成したASTから汎用性を落として更に最適化 • 任意のランタイムへの適用は 難しい • Graal VMに依存 高速なセルフホストインタプリタだが、特定のVM実装に依存 [5]Salim S. Salim, Andy Nisbet, and Mikel Luján. 2020. TruffleWasm: a WebAssembly interpreter on GraalVM. In Proceedings of the 16th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments (VEE '20). Association for Computing Machinery, New York, NY, USA, 88–100. https://doi.org/10.1145/3381052.3381325