Samsung / walrus

WebAssembly Lightweight RUntime
Apache License 2.0
40 stars 10 forks source link

Improve RefNull and RefIsNull operations #81

Closed zherczeg closed 1 year ago

zherczeg commented 1 year ago

I have found a bug:

(module
(func (export "defNull") (result externref) (local externref)
   local.get 0
)
)

(assert_return (invoke "defNull") (ref.null extern))

This fails because the memory is initialized to zero, and null is defined as ~0. I checked wabt, and they use 0 as null: https://github.com/Samsung/walrus/blob/interp/third_party/wabt/src/interp/interp.cc#L55

There is a test with (ref.extern 0), which should pass. I think we can do the same thing as the wabt test runner: https://github.com/Samsung/walrus/blob/interp/third_party/wabt/src/tools/spectest-interp.cc#L825