next up previous contents index
Next: The Optimize-Interface Declaration Up: Compiler Policy Previous: Compiler Policy   Contents   Index


The Optimize Declaration

optimize declaration optimize

The optimize declaration recognizes six differentqualities. The qualities are conceptually independent aspects of program performance. In reality, increasing one quality tends to have adverse effects on other qualities. The compiler compares the relative values of qualities when it needs to make a trade-off; i.e., if speed is greater than safety, then improve speed at the cost of safety.

The default for all qualities (except debug) is 1. Whenever qualities are equal, ties are broken according to a broad idea of what a good default environment is supposed to be. Generally this downplays speed, compile-speed and space in favor of safety and debug. Novice and casual users should stick to the default policy. Advanced users often want to improve speed and memory usage at the cost of safety and debuggability.

If the value for a quality is 0 or 3, then it may have a special interpretation. A value of 0 means ``totally unimportant'', and a 3 means ``ultimately important.'' These extreme optimization values enable ``heroic'' compilation strategies that are not always desirable and sometimes self-defeating. Specifying more than one quality as 3 is not desirable, since it doesn't tell the compiler which quality is most important.

These are the optimization qualities:

speed
speed optimization qualityHow fast the program should is run. speed 3 enables some optimizations that hurt debuggability.

compilation-speed
compilation-speed optimization qualityHow fast the compiler should run. Note that increasing this above safety weakens type checking.

space
space optimization qualityHow much space the compiled code should take up. Inline expansion is mostly inhibited when space is greater than speed. A value of 0 enables promiscuous inline expansion. Wide use of a 0 value is not recommended, as it may waste so much space that run time is slowed. See section inline-expansion for a discussion of inline expansion.

debug
debug optimization qualityHow debuggable the program should be. The quality is treated differently from the other qualities: each value indicates a particular level of debugger information; it is not compared with the other qualities. See section debugger-policy for more details.

safety
safety optimization qualityHow much error checking should be done. If speed, space or compilation-speed is more important than safety, then type checking is weakened (see section weakened-type-checks). If safety if 0, then no run time error checking is done. In addition to suppressing type checks, 0 also suppresses argument count checking, unbound-symbol checking and array bounds checks.

extensions:inhibit-warnings
inhibit-warnings optimization qualityThis is a CMU extension that determines how little (or how much) diagnostic output should be printed during compilation. This quality is compared to other qualities to determine whether to print style notes and warnings concerning those qualities. If speed is greater than inhibit-warnings, then notes about how to improve speed will be printed, etc. The default value is 1, so raising the value for any standard quality above its default enables notes for that quality. If inhibit-warnings is 3, then all notes and most non-serious warnings are inhibited. This is useful with declare to suppress warnings about unavoidable problems.


next up previous contents index
Next: The Optimize-Interface Declaration Up: Compiler Policy Previous: Compiler Policy   Contents   Index
Peter Van Eynde 2001-03-08