Abstract
Trace compilation is a technique used by just-in-time (JIT) compilers such as TraceMonkey, the JavaScript engine in the Mozilla Firefox browser. Contrary to traditional JIT machines, a trace compiler works on only part of the source program, normally a linear path inside a heavily executed loop. Because the trace is compiled during the interpretation of the source program the JIT compiler has access to runtime values. This observation gives the compiler the possibility of producing binary code specialized to these values. In this paper we explore such opportunity to provide an analysis that removes unnecessary overflow tests from JavaScript programs. Our optimization uses range analysis to show that some operations cannot produce overflows. The analysis is linear in size and space on the number of instructions present in the input trace, and it is more effective than traditional range analyses, because we have access to values known only at execution time. We have implemented our analysis on top of Firefox’s TraceMonkey, and have tested it on over 1000 scripts from several industrial strength benchmarks, including the scripts present in the top 100 most visited webpages in the Alexa index. We generate binaries to either x86 or the embedded microprocessor ST40-300. On the average, we eliminate 91.82% of the overflows in the programs present in the TraceMonkey test suite. This optimization provides an average code size reduction of 8.83% on ST40 and 6.63% on x86. Our optimization increases TraceMonkey’s runtime by 2.53%.
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
Aycock, J.: A brief history of just-in-time. ACM Computing Surveys 35(2), 97–113 (2003)
Bala, V., Duesterwald, E., Banerjia, S.: Dynamo: a transparent dynamic optimization system. In: PLDI, pp. 1–12. ACM, New York (2000)
Bodik, R., Gupta, R., Sarkar, V.: ABCD: eliminating array bounds checks on demand. In: PLDI, pp. 321–333. ACM, New York (2000)
Carette, J., Kucera, M.: Partial evaluation of maple. In: PEPM, pp. 41–50. ACM, New York (2007)
Chambers, C., Ungar, D.: Customization: optimizing compiler technology for self, a dynamically-typed object-oriented programming language. SIGPLAN Not. 24(7), 146–160 (1989)
Chang, M., Smith, E., Reitmaier, R., Bebenita, M., Gal, A., Wimmer, C., Eich, B., Franz, M.: Tracing for web 3.0: trace compilation for the next generation web applications. In: VEE, pp. 71–80. ACM, New York (2009)
Chevalier-Boisvert, M., Hendren, L., Verbrugge, C.: Optimizing matlab through just-in-time specialization. In: Gupta, R. (ed.) CC 2010. LNCS, vol. 6011, pp. 46–65. Springer, Heidelberg (2010)
ECMA Committe. ECMAScript Language Specification. ECMA, 5th edn. (2009)
Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficiently computing static single assignment form and the control dependence graph. TOPLAS 13(4), 451–490 (1991)
Elphick, D., Leuschel, M., Cox, S.: Partial evaluation of MATLAB. In: Pfenning, F., Macko, M. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 344–363. Springer, Heidelberg (2003)
Fisher, J.A.: Trace scheduling: A technique for global microcode compaction. Trans. Comput. 30, 478–490 (1981)
Richards, G., Lebresne, S., Burg, B., Vitek, J.: An analysis of the dynamic behavior of javascript programs. In: PLDI, pp. 1–12 (2010)
Gal, A.: Efficient Bytecode Verification and Compilation in a Virtual Machine. PhD thesis, University of California, Irvine (2006)
Gal, A., Eich, B., Shaver, M., Anderson, D., Kaplan, B., Hoare, G., Mandelin, D., Zbarsky, B., Orendorff, J., Ruderman, J., Smith, E., Reitmair, R., Haghighat, M.R., Bebenita, M., Change, M., Franz, M.: Trace-based just-in-time type specialization for dynamic languages. In: PLDI, pp. 465–478. ACM, New York (2009)
Gal, A., Probst, C.W., Franz, M.: Hotpathvm: an effective jit compiler for resource-constrained devices. In: VEE, pp. 144–153 (2006)
Goldberg, D.: What every computer scientist should know about floating-point arithmetic. Comput. Surv. 23, 5–48 (1991)
Harrison, W.H.: Compiler analysis of the value ranges for variables. IEEE Trans. Softw. Eng. 3(3), 243–250 (1977)
Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation, 1st edn. Prentice Hall, Englewood Cliffs (1993)
McCarthy, J.: Recursive functions of symbolic expressions and their computation by machine, part i. Communications of ACM 3(4), 184–195 (1960)
Patterson, J.R.C.: Accurate static branch prediction by value range propagation. In: PLDI, pp. 67–78. ACM, New York (1995)
Rigo, A.: Representation-based just-in-time specialization and the psyco prototype for python. In: PEPM, pp. 15–26. ACM, New York (2004)
Schultz, U.P., Lawall, J.L., Consel, C.: Automatic program specialization for java. TOPLAS 25(4), 452–499 (2003)
Shankar, A., Sastry, S.S., Bodík, R., Smith, J.E.: Runtime specialization with optimistic heap analysis. SIG. Not. 40(10), 327–343 (2005)
Stephenson, M., Babb, J., Amarasinghe, S.: Bidwidth analysis with application to silicon compilation. In: PLDI, pp. 108–120. ACM, New York (2000)
Su, Z., Wagner, D.: A class of polynomially solvable range constraints for interval analysis without widenings. Theoretical Computeter Science 345(1), 122–138 (2005)
Guo, S.y., Palsberg, J.: The essence of compiling with traces. In: POPL. ACM, New York (2011) (page to appear)
Zaleski, M.: YETI: a gradually extensible trace interpreter. PhD thesis, University of Toronto (2007)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2011 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Sol, R., Guillon, C., Quintão Pereira, F.M., Bigonha, M.A.S. (2011). Dynamic Elimination of Overflow Tests in a Trace Compiler. In: Knoop, J. (eds) Compiler Construction. CC 2011. Lecture Notes in Computer Science, vol 6601. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-19861-8_2
Download citation
DOI: https://doi.org/10.1007/978-3-642-19861-8_2
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-19860-1
Online ISBN: 978-3-642-19861-8
eBook Packages: Computer ScienceComputer Science (R0)