Skip to content

Instantly share code, notes, and snippets.

@lqd
Last active August 1, 2016 18:43
Show Gist options
  • Save lqd/e9596c20fa331ea83916ecb0c91c281c to your computer and use it in GitHub Desktop.
Save lqd/e9596c20fa331ea83916ecb0c91c281c to your computer and use it in GitHub Desktop.
- handle more types than i32s
- handle more of wasm's BinaryOps
- fix the `fun_names` map to not use the Sig but the Substs otherwise we'll end up with duplicate translated fns ( + with the same name) when more complex cases with traits/generics/monomorphizations are tested
- monomorphization tests to exercize more of the use cases (including the previous mentioned known issue)
- activate CI on the repo (it's been a couple times things related to isize have been broken either on x86 or x64; maybe automatically running rustfmt could be nice if that was possible)
- assert/panic — I actually just committed the first pass of this in my fork after writing this: https://github.com/brson/mir2wasm/pull/36
- have a list of milestones of language features: useful for us as well as possible entry points for new contributors
- tidy up the things eholk mentioned during the last big PR review (rusfmt, move the stack pointer, etc) (I started working on this already but it's not finished)
- optimize the calling convention esp re: functions returning structs (I started working on this already but it's not finished)
- optimize the prologue/epilogue away when the stack pointer hasn't moved during the fn (already have done this with the previous item work but it's not finished yet)
- update mir2wasm to a recent nightly: some things were added to help us backends out, and there have been MIR improvements and fixes (and more are coming, I'm especially looking forward to any of the 2 MIR locals optimization projects to land)
- investigate what exactly we need to compile core or a wasm-flavored core (besides the previous points, eg more types is an obvious need, as I found out when making progress on compiling core::cmp)
-> a quick investigation resulted in the following list (non-exhaustive):
1) a story for libcore::intrinsics (transmute, discriminant_value, fabsf32)
2) float constants (and the nightly we have is old enough to not have ConstFloat, so upgrading to a recent nightly is also a priority)
3) other typess than i32: u32, u64, i8, i16, usize, u8, u16
4) all binops (BitAnd, Shr, Shl, BitOr, Rem, BitXor)
5) unary ops (Not, already implemented in the `assert` PR)
6) SwitchInt terminator
7) promoted literals (probably requiring upgrading binaryen to use wasm globals, and also possibly requiring the use of miri)
8) ConstVal::Str (probably represented as pointers to a manual data section of the linear memory)
9) complex derefs like `tmp0 = &mut (*((*var0).5: &'a mut fmt::Write + 'a))` found in fmt::Formatter::write_str
10) a traits::resolve_trait_method that can fulfill_obligation for traits::VtableObject, found in fmt::Formatter::write_str, (unimplemented in miri as well)
11) (that's where my current testing stopped, but there will be more, surely closures, probably boxes, etc)
- investigate wasm fn exports (with some similar FFI to wasm fn imports) to be called from js. Possibly only supporting extern on fns will be enough, but with some restrictions on return and arg types being the primitive wasm types
- implement wasm fn imports like we described in the github issue #33
- prepare tests (and eventually benches) to be run in a real wasm environment, browsers and js engines: there's some html/js scaffolding; some of which I already have from when I ran some of our mir2wasm output in chrome, here: https://twitter.com/lqd/status/752945875383705600
- clean-up the unit type representation, the ret_var which can be removed, have the functions return void and not expect a return value, etc
- implement the todos in the code that can be implemented
- modify build.rs to check for CMakeCache.txt in binaryen, if it exists the build will fail, so notify the user (instead of just deleting the file)
- use miri for globals/statics/promoted constants etc (and possibly put those values inside wasm globals)
- more tests in general, this is almost always good :)
- implement the SwitchInt terminator to finish (I think) supporting the match construct (I started working on this already but it's not finished)
- there's a todo in the code but this one begs a comment: use a cli parsing library in the mir2wasm bin. I thought I'd talk about it with you guys before adding a crate to the compiler, but I just noticed tonight, that getopts is already used. So we'll just need to switch from my ad-hoc code to use the getopts matches!
- add tests about the use of the linear memory, alignment has not been dealt with (and I have no experience with it or the problems it can create)
- add another test run pass where the tests are run after asking binaryen to optimize the wasm module
- related to exports: eholk and I just had an interesting experience where v8 didn't launch the start function on module load if it wasn't exported, so we'd check the spec/examples/other impls to see if that's normal. Binaryen does execute it regardless, however. We might need to bring back the export for the start/main fn feature.
- references to locals of the primitive types (migrating it from the wasm stack to the linear memory stack)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment