News for hackers. Stuff that matters.
Re:Things Rust shipped without by api on Friday July 03, 2015 @04:31PM (#9827780)
That's pretty nifty, but it seems like something a really good compiler could achieve automatically. Of course I'm not sure if any compilers actually are that good.
Re:Things Rust shipped without by sklogic on Friday July 03, 2015 @06:55PM (#9828352)
This is not exactly how fast bytecode interpreters are implemented. There is one next step - pre-caching the jump table straight into the bytecode. And there is absolutely no way compiler can transform your ad hoc switch-based interpreter into a threaded code interpreter automatically - it is not allowed to rewrite your data willy-nilly.
Re:Things Rust shipped without by frivoal on Saturday July 04, 2015 @04:42PM (#9831542)
Hadn't thought of that, but it sounds interesting. I guess this means that opcodes in your bytecode need to be large enough to store a pointer, this could involve some tradeoffs in terms of minimizing instructions vs fitting in the cache, but I suppose it could fall on the right side of things often enough.
Re:Things Rust shipped without by sklogic on Saturday July 04, 2015 @04:53PM (#9831593)
32-bit opcodes are ok, even on 64-bit architectures, if you add a constant offset - see how it's done in OCaml.
Re:Things Rust shipped without by frivoal on Saturday July 04, 2015 @05:59PM (#9831730)
An offset from the first label, or some nearby alignment point? Makes sense.

Do you have a pointer to the relevant part of OCaml's source? The whole thing is probably worth a read, but don't think I can set aside enough time for that soon, and it could take me a while to find the right part.

Re:Things Rust shipped without by sklogic on Saturday July 04, 2015 @06:10PM (#9831762)
Re:Things Rust shipped without by frivoal on Sunday July 05, 2015 @03:06AM (#9832787)
Nice. Simple and efficient. I am going to read more from that code base. Looks like this might be a nice read as well: https://ocaml.org/docs/papers.html#BytecodeCompilerandByteco...
Re:Things Rust shipped without by Redoubts on Friday July 03, 2015 @06:47PM (#9828330)
Well, this is what is going into Python 2.7.11 for a 15% speed up, so apparently compilers aren't that good yet.

https://lwn.net/Articles/646888/

Re:Things Rust shipped without by frivoal on Friday July 03, 2015 @04:38PM (#9827822)
This is a fairly mechanical conversion, so suppose a sufficiently smart compiler could do that.

But assuming a sufficiently smart compiler when you depend on your code being fast tends to cause issues. Especially if you expect it to run on a bunch of platforms with compilers of varying qualities. Last time I saw code last this, we certainly couldn't rely on compilers being particularly smart, and we did care about speed.