Module Code

module Code: sig .. end
Utility functions for code manipulation, and optimization.

val remove_dead_code : ('a, 'b) ControlFlow.graph -> ('a, 'b) ControlFlow.graph
remove_dead_code g returns g without the vertices that cannot be reached from the root.
val optimize_jumps : ('a, 'b) ControlFlow.graph -> ('a, 'b) ControlFlow.graph
optimize_jumps g returns g except that empty nodes (i. e. with no instruction) have been short-circuited (but not removed, possibly producing dead code).
val optimize_switches : ('a, 'b) ControlFlow.graph -> ('a, 'b) ControlFlow.graph
optimize_switches g returns g except that lookup switches are replaced with table switches if it shorter.
type flattening_infos 
The type used to label nodes of a flattened graph.
val offset_of_flattening_infos : flattening_infos -> int32
Returns the offset associated with the label of the passed flattened vertex.
val flattened_graph : (int32 * 'a, 'b) ControlFlow.graph ->
(flattening_infos * 'a, 'b) ControlFlow.graph
Converts the passed graph, by assuming that it is already flattened, and that int32 labels are vertices offsets.
val flatten_graph : (int32 * Utils.u2 list, 'b) ControlFlow.graph ->
Instruction.t list * (Utils.u2 * Utils.u2) list *
Attribute.exception_table_element list *
(flattening_infos * int32, 'b) ControlFlow.graph
flatten_graph g returns a l, t, e, g' quadruple where g' is g labeled with code offsets corresponding to the instruction list l. t is the data for the LineNumberTable attribute, and e is the exception table for l.
val optimize_graph : ('a * Utils.u2 list, 'b) ControlFlow.graph ->
('a * Utils.u2 list, 'b) ControlFlow.graph
optimize_graph g returns an optimized version of graph g. It is equivalent to remove_dead_code (optimize_switches (optimize_jumps (Peephole.optimize_graph g))).
val compute_stack_infos : Name.for_class ->
StackState.instance StackState.unifier ->
(flattening_infos * 'a, 'b) ControlFlow.graph ->
StackState.t -> Utils.u2 * Utils.u2 * Attribute.stack_map_frame list
compute_stack_infos cn u g s returns max_stack, max_locals, stack_map_frame for the method whose control flow graph g,initial stack state s, and enclosing class cn are passed. The function u is used to unify stack states.

Raises StackState.Exception if the passed instruction lists associated with the graph vertices are incoherent.