Rust crate X; X -> JITs to wasm32, X -> JITs to x86_64

Is there any rust crate providing instruction set "XYZ" where

  1. XYZ is an instruction set
  2. XYZ supports > 4GB memory
  3. XYZ jits to x86_64 on x86_64
  4. XYZ jits to wasm32 on wasm32_unknown_unknown

?

For example. wat fails (2), cranelift-jit fails (4), dynasm fails (4).

The set of constraints you provided has only the empty set as a solution. Constraint number 2 alone pretty much guarantees it, as WASM32 is called that for a reason rather than WASM64: it's 32-bit and thus doesn't support more than 2^32 = 4GB.

I don't agree with this logic. Suppose we viewed rust as an "instruction set", and instead of rust-c, we had rust-jit.

Then, I would argue that rust-instruction-set / rust-jit would satisfy all 4 conditions.

  1. we view the rust AST as the instruction set
  2. rust definitely supports > 4GB memory
  3. on x86_64, rustc/rust-jit can generate x86_64 code
  4. on target=wasm32-unknown-unknown, rustc/rust-jit can generate wasm32 output

I think the crux of your argument assumes that step (1) fixes a pointer size, which then causes (2) and (4) to conflict. I'm okay with an "instruction set" where the ptr size is different for (3) and (4), and (2) is only supported some of the time.

Not at all. I merely looked up the definition of WASM32, and it will never support 64bit memory arrays.

There is a WASM64 planned but for all we know that's stabilized in 2030 at the glacial pace they're going at.

Condition (2) does not require that wasm32 supports > 4GB of memory.

Condition (2) is meant to state:

the instruction set (like Rust AST) supports > 4GB memory. On x86_64, we get 64bit ptrs, and on wasm32 we get 32bit pointers (and <= 4GB memory).

In that case I can't be sure, but I still think the set of solutions is empty in 2021.

In fact I don't know of any projects that JIT-compile to WASM at all.

I have not been able to build cranelift under wasm32-unknown-unkhnown.

However, if there is a way to go directly from InstBuilder in cranelift_codegen::ir - Rust to wasm32, it would certainly satisfy the requirements.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.