PeepholeOptimizer3

org.nlogo.generate.PeepholeOptimizer3
See thePeepholeOptimizer3 companion class

This class serves as a peep-hole optimizer. Its purpose is just to catch one specific inefficient pattern of bytecode that the inliner generates -- the needless STORE / LOAD combination.

IMPORTANT: This class is tricky, because the inefficient pattern we want to replace is not always safe to replace.

Even if DLOAD is called right after DSTORE, there may be another DLOAD later in the method body. The only way we can safely use this peep-hole optimizer is if we could guarantee that every argument to a report_* method was only referenced once in the bytecode of the method body. PeepholeSafeChecker checks for this. If a report_* or perform_* method is "PeepholeSafe", then a special label (PEEPHOLE_SAFE_FLAG) is inserted into the bytecode by the InstructionGenerator, which this class looks for, to make sure it is safe to perform the transformation.

~Forrest (6/19/2006)

It's looking for patterns like this: DSTORE 4 (L-special) // PEEPHOLE_SAFE_FLAG label L2 LINENUMBER 2 L2 (L3) // extra junk label DLOAD 4 And replacing them with just: L2 LINENUMBER 2 L2 (L3) ~Forrest (6/19/2006)

Attributes

Companion
class
Source
PeepholeOptimizer3.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete fields

val PEEPHOLE_FLAG_LABEL: Label

Attributes

Source
PeepholeOptimizer3.scala