/** Force stat begin eagerly */ public void markStatBegin() { if (alive && lineDebugInfo) { int line = lineMap.getLineNumber(pendingStatPos); char cp1 = (char)cp; char line1 = (char)line; if (cp1 == cp && line1 == line) addLineNumber(cp1, line1); } pendingStatPos = Position.NOPOS; }
public int newLocal(VarSymbol v) { int reg = v.adr = newLocal(v.erasure(types)); addLocalVar(v); return reg; }
Item load() { Chain trueChain = null; Chain falseChain = jumpFalse(); if (!isFalse()) { code.resolve(trueJumps); code.emitop0(iconst_1); trueChain = code.branch(goto_); } if (falseChain != null) { code.resolve(falseChain); code.emitop0(iconst_0); } code.resolve(trueChain); return stackItem[typecode]; }
Chain jumpFalse() { if (tree == null) return code.mergeChains(falseJumps, code.branch(code.negate(opcode))); // we should proceed further in -Xjcov mode only int startpc = code.curPc(); Chain c = code.mergeChains(falseJumps, code.branch(code.negate(opcode))); code.crt.put(tree, CRTable.CRT_BRANCH_FALSE, startpc, code.curPc()); return c; }
Chain jumpFalse() { if (tree == null) return Code.mergeChains(falseJumps, code.branch(Code.negate(opcode))); // we should proceed further in -Xjcov mode only int startpc = code.curCP(); Chain c = Code.mergeChains(falseJumps, code.branch(Code.negate(opcode))); code.crt.put(tree, CRTable.CRT_BRANCH_FALSE, startpc, code.curCP()); return c; }
Chain jumpTrue() { if (tree == null) return code.mergeChains(trueJumps, code.branch(opcode)); // we should proceed further in -Xjcov mode only int startpc = code.curPc(); Chain c = code.mergeChains(trueJumps, code.branch(opcode)); code.crt.put(tree, CRTable.CRT_BRANCH_TRUE, startpc, code.curPc()); return c; }
public void visitSwitch(JCSwitch tree) { int limit = code.nextreg; assert tree.selector.type.tag != CLASS; int startpcCrt = genCrt ? code.curPc() : 0; Item sel = genExpr(tree.selector, syms.intType); List<JCCase> cases = tree.cases; if (genCrt) code.crt.put(TreeInfo.skipParens(tree.selector), CRT_FLOW_CONTROLLER, startpcCrt, code.curPc()); } else { if (genCrt) code.crt.put(TreeInfo.skipParens(tree.selector), CRT_FLOW_CONTROLLER, startpcCrt, code.curPc()); Env<GenContext> switchEnv = env.dup(tree, new GenContext()); switchEnv.info.isSwitch = true; int startpc = code.curPc(); // the position of the selector operation code.emitop0(opcode); code.align(4); int tableBase = code.curPc(); // the start of the jump table int[] offsets = null; // a table of offsets for a lookupswitch code.emit4(-1); // leave space for default offset if (opcode == tableswitch) { code.emit4(lo); // minimum label code.emit4(hi); // maximum label for (long i = lo; i <= hi; i++) { // leave space for jump table code.emit4(-1);
if (Code.width(types.erasure(env.enclMethod.sym.type).getParameterTypes()) + extras > ClassFile.MAX_PARAMETERS) { log.error(tree.pos(), "limit.parameters"); if (code.isAlive()) { code.statBegin(TreeInfo.endPos(tree.body)); if (env.enclMethod == null || env.enclMethod.sym.type.getReturnType().hasTag(VOID)) { code.emitop0(return_); } else { int startpc = code.entryPoint(); CondItem c = items.makeCondItem(goto_); code.resolve(c.jumpTrue(), startpc); CRT_BLOCK, startpcCrt, code.curCP()); code.endScopes(0); if (code.checkLimits(tree.pos(), log)) { nerrs++; return; code.compressCatchTable(); code.fillExceptionParameterPositions();
MethodSymbol meth = tree.sym; if (Code.width(types.erasure(env.enclMethod.sym.type).getParameterTypes()) + (((tree.mods.flags & STATIC) == 0 || meth.isConstructor()) ? 1 : 0) > ClassFile.MAX_PARAMETERS) { if (code.isAlive()) { code.statBegin(TreeInfo.endPos(tree.body)); if (env.enclMethod == null || env.enclMethod.sym.type.getReturnType().tag == VOID) { code.emitop0(return_); } else { int startpc = code.entryPoint(); CondItem c = items.makeCondItem(goto_); code.resolve(c.jumpTrue(), startpc); CRT_BLOCK, startpcCrt, code.curPc()); code.endScopes(0); if (code.checkLimits(tree.pos(), log)) { nerrs++; return;
/** Emit an opcode with a one-byte operand field. */ public void emitop1(int op, int od) { emitop(op); if (!alive) return; emit1(od); switch (op) { case bipush: state.push(syms.intType); break; case ldc1: state.push(typeForPool(pool.pool[od])); break; default: throw new AssertionError(mnem(op)); } postop(); }
/** Emit an opcode. */ private void emitop(int op) { if (pendingJumps != null) resolvePending(); if (alive) { if (pendingStatPos != Position.NOPOS) markStatBegin(); if (pendingStackMap) { pendingStackMap = false; emitStackMap(); } if (debugCode) System.err.println("emit@" + cp + " stack=" + state.stacksize + ": " + mnem(op)); emit1(op); } }
/** Generate code to create an array with given element type and number * of dimensions. */ Item makeNewArray(DiagnosticPosition pos, Type type, int ndims) { Type elemtype = types.elemtype(type); if (types.dimensions(type) > ClassFile.MAX_DIMENSIONS) { log.error(pos, "limit.dimensions"); nerrs++; } int elemcode = Code.arraycode(elemtype); if (elemcode == 0 || (elemcode == 1 && ndims == 1)) { code.emitAnewarray(makeRef(pos, elemtype), type); } else if (elemcode == 1) { code.emitMultianewarray(ndims, makeRef(pos, type), type); } else { code.emitNewarray(elemcode, type); } return items.makeStackItem(type); }
meth.code = code = new Code(meth, fatcode, lineDebugInfo ? toplevel.lineMap : null, if (meth.isConstructor() && selfType != syms.objectType) selfType = UninitializedType.uninitializedThis(selfType); code.setDefined( code.newLocal( new VarSymbol(FINAL, names._this, selfType, meth.owner))); code.setDefined(code.newLocal(l.head.sym)); int startpcCrt = genCrt ? code.curPc() : 0; code.entryPoint();
meth.code = code = new Code(meth, fatcode, lineDebugInfo ? toplevel.lineMap : null, if (meth.isConstructor() && selfType != syms.objectType) selfType = UninitializedType.uninitializedThis(selfType); code.setDefined( code.newLocal( new VarSymbol(FINAL, names._this, selfType, meth.owner))); code.setDefined(code.newLocal(l.head.sym)); int startpcCrt = genCrt ? code.curCP() : 0; code.entryPoint();
public void visitIf(JCIf tree) { int limit = code.nextreg; Chain thenExit = null; CondItem c = genCond(TreeInfo.skipParens(tree.cond), CRT_FLOW_CONTROLLER); Chain elseChain = c.jumpFalse(); if (!c.isFalse()) { code.resolve(c.trueJumps); genStat(tree.thenpart, env, CRT_STATEMENT | CRT_FLOW_TARGET); thenExit = code.branch(goto_); } if (elseChain != null) { code.resolve(elseChain); if (tree.elsepart != null) genStat(tree.elsepart, env,CRT_STATEMENT | CRT_FLOW_TARGET); } code.resolve(thenExit); code.endScopes(limit); }