Abstract
In recent years there has been an increasing trend toward the incorpor ation of computers into a variety of devices where the amount of memory available is limited. This makes it desirable to try to reduce the size of applications where possible. This article explores the use of compiler techniques to accomplish code compaction to yield smaller executables. The main contribution of this article is to show that careful, aggressive, interprocedural optimization, together with procedural abstraction of repeated code fragments, can yield significantly better reductions in code size than previous approaches, which have generally focused on abstraction of repeated instruction sequences. We also show how “equivalent” code fragments can be detected and factored out using conventional compiler techniques, and without having to resort to purely linear treatments of code sequences as in suffix-tree-based approaches, thereby setting up a framework for code compaction that can be more flexible in its treatment of what code fragments are considered equivalent. Our ideas have been implemented in the form of a binary-rewriting tool that reduces the size of executables by about 30% on the average.
- AHO, A. V., SETHI, R., AND ULLMAN, J. D. 1985. Compilers--Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass. Google Scholar
- BAKER, B. S. 1993. A theory of parameterized pattern matching: Algorithms and applications (extended abstract). In Proc. ACM Symposium on Theory of Computing. ACM Press, New York, N.Y., 71-80. Google Scholar
- BAKER, B. S. AND MANBER, U. 1998. Deducing similarities in Java sources from bytecodes. In Proc. USENIX Annual Technical Conference. Usenix, Berkeley, CA, 179-190. Google Scholar
- BENES, M., NOWICK, S. M., AND WOLFE, A. 1998. A fast asynchronous Huffman decoder for compressed-code embedded processors. In Proc. International Symposium on Advanced Research in Asynchronous Circuits and Systems. IEEE Computer Society, Washington, D.C. Google Scholar
- COOPER, K. D. AND MCINTOSH, N. 1999. Enhanced code compression for embedded RISC processors. In A CM Conference on Programming Language Design and Implementation. ACM Press, New York, N.Y., 139-149. Google Scholar
- DEBRAY, S., EVANS, W., MUTH, R., AND DE SUTTER, B. 2000. Compiler techniques for code compaction. Tech. Rep. 00-04, Dept. of Computer Science, The University of Arizona. Mar.Google Scholar
- ERNST, J., EVANS, W., FRASER, C., Lucco, S., AND PROEBSTING, T. 1997. Code compression. In A CM Conference on Programming Language Design and Implementation. ACM Press, New York, N.Y. Google Scholar
- FRANZ, M. 1997. Adaptive compression of syntax trees and iterative dynamic code optimization: Two basic technologies for mobile-object systems. In Mobile Object Systems: Towards the Programmable Internet, J. Vitek and C. Tschudin, Eds. Number 1222 in Springer Lecture Notes in Computer Science. Springer, Heidelberg, Germany, 263-276. Tech. Report 97-04, Department of Information and Computer Science, University of California, Irvine. Google Scholar
- FRANZ, M. AND KISTLER, T. 1997. Slim binaries. Commun. ACM g0, 12 (Dec.), 87-94. Google Scholar
- FRASER, C. AND PROEBSTING, T. 1995. Custom instruction sets for code compression. Unpublished manuscript, http ://research.microsoft. com/ toddpro/papers/pldi2, ps.Google Scholar
- FRASER, C., MYERS, E., AND WENDT, A. 1984. Analyzing and compressing assembly code. In Proc. of the A CM SIGPLAN Symposium on Compiler Construction. Vol. 19. ACM Press, New York, N.Y., 117-121. Google Scholar
- FRASER, C. W. AND HANSON, D. R. 1995. A Retargetable C Compiler: Design and Implementation. Addison-Wesley, Reading, Mass. Google Scholar
- GAREY, M. R. AND JOHNSON, D. S. 1979. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, New York, N.Y. Google Scholar
- KNOOP, J., RIJTHING, O., AND STEFFEN, B. 1994. Optimal code motion: Theory and practice. ACM Trans. Program. Lang. Syst. 16, 4 (July), 1117-1155. Google Scholar
- MUCHNICK, S. S. 1997. Advanced Compiler Design and Implementation. Morgan Kaufman, San Francisco, CA. Google Scholar
- MUTH, R., DEBRAY, S. I~., WATTERSON, S., AND BOSSCHERE, I~. D. 1998. alto : A link-time optimizer for the DEC Alpha. Tech. Rep. 98-14, Dept. of Computer Science, The University of Arizona. Dec. To appear in Software Practice and Experience.Google Scholar
- PETTIS, I~. AND HANSEN, R. C. 1990. Profile-guided code positioning. In ACM Conference on Programming Language Design and Implementation. ACM Press, New York, N.Y., 16-27. Google Scholar
- PROEBSTING, T. 1995. Optimizing an ANSI C interpreter with superoperators. In Proc. Syrup. on Principles of Programming Languages. ACM Press, New York, N.Y., 322-332. Google Scholar
- VAN DE WIEL, R. 2000. The "Code Compaction" Bibliography. http://www.win.tue.nl/cs/pa/rikvdw/bibl.html.Google Scholar
- ZASTRE, M. J. 1993. Compacting object code via parameterized procedural abstraction. M.S. thesis, Dept. of Computing Science, University of Victoria.Google Scholar
Index Terms
- Compiler techniques for code compaction
Recommendations
Profile-guided code compression
As computers are increasingly used in contexts where the amount of available memory is limited, it becomes important to devise techniques that reduce the memory footprint of application programs while leaving them in an executable form. This paper ...
Adaptive object code compression
CASES '06: Proceedings of the 2006 international conference on Compilers, architecture and synthesis for embedded systemsPrevious object code compression schemes have employed static and semiadaptive compression algorithms to reduce the size of instruction memory in embedded systems. The suggestion by a number of researchers that adaptive compression techniques are ...
Profile-guided code compression
PLDI '02: Proceedings of the ACM SIGPLAN 2002 conference on Programming language design and implementationAs computers are increasingly used in contexts where the amount of available memory is limited, it becomes important to devise techniques that reduce the memory footprint of application programs while leaving them in an executable form. This paper ...
Comments