vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sandboxing?

rygo6 opened this issue · comments

Very nice project! I stumbled on this while searching for a C compiler with an intermediate language that is:

  • More manageable than LLVM IR
  • Faster compiling than LLVM
  • Faster than TCC at execution
  • Doesn't carry the performance issues of WASM opcodes.

I Was pleased to find this as it looks to fit all those conditions.

I had a few questions though if you don't mind answering.

First, your README has a few 'Do not use' warnings, namely:
MIR project is far away from any serious usage
I was wondering what's the extent of 'serious usage' in your view? What exactly is missing? What more would need to be done? Does it fail at compiling certain parts of C11? Or are certain optimizations just not fully working?

Second, my primary interest is getting a C compiler to output binaries with some degree of sandboxing baked into them. Akin to what WASM can enable, but probably achieved more how NaCl did it, or even the Quake3VM, by disallowing certain operations and writing any memory operation with checks. This looks like it wouldn't be terribly hard to adapt into the output of MIR for compilation, much easier than managing it with LLVM. But I was wondering if you had any thoughts on this yourself? Or already had any functionality implemented, or started, that could aid this?

Very nice project! I stumbled on this while searching for a C compiler with an intermediate language that is:

Thank you.

I had a few questions though if you don't mind answering.

First, your README has a few 'Do not use' warnings, namely: MIR project is far away from any serious usage I was wondering what's the extent of 'serious usage' in your view? What exactly is missing? What more would need to be done? Does it fail at compiling certain parts of C11? Or are certain optimizations just not fully working?

I meant that MIR is not a part of any widely used software yet and hence does not a have a rigorous testing from this usage. I would definitely consider MIR-based JIT in CRuby or CPython a serious usage.

I believe that C2MIR implements C11 standard (except for its optional parts) but it was not proved on C standard validation testsuite (e.g. plumhall) because it is very costly.

All optimizations works. All issues reported about it were fixed.

What is missed. A lot. E.g. debugging support, useful GCC extensions, some additional optimizations which could improve generated code performance, different MIR translators to/from other IR (LLVM, webasm, etc), important functionality for better JIT implementations of dynamic languages like basic block versioning, tracing, and meta-tracing. In other words, I have a lot of plans for the future MIR-development.

Second, my primary interest is getting a C compiler to output binaries with some degree of sandboxing baked into them. Akin to what WASM can enable, but probably achieved more how NaCl did it, or even the Quake3VM, by disallowing certain operations and writing any memory operation with checks. This looks like it wouldn't be terribly hard to adapt into the output of MIR for compilation, much easier than managing it with LLVM. But I was wondering if you had any thoughts on this yourself? Or already had any functionality implemented, or started, that could aid this?

This could be another direction for MIR-project but I am not sure it would be a high priority project for me as there are already competing projects with such features. Still I will think about this direction too.