簡易檢索 / 詳目顯示

研究生: 古耶莫
Guillermo Perez
論文名稱: Google Android 平台上的混合式即時編譯器
A Hybrid Just-In-Time Compiler for Android
指導教授: 鍾葉青
Chung, Yeh-Ching
口試委員: 徐慰中
梁伯嵩
陳呈瑋
學位類別: 碩士
Master
系所名稱: 電機資訊學院 - 資訊系統與應用研究所
Institute of Information Systems and Applications
論文出版年: 2012
畢業學年度: 100
語文別: 英文
論文頁數: 29
中文關鍵詞: 即時編譯器直譯器虛擬機器編譯器
外文關鍵詞: Method-Based, Trace-Based, Interpreters
相關次數: 點閱:1下載:0
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • Google Android 作業系統被大量使用在移動裝置中,其採用Dalvik虛擬機器做為執行程式的主要平台。Dalvik虛擬機器被視為一種Java虛擬機器,但需先將Java程式轉換成Google 自訂的DEX (Dalvik Executable)中間碼格式才能執行。他是一個register-based的虛擬機器,其採用trace-based的即時編譯器來加速程式執行中頻繁執行的部分。
    瀏覽器的JavaScript引擎通常採用一種由method-based以及trace-based組合而成的即時編譯技術,但其較推崇trace-based 的即時編譯器,主要原因是在於trace-based即時編譯器可優化頻繁執行的指令,特別是優化迴圈的能力;此外,即時編譯器可知道JavaScript執行時期的變數型態,並在假設變數是某種型態時產生不同的原生版本使執行速度更為快速。但是,Android的Dalvik虛擬機器對於DEX指令的執行並沒有保存其變數的型態,而是利用運算元來傳達運算子的可能型態;同時採用相當簡易的trace-based即時編譯器,其中並不包含上述所提到的優化。
    我們為Dalvik虛擬機器設計了一method-based即時編譯器,與以底層虛擬機(Low Level Virtual Machine)實作的提前式編譯器相比有更好的效能,且利用Android市集上公認的測試基準與Dalvik虛擬機器中的trace-based即時編譯器比較之下,我們的method-based即時編譯器擁有更好的效能表現。此外,藉由分享剖析以及編譯相關的資訊,將method-based和trace-based兩種技術適當混合,各取其優劣可以大幅度的提升效能;為了使快速的trace-based即時編譯器能和高度優化的method-based即時編譯器結合,我們一旦發現有機會達到提升效能的目的時就會利用剖析器選擇method給method-based即時編譯器編譯。


    The Dalvik virtual machine is the main application platform running on Google's Android operating system for mobile devices and tablets. It is a Java Virtual Machine implementation that executes Java programs that have been translated to Google's DEX intermediate representation. This register-based virtual machine runs a basic trace-based Just-In-Time compiler to speed up the execution of programs that contain hot traces.

    Web browser JavaScript engines usually run a combination of both method and trace-based JIT types. Such JavaScript engines advocate to the power of a trace-based JIT compiler because of its ability to optimize frequently executed instructions, especially inside loops. Because a JIT is able to observer the runtime type of JavaScript variables, it can have different native versions of loops that work faster under the assumption that a variable is of a certain type. Android's Dalvik virtual machine runs dex instructions, which does not preserve variable types but uses operations that reveal what the operators' types are likely to be, uses a very simple trace-based JIT but does not implement any of the above optimizations.

    The method-based JIT compiler presented here delivers performance improvement comparable to that of an Ahead-Of-Time compiler based on the Low Level Virtual Machine framework. The method-based JIT was compared against Dalvik's own trace-based JIT using common benchmarks available in the Android Market. Results show that our method-based JIT is better than a basic trace-based, and that, by sharing profiling and compilation information among each other, a smart combination of both JIT techniques can achieve a great performance gain. Using a fine-tunes profiler that selects methods to be method-based JIT compiled in order to combine fast trace-based JIT compilation with highly optimized method-based JIT compilation when there is an opportunity to do so.

    CONTENTS 中文摘要...........i Abstract..........ii Contents..........iii List of Figures...v List of Tables....vi 1 INTRODUCTION.............................1 2 RELATED WORK.............................3 2.1 Disassemblers..........................4 2.2 Method-Based Compilers.................4 2.2.1 Zero and Shark.......................4 2.3 Combined JIT Frameworks................4 2.3.1 Chrome's V8..........................5 2.3.2 JaegerMonkey.........................5 3 OVERVIEW: TOWARDS A HYBRID JIT FRAMEWORK.6 3.1 Method-Based JIT Compiler flow.........6 3.2 The Compiler...........................9 4 PROFILING APPROACH.......................10 4.1 Existing Profiling Tools...............10 4.2 Profiling for our Method-Based JIT.....11 4.3 Trace-Based vs. Method-Based JIT.......12 5 THE METHOD-BASED COMPILER................14 5.1 DEX code to LLVM bitcode...............14 5.1.1 Typing the Typeless..................15 5.2 LLVM Advantages........................15 5.3 Optimizations..........................15 5.3.1 Quick Field Access...................15 5.3.2 Installing the Compiled Method.......16 5.3.3 Invocation to System Libraries.......17 6 RESULTS..................................18 6.1 CaffeineMark 3.0 Benchmark.............18 6.2 BenchmarkPi............................21 6.3 Memory Overhead........................22 7 CONCLUSIONS..............................23 7.1 JIT Type Comparison....................23 7.2 JIT Behavior...........................24 7.3 Relevance..............................24 8 PROJECT STATUS AND FUTURE WORK...........25 8.1 Tool Status............................25 8.2 Future Work............................26 9 REFERENCES...............................27 LIST OF FIGURES 3.1 Main Thread State Diagram.....................7 3.2 Compiler Thread State Diagram.................8 6.1 CaffeineMark 3.0 benchmark results............19 6.2 CaffeineMark 3.0, second run..................20 6.3 Pi Benchmark results..........................21 6.4 Hybrid versus trace-based JIT memory overhead.22 LIST OF TABLES 5.1 Optimized opcodes....16 7.1 Summary of Results...23

    [1] Google android - an open handset alliance project. http://code.
    google.com/android/, 2008.
    [2] Arm: Floating point architecture. http://www.
    arm.com/products/processors/technologies/
    vector-floating-point.php, 2012.
    [3] V8 javascript engine. http://code.google.com/p/v8/, 2011.
    [4] S. Asghar, M. Hafeez, U. A. Malik, A. ur Rehman, and N. Riaz.
    A-jump, architecture for java universal message passing. In
    Proceedings of the 8th International Conference on Frontiers of
    Information Technology, FIT ’10, pages 34:1–34:6, New York,
    NY, USA, 2010. ACM. ISBN 978-1-4503-0342-2. doi: http:
    //doi.acm.org/10.1145/1943628.1943662. URL http://doi.acm.
    org/10.1145/1943628.1943662.
    [5] C. S. D. at the University of Illinois at Urbana-Champaign. clang: a
    c language family frontend for llvm. http://clang.llvm.org/,
    2012.
    [6] C. S. D. at the University of Illinois at Urbana-Champaign. The
    llvm target-independent code generator. http://llvm.org/docs/
    CodeGenerator.html#mc, 16 January, 2012.
    [7] V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: a transparent
    dynamic optimization system. SIGPLAN Not., 35(5):1–12, May
    2000. ISSN 0362-1340. doi: 10.1145/358438.349303. URL
    http://doi.acm.org/10.1145/358438.349303.
    [8] G. Benson. Zero and shark: a zero-assembly port of openjdk.
    http://today.java.net/pub/a/today/2009/05/21/
    zero-and-shark-openjdk-port.html, 2009.
    [9] B. Cheng and B. Buzbee. A jit compiler for android’s
    dalvik vm. http://dl.google.com/googleio/2010/
    android-jit-compiler-androids-dalvik-vm.pdf, 2010.
    [10] I. Free Software Foundation. Gcc, the gnu c compiler. http:
    //gcc.gnu.org/, 05 March, 2012.
    [11] A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. R.
    Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman,
    E. W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and
    M. Franz. Trace-based just-in-time type specialization for dynamic
    languages. SIGPLAN Not., 44:465–478, June 2009. ISSN
    0362-1340. doi: http://doi.acm.org/10.1145/1543135.1542528. URL
    http://doi.acm.org/10.1145/1543135.1542528.
    [12] Google. Android developer tools. http://developer.android.
    com/guide/developing/tools/index.html, 2007.
    [13] Google. Galaxy nexus. http://www.google.com/nexus/, 2011.
    [14] S.-y. Guo and J. Palsberg. The essence of compiling with traces.
    SIGPLAN Not., 46(1):563–574, Jan. 2011. ISSN 0362-1340. doi:
    10.1145/1925844.1926450. URL http://doi.acm.org/10.1145/
    1925844.1926450.
    [15] T. IEEE and T. O. Group. Posix.1-2008: The open group base specifications
    issue 7. http://pubs.opengroup.org/onlinepubs/
    9699919799/, 2001 - 2008.
    [16] H. Inoue, H. Hayashizaki, P. Wu, and T. Nakatani. A trace-based
    java jit compiler retrofitted from a method-based compiler. In Code
    Generation and Optimization (CGO), 2011 9th Annual IEEE/ACM
    International Symposium on, pages 246 –256, april 2011. doi:
    10.1109/CGO.2011.5764692.
    [17] JesusFreke. smali/baksmali: An assembler for android’s dex format.
    http://code.google.com/p/smali/, 2009.
    [18] D. Kurzyniec and V. Sunderam. Efficient cooperation between java
    and native codes jni performance benchmark. In In The 2001
    International Conference on Parallel and Distributed Processing
    Techniques and Applications, 2001.
    [19] C. Lattner, M. Brukman, and B. Gaeke. Jello: a retargetable just-intime
    compiler for llvm bytecode, 2002.
    [20] C. A. Lattner. Llvm: An infrastructure for multi-stage optimization.
    Technical report, 2002.
    [21] S.-W. Lee and S.-M. Moon. Selective just-in-time compilation
    for client-side mobile javascript engine. In Proceedings of the
    14th international conference on Compilers, architectures and
    synthesis for embedded systems, CASES ’11, pages 5–14, New
    York, NY, USA, 2011. ACM. ISBN 978-1-4503-0713-0. doi:
    10.1145/2038698.2038703. URL http://doi.acm.org/10.1145/
    2038698.2038703.
    [22] J. McCarthy. Recursive functions of symbolic expressions and their
    computation by machine, part i. Commun. ACM, 3(4):184–195,
    Apr. 1960. ISSN 0001-0782. doi: 10.1145/367177.367199. URL
    http://doi.acm.org/10.1145/367177.367199.
    [23] Mozilla. Jaegermonkey. https://wiki.mozilla.org/
    JaegerMonkey, 2010.
    [24] S. Oaks and H. Wong. Java Threads. O’Reilly Media, Inc., 2004.
    ISBN 0596007825.
    [25] Oracle. Java se specifications. http://docs.oracle.com/
    javase/specs/, 2012.
    [26] Oracle. Openjdk’s hotspot vm. http://openjdk.java.net/
    groups/hotspot/, 2012.
    [27] V. K. Polychronis. Benchmarkpi - android benchmarking tool.
    http://androidbenchmark.com/, 2009.
    [28] T. A. O. S. Project. Dalvik optimization and verification with dexopt.
    http://www.netmite.com/android/mydroid/dalvik/docs/
    dexopt.html, 2008.
    [29] G. Tim Bray. Renderscript. http://android-developers.
    blogspot.com/2011/02/introducing-renderscript.html,
    09 February, 2011.
    [30] C.-S. Wang, G. Perez, Y.-C. Chung, W.-C. Hsu, W.-K. Shih, and
    H.-R. Hsu. A method-based ahead-of-time compiler for android
    applications. In Proceedings of the 14th international conference on
    Compilers, architectures and synthesis for embedded systems, CASES
    ’11, pages 15–24, New York, NY, USA, 2011. ACM. ISBN 978-
    1-4503-0713-0. doi: http://doi.acm.org/10.1145/2038698.2038704.
    URL http://doi.acm.org/10.1145/2038698.2038704.

    無法下載圖示 全文公開日期 本全文未授權公開 (校內網路)
    全文公開日期 本全文未授權公開 (校外網路)
    全文公開日期 本全文未授權公開 (國家圖書館:臺灣博碩士論文系統)
    QR CODE