int addConstant(String k) { int utf8Index = 0xFFFF & addUtf8(k); int theIndex = itsStringConstHash.getInt(utf8Index, -1); if (theIndex == -1) { theIndex = itsTopIndex++; ensure(3); itsPool[itsTop++] = CONSTANT_String; itsTop = ClassFileWriter.putInt16(utf8Index, itsPool, itsTop); itsStringConstHash.put(utf8Index, theIndex); } itsPoolTypes.put(theIndex, CONSTANT_String); return theIndex; }
private void resolveGoto(int fromPC, int jumpPC) { int offset = jumpPC - fromPC; // Ensure that jumps do not overlap if (0 <= offset && offset <= 2) throw Kit.codeBug(); int offsetSite = fromPC + 1; if (offset != (short)offset) { if (itsData.longJumps == null) { itsData.longJumps = new UintMap(); } itsData.longJumps.put(offsetSite, jumpPC); offset = 0; } byte[] array = itsData.itsICode; array[offsetSite] = (byte)(offset >> 8); array[offsetSite + 1] = (byte)offset; }
/** * Set object value of the key. * If key does not exist, also set its int value to 0. */ public void put(int key, Object value) { if (key < 0) Kit.codeBug(); int index = ensureIndex(key, false); if (values == null) { values = new Object[1 << power]; } values[index] = value; }
int step = tableLookupStep(fraction, mask, power); int n = 0; do { rehashTable(intType); keys = this.keys; return insertNewKey(key);
static int[] getLineNumbers(InterpreterData data) { UintMap presentLines = new UintMap(); byte[] iCode = data.itsICode; int iCodeLength = iCode.length; for (int pc = 0; pc != iCodeLength;) { int bytecode = iCode[pc]; int span = bytecodeSpan(bytecode); if (bytecode == Icode_LINE) { if (span != 3) Kit.codeBug(); int line = getIndex(iCode, pc + 1); presentLines.put(line, 0); } pc += span; } return presentLines.getKeys(); }
/** * Calculate partial dependencies for super blocks. * * This is used as a workaround for dead code that is generated. Only * one dependency per super block is given. */ private SuperBlock[] getSuperBlockDependencies() { SuperBlock[] deps = new SuperBlock[superBlocks.length]; for (int i = 0; i < itsExceptionTableTop; i++) { ExceptionTableEntry ete = itsExceptionTable[i]; short startPC = (short) getLabelPC(ete.itsStartLabel); short handlerPC = (short) getLabelPC(ete.itsHandlerLabel); SuperBlock handlerSB = getSuperBlockFromOffset(handlerPC); SuperBlock dep = getSuperBlockFromOffset(startPC); deps[handlerSB.getIndex()] = dep; } int[] targetPCs = itsJumpFroms.getKeys(); for (int i = 0; i < targetPCs.length; i++) { int targetPC = targetPCs[i]; int branchPC = itsJumpFroms.getInt(targetPC, -1); SuperBlock branchSB = getSuperBlockFromOffset(branchPC); SuperBlock targetSB = getSuperBlockFromOffset(targetPC); deps[targetSB.getIndex()] = branchSB; } return deps; }
public final void markTableSwitchCase(int switchStart, int caseIndex, int stackTop) { if (!(0 <= stackTop && stackTop <= itsMaxStack)) throw new IllegalArgumentException("Bad stack index: "+stackTop); itsStackTop = (short)stackTop; addSuperBlockStart(itsCodeBufferTop); itsJumpFroms.put(itsCodeBufferTop, switchStart); setTableSwitchJump(switchStart, caseIndex, itsCodeBufferTop); }
public void remove(int key) { if (key < 0) Kit.codeBug(); int index = findIndex(key); if (0 <= index) { keys[index] = DELETED; --keyCount; // Allow to GC value and make sure that new key with the deleted // slot shall get proper default values if (values != null) { values[index] = null; } if (ivaluesShift != 0) { keys[ivaluesShift + index] = 0; } } }
private int insertNewKey(int key) { if (check && occupiedCount != keyCount) Kit.codeBug(); if (check && keyCount == 1 << power) Kit.codeBug(); int[] keys = this.keys; int fraction = key * A; int index = fraction >>> (32 - power); if (keys[index] != EMPTY) { int mask = (1 << power) - 1; int step = tableLookupStep(fraction, mask, power); int firstIndex = index; do { if (check && keys[index] == DELETED) Kit.codeBug(); index = (index + step) & mask; if (check && firstIndex == index) Kit.codeBug(); } while (keys[index] != EMPTY); } keys[index] = key; ++occupiedCount; ++keyCount; return index; }
int key = old[i]; if (key != EMPTY && key != DELETED) { int index = insertNewKey(key); if (oldValues != null) { values[index] = oldValues[i];
byte getConstantType(int index) { return (byte) itsPoolTypes.getInt(index, 0); }
} else { frame.pc = frame.idata.longJumps. getExistingInt(frame.pc);
static int[] getLineNumbers(InterpreterData data) { UintMap presentLines = new UintMap(); byte[] iCode = data.itsICode; int iCodeLength = iCode.length; for (int pc = 0; pc != iCodeLength;) { int bytecode = iCode[pc]; int span = bytecodeSpan(bytecode); if (bytecode == Icode_LINE) { if (span != 3) Kit.codeBug(); int line = getIndex(iCode, pc + 1); presentLines.put(line, 0); } pc += span; } return presentLines.getKeys(); }
int step = tableLookupStep(fraction, mask, power); int n = 0; do { rehashTable(intType); return insertNewKey(key);
/** * Calculate partial dependencies for super blocks. * * This is used as a workaround for dead code that is generated. Only * one dependency per super block is given. */ private SuperBlock[] getSuperBlockDependencies() { SuperBlock[] deps = new SuperBlock[superBlocks.length]; for (int i = 0; i < itsExceptionTableTop; i++) { ExceptionTableEntry ete = itsExceptionTable[i]; short startPC = (short) getLabelPC(ete.itsStartLabel); short handlerPC = (short) getLabelPC(ete.itsHandlerLabel); SuperBlock handlerSB = getSuperBlockFromOffset(handlerPC); SuperBlock dep = getSuperBlockFromOffset(startPC); deps[handlerSB.getIndex()] = dep; } int[] targetPCs = itsJumpFroms.getKeys(); for (int i = 0; i < targetPCs.length; i++) { int targetPC = targetPCs[i]; int branchPC = itsJumpFroms.getInt(targetPC, -1); SuperBlock branchSB = getSuperBlockFromOffset(branchPC); SuperBlock targetSB = getSuperBlockFromOffset(targetPC); deps[targetSB.getIndex()] = branchSB; } return deps; }
int addConstant(float k) { ensure(5); itsPool[itsTop++] = CONSTANT_Float; int bits = Float.floatToIntBits(k); itsTop = ClassFileWriter.putInt32(bits, itsPool, itsTop); itsPoolTypes.put(itsTopIndex, CONSTANT_Float); return itsTopIndex++; }
public void remove(int key) { if (key < 0) Kit.codeBug(); int index = findIndex(key); if (0 <= index) { keys[index] = DELETED; --keyCount; // Allow to GC value and make sure that new key with the deleted // slot shall get proper default values if (values != null) { values[index] = null; } if (ivaluesShift != 0) { keys[ivaluesShift + index] = 0; } } }
private int insertNewKey(int key) { if (check && occupiedCount != keyCount) Kit.codeBug(); if (check && keyCount == 1 << power) Kit.codeBug(); int[] keys = this.keys; int fraction = key * A; int index = fraction >>> (32 - power); if (keys[index] != EMPTY) { int mask = (1 << power) - 1; int step = tableLookupStep(fraction, mask, power); int firstIndex = index; do { if (check && keys[index] == DELETED) Kit.codeBug(); index = (index + step) & mask; if (check && firstIndex == index) Kit.codeBug(); } while (keys[index] != EMPTY); } keys[index] = key; ++occupiedCount; ++keyCount; return index; }
int key = old[i]; if (key != EMPTY && key != DELETED) { int index = insertNewKey(key); if (oldValues != null) { values[index] = oldValues[i];
byte getConstantType(int index) { return (byte) itsPoolTypes.getInt(index, 0); }