Yep it uses the labeled break and continue. It's not quite as fast as goto
state machines because it has to use a state table to decide where to jump
to.
I've been thinking of a couple alternatives that could make us as fast as a
c state machine. The simplest night be to leverage the fact that llvm can
optimize certain recursive function calls into tail calls, and lower those
into jumps. If we go this route, we could only do this for internal
functions with certain properties, so it could be nice to add a
`#[tail_call] annotation that'll validate these conditions.
A little more complicated thing would be to add what I call constrained
computed gotos. This would allow labels to be placed on match arms as in:
match 'a {
'a => { continue 'b; }
'b => { ... }
...
}
The constraint is that we can only jump to well defined arms from inside
the match block. I really need to write it up as an RFC someday.
The most complicatedas is to use unsafe code embedded asm to jump around.
On Sunday, March 23, 2014, Tony Arcieri <[email protected]> wrote:
> On Sun, Mar 23, 2014 at 11:42 AM, Corey Richardson
> <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>
> > wrote:
>
>> Note that there's Rust support for Ragel
>> (https://github.com/erickt/ragel), so you can just use that. It's much
>> easier than writing out your state machines by hand.
>
>
> What kind of code is the Rust backend(s) capable of emitting? Can it do
> labeled break/continue to generate jump-driven FSMs the same way it does
> with Java?
>
> --
> Tony Arcieri
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev