Hello, World

The smallest FunctionalScript program: it writes hello, world to standard output. The demo below runs it as JavaScript and as WebAssembly, and shows what each run wrote and how long it took. The program spells its bytes as a bigint, since fjs compile cannot compile fjs/types/bit_vec yet.

See WASM demos for the other pages.

Demo

The same FunctionalScript program, run two ways: as the JavaScript it already is, and compiled by fjs compile to Rust on the NaNVM runtime, then to WebAssembly. Run calls each in turn and shows what it wrote to standard output and how long the call took.

FunctionalScript source:

/**
 * Writes `hello, world` to standard output.
 *
 * The program is an effect: one `write` command, with the text as UTF-8
 * bytes in a bit vector. It is written out by hand because `fjs compile`
 * cannot compile `log` and `utf8` yet.
 *
 * @module
 */

/** `hello, world\n` as UTF-8. */
const greeting = -0xe8_656c_6c6f_2c20_776f_726c_640an

export default () => ({
    command: 'write',
    payload: ['stdout', greeting],
    continuation: () => () => ['ok', undefined],
})

Rust that fjs compile writes from it, on the NaNVM runtime:

// @generated by `fjs compile`. Do not edit: recompile the source module instead.

use nanvm_lib::vm::unstable::{bigint_any_words, string_any, string_key};
use nanvm_lib::vm::{Any, Array, IStaticFunction, Nullish, ToAny, ToArray, ToObject};

#[rustfmt::skip]
#[allow(clippy::if_same_then_else)]
pub fn module<A: IStaticFunction>(_runtime: Any<A>) -> Result<Any<A>, Any<A>> {
    Ok([(string_key("default"), A::static_function(|_self, _args| { Ok([(string_key("command"), string_any("write")), (string_key("payload"), [string_any("stdout"), bigint_any_words(true, &[0x2c20776f726c640a, 0x000000e8656c6c6f])].to_array().to_any()), (string_key("continuation"), A::static_function(|_self, _args| { Ok(A::static_function(|_self, _args| { Ok([string_any("ok"), Nullish::Undefined.to_any()].to_array().to_any()) }, 0, Array::default(), Some("()=>[\"ok\",undefined]")).to_any()) }, 0, Array::default(), Some("()=>()=>[\"ok\",undefined]")).to_any())].to_object().to_any()) }, 0, Array::default(), Some("()=>{return {\"command\":\"write\",\"payload\":[\"stdout\",-18412322765356148968355179291658n],\"continuation\":()=>()=>[\"ok\",undefined]};}")).to_any())].to_object().to_any())
}

WebAssembly text (WAT) of the functions compiled from this source, without the NaNVM runtime:

  (func $nanvm_demos::samples::hello::module::<nanvm_lib::naive::Naive> (;267;) (type 1) (param i32 i32)
    (local i32 i32 i32 i32 i32)
    global.get $__stack_pointer
    i32.const 96
    i32.sub
    local.tee 2
    global.set $__stack_pointer
    local.get 2
    i32.const 0
    i32.store16 offset=28
    local.get 2
    i32.const 1057715
    i32.store offset=24
    local.get 2
    i32.const 1057708
    i32.store offset=20
    local.get 2
    i32.const 48
    i32.add
    local.get 2
    i32.const 20
    i32.add
    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
    block ;; label = @1
      block ;; label = @2
        block ;; label = @3
          local.get 2
          i32.load8_u offset=48
          local.tee 3
          i32.const 255
          i32.ne
          br_if 0 (;@3;)
          local.get 2
          i32.load offset=56
          local.set 4
          local.get 2
          i32.load offset=52
          local.set 5
          local.get 2
          i32.const 0
          i32.store8 offset=32
          local.get 2
          i32.const 8
          i32.add
          local.get 2
          i32.const 32
          i32.add
          call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::sources::empty::Empty<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
          local.get 2
          local.get 2
          i32.load offset=12
          local.tee 6
          i32.store offset=52
          local.get 2
          local.get 2
          i32.load offset=8
          local.tee 3
          i32.store offset=48
          block ;; label = @4
            local.get 2
            i32.load8_u offset=32
            i32.const 1
            i32.ne
            br_if 0 (;@4;)
            local.get 3
            local.get 3
            i32.load
            i32.const -1
            i32.add
            local.tee 0
            i32.store
            local.get 0
            br_if 3 (;@1;)
            local.get 2
            i32.const 48
            i32.add
            call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
            br 3 (;@1;)
          end
          local.get 3
          i32.eqz
          br_if 2 (;@1;)
          i32.const 49
          i32.const 0
          local.get 3
          local.get 6
          i32.const 1057838
          i32.const 129
          call $<nanvm_lib::naive::function::Function>::new
          local.set 3
          local.get 2
          i32.const 0
          i32.store8 offset=20
          local.get 2
          local.get 3
          i32.store offset=68
          local.get 2
          i32.const 7
          i32.store8 offset=64
          local.get 2
          local.get 4
          i32.store offset=60
          local.get 2
          local.get 5
          i32.store offset=56
          local.get 2
          i64.const 4294967296
          i64.store offset=48
          local.get 2
          local.get 2
          i32.const 20
          i32.add
          i32.store offset=80
          local.get 2
          local.get 2
          i32.const 48
          i32.add
          call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>), 1>, core::result::Result<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>), ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>)>>::to_rc_slice"
          local.get 2
          local.get 2
          i32.load offset=4
          local.tee 4
          i32.store offset=36
          local.get 2
          local.get 2
          i32.load
          local.tee 3
          i32.store offset=32
          block ;; label = @4
            local.get 2
            i32.load8_u offset=20
            i32.const 1
            i32.ne
            br_if 0 (;@4;)
            local.get 3
            local.get 3
            i32.load
            i32.const -1
            i32.add
            local.tee 0
            i32.store
            local.get 0
            br_if 2 (;@2;)
            local.get 2
            i32.const 32
            i32.add
            call $"<alloc::rc::Rc<[(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>)]>>::drop_slow"
            br 2 (;@2;)
          end
          local.get 3
          i32.eqz
          br_if 1 (;@2;)
          local.get 0
          local.get 4
          i32.store offset=16
          local.get 0
          local.get 3
          i32.store offset=12
          local.get 0
          i32.const 5
          i32.store8 offset=8
          local.get 0
          i64.const 0
          i64.store
          local.get 1
          call $"#func262 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
          local.get 2
          i32.const 96
          i32.add
          global.set $__stack_pointer
          return
        end
        local.get 2
        local.get 2
        i32.load8_u offset=51
        i32.store8 offset=35
        local.get 2
        local.get 2
        i32.load16_u offset=49 align=1
        i32.store16 offset=33 align=1
        local.get 2
        local.get 2
        i32.load offset=60
        i32.store offset=44
        local.get 2
        local.get 2
        i64.load offset=52 align=4
        i64.store offset=36 align=4
        local.get 2
        local.get 3
        i32.store8 offset=32
        i32.const 1065572
        i32.const 43
        local.get 2
        i32.const 32
        i32.add
        i32.const 1065556
        i32.const 1065616
        call $core::result::unwrap_failed
        unreachable
      end
      i32.const 1057428
      i32.const 43
      local.get 2
      i32.const 95
      i32.add
      i32.const 1057412
      i32.const 1057472
      call $core::result::unwrap_failed
      unreachable
    end
    i32.const 1057428
    i32.const 43
    local.get 2
    i32.const 95
    i32.add
    i32.const 1057412
    i32.const 1057472
    call $core::result::unwrap_failed
    unreachable
  )
  (func $"<nanvm_demos::samples::hello::module<nanvm_lib::naive::Naive>::{closure#0} as core::ops::function::FnOnce<(&nanvm_lib::naive::function::Function, nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>)>>::call_once" (;268;) (type 4) (param i32 i32 i32 i32)
    (local i32 i32 i32 i32 i32 i32 i32 i64 i32 i32 i32 i32 i32)
    global.get $__stack_pointer
    i32.const 176
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 4
    local.get 3
    i32.store offset=28
    local.get 4
    local.get 2
    i32.store offset=24
    local.get 4
    i32.const 0
    i32.store16 offset=60
    local.get 4
    i32.const 1059932
    i32.store offset=56
    local.get 4
    i32.const 1059925
    i32.store offset=52
    local.get 4
    i32.const 80
    i32.add
    local.get 4
    i32.const 52
    i32.add
    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
    block ;; label = @1
      block ;; label = @2
        block ;; label = @3
          block ;; label = @4
            block ;; label = @5
              block ;; label = @6
                block ;; label = @7
                  block ;; label = @8
                    local.get 4
                    i32.load8_u offset=80
                    local.tee 3
                    i32.const 255
                    i32.ne
                    br_if 0 (;@8;)
                    local.get 4
                    i32.load offset=88
                    local.set 5
                    local.get 4
                    i32.load offset=84
                    local.set 6
                    local.get 4
                    i32.const 0
                    i32.store16 offset=60
                    local.get 4
                    i32.const 1059937
                    i32.store offset=56
                    local.get 4
                    i32.const 1059932
                    i32.store offset=52
                    local.get 4
                    i32.const 80
                    i32.add
                    local.get 4
                    i32.const 52
                    i32.add
                    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
                    local.get 4
                    i32.load8_u offset=80
                    local.tee 3
                    i32.const 255
                    i32.ne
                    br_if 1 (;@7;)
                    local.get 4
                    i32.load offset=88
                    local.set 7
                    local.get 4
                    i32.load offset=84
                    local.set 8
                    local.get 4
                    i32.const 0
                    i32.store16 offset=60
                    local.get 4
                    i32.const 1059944
                    i32.store offset=56
                    local.get 4
                    i32.const 1059937
                    i32.store offset=52
                    local.get 4
                    i32.const 80
                    i32.add
                    local.get 4
                    i32.const 52
                    i32.add
                    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
                    local.get 4
                    i32.load8_u offset=80
                    local.tee 3
                    i32.const 255
                    i32.ne
                    br_if 2 (;@6;)
                    local.get 4
                    i32.load offset=88
                    local.set 9
                    local.get 4
                    i32.load offset=84
                    local.set 10
                    local.get 4
                    i32.const 0
                    i32.store16 offset=60
                    local.get 4
                    i32.const 1059950
                    i32.store offset=56
                    local.get 4
                    i32.const 1059944
                    i32.store offset=52
                    local.get 4
                    i32.const 80
                    i32.add
                    local.get 4
                    i32.const 52
                    i32.add
                    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
                    local.get 4
                    i32.load8_u offset=80
                    local.tee 3
                    i32.const 255
                    i32.ne
                    br_if 3 (;@5;)
                    local.get 4
                    i64.load offset=84 align=4
                    local.set 11
                    local.get 4
                    i32.const 32
                    i32.add
                    i32.const 4
                    i32.or
                    i32.const 255
                    i32.const 1059952
                    i32.const 1059968
                    call $<nanvm_lib::vm::bigint::BigInt<nanvm_lib::naive::Naive>>::normalize_new::<core::iter::adapters::copied::Copied<core::slice::iter::Iter<u64>>>
                    local.get 4
                    i32.const 4
                    i32.store8 offset=32
                    local.get 4
                    i32.const 0
                    i32.store8 offset=52
                    local.get 4
                    local.get 11
                    i64.store offset=92 align=4
                    local.get 4
                    i32.const 3
                    i32.store8 offset=88
                    local.get 4
                    i64.const 8589934592
                    i64.store offset=80
                    local.get 4
                    local.get 4
                    i64.load offset=32
                    i64.store offset=104
                    local.get 4
                    local.get 4
                    i64.load offset=40
                    i64.store offset=112
                    local.get 4
                    local.get 4
                    i32.const 52
                    i32.add
                    i32.store offset=120
                    local.get 4
                    i32.const 16
                    i32.add
                    local.get 4
                    i32.const 80
                    i32.add
                    call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, 2>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
                    local.get 4
                    local.get 4
                    i32.load offset=20
                    local.tee 12
                    i32.store offset=68
                    local.get 4
                    local.get 4
                    i32.load offset=16
                    local.tee 3
                    i32.store offset=64
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=52
                      i32.const 1
                      i32.ne
                      br_if 0 (;@9;)
                      local.get 3
                      local.get 3
                      i32.load
                      i32.const -1
                      i32.add
                      local.tee 0
                      i32.store
                      local.get 0
                      br_if 8 (;@1;)
                      local.get 4
                      i32.const 64
                      i32.add
                      call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
                      br 8 (;@1;)
                    end
                    local.get 3
                    i32.eqz
                    br_if 7 (;@1;)
                    local.get 4
                    i32.const 0
                    i32.store16 offset=60
                    local.get 4
                    i32.const 1059980
                    i32.store offset=56
                    local.get 4
                    i32.const 1059968
                    i32.store offset=52
                    local.get 4
                    i32.const 80
                    i32.add
                    local.get 4
                    i32.const 52
                    i32.add
                    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
                    local.get 4
                    i32.load8_u offset=80
                    local.tee 13
                    i32.const 255
                    i32.ne
                    br_if 4 (;@4;)
                    local.get 4
                    i32.load offset=88
                    local.set 14
                    local.get 4
                    i32.load offset=84
                    local.set 15
                    local.get 4
                    i32.const 0
                    i32.store8 offset=64
                    local.get 4
                    i32.const 8
                    i32.add
                    local.get 4
                    i32.const 64
                    i32.add
                    call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::sources::empty::Empty<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
                    local.get 4
                    local.get 4
                    i32.load offset=12
                    local.tee 16
                    i32.store offset=84
                    local.get 4
                    local.get 4
                    i32.load offset=8
                    local.tee 13
                    i32.store offset=80
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=64
                      i32.const 1
                      i32.ne
                      br_if 0 (;@9;)
                      local.get 13
                      local.get 13
                      i32.load
                      i32.const -1
                      i32.add
                      local.tee 0
                      i32.store
                      local.get 0
                      br_if 7 (;@2;)
                      local.get 4
                      i32.const 80
                      i32.add
                      call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
                      br 7 (;@2;)
                    end
                    local.get 13
                    i32.eqz
                    br_if 6 (;@2;)
                    i32.const 50
                    i32.const 0
                    local.get 13
                    local.get 16
                    i32.const 1059980
                    i32.const 24
                    call $<nanvm_lib::naive::function::Function>::new
                    local.set 13
                    local.get 4
                    i32.const 0
                    i32.store8 offset=52
                    local.get 4
                    local.get 13
                    i32.store offset=148
                    local.get 4
                    i32.const 7
                    i32.store8 offset=144
                    local.get 4
                    local.get 14
                    i32.store offset=140
                    local.get 4
                    local.get 15
                    i32.store offset=136
                    local.get 4
                    local.get 12
                    i32.store offset=128
                    local.get 4
                    local.get 3
                    i32.store offset=124
                    local.get 4
                    i32.const 6
                    i32.store8 offset=120
                    local.get 4
                    local.get 9
                    i32.store offset=116
                    local.get 4
                    local.get 10
                    i32.store offset=112
                    local.get 4
                    local.get 7
                    i32.store offset=104
                    local.get 4
                    local.get 8
                    i32.store offset=100
                    local.get 4
                    i32.const 3
                    i32.store8 offset=96
                    local.get 4
                    local.get 5
                    i32.store offset=92
                    local.get 4
                    local.get 6
                    i32.store offset=88
                    local.get 4
                    i64.const 12884901888
                    i64.store offset=80
                    local.get 4
                    local.get 4
                    i32.const 52
                    i32.add
                    i32.store offset=160
                    local.get 4
                    local.get 4
                    i32.const 80
                    i32.add
                    call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>), 3>, core::result::Result<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>), ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>)>>::to_rc_slice"
                    local.get 4
                    local.get 4
                    i32.load offset=4
                    local.tee 13
                    i32.store offset=68
                    local.get 4
                    local.get 4
                    i32.load
                    local.tee 3
                    i32.store offset=64
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=52
                      i32.const 1
                      i32.ne
                      br_if 0 (;@9;)
                      local.get 3
                      local.get 3
                      i32.load
                      i32.const -1
                      i32.add
                      local.tee 0
                      i32.store
                      local.get 0
                      br_if 6 (;@3;)
                      local.get 4
                      i32.const 64
                      i32.add
                      call $"<alloc::rc::Rc<[(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>)]>>::drop_slow"
                      br 6 (;@3;)
                    end
                    local.get 3
                    i32.eqz
                    br_if 5 (;@3;)
                    local.get 0
                    local.get 13
                    i32.store offset=16
                    local.get 0
                    local.get 3
                    i32.store offset=12
                    local.get 0
                    i32.const 5
                    i32.store8 offset=8
                    local.get 0
                    i64.const 0
                    i64.store
                    local.get 2
                    local.get 2
                    i32.load
                    i32.const -1
                    i32.add
                    local.tee 0
                    i32.store
                    block ;; label = @9
                      local.get 0
                      br_if 0 (;@9;)
                      local.get 4
                      i32.const 24
                      i32.add
                      call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
                    end
                    local.get 4
                    i32.const 176
                    i32.add
                    global.set $__stack_pointer
                    return
                  end
                  local.get 4
                  local.get 4
                  i32.load8_u offset=83
                  i32.store8 offset=67
                  local.get 4
                  local.get 4
                  i32.load16_u offset=81 align=1
                  i32.store16 offset=65 align=1
                  local.get 4
                  local.get 4
                  i32.load offset=92
                  i32.store offset=76
                  local.get 4
                  local.get 4
                  i64.load offset=84 align=4
                  i64.store offset=68 align=4
                  local.get 4
                  local.get 3
                  i32.store8 offset=64
                  i32.const 1065572
                  i32.const 43
                  local.get 4
                  i32.const 64
                  i32.add
                  i32.const 1065556
                  i32.const 1065616
                  call $core::result::unwrap_failed
                  unreachable
                end
                local.get 4
                local.get 4
                i32.load8_u offset=83
                i32.store8 offset=67
                local.get 4
                local.get 4
                i32.load16_u offset=81 align=1
                i32.store16 offset=65 align=1
                local.get 4
                local.get 4
                i32.load offset=92
                i32.store offset=76
                local.get 4
                local.get 4
                i64.load offset=84 align=4
                i64.store offset=68 align=4
                local.get 4
                local.get 3
                i32.store8 offset=64
                i32.const 1065572
                i32.const 43
                local.get 4
                i32.const 64
                i32.add
                i32.const 1065556
                i32.const 1065616
                call $core::result::unwrap_failed
                unreachable
              end
              local.get 4
              local.get 4
              i32.load8_u offset=83
              i32.store8 offset=67
              local.get 4
              local.get 4
              i32.load16_u offset=81 align=1
              i32.store16 offset=65 align=1
              local.get 4
              local.get 4
              i32.load offset=92
              i32.store offset=76
              local.get 4
              local.get 4
              i64.load offset=84 align=4
              i64.store offset=68 align=4
              local.get 4
              local.get 3
              i32.store8 offset=64
              i32.const 1065572
              i32.const 43
              local.get 4
              i32.const 64
              i32.add
              i32.const 1065556
              i32.const 1065616
              call $core::result::unwrap_failed
              unreachable
            end
            local.get 4
            local.get 4
            i32.load8_u offset=83
            i32.store8 offset=67
            local.get 4
            local.get 4
            i32.load16_u offset=81 align=1
            i32.store16 offset=65 align=1
            local.get 4
            local.get 4
            i32.load offset=92
            i32.store offset=76
            local.get 4
            local.get 4
            i64.load offset=84 align=4
            i64.store offset=68 align=4
            local.get 4
            local.get 3
            i32.store8 offset=64
            i32.const 1065572
            i32.const 43
            local.get 4
            i32.const 64
            i32.add
            i32.const 1065556
            i32.const 1065616
            call $core::result::unwrap_failed
            unreachable
          end
          local.get 4
          local.get 4
          i32.load8_u offset=83
          i32.store8 offset=67
          local.get 4
          local.get 4
          i32.load16_u offset=81 align=1
          i32.store16 offset=65 align=1
          local.get 4
          local.get 4
          i32.load offset=92
          i32.store offset=76
          local.get 4
          local.get 4
          i64.load offset=84 align=4
          i64.store offset=68 align=4
          local.get 4
          local.get 13
          i32.store8 offset=64
          i32.const 1065572
          i32.const 43
          local.get 4
          i32.const 64
          i32.add
          i32.const 1065556
          i32.const 1065616
          call $core::result::unwrap_failed
          unreachable
        end
        i32.const 1057428
        i32.const 43
        local.get 4
        i32.const 175
        i32.add
        i32.const 1057412
        i32.const 1057472
        call $core::result::unwrap_failed
        unreachable
      end
      i32.const 1057428
      i32.const 43
      local.get 4
      i32.const 175
      i32.add
      i32.const 1057412
      i32.const 1057472
      call $core::result::unwrap_failed
      unreachable
    end
    i32.const 1057428
    i32.const 43
    local.get 4
    i32.const 175
    i32.add
    i32.const 1057412
    i32.const 1057472
    call $core::result::unwrap_failed
    unreachable
  )
  (func $"<nanvm_demos::samples::hello::module<nanvm_lib::naive::Naive>::{closure#0}::{closure#0} as core::ops::function::FnOnce<(&nanvm_lib::naive::function::Function, nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>)>>::call_once" (;306;) (type 4) (param i32 i32 i32 i32)
    (local i32 i32)
    global.get $__stack_pointer
    i32.const 32
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 4
    local.get 3
    i32.store offset=12
    local.get 4
    local.get 2
    i32.store offset=8
    local.get 4
    i32.const 0
    i32.store8 offset=19
    local.get 4
    local.get 4
    i32.const 19
    i32.add
    call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::sources::empty::Empty<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
    local.get 4
    local.get 4
    i32.load offset=4
    local.tee 5
    i32.store offset=24
    local.get 4
    local.get 4
    i32.load
    local.tee 3
    i32.store offset=20
    block ;; label = @1
      block ;; label = @2
        local.get 4
        i32.load8_u offset=19
        i32.const 1
        i32.ne
        br_if 0 (;@2;)
        local.get 3
        local.get 3
        i32.load
        i32.const -1
        i32.add
        local.tee 2
        i32.store
        local.get 2
        br_if 1 (;@1;)
        local.get 4
        i32.const 20
        i32.add
        call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
        br 1 (;@1;)
      end
      local.get 3
      i32.eqz
      br_if 0 (;@1;)
      local.get 0
      i32.const 77
      i32.const 0
      local.get 3
      local.get 5
      i32.const 1060955
      i32.const 20
      call $<nanvm_lib::naive::function::Function>::new
      i32.store offset=12
      local.get 0
      i32.const 7
      i32.store8 offset=8
      local.get 0
      i64.const 0
      i64.store
      local.get 2
      local.get 2
      i32.load
      i32.const -1
      i32.add
      local.tee 0
      i32.store
      block ;; label = @2
        local.get 0
        br_if 0 (;@2;)
        local.get 4
        i32.const 8
        i32.add
        call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
      end
      local.get 4
      i32.const 32
      i32.add
      global.set $__stack_pointer
      return
    end
    i32.const 1057428
    i32.const 43
    local.get 4
    i32.const 31
    i32.add
    i32.const 1057412
    i32.const 1057472
    call $core::result::unwrap_failed
    unreachable
  )
  (func $"<nanvm_demos::samples::hello::module<nanvm_lib::naive::Naive>::{closure#0}::{closure#0}::{closure#0} as core::ops::function::FnOnce<(&nanvm_lib::naive::function::Function, nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>)>>::call_once" (;310;) (type 4) (param i32 i32 i32 i32)
    (local i32 i64 i32)
    global.get $__stack_pointer
    i32.const 112
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 4
    local.get 3
    i32.store offset=24
    local.get 4
    local.get 2
    i32.store offset=20
    local.get 4
    i32.const 0
    i32.store16 offset=36
    local.get 4
    i32.const 1061022
    i32.store offset=32
    local.get 4
    i32.const 1061020
    i32.store offset=28
    local.get 4
    i32.const 56
    i32.add
    local.get 4
    i32.const 28
    i32.add
    call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
    block ;; label = @1
      block ;; label = @2
        local.get 4
        i32.load8_u offset=56
        local.tee 3
        i32.const 255
        i32.ne
        br_if 0 (;@2;)
        local.get 4
        i64.load offset=60 align=4
        local.set 5
        local.get 4
        i32.const 0
        i32.store8 offset=28
        local.get 4
        i32.const 256
        i32.store16 offset=80
        local.get 4
        local.get 5
        i64.store offset=68 align=4
        local.get 4
        i32.const 3
        i32.store8 offset=64
        local.get 4
        i64.const 8589934592
        i64.store offset=56
        local.get 4
        local.get 4
        i32.const 28
        i32.add
        i32.store offset=96
        local.get 4
        i32.const 8
        i32.add
        local.get 4
        i32.const 56
        i32.add
        call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, 2>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
        local.get 4
        local.get 4
        i32.load offset=12
        local.tee 6
        i32.store offset=44
        local.get 4
        local.get 4
        i32.load offset=8
        local.tee 3
        i32.store offset=40
        block ;; label = @3
          local.get 4
          i32.load8_u offset=28
          i32.const 1
          i32.ne
          br_if 0 (;@3;)
          local.get 3
          local.get 3
          i32.load
          i32.const -1
          i32.add
          local.tee 0
          i32.store
          local.get 0
          br_if 2 (;@1;)
          local.get 4
          i32.const 40
          i32.add
          call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
          br 2 (;@1;)
        end
        local.get 3
        i32.eqz
        br_if 1 (;@1;)
        local.get 0
        local.get 6
        i32.store offset=16
        local.get 0
        local.get 3
        i32.store offset=12
        local.get 0
        i32.const 6
        i32.store8 offset=8
        local.get 0
        i64.const 0
        i64.store
        local.get 2
        local.get 2
        i32.load
        i32.const -1
        i32.add
        local.tee 0
        i32.store
        block ;; label = @3
          local.get 0
          br_if 0 (;@3;)
          local.get 4
          i32.const 20
          i32.add
          call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
        end
        local.get 4
        i32.const 112
        i32.add
        global.set $__stack_pointer
        return
      end
      local.get 4
      local.get 4
      i32.load8_u offset=59
      i32.store8 offset=43
      local.get 4
      local.get 4
      i32.load16_u offset=57 align=1
      i32.store16 offset=41 align=1
      local.get 4
      local.get 4
      i32.load offset=68
      i32.store offset=52
      local.get 4
      local.get 4
      i64.load offset=60 align=4
      i64.store offset=44 align=4
      local.get 4
      local.get 3
      i32.store8 offset=40
      i32.const 1065572
      i32.const 43
      local.get 4
      i32.const 40
      i32.add
      i32.const 1065556
      i32.const 1065616
      call $core::result::unwrap_failed
      unreachable
    end
    i32.const 1057428
    i32.const 43
    local.get 4
    i32.const 111
    i32.add
    i32.const 1057412
    i32.const 1057472
    call $core::result::unwrap_failed
    unreachable
  )

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs