google / schism

A self-hosting Scheme to WebAssembly compiler
Apache License 2.0
1.27k stars 65 forks source link

Allow inline Wasm #68

Open eholk opened 5 years ago

eholk commented 5 years ago

It'd be nice to have a (limited) way to write inline WebAssembly in Schism. I'd propose something like:

(define-wasm (foo (i32 a) (i32 b))
  (i32.add a b))

The reason for this is that once we have library support (#19), we might be able to move a lot of the intrinsics out of the compiler. For example, allocation, cons, car, cdr, etc., are all made up of low-level calls that basically read and write memory directly. With inline wasm, we could write these functions in assembly instead and maybe remove the intrinsics from the compiler (or just write the intrinsics themselves as a library).

I don't expect inline wasm to be widely used in Schism, but it would be helpful in implementing a lot of the low-level functionality.

seanjensengrey commented 4 years ago

This would seem perfect for playing around with https://github.com/WebAssembly/simd

eholk commented 4 years ago

I agree! It'd let someone write a library of SIMD primitives to try out.