Home » openjdk-7 » com.sun.tools » javac » jvm » [javadoc | source]
com.sun.tools.javac.jvm
public class: Code [javadoc | source]
java.lang.Object
   com.sun.tools.javac.jvm.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 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.
Nested Class Summary:
public enum class  Code.StackMapFormat   
static class  Code.StackMapFrame  An entry in the stack map. 
public static class  Code.Chain  A chain represents a list of unresolved jumps. Jump locations are sorted in decreasing order. 
class  Code.State   
static class  Code.LocalVar  A live range of a local variable. 
Field Summary
public final  boolean debugCode     
public final  boolean needStackMap     
final  Types types     
final  Symtab syms     
public  int max_stack    The maximum stack size. 
public  int max_locals    The maximum number of local variable slots. 
public  byte[] code    The code buffer. 
public  int cp    the current code pointer. 
 ListBuffer<char> catchInfo    A buffer for expression catch data. Each enter is a vector of four unsigned shorts. 
 List<char> lineInfo    A buffer for line number information. Each entry is a vector of two unsigned shorts. 
public  CRTable crt    The CharacterRangeTable 
public  boolean fatcode    Are we generating code with jumps >= 32K? 
 State state    The current machine state (registers and stack). 
public  int nextreg    The next available register. 
 Chain pendingJumps    A chain for jumps to be resolved before the next opcode is emitted. We do this lazily to avoid jumps to jumps. 
 int pendingStatPos    The position of the currently statement, if we are at the start of this statement, NOPOS otherwise. We need this to emit line numbers lazily, which we need to do because of jump-to-jump optimization. 
 boolean pendingStackMap    Set true when a stackMap is needed at the current PC. 
 StackMapFormat stackMap    The stack map format to be generated. 
 boolean varDebugInfo    Switch: emit variable debug info. 
 boolean lineDebugInfo    Switch: emit line number info. 
 LineMap lineMap    Emit line number info if map supplied 
final  Pool pool    The constant pool of the current class. 
final  MethodSymbol meth     
 StackMapFrame[] stackMapBuffer    A buffer of cldc stack map entries. 
 StackMapTableFrame[] stackMapTableBuffer    A buffer of compressed StackMapTable entries. 
 int stackMapBufferSize     
 int lastStackMapPC    The last PC at which we generated a stack map. 
 StackMapFrame lastFrame    The last stack map frame in StackMapTable. 
 StackMapFrame frameBeforeLast    The stack map frame before the last one. 
static  Type jsrReturnValue     
 LocalVar[] lvar    Local variables, indexed by register. 
 LocalVar[] varBuffer    Previously live local variables, to be put into the variable table. 
 int varBufferSize     
Constructor:
 public Code(MethodSymbol meth,
    boolean fatcode,
    LineMap lineMap,
    boolean varDebugInfo,
    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 from com.sun.tools.javac.jvm.Code Summary:
addCatch,   addLineNumber,   align,   arraycode,   branch,   checkLimits,   curPc,   emit4,   emitAnewarray,   emitCLDCStackMap,   emitInvokedynamic,   emitInvokeinterface,   emitInvokespecial,   emitInvokestatic,   emitInvokevirtual,   emitJump,   emitMultianewarray,   emitNewarray,   emitStackMap,   emitStackMapFrame,   emitop0,   emitop1,   emitop1w,   emitop1w,   emitop2,   emitop4,   endScopes,   entryPoint,   entryPoint,   entryPoint,   get4,   getInitialFrame,   isAlive,   markDead,   markStatBegin,   mergeChains,   mnem,   negate,   newLocal,   newRegSegment,   postop,   put4,   putVar,   resolve,   resolve,   resolvePending,   setDefined,   setDefined,   setUndefined,   statBegin,   truncate,   typecode,   width,   width,   width
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.tools.javac.jvm.Code Detail:
 public  void addCatch(char startPc,
    char endPc,
    char handlerPc,
    char catchType) 
    Add a catch clause to code.
 public  void addLineNumber(char startPc,
    char lineNumber) 
    Add a line number entry.
 public  void align(int incr) 
    Align code pointer to next `incr' boundary.
 public static int arraycode(Type type) 
    Given a type, return its code for allocating arrays of that type.
 public Chain branch(int opcode) 
    Emit a branch with given opcode; return its chain. branch differs from jump in that jsr is treated as no-op.
 public boolean checkLimits(DiagnosticPosition pos,
    Log log) 
    Check the code against VM spec limits; if problems report them and return true.
 public int curPc() 
    The current output code pointer.
 public  void emit4(int od) 
    Emit four bytes of code.
 public  void emitAnewarray(int od,
    Type arrayType) 
    Emit anewarray.
  void emitCLDCStackMap(int pc,
    int localsSize) 
    Emit a CLDC stack map frame.
 public  void emitInvokedynamic(int desc,
    Type mtype) 
    Emit an invokedynamic instruction.
 public  void emitInvokeinterface(int meth,
    Type mtype) 
    Emit an invokeinterface instruction.
 public  void emitInvokespecial(int meth,
    Type mtype) 
    Emit an invokespecial instruction.
 public  void emitInvokestatic(int meth,
    Type mtype) 
    Emit an invokestatic instruction.
 public  void emitInvokevirtual(int meth,
    Type mtype) 
    Emit an invokevirtual instruction.
 public int emitJump(int opcode) 
    Emit a jump instruction. Return code pointer of instruction to be patched.
 public  void emitMultianewarray(int ndims,
    int type,
    Type arrayType) 
    Emit a multinewarray instruction.
 public  void emitNewarray(int elemcode,
    Type arrayType) 
    Emit newarray.
 public  void emitStackMap() 
    Emit a stack map entry.
  void emitStackMapFrame(int pc,
    int localsSize) 
 public  void emitop0(int op) 
    Emit an opcode with no operand field.
 public  void emitop1(int op,
    int od) 
    Emit an opcode with a one-byte operand field.
 public  void emitop1w(int op,
    int od) 
    Emit an opcode with a one-byte operand field; widen if field does not fit in a byte.
 public  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.
 public  void emitop2(int op,
    int od) 
    Emit an opcode with a two-byte operand field.
 public  void emitop4(int op,
    int od) 
    Emit an opcode with a four-byte operand field.
 public  void endScopes(int first) 
    End scopes of all variables with registers >= first.
 public int entryPoint() 
    Declare an entry point; return current code pointer
 public int entryPoint(State state) 
    Declare an entry point with initial state; return current code pointer
 public int entryPoint(State state,
    Type pushed) 
    Declare an entry point with initial state plus a pushed value; return current code pointer
 public int get4(int pc) 
    Return four code bytes at position pc as an int.
 StackMapFrame getInitialFrame() 
 public boolean isAlive() 
    Is code generation currently enabled?
 public  void markDead() 
    Switch code generation on/off.
 public  void markStatBegin() 
    Force stat begin eagerly
 public static Chain mergeChains(Chain chain1,
    Chain chain2) 
    Merge the jumps in of two chains into one.
 public static String mnem(int opcode) 
    static tables ************************************************************************
 public static int negate(int opcode) 
    Negate a branch opcode.
 public int newLocal(VarSymbol v) 
 public  void newRegSegment() 
    Start a set of fresh registers.
  void postop() 
 public  void put4(int pc,
    int od) 
    Place four bytes into code at address pc. Pre: pc + 4 <= cp.
  void putVar(LocalVar var) 
    Put a live variable range into the buffer to be output to the class file.
 public  void resolve(Chain chain) 
    Resolve chain to point to current code pointer.
 public  void resolve(Chain chain,
    int target) 
    Resolve chain to point to given target.
 public  void resolvePending() 
    Resolve any pending jumps.
 public  void setDefined(Bits newDefined) 
    Set the current variable defined state.
 public  void setDefined(int adr) 
    Mark a register as being (possibly) defined.
 public  void setUndefined(int adr) 
    Mark a register as being undefined.
 public  void statBegin(int pos) 
    Mark beginning of statement.
 public static int truncate(int tc) 
    Collapse type code for subtypes of int to INTcode.
 public static int typecode(Type type) 
    Given a type, return its type code (used implicitly in the JVM architecture).
 public static int width(int typecode) 
    The width in bytes of objects of the type.
 public static int width(Type type) 
 public static int width(List<Type> types) 
    The total width taken up by a vector of objects.