簡易檢索 / 詳目顯示

研究生: 王誌陞
Wang, Chih-Sheng
論文名稱: An Ahead-of-Time compilation and optimization framework based on LLVM for Google Android
針對Google Android平台的提前式編譯優化架構
指導教授: 鍾葉青
Chung, Yeh-Ching
口試委員: 徐慰中
金仲達
學位類別: 碩士
Master
系所名稱: 電機資訊學院 - 資訊工程學系
Computer Science
論文出版年: 2011
畢業學年度: 99
語文別: 中文
論文頁數: 32
中文關鍵詞: 編譯器
相關次數: 點閱:3下載:0
分享至:
查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報
  • Android程式的執行是經由翻譯的技術執行於一個叫Dalvik virtual machine (DVM) 的虛擬機之上,經由翻譯的技術執行。 為了降低執行時的翻譯成本, Google 加入了一個trace-based的即時編譯器到Android 2.2之後的系統中. 考量到有限的資源與使用者的即時感受,即時編譯器無法使用太多優化技巧去產生高品質的目的程式碼。 在本篇論文中,我們出了一個基於LLVM實作的method-based提前式編譯, 在不改動Andrdoid應用程式的程式碼的前提下,加速整體應用程式的執行效率。 主要的想法是把應用程式中比較花時間的函式經由原本的DEX程式碼轉成C語言程式碼,並利用GCC編譯器把C語言程式碼轉成在目標平台上執行的機器碼。 透過Java Native Interface (JNI)函式庫,DVM可以成功的呼叫到我們產生的函式。 預先式編譯器和即時式編譯器都有各自的優缺點。 為了結合這兩者的優點並過濾缺點,我們會收集程式執行的資訊並透過一個演算法去決定一個函式應該要被哪一種型態的編譯器處理。 我們使用了三個Google用來測量即時式編譯器的程式來量測數據。 根據結果顯示,透過我們的預先式編譯器, 應用程式的執行時間是比原本的編譯模式快3.6到5.7倍,比即時式編譯器慢0.4%到快58.4%


    The execution environment of Android system is based on a virtual machine called Dalvik virtual machine (DVM) in which the execution of an application program is in interpret-mode. To reduce the interpretation overhead of DVM, Google has included a trace-based just-in-time compiler (JITC) in the latest version of Android. Due to limited resources and the requirement for reasonable response time, the JITC is unable to apply deep optimizations to generate high quality code. In this paper, we propose a method-based ahead-of-time compiler (AOTC) based on LLVM[27], to speed up the execution of Android applications without the modification of any components of Android framework. The main idea is to convert the hot methods of an application program from DEX code to C code and uses the GCC compiler to translate the C code to the corresponding native code. With the Java Native Interface (JNI) library, the translated native code can be called by DVM. Both AOTC and JITC have their strength and weakness. In order to combine the strength and avoid the weakness of AOTC and JITC, we have proposed a cost model to determine whether a method should be handled by AOTC or JITC during profiling. To evaluate the performance, three benchmarks used by Google JITC are used as test cases. The performance results show that, with AOTC, the execution time of an application is 3.6 to 5.7 times faster than that without JITC, and -0.4% to 58.4% faster than that with JITC.

    1. Introduction 1 2. OVERVIEW 4 2.1. Framework Components 4 2.2. Execution Flow 4 3. The Static Profiling Model 5 3.1. The Profiling Method 5 3.2. Detecting Hot Methods 6 3.3. Avoid Invocation Overhead 8 3.4. The Cost model 9 4. COMPILATION AND OPTIMIZATION 9 4.1. DEX-to-C Convertion 9 4.1.1 Why DEX-to-C? 10 4.1.2 DEX code Preprocessing 12 4.1.3 DEX-to-C type recovery issues 14 4.1.4 Code generation 16 4.2. Optimizations 16 4.2.1 Ahead of time resolution 18 4.2.2 Caching 18 4.2.3 Method chaining 19 5. EXPERIMENTAL RESULTS 20 5.1. Performance of CaffeineMark 3.0 21 5.2. Performance of Linpack 24 5.3. Performance of BenchmarkPi 25 5.4. Comparisons with GCJ 26 6. RELATED WORK 28 7. SUMMARY and CONCLUSIONS 29 8. REFERENCES 30

    [1] Google Android - An Open Handset Alliance Project, 2008. http://code.google.com/android/
    [2] GCJ - The GNU Compiler for the Java Programming Language,
    http://gcc.gnu.org/java/
    [3] Sun Java Native Interface, 1997, http://java.sun.com/j2se/1.3/docs/guide/jni/
    [4] Proebsting, T. A., Townsend, G., Bridges, P., Hartman, J. H., Newsham, T. and Watterson, S. A. Toba: Java For Applications: A Way Ahead of Time (WAT) Compiler. University of Arizona, 1997.
    [5] Muller, G., B, Moura, r., Bellard, F. and Consel, C. Harissa: A flexible and efficient java environment mixing bytecode and compiled code. In Proceedings of the Proceedings of the 3rd conference on USENIX Conference on Object-Oriented Technologies (COOTS) - Volume 3 (Portland, Oregon, 1997). USENIX Association.
    [6] Weiss, M., Fran, Ferri, o. d., Delsart, B., Fabre, C., Hirsch, F., Johnson, E. A., Joloboff, V., Roy, F., Siebert, F. and Spengler, X. TurboJ, a Java Bytecode-to-Native Compiler. In Proceedings of the Proceedings of the ACM SIGPLAN Workshop on Languages, Compilers, and Tools for Embedded Systems (1998). Springer-Verlag.
    [7] Varma, A. and Bhattacharyya, S. S. Java-through-C Compilation: An Enabling Technology for Java in Embedded Systems. In Proceedings of the Proceedings of the conference on Design, automation and test in Europe - Volume 3 (2004). IEEE Computer Society.
    [8] Dean, J., Grove, D. and Chambers, C. Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis. In Proceedings of the Proceedings of the 9th European Conference on Object-Oriented Programming (1995). Springer-Verlag.
    [9] Krintz, C. Coupling on-line and off-line profile information to improve program performance. In Proceedings of the Proceedings of the international symposium on Code generation and optimization: feedback-directed and runtime optimization (San Francisco, California, 2003). IEEE Computer Society
    [10] Krintz, C. and Calder, B. Using annotations to reduce dynamic optimization time. In Proceedings of the Proceedings of the ACM SIGPLAN 2001 conference on Programming language design and implementation (Snowbird, Utah, United States, 2001). ACM.
    [11] Hong, S., Kim, J.-C., Shin, J. W., Moon, S.-M., Oh, H.-S., Lee, J. and Choi, H.-K. Java client ahead-of-time compiler for embedded systems. (San Diego, California, USA, 2007). LCTES’07. ACM.
    [12] Sun javac - Java programming language compiler, 2002, http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html
    [13] Google Android Dx tool, 2007, http://developer.android.com/intl/zh-TW/guide/developing/tools/othertools.html#dx
    [14] JesusFreke smali/baksmali: An assembler for Android's dex format 2009),
    http://code.google.com/p/smali/
    [15] Google Dalvik Optimization and Verification With dexopt, 2008, http://android.git.kernel.org/?p=platform/dalvik.git;a=blob_plain;f=docs/dexopt.html;hb=master
    [16] Gal, A., Eich, B., Shaver, M., Anderson, D., Mandelin, D., Haghighat, M. R., Kaplan, B., Hoare, G., Zbarsky, B., Orendorff, J., Ruderman, J., Smith, E. W., Reitmaier, R., Bebenita, M., Chang, M. and Franz, M. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the Proceedings of the 2009 ACM SIGPLAN conference on Programming language design and implementation (Dublin, Ireland, 2009). ACM.
    [17] Pendragon CaffeineMark1997,
    http://www.benchmarkhq.ru/cm30/
    [18] Vall, R., e-Rai, Co, P., Gagnon, E., Hendren, L., Lam, P. and Sundaresan, V. Soot - a Java bytecode optimization framework. In Proceedings of the Proceedings of the 1999 conference of the Centre for Advanced Studies on Collaborative research (Mississauga, Ontario, Canada, 1999). IBM Press.
    [19] dex2jar: Translate android DEX bytecode back to Java bytecode - http://code.google.com/p/dex2jar
    [20] Stepanoan, L., Brown, A. D., Kielstra, A., Koblents, G., and Stoodley, K. Inlining Java native calls at runtime. In Proceedings of the 1st ACM/USENIX international conference on Virtual execution environments. (Chicago, IL, USA, 2005) VEE’05. ACM.
    [21] UNDX: Translate android DEX bytecode back to Java bytecode,
    http://illegalaccess.org/undx.html
    [22] BenchmarkPi – The Android benchmark tool,
    http://androidbenchmark.com/
    [23] Linpack for Android - http://www.greenecomputing.com/apps/linpack/
    [24] ARM NEON instruction - http://www.arm.com/zh/products/processors/technologies/neon.php
    [25] Monkey - http://developer.android.com/intl/zh-TW/guide/developing/tools/monkey.html
    [26] Java HotSpot Client and Server Virtual Machines
    http://download.oracle.com/javase/1.3/docs/guide/performance/hotspot.html
    [27] Chris Lattner,Vikram Adve - The LLVM Compiler Framework and Infrastructure Tutorial. In LCPC'04 Mini Workshop on Compiler Research Infrastructures, West Lafayette, Indiana, Sep. 2004.
    [28] CoreMark- an EEMBC benchmark
    http://www.coremark.org/home.php

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