Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing functions with anyref locals runs into assertion #2444

Closed
dcodeIO opened this issue Nov 17, 2019 · 1 comment · Fixed by #2451
Closed

Optimizing functions with anyref locals runs into assertion #2444

dcodeIO opened this issue Nov 17, 2019 · 1 comment · Fixed by #2451
Assignees

Comments

@dcodeIO
Copy link
Contributor

dcodeIO commented Nov 17, 2019

I'm currently trying to track down a Binaryen assertion happening with the following module:

(module
  (import "ref" "null" (global $ref_null anyref))
  (import "ref" "is_null" (func $ref_is_null (param anyref) (result i32)))
  (func $test
    (local $0 anyref)
    (local.set $0
      (global.get $ref_null)
    )
    (drop
      (call $ref_is_null
        (local.get $0)
      )
    )
    ;; remove this to make it work:
    (drop
      (call $ref_is_null
        (local.get $0)
      )
    )
  )
  (export $test $test)
)

which yields

abort(Assertion failed: false, at: ./src/literal.h,87,makeFromInt32)

when I attempt to optimize it with optimizeLevel > 1. The problem goes away if I remove the second

    (drop
      (call $ref_is_null
        (local.get $0)
      )
    )

from the function or make $0 a function parameter, so I guess that there is an optimization trying to move/copy local values around that causes this as soon as there are two local.gets of the same anyref local or something along those lines. This isn't overly important, just ran into this while trying to polyfill ref.null etc. so we can have shiny things. Perhaps there's an easy fix?

@aheejin
Copy link
Member

aheejin commented Nov 18, 2019

I'm working on reference types support now, and this will be fixed by that patch soon. Thank you for reporting.

aheejin added a commit that referenced this issue Dec 31, 2019
This adds support for the reference type proposal. This includes support
for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`)
and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and
new typed `select`. This also adds subtype relationship support between
reference types.

This does not include table instructions yet. This also does not include
wasm2js support.

Fixes #2444 and fixes #2447.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants