<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/wasm, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>wasm/README.md: Add a note about the Ruby built for wasm. [ci skip]</title>
<updated>2022-11-10T22:57:25+00:00</updated>
<author>
<name>Jun Aruga</name>
<email>jaruga@redhat.com</email>
</author>
<published>2022-11-10T12:24:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4c554096bfc08939e9eb1fb1773514b62b8b95b5'/>
<id>4c554096bfc08939e9eb1fb1773514b62b8b95b5</id>
<content type='text'>
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
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
```
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] Scan machine stack based on `ec-&gt;machine.stack_{start,end}`</title>
<updated>2022-11-05T20:03:21+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2022-11-05T16:10:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3a6cdeda89280ade714f158830acee88fb36306d'/>
<id>3a6cdeda89280ade714f158830acee88fb36306d</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] get rid of workaround use of older binaryen and update to latest</title>
<updated>2022-07-06T02:59:38+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2022-07-06T02:14:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=76619bbb1198082e94716874777f282c59d2cc70'/>
<id>76619bbb1198082e94716874777f282c59d2cc70</id>
<content type='text'>
We no longer need to use older version of binaryen since the blocker
issue has been resolved https://github.com/WebAssembly/binaryen/issues/4401
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We no longer need to use older version of binaryen since the blocker
issue has been resolved https://github.com/WebAssembly/binaryen/issues/4401
</pre>
</div>
</content>
</entry>
<entry>
<title>wasm/README.md: add manual config.guess download and autoconf steps</title>
<updated>2022-03-15T01:25:12+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2022-03-15T01:21:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=459bbdeb74224168af5c2b288f206485f7866872'/>
<id>459bbdeb74224168af5c2b288f206485f7866872</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] vm.c: stop unwinding to main for every vm_exec call by setjmp</title>
<updated>2022-02-18T09:28:18+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2022-01-27T12:33:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=dff70b50d01930213e7799ee52969ff309cc3601'/>
<id>dff70b50d01930213e7799ee52969ff309cc3601</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>* expand tabs. [ci skip]</title>
<updated>2022-01-19T02:19:20+00:00</updated>
<author>
<name>git</name>
<email>svn-admin@ruby-lang.org</email>
</author>
<published>2022-01-19T02:19:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a892e5599ec8ec441a8d8b878efa855ef283ed08'/>
<id>a892e5599ec8ec441a8d8b878efa855ef283ed08</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] wasm/README.md: write a brief instruction to cross build</title>
<updated>2022-01-19T02:19:06+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2021-12-14T15:32:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4f579ecfcee2dc230bd7f744c6db8f8d8d902ad8'/>
<id>4f579ecfcee2dc230bd7f744c6db8f8d8d902ad8</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] add unit test suite for fiber, register scan, sjlj in platform dir</title>
<updated>2022-01-19T02:19:06+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2021-12-08T13:19:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f72f01abd89640b083b4067e4be399448f0fb6ce'/>
<id>f72f01abd89640b083b4067e4be399448f0fb6ce</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libc</title>
<updated>2022-01-19T02:19:06+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2022-01-15T16:18:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7ee786388ae0d6f8c8cea7bf012cc11fdb5b534a'/>
<id>7ee786388ae0d6f8c8cea7bf012cc11fdb5b534a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[wasm] add asyncify based setjmp, fiber, register scan emulation</title>
<updated>2022-01-19T02:19:06+00:00</updated>
<author>
<name>Yuta Saito</name>
<email>kateinoigakukun@gmail.com</email>
</author>
<published>2022-01-15T14:10:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=65f95f26ff0e7b4be4704fedc52344a26d22a4e2'/>
<id>65f95f26ff0e7b4be4704fedc52344a26d22a4e2</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
</feed>
