Skip to main content

The Treewidth of Java Programs

  • Conference paper
  • First Online:
Algorithm Engineering and Experiments (ALENEX 2002)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2409))

Included in the following conference series:

Abstract

Intuitively, the treewidth of a graph G measures how close G is to being a tree. The lower the treewidth, the faster we can solve various optimization problems on G, by dynamic programming along the tree structure. In the paper M.Thorup, All Structured Programs have Small Tree-Width and Good Register Allocation [8] it is shown that the control-flow graph of any goto-free C program is at most 6. This result opened for the possibility of applying the dynamic programming bounded treewidth algorithms to various compiler optimization tasks. In this paper we explore this possibility, in particular for Java programs. We first show that even if Java does not have a goto, the labelled break and continue statements are in a sense equally bad, and can be used to construct Java programs that are arbitrarily hard to understand and optimize.

For Java programs lacking these labelled constructs Thorup’s result for C still holds, and in the second part of the paper we analyze the treewidth of label-free Java programs empirically. We do this by means of a parser that computes a tree-decomposition of the control-flow graph of a given Java program. We report on experiments running the parser on several of the Java API packages, and the results tell us that on average the treewidth of the control-flow graph of these Java programs is no more than 2.7. This is the first empirical test of Thorup’s result, and it confirms our suspicion that the upper bounds of treewidth 6, 5 and 4 are rarely met in practice, boding well for the application of treewidth to compiler optimization.

Part of this research was made possible by visiting funds from The Norwegian Research Council and the Région Lorraine

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. A. V. Aho, R. Sethi, and J. D. Ullman. Compilers, Principles, Techniques and Tools. Addison-Wesley, 1986.

    Google Scholar 

  2. S. Alstrup, P. Lauridsen, and M. Thorup. Generalized dominators for structured programs. In Proceedings of the 3rd Static Analysis Symposium, volume 1145 of LNCS, pages 42–51, 1996.

    Google Scholar 

  3. H. Bodlaender, J. Gustedt, and J. A. Telle. Linear-time register allocation for a fixed number of registers and no stack variables. In Proceedings 9th ACM-SIAM Symposium on Discrete Algorithms (SODA’98), pages 574–583, 1998.

    Google Scholar 

  4. E. W. Dijkstra. Go to statement considered harmful. Comm. ACM, 11(3):147–148, 1968.

    Article  MathSciNet  Google Scholar 

  5. S. Kannan and T. Proebsting. Register allocation in structured programs. In Proceedings of the Sixth Annual ACM-SIAM Symposium on Discrete Algorithms, pages 360–368, San Francisco, California, 22–24 Jan. 1995.

    Google Scholar 

  6. T. Nishizeki, K. Takamizawa, and N. Saito. Algorithms for detecting series-parallel graphs and D-charts. Trans. Inst. Elect. Commun. Eng. Japan, 59(3):259–260, 1976.

    Google Scholar 

  7. N. Robertson and P. Seymour. Graph minors II. Algorithmic aspects of tree-width. Journal of Algorithms, 1986.

    Google Scholar 

  8. M. Thorup. Structured programs have small tree-width and good register allocation. Information and Computation, 142(2), 1998.

    Google Scholar 

  9. J. van Leeuwen. Handbook of Theoretical Computer Science, volume A, chapter Graph Algorithms-Classes of graphs, pages 545–551. Elsevier, Amsterdam, 1990.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2002 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Gustedt, J., Mæhle, O.A., Telle, J.A. (2002). The Treewidth of Java Programs. In: Mount, D.M., Stein, C. (eds) Algorithm Engineering and Experiments. ALENEX 2002. Lecture Notes in Computer Science, vol 2409. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45643-0_7

Download citation

  • DOI: https://doi.org/10.1007/3-540-45643-0_7

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-43977-6

  • Online ISBN: 978-3-540-45643-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics