static StackMapTableFrame getInstance(StackMapFrame this_frame,
int prev_pc,
Type[] prev_locals,
Types types) {
Type[] locals = this_frame.locals;
Type[] stack = this_frame.stack;
int offset_delta = this_frame.pc - prev_pc - 1;
if (stack.length == 1) {
if (locals.length == prev_locals.length
&& compare(prev_locals, locals, types) == 0) {
return new SameLocals1StackItemFrame(offset_delta, stack[0]);
}
} else if (stack.length == 0) {
int diff_length = compare(prev_locals, locals, types);
if (diff_length == 0) {
return new SameFrame(offset_delta);
} else if (-MAX_LOCAL_LENGTH_DIFF < diff_length && diff_length < 0) {
// APPEND
Type[] local_diff = new Type[-diff_length];
for (int i=prev_locals.length, j=0; i< locals.length; i++,j++) {
local_diff[j] = locals[i];
}
return new AppendFrame(SAME_FRAME_EXTENDED - diff_length,
offset_delta,
local_diff);
} else if (0 < diff_length && diff_length < MAX_LOCAL_LENGTH_DIFF) {
// CHOP
return new ChopFrame(SAME_FRAME_EXTENDED - diff_length,
offset_delta);
}
}
// FULL_FRAME
return new FullFrame(offset_delta, locals, stack);
}
Compare this frame with the previous frame and produce
an entry of compressed stack map frame. |