Code Monkey home page Code Monkey logo

Comments (3)

vnmakarov avatar vnmakarov commented on July 21, 2024

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.

alstrup avatar alstrup commented on July 21, 2024

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.

vnmakarov avatar vnmakarov commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.