Week 10

Exercises on optimization

  1. Consider the following two proposals for new peephole patterns. Are they sound? How would those that are sound look as C-code? Would they ever be relevant?

    • Replace
      ldc_string "..."
      dup
      ifnull L
      
      by
      ldc_string "..."
      

    • Replace
      return
      <<anything>>
      
      by
      return
      

    Motivation: get you thinking about the upcoming peephole contest deliverable.

  2. Study the contents of the WIG run-time libraries in wig/lib. How could you adapt or port them for use by your own generated code?

    Motivation: you may well want to implement such a library for programs compiled by your own WIG compiler.

  3. Outline a strategy for WIG code generation. What parts are tricky?

    Motivation: codegen is the final phase left for you to implement in your WIG compiler.

  4. What kinds of optimizations might be relevant for WIG programs? Why?

    Motivation: domain-specific programming languages generally present novel and interesting optimization opportunities.

  5. (Optional.) Study the code for optimizing JOOS programs. What parts are unclear?

    Motivation: help prepare you for the upcoming peephole contest deliverable.

Maintained by Christopher J. F. Pickett. [HOME]