# Interface: com.pnfsoftware.jeb.core.units.code.android.ir.IDMasterOptimizer

A manager of [IR optimizers](IDOptimizer). 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](IDGlobalContext#createMasterOptimizer). 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: add
- parameter: `optimizer`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDOptimizer`
- return type: `boolean`

Description: Register an external optimizer.
parameter: optimizer: an optimizer
return: true if the optimizer was registered

## Method: findOptimizer
- parameter: `cl`, type: `java.lang.Class<T>`
- return type: `T`

Description: 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.
parameter: T: optimizer type
parameter: cl: optimizer type
return: a registered optimizer of the provided type or null

## Method: getInstrumenters
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.ir.IDMasterOptimizerInstrumenter>`

Description: Retrieve registered optimizer instrumenters.
return: the registered instrumenters

## Method: getListOfOptimizers
- return type: `java.util.List<com.pnfsoftware.jeb.core.units.code.android.ir.IDOptimizer>`

Description: 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)](#setOptimizerEnabled(IDOptimizer, boolean)).
return: read\-only list of currently registered optimizers

## Method: getTarget
- return type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMethodContext`

Description: Retrieve the IR method context to be optimized.
return: the target method context

## Method: isSafeMode
- return type: `boolean`

Description: Determine whether safe mode is enabled. In safe mode, the only optimizers that are run are those whose [type](IDOptimizer#getType()) is [DOptimizerType#NORMAL](DOptimizerType#NORMAL).
return: true if safe mode is enabled

## Method: perform
- return type: `int`

Description: Perform optimizations on the [target](#getTarget()).
return: the number of optimizations performed

## Method: registerInstrumenter
- parameter: `inst`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMasterOptimizerInstrumenter`

Description: Register an optimizer instrumenter.
parameter: inst: instrumenter to register

## Method: remove
- parameter: `optimizer`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDOptimizer`
- return type: `boolean`

Description: Unregister an external optimizer.
parameter: optimizer: a previously\-registered optimizer
return: true if the optimizer was unregistered

## Method: setOptimizerEnabled
- parameter: `opt`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDOptimizer`
- parameter: `enabled`, type: `boolean`

Description: Enable or disable an optimizer.
parameter: opt: optimizer to update
parameter: enabled: true to enable the optimizer, false to disable it

## Method: setPolicyForOptimizerTag
- parameter: `tag`, type: `java.lang.String`
- parameter: `allowed`, type: `boolean`

Description: 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)`.
parameter: tag: tag name; the special name `"*"` means all tags; the special name `""`            \(empty string\) or null string means no tag
parameter: allowed: true to allow the master optimizer to run the optimizer with the specified            tag; false to block it

## Method: setSafeMode
- parameter: `enabled`, type: `boolean`

Description: Enable or disable safe mode. In safe mode, the only optimizers that are run are those whose [type](IDOptimizer#getType()) is [DOptimizerType#NORMAL](DOptimizerType#NORMAL).
parameter: enabled: true to enable safe mode, false to disable it

## Method: unregisterInstrumenter
- parameter: `inst`, type: `com.pnfsoftware.jeb.core.units.code.android.ir.IDMasterOptimizerInstrumenter`

Description: Unregister an optimizer instrumenter.
parameter: inst: instrumenter to unregister

