I tried this for Rust once! It didn’t go well, but maybe Swift will do better
-
-
What problems did you run into?
1 reply 0 retweets 0 likes -
I wrote an entire VM in C++ templates to interpret these layouts as quickly as possible to adjust reference counts and such. It was a large speed penalty (~30% of time profile of Rust code was spent in it or something) and didn’t even reduce code size that much.
2 replies 0 retweets 0 likes -
But this was used for everything; the compiler had no specialization at all. So maybe things would be different if this was only for cold code.
1 reply 0 retweets 1 like -
I was pretty burned on the whole approach after that and resolved that I’ll just use an interpreter and/or a JIT if I ever wanted to avoid template specialization again. Maybe I should have tried harder, but that was the result.
1 reply 0 retweets 0 likes -
You know, I have a sneaking suspicion that a “PGO” for Rust that did nothing more than replace cold functions with MIR and interpret them with Miri would probably be disgustingly effective at reducing code size without much perf hit I don’t think we should do this of course :)
1 reply 0 retweets 5 likes -
You should totally do it. I suspect an interpreter is the right answer even for unspecialized Swift code, since it's already a bunch of indirect jumps anyway
1 reply 0 retweets 1 like -
Yeah, I'd be very tempted to do an interpreter for Swift in your position. Could even allow for some cool hot code reload and instant feedback, and maybe even dynamic code generation on iOS devices
1 reply 0 retweets 0 likes -
For Rust an interpreter would probably be most useful for improving edit/run cycle time. cc
@eddyb_r Everyone seems to be converging on tiered compilation... e.g. Android is no longer pure AOT2 replies 0 retweets 4 likes -
like miri? (cc
@oli_obk) or something lower-level like Cranelift? (cc@Sunfishcode)1 reply 0 retweets 3 likes
Not sure! Having multiple tiers seems like a sound approach
-
-
there's also a choice of concrete memory space (wasm-like) vs abstract (miri-like) the latter gives you UB-detection powers
0 replies 0 retweets 4 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.