private void printFrame(StringBuffer buffer, StackMapFrame frame) { String pattern = "[pc : {0} locals: {1} stack items: {2}\nlocals: {3}\nstack: {4}\n]"; //$NON-NLS-1$ int localsLength = frame.locals == null ? 0 : frame.locals.length; buffer.append(MessageFormat.format( pattern, new Object[] { Integer.toString(frame.pc), Integer.toString(frame.getNumberOfLocals()), Integer.toString(frame.numberOfStackItems), print(frame.locals, localsLength), print(frame.stackItems, frame.numberOfStackItems) } )); } private String print(VerificationTypeInfo[] infos, int length) {
public int getFrameType(StackMapFrame prevFrame) { final int offsetDelta = getOffsetDelta(prevFrame); switch(this.numberOfStackItems) { case 0 : switch(numberOfDifferentLocals(prevFrame)) { case 0 : return offsetDelta <= 63 ? SAME_FRAME : SAME_FRAME_EXTENDED; case 1 : case 2 : case 3 : return APPEND_FRAME; case -1 : case -2 : case -3 : return CHOP_FRAME; } break; case 1 : switch(numberOfDifferentLocals(prevFrame)) { case 0 : return offsetDelta <= 63 ? SAME_LOCALS_1_STACK_ITEMS : SAME_LOCALS_1_STACK_ITEMS_EXTENDED; } } return FULL_FRAME; } public void addLocal(int resolvedPosition, VerificationTypeInfo info) {
int offsetDelta = currentFrame.getOffsetDelta(prevFrame); switch (currentFrame.getFrameType(prevFrame)) { case StackMapFrame.APPEND_FRAME : if (localContentsOffset + 3 >= this.contents.length) { resizeContents(3); int numberOfDifferentLocals = currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 + numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); this.contents[localContentsOffset++] = (byte) offsetDelta; int index = currentFrame.getIndexOfDifferentLocals(numberOfDifferentLocals); int numberOfLocals = currentFrame.getNumberOfLocals(); for (int i = index; i < currentFrame.locals.length && numberOfDifferentLocals > 0; i++) { if (localContentsOffset + 6 >= this.contents.length) { resizeContents(3); numberOfDifferentLocals = -currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 - numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
StackMapFrame frame = new StackMapFrame(maxLocals); if (!isClinit) { initializeDefaultLocals(frame, methodBinding, maxLocals, codeLength); frames.add(frame.duplicate()); while (true) { int currentPC = pc - codeOffset; if (typeBinding != null) { if (stackDepthMarker.delta > 0) { frame.addStackItem(new VerificationTypeInfo(typeBinding)); } else { frame.stackItems[frame.numberOfStackItems - 1] = new VerificationTypeInfo(typeBinding); frame.addStackItem(new VerificationTypeInfo(0, VerificationTypeInfo.ITEM_OBJECT, exceptionMarker.constantPoolName)); indexInExceptionMarkers++; if (indexInExceptionMarkers < exceptionsMarkersLength) { StackMapFrame currentFrame = frame.duplicate(); currentFrame.pc = currentPC; break; case Opcodes.OPC_aconst_null: frame.addStackItem(TypeBinding.NULL); pc++; break; case Opcodes.OPC_iconst_4: case Opcodes.OPC_iconst_5:
int prevLocalsLength = prevLocals == null ? 0 : prevLocals.length; int currentLocalsLength = currentLocals == null ? 0 : currentLocals.length; int prevNumberOfLocals = prevFrame.getNumberOfLocals(); int currentNumberOfLocals = getNumberOfLocals(); if (equals(prevLocal, currentLocal) && indexInPrevLocals == indexInCurrentLocals) { if (result != 0) { result = Integer.MAX_VALUE;
public StackMapFrame duplicate() { int length = this.locals.length; StackMapFrame result = new StackMapFrame(length); result.numberOfLocals = -1; result.numberOfDifferentLocals = -1; result.pc = this.pc; result.numberOfStackItems = this.numberOfStackItems; if (length != 0) { result.locals = new VerificationTypeInfo[length]; for (int i = 0; i < length; i++) { final VerificationTypeInfo verificationTypeInfo = this.locals[i]; if (verificationTypeInfo != null) { result.locals[i] = verificationTypeInfo.duplicate(); } } } length = this.numberOfStackItems; if (length != 0) { result.stackItems = new VerificationTypeInfo[length]; for (int i = 0; i < length; i++) { result.stackItems[i] = this.stackItems[i].duplicate(); } } return result; } public int numberOfDifferentLocals(StackMapFrame prevFrame) {
localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; int numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
int offsetDelta = currentFrame.getOffsetDelta(prevFrame); switch (currentFrame.getFrameType(prevFrame)) { case StackMapFrame.APPEND_FRAME : if (localContentsOffset + 3 >= this.contents.length) { resizeContents(3); int numberOfDifferentLocals = currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 + numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); this.contents[localContentsOffset++] = (byte) offsetDelta; int index = currentFrame.getIndexOfDifferentLocals(numberOfDifferentLocals); int numberOfLocals = currentFrame.getNumberOfLocals(); for (int i = index; i < currentFrame.locals.length && numberOfDifferentLocals > 0; i++) { if (localContentsOffset + 6 >= this.contents.length) { resizeContents(3); numberOfDifferentLocals = -currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 - numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
StackMapFrame frame = new StackMapFrame(maxLocals); if (!isClinit) { initializeDefaultLocals(frame, methodBinding, maxLocals, codeLength); frames.add(frame.duplicate()); while (true) { int currentPC = pc - codeOffset; if (typeBinding != null) { if (stackDepthMarker.delta > 0) { frame.addStackItem(new VerificationTypeInfo(typeBinding)); } else { frame.stackItems[frame.numberOfStackItems - 1] = new VerificationTypeInfo(typeBinding); frame.addStackItem(new VerificationTypeInfo(0, VerificationTypeInfo.ITEM_OBJECT, exceptionMarker.constantPoolName)); indexInExceptionMarkers++; if (indexInExceptionMarkers < exceptionsMarkersLength) { StackMapFrame currentFrame = frame.duplicate(); currentFrame.pc = currentPC; break; case Opcodes.OPC_aconst_null: frame.addStackItem(TypeBinding.NULL); pc++; break; case Opcodes.OPC_iconst_4: case Opcodes.OPC_iconst_5:
int prevLocalsLength = prevLocals == null ? 0 : prevLocals.length; int currentLocalsLength = currentLocals == null ? 0 : currentLocals.length; int prevNumberOfLocals = prevFrame.getNumberOfLocals(); int currentNumberOfLocals = getNumberOfLocals(); if (equals(prevLocal, currentLocal) && indexInPrevLocals == indexInCurrentLocals) { if (result != 0) { result = Integer.MAX_VALUE;
public StackMapFrame duplicate() { int length = this.locals.length; StackMapFrame result = new StackMapFrame(length); result.numberOfLocals = -1; result.numberOfDifferentLocals = -1; result.pc = this.pc; result.numberOfStackItems = this.numberOfStackItems; if (length != 0) { result.locals = new VerificationTypeInfo[length]; for (int i = 0; i < length; i++) { final VerificationTypeInfo verificationTypeInfo = this.locals[i]; if (verificationTypeInfo != null) { result.locals[i] = verificationTypeInfo.duplicate(); } } } length = this.numberOfStackItems; if (length != 0) { result.stackItems = new VerificationTypeInfo[length]; for (int i = 0; i < length; i++) { result.stackItems[i] = this.stackItems[i].duplicate(); } } return result; } public int numberOfDifferentLocals(StackMapFrame prevFrame) {
localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; int numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
int offsetDelta = currentFrame.getOffsetDelta(prevFrame); switch (currentFrame.getFrameType(prevFrame)) { case StackMapFrame.APPEND_FRAME : if (localContentsOffset + 3 >= this.contents.length) { resizeContents(3); int numberOfDifferentLocals = currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 + numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); this.contents[localContentsOffset++] = (byte) offsetDelta; int index = currentFrame.getIndexOfDifferentLocals(numberOfDifferentLocals); int numberOfLocals = currentFrame.getNumberOfLocals(); for (int i = index; i < currentFrame.locals.length && numberOfDifferentLocals > 0; i++) { if (localContentsOffset + 6 >= this.contents.length) { resizeContents(3); numberOfDifferentLocals = -currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 - numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
StackMapFrame frame = new StackMapFrame(maxLocals); if (!isClinit) { initializeDefaultLocals(frame, methodBinding, maxLocals, codeLength); frames.add(frame.duplicate()); while (true) { int currentPC = pc - codeOffset; if (typeBinding != null) { if (stackDepthMarker.delta > 0) { frame.addStackItem(new VerificationTypeInfo(typeBinding)); } else { frame.stackItems[frame.numberOfStackItems - 1] = new VerificationTypeInfo(typeBinding); frame.addStackItem(new VerificationTypeInfo(0, VerificationTypeInfo.ITEM_OBJECT, exceptionMarker.constantPoolName)); indexInExceptionMarkers++; if (indexInExceptionMarkers < exceptionsMarkersLength) { StackMapFrame currentFrame = frame.duplicate(); currentFrame.pc = currentPC; break; case Opcodes.OPC_aconst_null: frame.addStackItem(TypeBinding.NULL); pc++; break; case Opcodes.OPC_iconst_4: case Opcodes.OPC_iconst_5:
private void printFrame(StringBuffer buffer, StackMapFrame frame) { String pattern = "[pc : {0} locals: {1} stack items: {2}\nlocals: {3}\nstack: {4}\n]"; //$NON-NLS-1$ int localsLength = frame.locals == null ? 0 : frame.locals.length; buffer.append(MessageFormat.format( pattern, new Object[] { Integer.toString(frame.pc), Integer.toString(frame.getNumberOfLocals()), Integer.toString(frame.numberOfStackItems), print(frame.locals, localsLength), print(frame.stackItems, frame.numberOfStackItems) } )); } private String print(VerificationTypeInfo[] infos, int length) {
public int getFrameType(StackMapFrame prevFrame) { final int offsetDelta = getOffsetDelta(prevFrame); switch(this.numberOfStackItems) { case 0 : switch(numberOfDifferentLocals(prevFrame)) { case 0 : return offsetDelta <= 63 ? SAME_FRAME : SAME_FRAME_EXTENDED; case 1 : case 2 : case 3 : return APPEND_FRAME; case -1 : case -2 : case -3 : return CHOP_FRAME; } break; case 1 : switch(numberOfDifferentLocals(prevFrame)) { case 0 : return offsetDelta <= 63 ? SAME_LOCALS_1_STACK_ITEMS : SAME_LOCALS_1_STACK_ITEMS_EXTENDED; } } return FULL_FRAME; } public void addLocal(int resolvedPosition, VerificationTypeInfo info) {
int prevLocalsLength = prevLocals == null ? 0 : prevLocals.length; int currentLocalsLength = currentLocals == null ? 0 : currentLocals.length; int prevNumberOfLocals = prevFrame.getNumberOfLocals(); int currentNumberOfLocals = getNumberOfLocals(); if (equals(prevLocal, currentLocal) && indexInPrevLocals == indexInCurrentLocals) { if (result != 0) { result = Integer.MAX_VALUE;
public StackMapFrame duplicate() { int length = this.locals.length; StackMapFrame result = new StackMapFrame(length); result.numberOfLocals = -1; result.numberOfDifferentLocals = -1; result.pc = this.pc; result.numberOfStackItems = this.numberOfStackItems; if (length != 0) { result.locals = new VerificationTypeInfo[length]; for (int i = 0; i < length; i++) { final VerificationTypeInfo verificationTypeInfo = this.locals[i]; if (verificationTypeInfo != null) { result.locals[i] = verificationTypeInfo.duplicate(); } } } length = this.numberOfStackItems; if (length != 0) { result.stackItems = new VerificationTypeInfo[length]; for (int i = 0; i < length; i++) { result.stackItems[i] = this.stackItems[i].duplicate(); } } return result; } public int numberOfDifferentLocals(StackMapFrame prevFrame) {
localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; int numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
int offsetDelta = currentFrame.getOffsetDelta(prevFrame); switch (currentFrame.getFrameType(prevFrame)) { case StackMapFrame.APPEND_FRAME : if (localContentsOffset + 3 >= this.contents.length) { resizeContents(3); int numberOfDifferentLocals = currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 + numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); this.contents[localContentsOffset++] = (byte) offsetDelta; int index = currentFrame.getIndexOfDifferentLocals(numberOfDifferentLocals); int numberOfLocals = currentFrame.getNumberOfLocals(); for (int i = index; i < currentFrame.locals.length && numberOfDifferentLocals > 0; i++) { if (localContentsOffset + 6 >= this.contents.length) { resizeContents(3); numberOfDifferentLocals = -currentFrame.numberOfDifferentLocals(prevFrame); this.contents[localContentsOffset++] = (byte) (251 - numberOfDifferentLocals); this.contents[localContentsOffset++] = (byte) (offsetDelta >> 8); localContentsOffset += 2; // leave two spots for number of locals int numberOfLocalEntries = 0; numberOfLocals = currentFrame.getNumberOfLocals(); int numberOfEntries = 0; int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;