summaryrefslogtreecommitdiff
path: root/wasm
Commit message (Collapse)AuthorAgeFilesLines
* wasm/README.md: Add a note about the Ruby built for wasm. [ci skip]Jun Aruga2022-11-111-0/+10
| | | | | | | | | | | | | | | | | | | | The Ruby built for wasm cannot be execute without a WebAssembly runtime. ``` $ ruby-wasm32-wasi/usr/local/bin/ruby -e 'puts "a"' bash: ruby-wasm32-wasi/usr/local/bin/ruby: cannot execute binary file: Exec format error ``` Because the Ruby's file type is different from the one built normally, that is the `/usr/local/ruby-3.2.0-preview2/bin/ruby` below. ``` $ file ruby-wasm32-wasi/usr/local/bin/ruby ruby-wasm32-wasi/usr/local/bin/ruby: WebAssembly (wasm) binary module version 0x1 (MVP) $ file /usr/local/ruby-3.2.0-preview2/bin/ruby /usr/local/ruby-3.2.0-preview2/bin/ruby: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=a37822085e285c0971159982e7642dda88cea606, for GNU/Linux 3.2.0, with debug_info, not stripped ```
* [wasm] Scan machine stack based on `ec->machine.stack_{start,end}`Yuta Saito2022-11-062-6/+5
| | | | | | | | fiber machine stack is placed outside of C stack allocated by wasm-ld, so highest stack address recorded by `rb_wasm_record_stack_base` is invalid when running on non-main fiber. Therefore, we should scan `stack_{start,end}` which always point a valid stack range in any context.
* [wasm] get rid of workaround use of older binaryen and update to latestYuta Saito2022-07-061-2/+1
| | | | | We no longer need to use older version of binaryen since the blocker issue has been resolved https://github.com/WebAssembly/binaryen/issues/4401
* wasm/README.md: add manual config.guess download and autoconf stepsYuta Saito2022-03-151-2/+9
| | | | | | | | Autoconf distributed with Ubuntu 22.04 is very old and doesn't support WASI as an OS, so add instructions to download the latest config.guess, then run `./autogen.sh`. See also: https://github.com/ruby/chkbuild/commit/2297012efd6364f6fde45f54531b6fc0f0838ec9
* [wasm] vm.c: stop unwinding to main for every vm_exec call by setjmpYuta Saito2022-02-183-0/+114
| | | | | | | | | | | | | | | | | | | | | | | | the original rb_wasm_setjmp implementation always unwinds to the root call frame to have setjmp compatible interface, and simulate sjlj's undefined behavior. Therefore, every vm_exec call unwinds to main, and a deep call stack makes setjmp call very expensive. The following snippet from optcarrot takes 5s even though it takes less than 0.3s on native. ``` [0x0, 0x4, 0x8, 0xc].map do |attr| (0..7).map do |j| (0...0x10000).map do |i| clr = i[15 - j] * 2 + i[7 - j] clr != 0 ? attr | clr : 0 end end end ``` This patch adds a WASI specialized vm_exec which uses lightweight try-catch API without unwinding to the root frame. After this patch, the above snippet takes only 0.5s.
* * expand tabs. [ci skip]git2022-01-191-1/+1
| | | | | Tabs were expanded because the file did not have any tab indentation in unedited lines. Please update your editor config, and use misc/expand_tabs.rb in the pre-commit hook.
* [wasm] wasm/README.md: write a brief instruction to cross buildYuta Saito2022-01-191-0/+54
|
* [wasm] add unit test suite for fiber, register scan, sjlj in platform dirYuta Saito2022-01-194-0/+301
|
* [wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libcYuta Saito2022-01-192-0/+200
|
* [wasm] add asyncify based setjmp, fiber, register scan emulationYuta Saito2022-01-1912-0/+576
configure.ac: setup build tools and register objects main.c: wrap main with rb_wasm_rt_start to handle asyncify unwinds tool/m4/ruby_wasm_tools.m4: setup default command based on WASI_SDK_PATH environment variable. checks wasm-opt which is used for asyncify. tool/wasm-clangw wasm/wasm-opt: a clang wrapper which replaces real wasm-opt with do-nothing wasm-opt to avoid misoptimization before asyncify. asyncify is performed at POSTLINK, but clang linker driver tries to run optimization by wasm-opt unconditionally. inlining pass at wasm level breaks asyncify's assumption, so should not optimize before POSTLIK. wasm/GNUmakefile.in: wasm specific rules to compile objects