skip to main content
article
Open Access

Compiler techniques for code compaction

Published:01 March 2000Publication History
Skip Abstract Section

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.

References

  1. AHO, A. V., SETHI, R., AND ULLMAN, J. D. 1985. Compilers--Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass. Google ScholarGoogle Scholar
  2. 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 ScholarGoogle Scholar
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle Scholar
  5. 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 ScholarGoogle Scholar
  6. 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 ScholarGoogle Scholar
  7. 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 ScholarGoogle Scholar
  8. 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 ScholarGoogle Scholar
  9. FRANZ, M. AND KISTLER, T. 1997. Slim binaries. Commun. ACM g0, 12 (Dec.), 87-94. Google ScholarGoogle Scholar
  10. FRASER, C. AND PROEBSTING, T. 1995. Custom instruction sets for code compression. Unpublished manuscript, http ://research.microsoft. com/ toddpro/papers/pldi2, ps.Google ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar
  12. FRASER, C. W. AND HANSON, D. R. 1995. A Retargetable C Compiler: Design and Implementation. Addison-Wesley, Reading, Mass. Google ScholarGoogle Scholar
  13. 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 ScholarGoogle Scholar
  14. 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 ScholarGoogle Scholar
  15. MUCHNICK, S. S. 1997. Advanced Compiler Design and Implementation. Morgan Kaufman, San Francisco, CA. Google ScholarGoogle Scholar
  16. 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 ScholarGoogle Scholar
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle Scholar
  19. VAN DE WIEL, R. 2000. The "Code Compaction" Bibliography. http://www.win.tue.nl/cs/pa/rikvdw/bibl.html.Google ScholarGoogle Scholar
  20. ZASTRE, M. J. 1993. Compacting object code via parameterized procedural abstraction. M.S. thesis, Dept. of Computing Science, University of Victoria.Google ScholarGoogle Scholar

Index Terms

  1. Compiler techniques for code compaction

      Recommendations

      Reviews

      Robert Ballance

      Cell phones, vehicles, appliances—all use embedded microcontrollers. Manufacturers need to fit increasing sophisticated programs into small amounts of memory. Code compaction techniques are needed in order <__?__Pub Caret>to meet these size <__?__Pub Fmt nolinebreak>requirements.<__?__Pub Fmt /nolinebreak> The authors present an aggressive approach to code compaction. Starting with an effective interprocedural optimizer, they then show that many common interprocedural optimizations can be combined with code factoring to significantly reduce the size of programs. Experimental results show size reductions of close to 30 percent compared to non-compacted programs. Code factoring analyzes the instructions within the control flow graph of a program. The algorithms account for trivial differences in program fragments, such as register renaming, and for architecture-dependent common code fragments, such as the procedure prologues and epilogues defined by a calling convention. Code factoring can introduce new procedures that can be called from several sites. Factoring can also eliminate common instruction sequences by moving them to points in the control flow graph that either dominate or postdominate their original sites. In this case, no new procedures or calls have to be introduced. Do compacted programs run slower__?__ Perhaps not surprisingly, some programs run faster when compacted, while others run slower. The speedups may be due to the use of a number of effective interprocedural analysis algorithms that may speed up a program even without the code factoring phase. Also, some code motion techniques are low-overhead. Overall, this paper is an excellent introduction to a specific code compaction strategy. Experimental results back the authors' claims of efficacy. Sections on related work provide pointers to the current literature. The techniques presented also illustrate the interdependence among optimization techniques. In this case, there is a powerful synergy between interprocedural optimization and compaction.

      Access critical reviews of Computing literature here

      Become a reviewer for Computing Reviews.

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM Transactions on Programming Languages and Systems
        ACM Transactions on Programming Languages and Systems  Volume 22, Issue 2
        March 2000
        244 pages
        ISSN:0164-0925
        EISSN:1558-4593
        DOI:10.1145/349214
        Issue’s Table of Contents

        Copyright © 2000 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 1 March 2000
        Published in toplas Volume 22, Issue 2

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader