public class Code extends Object
This is NOT part of any supported API. 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.
Modifier and Type | Class and Description |
---|---|
static class |
Code.Chain
A chain represents a list of unresolved jumps.
|
static class |
Code.StackMapFormat |
Modifier and Type | Field and Description |
---|---|
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?
|
int |
max_locals
The maximum number of local variable slots.
|
int |
max_stack
The maximum stack size.
|
boolean |
needStackMap |
int |
nextreg
The next available register.
|
Constructor and Description |
---|
Code(Symbol.MethodSymbol meth,
boolean fatcode,
Position.LineMap lineMap,
boolean varDebugInfo,
Code.StackMapFormat stackMap,
boolean debugCode,
CRTable crt,
Symtab syms,
Types types,
Pool pool,
LVTRanges lvtRanges)
Construct a code object, given the settings of the fatcode,
debugging info switches and the CharacterRangeTable.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
void |
closeAliveRanges(JCTree tree) |
void |
closeAliveRanges(JCTree tree,
int closingCP) |
void |
compressCatchTable() |
int |
curCP()
The current output code pointer.
|
void |
emit4(int od)
Emit four bytes of code.
|
void |
emitAnewarray(int od,
Type arrayType)
Emit anewarray.
|
void |
emitInvokedynamic(int desc,
Type mtype)
Emit an invokedynamic instruction.
|
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 |
emitLdc(int od)
Emit a ldc (or ldc_w) instruction, taking into account operand size
|
void |
emitMultianewarray(int ndims,
int type,
Type arrayType)
Emit a multinewarray instruction.
|
void |
emitNewarray(int elemcode,
Type arrayType)
Emit newarray.
|
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.
|
void |
endScopes(int first)
End scopes of all variables with registers ≥ first.
|
int |
entryPoint()
Declare an entry point; return current code pointer
|
int |
entryPoint(com.sun.tools.javac.jvm.Code.State state)
Declare an entry point with initial state;
return current code pointer
|
int |
entryPoint(com.sun.tools.javac.jvm.Code.State state,
Type pushed)
Declare an entry point with initial state plus a pushed value;
return current code pointer
|
void |
fillExceptionParameterPositions() |
int |
get4(int pc)
Return four code bytes at position pc as an int.
|
int |
getLVTSize()
Calculates the size of the LocalVariableTable.
|
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 String |
mnem(int opcode)
static tables
|
static int |
negate(int opcode)
Negate a branch opcode.
|
int |
newLocal(Symbol.VarSymbol v) |
void |
newRegSegment()
Start a set of fresh registers.
|
void |
put4(int pc,
int od)
Place four bytes into code at address pc.
|
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).
|
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) |
public final boolean debugCode
public final boolean needStackMap
public int max_stack
public int max_locals
public byte[] code
public int cp
public CRTable crt
public boolean fatcode
public int nextreg
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, LVTRanges lvtRanges)
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 arraycode(Type type)
public int curCP()
public void emit4(int od)
public void emitLdc(int od)
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 emitInvokedynamic(int desc, Type mtype)
public void emitop0(int op)
public void emitop1(int op, int od)
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)
public void put4(int pc, int od)
public int get4(int pc)
public boolean isAlive()
public void markDead()
public int entryPoint()
public int entryPoint(com.sun.tools.javac.jvm.Code.State state)
public int entryPoint(com.sun.tools.javac.jvm.Code.State state, Type pushed)
public void emitStackMap()
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 compressCatchTable()
public void addLineNumber(char startPc, char lineNumber)
public void statBegin(int pos)
public void markStatBegin()
public void closeAliveRanges(JCTree tree)
public void closeAliveRanges(JCTree tree, int closingCP)
public int getLVTSize()
public void setDefined(Bits newDefined)
public void setDefined(int adr)
public void setUndefined(int adr)
public void fillExceptionParameterPositions()
public int newLocal(Symbol.VarSymbol v)
public void newRegSegment()
public void endScopes(int first)
public static String mnem(int opcode)
Copyright © 2015. All rights reserved.