VerifyError: Frame offset out of bytecode range
Michael van Acken
michael.van.acken at gmail.com
Sat Jul 23 08:49:35 UTC 2022
(Btw, kudos to whoever took Zelazny's Amber novels as an inspiration
for a project name. Learning about this triggered a massive trip down
memory lane for me.)
Note: This post is also a kind of addendum to the printing discussion
on the other thread.
I have StackMapGenerator throwing "VerifyError: Frame offset out of
bytecode range", and this may be caused by an interaction with the
recently added ifThenElse().
Input is this unit test:
(is (= '[["LOCAL 0: int i"]
(ILOAD_0)
(ICONST_1)
(IADD)
(ISTORE_1)
["LOCAL 1: int __temp"]
(ILOAD_0)
(ICONST_2)
(IADD)
(ISTORE_2)
["LOCAL 2: int __temp"]
(ILOAD_0)
(ICONST_3)
(IADD)
(ISTORE_3)
["LOCAL 3: int __temp"]
(ILOAD_1)
(ILOAD_2)
(IF_ICMPGE L:1)
(ILOAD_2)
(ILOAD_3)
(IF_ICMPGE L:0)
(ICONST_1)
(IRETURN)
[L:0]
(ICONST_0)
(IRETURN)
[L:1]
(ICONST_0)
(IRETURN)]
(asm-expr [^int i] (< (+ i 1) (+ i 2) (+ i 3)))))
Extending CodeBuilder.java's "with" method with println like such
public CodeBuilder with(CodeElement element) {
System.out.println("with "+element);
if (element.toString().contains("OP=GOTO")) {
new Throwable().printStackTrace();
}
((AbstractElement) element).writeTo(this);
return this;
}
I get the output below (after some manual indentation). With the
exception of the additional GOTO inserted by ifThenElse() before the
final ICONST_0, this seems to match the intended output.
:accept ClassBuilder start
:accept CodeBuilder start
with LocalVariable[Slot=0, name=i, descriptor='I']
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with Load[OP=ILOAD_0, slot=0]
with UnboundIntrinsicConstantInstruction[op=ICONST_1]
with UnboundOperatorInstruction[op=IADD]
with Store[OP=ISTORE_1, slot=1]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with LocalVariable[Slot=1, name=__temp, descriptor='I']
with Load[OP=ILOAD_0, slot=0]
with UnboundIntrinsicConstantInstruction[op=ICONST_2]
with UnboundOperatorInstruction[op=IADD]
with Store[OP=ISTORE_2, slot=2]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with LocalVariable[Slot=2, name=__temp, descriptor='I']
with Load[OP=ILOAD_0, slot=0]
with UnboundIntrinsicConstantInstruction[op=ICONST_3]
with UnboundOperatorInstruction[op=IADD]
with Store[OP=ISTORE_3, slot=3]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with LocalVariable[Slot=3, name=__temp, descriptor='I']
with Load[OP=ILOAD_1, slot=1]
with Load[OP=ILOAD_2, slot=2]
with Branch[OP=IF_ICMPGE]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
:accept CodeBuilder start
with Load[OP=ILOAD_2, slot=2]
with Load[OP=ILOAD_3, slot=3]
with Branch[OP=IF_ICMPGE]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
:accept CodeBuilder start
with UnboundIntrinsicConstantInstruction[op=ICONST_1]
with Return[OP=IRETURN]
:accept CodeBuilder end
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
:accept CodeBuilder start
with UnboundIntrinsicConstantInstruction[op=ICONST_0]
with Return[OP=IRETURN]
:accept CodeBuilder end
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
:accept CodeBuilder end
with Branch[OP=GOTO]
java.lang.Throwable
at
java.base/jdk.classfile.impl.DirectCodeBuilder.with(DirectCodeBuilder.java:143)
at
java.base/jdk.classfile.impl.DirectCodeBuilder.with(DirectCodeBuilder.java:75)
at
java.base/jdk.classfile.impl.BlockCodeBuilderImpl.with(BlockCodeBuilderImpl.java:90)
at
java.base/jdk.classfile.impl.BlockCodeBuilderImpl.with(BlockCodeBuilderImpl.java:39)
at
java.base/jdk.classfile.CodeBuilder.branchInstruction(CodeBuilder.java:383)
at java.base/jdk.classfile.CodeBuilder.ifThenElse(CodeBuilder.java:288)
at
tcljc.emitter.bytecode.__ns100.expr-insns$split-join-insn~4(bytecode.cljt:638)
[...]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
:accept CodeBuilder start
with UnboundIntrinsicConstantInstruction[op=ICONST_0]
with Return[OP=IRETURN]
:accept CodeBuilder end
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
with Label[context=CodeBuilder[id=1458540918], contextInfo=-1]
:accept CodeBuilder end
[...]
:accept ClassBuilder end
Generating stack maps for class: __ns100 method: fnbody~1 with signature:
MethodTypeDesc[(int)boolean]
ERROR at tcljc.switch-test/int-cmp-test:45
[...]
java.lang.VerifyError: Frame offset out of bytecode range at fnbody~1
at
java.base/jdk.classfile.impl.StackMapGenerator.generatorError(StackMapGenerator.java:865)
at
java.base/jdk.classfile.impl.StackMapGenerator$2.set(StackMapGenerator.java:878)
at
java.base/jdk.classfile.impl.StackMapGenerator.detectFrameOffsets(StackMapGenerator.java:893)
at
java.base/jdk.classfile.impl.StackMapGenerator.generate(StackMapGenerator.java:308)
at
java.base/jdk.classfile.impl.StackMapGenerator.<init>(StackMapGenerator.java:248)
at
java.base/jdk.classfile.impl.DirectCodeBuilder$4.writeBody(DirectCodeBuilder.java:298)
at
java.base/jdk.classfile.impl.UnboundAttribute$AdHocAttribute.writeTo(UnboundAttribute.java:931)
at
java.base/jdk.classfile.impl.AttributeHolder.writeTo(AttributeHolder.java:60)
at
java.base/jdk.classfile.impl.DirectMethodBuilder.writeTo(DirectMethodBuilder.java:137)
at
java.base/jdk.classfile.impl.BufWriterImpl.writeList(BufWriterImpl.java:197)
at
java.base/jdk.classfile.impl.DirectClassBuilder.build(DirectClassBuilder.java:177)
at java.base/jdk.classfile.Classfile.build(Classfile.java:216)
at java.base/jdk.classfile.Classfile.build(Classfile.java:198)
at java.base/jdk.classfile.Classfile.build(Classfile.java:184)
at tcljc.emitter.__ns100.build-segment~1(emitter.cljt:190)
[...]
-- mva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220723/fdae829c/attachment.htm>
More information about the classfile-api-dev
mailing list