Re: converting MethodVisitor.visitVarInsn(int opCode, int var) into NOOP?

"Eugene Kuleshov" (via asm Mailing List) <[email protected]> Fri, 29 Jan 2021 17:57:34 -0500
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CADFjdoXpi_tLUJxp2OfusvcP_1m0ZvWotK0v4xYLOS-E0oQFbw@mail.gmail.com>
This is a multi-part message in MIME format...

------------=_1611961069-9996-5
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

What you need to do with stack depends on the opcode parameter value.

See the visitVarInsn(...) method javadoc:
https://asm.ow2.io/javadoc/org/objectweb/asm/MethodVisitor.html#visitVarIns=
n-int-int-

opcode - the opcode of the local variable instruction to be visited.
This opcode is either ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE,
LSTORE, FSTORE, DSTORE, ASTORE or RET

Some of those codes put values to the stack. Some opcodes put one word
and others - put two words, some others take one or two words from the
stack, and the ret one doesn't change the stack. E.g. see
https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings

  regards,
  Eugene




On Fri, Jan 29, 2021 at 5:47 PM gl <[email protected]> wrote:
>
> I might have missed pointers in the documentation. With following code:
>
> @Override
> public void visitVarInsn(int opCode, int var) {
>   newOpCode =3D ???
>   newVar =3D ???
>   super.visitVarInsn(newOpCode, newVar);
> }
>
> What should be the value of newOpCode/newVar call to make the current ins=
truction a NOOP (and still POP the corresponding value)? Using Opcodes.POP =
fails with java.lang.VerifyError which is probably expected as POP doesn't =
take an argument. Not making the super call also throws java.lang.VerifyErr=
or and so does calling super.visitInsn(Opcodes.POP);
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=3Dhelp
> OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1611961069-9996-5
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

------------=_1611961069-9996-5--