PSL Optimizer Tool
The PATROL PSL Optimizer tool is a three-level, multi-pass, intermediate code (quad) optimizer
Supported Platforms
Operating Systems
- UNIX
- Windows
PATROL Versions
- PATROL 3.2 only
Resource Requirements
The PSL Optimizer requires no additional resources beyond those specified for running the PATROL product.
When to Use the PSL Optimizer
Use this tool to optimize your KM code.
How to Install the PSL Optimizer
This tool is part of the PATROL Agent. No further setup is required once PATROL has been installed.
How to Deactivate the PSL Optimizer
Since this tool is part of the PATROL product, there is no requirement to deactivate the tool.
About the PSL Optimizer
When a PSL script is compiled, it is compiled down to an intermediate code. The PATROL Optimizer transforms the intermediate code generated by the PSL Compiler so that the code executes more efficiently in the PSL interpreter.
Optimization Levels
You can specify the level of optimization by using the -O
flag with the PSL stand-alone compiler or with the PATROL Agent function. You can also use the pragma
keyword in PSL to set the optimization level for a particular PSL script.
The supported levels of optimization are:
Level Code | Description |
---|---|
0 | no optimization |
1 | peephole optimization (default) |
2 | local optimization |
3 | global optimization |
Level 1: Peephole optimizations
Level 1 optimizations are ignorant of a program's control flow and are limited to the analysis of a program on an instruction by instruction basis.
Level 1 optimizations include the following:
- jump chain reduction
- useless jump removal
- redundant instruction removal
- parameter packing
Jump chain reduction
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.
Useless jump removal
Redundant instruction removal
Parameter Packing
Level 2: Local optimizations
- constant folding
- constant propagation
- global constant propagation
- definition removal
- string concatenation conversion
- parameter ordering
Constant folding
Constant propagation
Global constant propagation
Definition removal
String concatenation conversion
Parameter ordering
Level 3: Global optimizations
Block chain reduction
Unreachable code removal
Code that can never be executed is removed.
Loop tail logic injection
Orphan block inlining
Optimization Criteria
The PSL Optimizer decides at what level to optimize a program based on the following criteria:
Requested level of optimization
Demanded level of optimization
Note
Note that the O in the O2 in the line above is an uppercase alphabetic character and not a number zero.
Note
Note that the 0
in the 02
in the line above is a numeric and not an alpha capital letter O.
Maximum level of optimization
# This program will be optimized at level 1 and # print the levels 1 and 2 results for the # program and its processes.
pragma
" -01P2
"
Command-Line Specified Options
The PSL Optimizer tool can be controlled using the following methods:
- Via a command-line switch for the
psl
andPatrolAgent
commands. This affects scripts system wide. - Via the
pragma
PSL statement. This affects only the script using the pragma statement.
The format is as follows: -O # M# P#
Symbol | Description |
---|---|
| specify the demanded optimization level If no level is specified, the requested optimization level, defined implicitly based on the context of the PSL script, will be used. Valid values are 0, 1, 2 and 3. |
| specify the maximum optimization level. Valid values are 0, 1, 2 and 3. The default level is 3. |
| Specify the level at which to print optimization results (to stdout). Valid values are:
|
Comments
Log in or register to comment.