Re: Re: NOP ATHROW hack defeated !

Rémi Forax <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
On 06/08/2011 02:36 AM, Charles Oliver Nutter wrote:
> On Tue, Jun 7, 2011 at 6:09 PM, Rémi Forax<[email protected]>  wrote:
>> After discussion with some friends from Cambridge,
>> I figure out why you generate unreachable code.
>> In your compiler, the instruction visitor should return if the next
>> instruction
>> will be called or not.
>> By example, after these Java instructions break, continue, return or throw
>> the next instruction is dead. So if you have an if/else (it's the same with
>> a loop),
>> if the block of the true branchends with one of these instruction,
>> you should not generate the goto to jump after the else block.
> Yes, I know that. In practice, though, it's more difficult to fix.
> early returns can be done as part of an expression:
>
> a = if b
>    c
> else
>    return
> end
>
> And because all code in Ruby is an expression, loops, conditionals,
> exception-handling blocks, and so on are all expressions. Then imagine
> these expressions are nested arbitrarily deep. That makes it difficult
> to just "not generate the goto" because I would need to analyze an
> arbitrary amount of downstream code to find which paths will continue
> executing and which ones will not.

It's easy if you have a specific pass on your AST that calculates
that information. And as a trick, you can reuse the typechecking pass
to implement this analysis if your visitors returns a couple type,alive.

> Regardless...I'm still convinced this is at its core a problem in ASM,
> since the same code without ASM doing frame calculation verifies
> correctly on pre-Java 6 verifiers. Therefore it ought to be possible
> to make that code with frame calculation verify on Java 6+. Agreed?

Yes :)

> I admit it's a weakness in JRuby's compiler, but since the code *does*
> verify when ASM isn't rewriting it, I think the ball is in ASM's
> court.
>
> - Charlie

Rémi
message-footer.txt (text/plain, 238 B)
-- 
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.