Skip to content

pmatos/racket-binaryen

Repository files navigation

CI Scribble

racket-binaryen

Binaryen bindings for Racket.

Currently, this work is experimental. There is some initial documentation evolving together with the implementation of safe bindings but it's highly incomplete.

Andy Wingo gave a "Compiling to WebAssembly" presentation at FOSDEM'21, and published his artifacts.

I implemented the same compiler in Racket using the binaryen bindings (see tests/wingo-raw.rkt). To run it on the same example Andy presented try:

$ racket test/wingo-raw.rkt test/wingo_fact.scm 
"Compiled module:"
(module
 (type $i32_=>_i32 (func (param i32) (result i32)))
 (export "fac" (func $fac))
 (func $fac (param $0 i32) (result i32)
  (if (result i32)
   (i32.eqz
    (local.get $0)
   )
   (i32.const 1)
   (i32.mul
    (local.get $0)
    (call $fac
     (i32.sub
      (local.get $0)
      (i32.const 1)
     )
    )
   )
  )
 )
)
"Optimized module:"
(module
 (type $i32_=>_i32 (func (param i32) (result i32)))
 (export "fac" (func $fac))
 (func $fac (; has Stack IR ;) (param $0 i32) (result i32)
  (if (result i32)
   (local.get $0)
   (i32.mul
    (call $fac
     (i32.sub
      (local.get $0)
      (i32.const 1)
     )
    )
    (local.get $0)
   )
   (i32.const 1)
  )
 )
)

About

Binaryen bindings for Racket

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy