Interface IDMasterOptimizer


public interface IDMasterOptimizer
A manager of IR optimizers. A master optimizer (MO) orchestrates and executes optimizers. This class is currently not meant to be implemented by third-party code. To create a master optimizer instance, use IDGlobalContext.createMasterOptimizer(com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext, boolean, boolean, boolean). Most IR optimizers will not need to create and use MOs on their own. However, some multi-stage advanced optimizers may need intermediate code clean-up before proceeding to a later phase. In such cases, using an MO may be necessary.

Implementation note: the master optimizer may call optimizers repeatedly until no more optimizations are performed.

  • Method Details

    • getTarget

      IDMethodContext getTarget()
      Retrieve the IR method context to be optimized.
      Returns:
    • add

      boolean add(IDOptimizer optimizer)
      Register an external optimizer.
      Parameters:
      optimizer - an optimizer
      Returns:
      true if the optimizer was registered
    • remove

      boolean remove(IDOptimizer optimizer)
      Unregister an external optimizer.
      Parameters:
      optimizer - a previously-registered optimizer
      Returns:
      true if the optimizer was unregistered
    • getListOfOptimizers

      List<IDOptimizer> getListOfOptimizers()
      Retrieve the list of all optimizers. The returned list contains all optimizers (built-in, external, etc.) registered with this MO. While the list is immutable, the optimizer objects can be acted upon. For example, optimizers (including internal optimizers) may be selectively enabled or disabled via setOptimizerEnabled(IDOptimizer, boolean).
      Returns:
      read-only list of currently registered optimizers
    • setOptimizerEnabled

      void setOptimizerEnabled(IDOptimizer opt, boolean enabled)
      Enable or disable an optimizer.
      Parameters:
      opt -
      enabled -
    • findOptimizer

      <T extends IDOptimizer> T findOptimizer(Class<T> cl)
      Find an optimizer by type. If multiple optimizers of the same type were registered (a practice that is not recommended), the first one is returned.
      Type Parameters:
      T -
      Parameters:
      cl - optimizer type
      Returns:
      a registered optimizer of the provided type or null
    • setSafeMode

      void setSafeMode(boolean enabled)
      Enable or disable safe mode. In safe mode, the only optimizers that are run are those whose type is DOptimizerType.NORMAL.
      Parameters:
      enabled -
    • isSafeMode

      boolean isSafeMode()
      Determine whether safe mode is enabled. In safe mode, the only optimizers that are run are those whose type is DOptimizerType.NORMAL.
      Returns:
    • setPolicyForOptimizerTag

      void setPolicyForOptimizerTag(String tag, boolean allowed)
      Set the running policy associated to a tag or group of tags. Policy checks when deciding whether an optimizer should be run works as follow: 1) the tag must be allowed, 2) if passed, the tag must not be blocked. By default, all tags are allowed, none are blocked. To reset to that default policy: first invoke this method with ("*", true), then invoke it with (null, false).
      Parameters:
      tag - tag name; the special name "*" means all tags; the special name "" (empty string) or null string means no tag
      allowed - true to allow the master optimizer to run the optimizer with the specified tag; false to block it
    • perform

      int perform()
      Perform optimizations on the target.
      Returns:
      the number of optimizations performed
    • registerInstrumenter

      void registerInstrumenter(IDMasterOptimizerInstrumenter inst)
      Parameters:
      inst -
    • unregisterInstrumenter

      void unregisterInstrumenter(IDMasterOptimizerInstrumenter inst)
      Parameters:
      inst -
    • getInstrumenters

      List<IDMasterOptimizerInstrumenter> getInstrumenters()
      Returns: