PSL Optimizer


The PSL Optimizer includes the following:

  • PSL Optimizer architecture
    • Three levels
    • Mutli-pass
    • Intermediate code optimizer
  • PSL Optimizer functions
  • Specifying options
    • Command line
    • Pragma PSL statement

Levels of Optimization

The PSL Optimizer supports the following levels:

  • 0 - no optimization
  • Level 1 (peephole) optimization
  • Level 2 (local) optimization
  • Level 3 (global) optimization

Level 1 Optimization

The following section explains Level 1 optimization. 

  • Level 1 - Remove Useless Jumps: This optimization looks for unconditional and conditional jumps to the next instruction. The jump is then removed.
  • Level 1 - Reduce Jump Chains: This optimization looks for unconditional jumps to one or more Control Transfer Statement (CTS) instructions. The terminal CTS instruction is 
                   then replicated onto all of the non-terminal CTS instructions.
  • Level 1 - Remove Redundant Quad: This optimization looks for redundant statements without side effects. One of the redundant statements is then removed.
  • Level 1 - Pack Parameters: This optimization looks for adjacent parameter instructions and packs them into a more efficient parameter instruction.

Level 2 Optimization

The following section explains Level 2 optimization. 

  • Level 2 - String joining: Chains of string concatenations are converted into a single and more efficient call to the PSL join() function.
  • Level 2 - Fold and propagate: Expressions are evaluated when their arguments are known at optimization time. The result of the folded expression replaces the original expression with an assignment operation.
  • Level 2 - Remove Multiple and unused Definitions: Expressions defining symbols that are later defined, without first being referenced, are removed. Expressions with side effects remove only the assignment to the symbol.
  • Level 2 - Reorder Parameters: Parameter statements with nested expressions are re-ordered so all expression evaluation occurs before the first parameter statement and all parameter statements immediately precede the call statement. This exposes Level 1 parameter packing opportunities.

Level 3 Optimization

The following section explains Level 3 optimization.

  • Level 3 - Remove Unreachable Code: Code that can never be executed is removed.
  • Level 3 - Reduce Block Chains: One or more basic blocks that are entered from an unconditional jump are copied to the jump point. The resultant basic block is then extended to include the copied block.

The Optimizer and Menu Commands

  • Menu commands are compiled for every execution (if in PSL source)
  • Optimization is by default 3 (version 3.2 and later)
    • Every time cost of optimization (which is expensive): pragma "O0" (O-zero)
    • Libraries: No cost

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC PATROL Agent 10.0