|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.tools.javac.jvm.Code
public class Code
An internal structure that corresponds to the code attribute of methods in a classfile. The class also provides some utility operations to generate bytecode instructions.
This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
| Nested Class Summary | |
|---|---|
static class |
Code.Chain
A chain represents a list of unresolved jumps. |
(package private) static class |
Code.LocalVar
A live range of a local variable. |
private static class |
Code.Mneumonics
|
static class |
Code.StackMapFormat
|
(package private) static class |
Code.StackMapFrame
An entry in the stack map. |
(package private) class |
Code.State
|
| Field Summary | |
|---|---|
private boolean |
alive
Code generation enabled? |
(package private) ListBuffer<char[]> |
catchInfo
A buffer for expression catch data. |
byte[] |
code
The code buffer. |
int |
cp
the current code pointer. |
CRTable |
crt
The CharacterRangeTable |
boolean |
debugCode
|
boolean |
fatcode
Are we generating code with jumps >= 32K? |
private boolean |
fixedPc
Is it forbidden to compactify code, because something is pointing to current location? |
(package private) Code.StackMapFrame |
frameBeforeLast
The stack map frame before the last one. |
(package private) static Type |
jsrReturnValue
|
(package private) Code.StackMapFrame |
lastFrame
The last stack map frame in StackMapTable. |
(package private) int |
lastStackMapPC
The last PC at which we generated a stack map. |
(package private) boolean |
lineDebugInfo
Switch: emit line number info. |
(package private) List<char[]> |
lineInfo
A buffer for line number information. |
(package private) Position.LineMap |
lineMap
Emit line number info if map supplied |
(package private) Code.LocalVar[] |
lvar
Local variables, indexed by register. |
int |
max_locals
The maximum number of local variable slots. |
int |
max_stack
The maximum stack size. |
(package private) Symbol.MethodSymbol |
meth
|
boolean |
needStackMap
|
int |
nextreg
The next available register. |
(package private) Code.Chain |
pendingJumps
A chain for jumps to be resolved before the next opcode is emitted. |
(package private) boolean |
pendingStackMap
Set true when a stackMap is needed at the current PC. |
(package private) int |
pendingStatPos
The position of the currently statement, if we are at the start of this statement, NOPOS otherwise. |
(package private) Pool |
pool
The constant pool of the current class. |
(package private) Code.StackMapFormat |
stackMap
The stack map format to be generated. |
(package private) Code.StackMapFrame[] |
stackMapBuffer
A buffer of cldc stack map entries. |
(package private) int |
stackMapBufferSize
|
(package private) ClassWriter.StackMapTableFrame[] |
stackMapTableBuffer
A buffer of compressed StackMapTable entries. |
(package private) Code.State |
state
The current machine state (registers and stack). |
(package private) Symtab |
syms
|
(package private) Types |
types
|
(package private) Code.LocalVar[] |
varBuffer
Previously live local variables, to be put into the variable table. |
(package private) int |
varBufferSize
|
(package private) boolean |
varDebugInfo
Switch: emit variable debug info. |
| Constructor Summary | |
|---|---|
Code(Symbol.MethodSymbol meth,
boolean fatcode,
Position.LineMap lineMap,
boolean varDebugInfo,
Code.StackMapFormat stackMap,
boolean debugCode,
CRTable crt,
Symtab syms,
Types types,
Pool pool)
Construct a code object, given the settings of the fatcode, debugging info switches and the CharacterRangeTable. |
|
| Method Summary | |
|---|---|
void |
addCatch(char startPc,
char endPc,
char handlerPc,
char catchType)
Add a catch clause to code. |
void |
addLineNumber(char startPc,
char lineNumber)
Add a line number entry. |
private void |
addLocalVar(Symbol.VarSymbol v)
Add a new local variable. |
void |
align(int incr)
Align code pointer to next `incr' boundary. |
static int |
arraycode(Type type)
Given a type, return its code for allocating arrays of that type. |
Code.Chain |
branch(int opcode)
Emit a branch with given opcode; return its chain. |
boolean |
checkLimits(JCDiagnostic.DiagnosticPosition pos,
Log log)
Check the code against VM spec limits; if problems report them and return true. |
int |
curPc()
The current output code pointer. |
private void |
emit1(int od)
Emit a byte of code. |
private void |
emit2(int od)
Emit two bytes of code. |
void |
emit4(int od)
Emit four bytes of code. |
void |
emitAnewarray(int od,
Type arrayType)
Emit anewarray. |
(package private) void |
emitCLDCStackMap(int pc,
int localsSize)
Emit a CLDC stack map frame. |
void |
emitInvokeinterface(int meth,
Type mtype)
Emit an invokeinterface instruction. |
void |
emitInvokespecial(int meth,
Type mtype)
Emit an invokespecial instruction. |
void |
emitInvokestatic(int meth,
Type mtype)
Emit an invokestatic instruction. |
void |
emitInvokevirtual(int meth,
Type mtype)
Emit an invokevirtual instruction. |
int |
emitJump(int opcode)
Emit a jump instruction. |
void |
emitMultianewarray(int ndims,
int type,
Type arrayType)
Emit a multinewarray instruction. |
void |
emitNewarray(int elemcode,
Type arrayType)
Emit newarray. |
private void |
emitop(int op)
Emit an opcode. |
void |
emitop0(int op)
Emit an opcode with no operand field. |
void |
emitop1(int op,
int od)
Emit an opcode with a one-byte operand field. |
void |
emitop1w(int op,
int od)
Emit an opcode with a one-byte operand field; widen if field does not fit in a byte. |
void |
emitop1w(int op,
int od1,
int od2)
Emit an opcode with two one-byte operand fields; widen if either field does not fit in a byte. |
void |
emitop2(int op,
int od)
Emit an opcode with a two-byte operand field. |
void |
emitop4(int op,
int od)
Emit an opcode with a four-byte operand field. |
void |
emitStackMap()
Emit a stack map entry. |
(package private) void |
emitStackMapFrame(int pc,
int localsSize)
|
private void |
endScope(int adr)
End the scope of a variable. |
void |
endScopes(int first)
End scopes of all variables with registers >= first. |
int |
entryPoint()
Declare an entry point; return current code pointer |
int |
entryPoint(Code.State state)
Declare an entry point with initial state; return current code pointer |
int |
entryPoint(Code.State state,
Type pushed)
Declare an entry point with initial state plus a pushed value; return current code pointer |
private int |
get1(int pc)
Return code byte at position pc as an unsigned int. |
private int |
get2(int pc)
Return two code bytes at position pc as an unsigned int. |
int |
get4(int pc)
Return four code bytes at position pc as an int. |
(package private) Code.StackMapFrame |
getInitialFrame()
|
private int |
getLocalsSize()
|
boolean |
isAlive()
Is code generation currently enabled? |
void |
markDead()
Switch code generation on/off. |
void |
markStatBegin()
Force stat begin eagerly |
static Code.Chain |
mergeChains(Code.Chain chain1,
Code.Chain chain2)
Merge the jumps in of two chains into one. |
static java.lang.String |
mnem(int opcode)
static tables |
static int |
negate(int opcode)
Negate a branch opcode. |
private int |
newLocal(int typecode)
Create a new local variable address and return it. |
int |
newLocal(Symbol.VarSymbol v)
|
private int |
newLocal(Type type)
|
void |
newRegSegment()
Start a set of fresh registers. |
(package private) void |
postop()
|
private void |
put1(int pc,
int op)
Place a byte into code at address pc. |
private void |
put2(int pc,
int od)
Place two bytes into code at address pc. |
void |
put4(int pc,
int od)
Place four bytes into code at address pc. |
(package private) void |
putVar(Code.LocalVar var)
Put a live variable range into the buffer to be output to the class file. |
void |
resolve(Code.Chain chain)
Resolve chain to point to current code pointer. |
void |
resolve(Code.Chain chain,
int target)
Resolve chain to point to given target. |
void |
resolvePending()
Resolve any pending jumps. |
void |
setDefined(Bits newDefined)
Set the current variable defined state. |
void |
setDefined(int adr)
Mark a register as being (possibly) defined. |
void |
setUndefined(int adr)
Mark a register as being undefined. |
void |
statBegin(int pos)
Mark beginning of statement. |
static int |
truncate(int tc)
Collapse type code for subtypes of int to INTcode. |
static int |
typecode(Type type)
Given a type, return its type code (used implicitly in the JVM architecture). |
private Type |
typeForPool(java.lang.Object o)
The type of a constant pool entry. |
static int |
width(int typecode)
The width in bytes of objects of the type. |
static int |
width(List<Type> types)
The total width taken up by a vector of objects. |
static int |
width(Type type)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final boolean debugCode
public final boolean needStackMap
final Types types
final Symtab syms
public int max_stack
public int max_locals
public byte[] code
public int cp
ListBuffer<char[]> catchInfo
List<char[]> lineInfo
public CRTable crt
public boolean fatcode
private boolean alive
Code.State state
private boolean fixedPc
public int nextreg
Code.Chain pendingJumps
int pendingStatPos
boolean pendingStackMap
Code.StackMapFormat stackMap
boolean varDebugInfo
boolean lineDebugInfo
Position.LineMap lineMap
final Pool pool
final Symbol.MethodSymbol meth
Code.StackMapFrame[] stackMapBuffer
ClassWriter.StackMapTableFrame[] stackMapTableBuffer
int stackMapBufferSize
int lastStackMapPC
Code.StackMapFrame lastFrame
Code.StackMapFrame frameBeforeLast
static Type jsrReturnValue
Code.LocalVar[] lvar
Code.LocalVar[] varBuffer
int varBufferSize
| Constructor Detail |
|---|
public Code(Symbol.MethodSymbol meth,
boolean fatcode,
Position.LineMap lineMap,
boolean varDebugInfo,
Code.StackMapFormat stackMap,
boolean debugCode,
CRTable crt,
Symtab syms,
Types types,
Pool pool)
| Method Detail |
|---|
public boolean checkLimits(JCDiagnostic.DiagnosticPosition pos,
Log log)
public static int typecode(Type type)
public static int truncate(int tc)
public static int width(int typecode)
public static int width(Type type)
public static int width(List<Type> types)
public static int arraycode(Type type)
public int curPc()
private void emit1(int od)
private void emit2(int od)
public void emit4(int od)
private void emitop(int op)
void postop()
public void emitMultianewarray(int ndims,
int type,
Type arrayType)
public void emitNewarray(int elemcode,
Type arrayType)
public void emitAnewarray(int od,
Type arrayType)
public void emitInvokeinterface(int meth,
Type mtype)
public void emitInvokespecial(int meth,
Type mtype)
public void emitInvokestatic(int meth,
Type mtype)
public void emitInvokevirtual(int meth,
Type mtype)
public void emitop0(int op)
public void emitop1(int op,
int od)
private Type typeForPool(java.lang.Object o)
public void emitop1w(int op,
int od)
public void emitop1w(int op,
int od1,
int od2)
public void emitop2(int op,
int od)
public void emitop4(int op,
int od)
public void align(int incr)
private void put1(int pc,
int op)
private void put2(int pc,
int od)
public void put4(int pc,
int od)
private int get1(int pc)
private int get2(int pc)
public int get4(int pc)
public boolean isAlive()
public void markDead()
public int entryPoint()
public int entryPoint(Code.State state)
public int entryPoint(Code.State state,
Type pushed)
public void emitStackMap()
private int getLocalsSize()
void emitCLDCStackMap(int pc,
int localsSize)
void emitStackMapFrame(int pc,
int localsSize)
Code.StackMapFrame getInitialFrame()
public static int negate(int opcode)
public int emitJump(int opcode)
public Code.Chain branch(int opcode)
public void resolve(Code.Chain chain,
int target)
public void resolve(Code.Chain chain)
public void resolvePending()
public static Code.Chain mergeChains(Code.Chain chain1,
Code.Chain chain2)
public void addCatch(char startPc,
char endPc,
char handlerPc,
char catchType)
public void addLineNumber(char startPc,
char lineNumber)
public void statBegin(int pos)
public void markStatBegin()
private void addLocalVar(Symbol.VarSymbol v)
public void setDefined(Bits newDefined)
public void setDefined(int adr)
public void setUndefined(int adr)
private void endScope(int adr)
void putVar(Code.LocalVar var)
private int newLocal(int typecode)
private int newLocal(Type type)
public int newLocal(Symbol.VarSymbol v)
public void newRegSegment()
public void endScopes(int first)
public static java.lang.String mnem(int opcode)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||