On 24.01.20 18:38, Milles, Eric (TR Tech, Content & Ops) wrote:
I could use some help with ASM.  At the end of each constructor/method,
the Groovy compiler executes the code below.  The idea is to add a
return in case return or throw is missing from the source code.
However, if no paths can get to the extra return, NOP and ATHROW
instructions are added instead.  So the if/else should be skipped.  If I
add line number information to this return, it may result in uncoverable
lines in some cases.

*Is it possible to use the ASM API to determine if all paths in a method
body have resulted in return or throw?*

You will notice that the code below does not do the NOP ATHROW. Instead
the sequence is added by ASM actually replacing code from us, that is
not reachable.

My suggestion would be something else. I would suggest to do a simple
escape analysis on the program and a return (even for void methods,
since they need that too) if there is a missing return. The "last"
return in the code would have to have a special marking telling our code
generation that this is where the method really, really ends and write
out all those end labels, that have not yet been written by clearing the
operand stack. That way we can avoid those dangling label ranges as well
(improving the debugger story)

WDY?

bye Jochen

Reply via email to