A Low-Footprint Java-to-Native Compilation Scheme Using Formal Methods
Ahead-of-Time and Just-in-Time compilation are common ways to improve runtime performances of restrained systems like Java Card by turning critical Java methods into native code. However, native code is much bigger than Java bytecode, which severely limits or even forbids these practices for devices with memory constraints.
In this paper, we describe and evaluate a method for reducing natively-compiled code by suppressing runtime exception check sites, which are emitted when compiling bytecodes that may potentially throw runtime exceptions. This is made possible by completing the Java program with JML annotations, and using a theorem prover in order to formally prove that the compiled methods never throw runtime exceptions. Runtime exception check sites can then safely be removed from the generated native code, as it is proved they will never be entered.
We have experimented our approach on several card-range and embedded Java applications, and were able to remove almost all the exception check sites. Results show memory footprints for native code that are up to 70% smaller than the non-optimized version, and sometimes as low than 115% the size of the Java bytecode when compiled for ARM thumb.
KeywordsVirtual Machine Smart Card Proof Obligation Java Virtual Machine Memory Footprint
- 2.Lagosanto, L.: Next-generation embedded java operating system for smart cards. In: 4th Gemplus Developer Conference (2002)Google Scholar
- 3.Grimaud, G., Vandewalle, J.-J.: Introducing research issues for next generation Java-based smart card platforms. In: Proc. Smart Objects Conference (sOc 2003), Grenoble, France (2003)Google Scholar
- 5.Lindholm, T., Yellin, F.: Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., Amsterdam (1999)Google Scholar
- 6.Ishizaki, K., Kawahito, M., Yasue, T., Takeuchi, M., Ogasawara, T., Suganuma, T., Onodera, T., Komatsu, H., Nakatani, T.: Design, implementation, and evaluation of optimizations in a just-in-time compiler. In: JAVA 1999: Proceedings of the ACM 1999 conference on Java Grande, pp. 119–128. ACM Press, New York (1999)CrossRefGoogle Scholar
- 7.Proebsting, T.A., Townsend, G., Bridges, P., Hartman, J.H., Newsham, T., Watterson, S.A.: Toba: Java for applications: A way ahead of time (wat) compiler. In: Third USENIX Conference on Object-Oriented Technologies (COOTS), Portland, Oregon, University of Arizona (June 1997)Google Scholar
- 8.Muller, G., Moura, B., Bellard, F., Consel, C.: Harissa: a flexible and efficient java environment mixing bytecode and compiled code. In: Third USENIX Conference on Object-Oriented Technologies (COOTS), USENIX, Portland (June 1997)Google Scholar
- 9.JC Virtual Machine, http://jcvm.sourceforge.net/
- 10.Vall´ee-Rai, R., Hendren, L., Sundaresan, V., Lam, P., Gagnon, E., Co, P.: Soot - a java optimization framework. In: Proceedings of CASCON 1999, pp. 125–135 (1999)Google Scholar
- 13.Leavens, G.T., Poll, E., Clifton, C., Cheon, Y., Ruby, C., Cok, D., Mller, P., Kiniry, J.: JML Reference Manual (July 2005)Google Scholar
- 14.Pavlova, M.: Java bytecode logic and specification. tech. rep., INRIA, Sophia- Antipolis, Draft version (2005)Google Scholar
- 16.Java In The Small, http://www.lifl.fr/RD2P/JITS/