Comments (3)
Thank you for the question.
Yes, MIR is pretty close to WASM in opcodes. WASM-to-MIR compiler probably would be an easy target (if we want to generate a better MIR, it could be a bigger work as it needs some data-flow analysis). We just need a small runtime to implement wasm insns (like math function insns) absent in MIR.
As for MIR-to-WASM translator it is more challenging work. WASM is more constraining on CFG structure. Also MIR can call functions whose address is a value and I would like to implement labels as values in MIR to support GCC label extension. These MIR features contradict to wasm sandboxing approach.
Although standard C can generate MIR with more CFG constraints. Still C->MIR->WASM can be a challenging work.
I don't know when I could start any work on WASM/MIR. I am going to focus on other MIR directions right now which is to use it for Ruby JIT.
from mir.
Thanks for the elaborate response. Emscripten somehow manages to compile arbitrary C and C++ to WASM, so it must be possible. Of course, it might be tricky, so I get your point about impedance mismatch and the engineer effort involved.
Still, I do see value in a restricted version of MIR that could target WASM. In my case, I have a functional language, which does not require calling arbitrary addresses or arbitrary control flow. With such relevant restrictions in mind, would it be easier, or will the various optimizers violate such self-imposed constraints?
from mir.
Thanks for the elaborate response. Emscripten somehow manages to compile arbitrary C and C++ to WASM, so it must be possible. Of course, it might be tricky, so I get your point about impedance mismatch and the engineer effort involved.
I did not investigated this. But I guess you need to do whole-program analysis to find functions used as values. If you don't use function values or use them in some contraint way (it can be a pretty big subset of C programs), you can avoid such analysis.
Still, I do see value in a restricted version of MIR that could target WASM. In my case, I have a functional language, which does not require calling arbitrary addresses or arbitrary control flow. With such relevant restrictions in mind, would it be easier, or will the various optimizers violate such self-imposed constraints?
Full MIR->WASM can be challenging. But as I wrote above for a big subset of C programs C->MIR->WASM is a doable projects.
I think MIR->WASM is more useful application than WASM->MIR case. I am busy with other projects until May. Probably I will start work on MIR->WASM after that.
from mir.
Related Issues (20)
- Segfault in `classify_node` HOT 1
- Segfault in `get_enum_basic_type` HOT 1
- Segfault in `get_enum_basic_type` HOT 1
- heap-buffer-overflow in `def_symbol` HOT 1
- heap-buffer-overflow in `VARR_token_tpush` and `VARR_token_tpop` HOT 3
- Assertion failed: (0), function out_op, file mir2c.c, line 65 HOT 8
- Supplying custom allocation/deallocation routines HOT 2
- Building with zig and failing at runtime on `mir_hash_1`
- Support for system calls? HOT 11
- Issue 361 test case failed HOT 2
- Shebang support for Mir files? HOT 13
- Awk has a syntax error in the benchmarks HOT 16
- Allow MIR text to be mixed in with C API
- Bug in mir-gen-x86_64.c on bbv branch HOT 3
- Add Apple Silicon CI support HOT 2
- Assertion error in 'process_aggregate_arg' for anonymous struct/union HOT 2
- Assertion error in 'get_uptodate_def_insn' relating to division by `sizeof(char)` HOT 3
- Please implement _Thread_local HOT 1
- CMake build broken with 9b7aa03 HOT 2
- Feature request: add debug info support?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mir.