-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed as duplicate
Description
Background
I'm working on a port of Lua to Rust and currently hit a road block to make Rust performance to match with C version due to Rust currently does not support computed goto. For people who does not familiar with computed goto it is a GCC extension to allows getting the address of a label and goto
statement can jump into that label dynamically:
static void *array[] = { &&foo, &&bar, &&hack };
goto *array[i];
This technique can drastically increase the performance of bytecode interpreter due to a jump to next handler can be inlined instead of jumping back to the beginning on the loop then do a next jump.
Proposal
I propose adding an attribute on continue
statement to inline the jump like this:
loop {
match inst.op() {
Op::Bar => {
inst = instructions.next();
#[inline]
continue;
}
Op::Foo => {
inst = instructions.next();
#[inline]
continue;
}
}
}
Metadata
Metadata
Assignees
Labels
No labels