APIdia Launch Partner
Top Inners Fields Constructors Methods
com.sun.org.apache.xalan.internal.xsltc.compiler.util

public Class MethodGenerator

extends MethodGen
implements Constants
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xalan.internal.xsltc.compiler.Constants
Known Direct Subclasses
com.sun.org.apache.xalan.internal.xsltc.compiler.util.NamedMethodGenerator, com.sun.org.apache.xalan.internal.xsltc.compiler.util.RtMethodGenerator, com.sun.org.apache.xalan.internal.xsltc.compiler.util.TestGenerator, com.sun.org.apache.xalan.internal.xsltc.compiler.util.AttributeSetMethodGenerator, com.sun.org.apache.xalan.internal.xsltc.compiler.util.CompareGenerator, com.sun.org.apache.xalan.internal.xsltc.compiler.util.MatchGenerator
Imports
com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.classfile.Field, .Method, com.sun.org.apache.bcel.internal.generic.ALOAD, .ASTORE, .BranchHandle, .BranchInstruction, .ConstantPoolGen, .DLOAD, .DSTORE, .FLOAD, .FSTORE, .GETFIELD, .GOTO, .ICONST, .ILOAD, .INVOKEINTERFACE, .INVOKESPECIAL, .INVOKESTATIC, .INVOKEVIRTUAL, .ISTORE, .IfInstruction, .IndexedInstruction, .Instruction, .InstructionConst, .InstructionHandle, .InstructionList, .InstructionTargeter, .LLOAD, .LSTORE, .LocalVariableGen, .LocalVariableInstruction, .MethodGen, .NEW, .PUTFIELD, .RET, .Select, .TargetLostException, .Type, com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern, .XSLTC, java.util.ArrayList, .Collections, .HashMap, .LinkedHashMap, .Iterator, .List, .Map, .Stack

Authors
Jacek Ambroziak, Santiago Pericas-Geertsen

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
MethodGenerator.Chunk

Used to keep track of an outlineable chunk of instructions in the current method.

protected class
MethodGenerator.LocalVariableRegistry

Keeps track of all local variables used in the method.

Field Summary

Modifier and TypeField and Description
private boolean
private final Instruction
private final Instruction
private final Instruction
private final Instruction
private final Instruction
private final Instruction
private final Instruction
private final Instruction
private final Instruction
private Instruction
private Instruction
private MethodGenerator.LocalVariableRegistry
private final Instruction
private final Instruction
private Map<Pattern, InstructionList>
_preCompiled

A mapping between patterns and instruction lists used by test sequences to avoid compiling the same pattern multiple times.

private final Instruction
private final Instruction
private SlotAllocator
private final Instruction
private final Instruction
private final Instruction
private static final int
private static final String
private static final int
protected static final int
private static final int
private int
m_openChunks

Track the number of outlineable chunks started but not yet ended.

private int
m_totalChunks

Track the number of outlineable chunks seen.

private static final int
private static final int
private static final int
private static final int
private static final String
private static final int

Constructor Summary

AccessConstructor and Description
public
MethodGenerator(int access_flags, Type return_type, Type[] arg_types, String[] arg_names, String method_name, String class_name, InstructionList il, ConstantPoolGen cpg)

Method Summary

Modifier and TypeMethod and Description
public void
addInstructionList(Pattern pattern, InstructionList ilist)

Add a pre-compiled pattern to this mode.

public LocalVariableGen
public LocalVariableGen
public final Instruction
public final Instruction
public final Instruction
private List<MethodGenerator.Chunk>

Returns:

a java.util.List containing the MethodGenerator.Chunks that may be outlined from this method
getCandidateChunks
(ClassGenerator
The ClassGen with which the generated methods will be associated
classGen
,
int
the size of the bytecode in the original method
totalMethodSize
)

Find the outlineable chunks in this method that would be the best choices to outline, based on size and position in the method.

pack-priv Method[]

Returns:

an array of all the Methods generated
getGeneratedMethods
(ClassGenerator
the ClassGenerator of which these methods are members
classGen
)

Get all Methods generated by this MethodGenerator.

public InstructionList
getInstructionList(Pattern pattern)

Get the instruction list for a pre-compiled pattern.

public int
public LocalVariableGen
private MethodGenerator.LocalVariableRegistry
protected Method
public Instruction
loadContextNode()

by default context node is the same as current node.

public Instruction
public Instruction
public Instruction
public Instruction
private static Instruction

Returns:

the generated LoadInstruction
loadLocal
(int
the JVM stack frame index of the variable that is to be loaded
index
,
Type
the Type of the variable
type
)

Helper method to generate an instance of a subclass of LoadInstruction based on the specified Type that will load the specified local variable

public void
markChunkEnd()

Mark the end of an outlineable chunk of code.

public void
markChunkStart()

Mark the end of the method's InstructionList as the start of an outlineable chunk of code.

private List<MethodGenerator.Chunk>

Returns:

a java.util.List of MethodGenerator.Chunks maximally merged
mergeAdjacentChunks
(MethodGenerator.Chunk[]
array of sibling MethodGenerator.Chunks that are under consideration for outlining. Chunks must be in the order encountered in the InstructionList
chunks
)

Merge adjacent sibling chunks to produce larger candidate chunks for outlining

public final Instruction
public final Instruction
pack-priv boolean

Returns:

true if and only if the specified variable is in use at the particular byte code offset.
offsetInLocalVariableGenRange
(LocalVariableGen
the LocalVariableGen for the variable
lvg
,
int
the position in the byte code
offset
)

Determines whether a particular variable is in use at a particular offset in the byte code for this method.

private Method

Returns:

The new Method containing the outlined code.
outline
(InstructionHandle
The InstructionHandle of the first instruction in the chunk to outline
first
,
InstructionHandle
The InstructionHandle of the last instruction in the chunk to outline
last
,
String
The name of the new method
outlinedMethodName
,
ClassGenerator
The ClassGenerator of which the original and new methods will be members
classGen
)

Given an outlineable chunk of code in the current MethodGenerator move ("outline") the chunk to a new method, and replace the chunk in the old method with a reference to that new method.

public Method[]

Returns:

an array of the outlined Methods and the original method itself
outlineChunks
(ClassGenerator
The ClassGen with which the generated methods will be associated
classGen
,
int
The number of bytes of bytecode represented by the InstructionList of this method
originalMethodSize
)

Breaks up the IL for this MethodGenerator into separate outlined methods so that no method exceeds the 64KB limit on the length of the byte code associated with a method.

public void
removeLocalVariable(LocalVariableGen lvg)

Overrides com.sun.org.apache.bcel.internal.generic.MethodGen.removeLocalVariable.

Remove a local variable, its slot will not be reused, if you do not use addLocalVariable with an explicit index argument.

public final Instruction
public void
setMaxLocals()

Overrides com.sun.org.apache.bcel.internal.generic.MethodGen.setMaxLocals.

Compute maximum number of local variables.

public final Instruction
public final Instruction
public final Instruction
public Instruction
public Instruction
public Instruction
public Instruction
public Instruction
private static Instruction

Returns:

the generated StoredInstruction
storeLocal
(int
the JVM stack frame index of the variable that is to be stored
index
,
Type
the Type of the variable
type
)

Helper method to generate an instance of a subclass of StoreInstruction based on the specified Type that will store a value in the specified local variable

public final Instruction
pack-priv boolean

Returns:

true if the InstructionList was modified; false otherwise
widenConditionalBranchTargetOffsets
()

Rewrites branches to avoid the JVM limits of relative branch offsets.

Inherited from com.sun.org.apache.bcel.internal.generic.MethodGen:
addAnnotationsAsAttributeaddCodeAttributeaddExceptionaddExceptionHandleraddLineNumberaddLocalVariableaddLocalVariableaddObserveraddParameterAnnotationaddParameterAnnotationsAsAttributecopyequalsgetAnnotationsOnParametergetArgumentNamegetArgumentNamesgetArgumentTypegetArgumentTypesgetClassNamegetCodeAttributesgetComparatorgetExceptionHandlersgetExceptionsgetInstructionListgetLineNumbersgetLineNumberTablegetLocalVariablesgetLocalVariableTablegetLocalVariableTypeTablegetMaxLocalsgetMaxStackgetMaxStackgetMethodgetReturnTypegetSignaturehashCoderemoveCodeAttributeremoveCodeAttributesremoveExceptionremoveExceptionHandlerremoveExceptionHandlersremoveExceptionsremoveLineNumberremoveLineNumbersremoveLocalVariablesremoveLocalVariableTypeTableremoveNOPsremoveObserverremoveRuntimeAttributessetArgumentNamesetArgumentNamessetArgumentTypesetArgumentTypessetClassNamesetComparatorsetInstructionListsetMaxLocalssetMaxStacksetMaxStacksetReturnTypestripAttributestoStringupdate