New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 633895 link

Starred by 4 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

V8 WebAssembly imports not working with bound functions

Reported by alex.ber...@gmail.com, Aug 3 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36 Vivaldi/1.2.490.43

Steps to reproduce the problem:
const instance = Wasm.instantiateModule(code, {
  'ethereum': {
    'sstore': ethInterface.sstore.bind(ethInterface), // fails
    'sload': function () {}, // works, obviously
    'return': function () {}.bind('test'), // fails
  }
})

WasmModule::Instantiate(): Import #0 module="ethereum" function="sstore" error: not a function

What is the expected behavior?
That bound functions work the same way as normal functions.

What went wrong?
Cannot use bound functions with Wasm.instantiateModule. Only regular functions work.

As a workaround I'm using a Function.bind polyfill, which ensures the bound function is a regular function.

I assume native bound functions are handled differently within V8 for optimisation reasons.

The line which causes the above error message: https://github.com/v8/v8/blob/master/src/wasm/wasm-module.cc#L496

Did this work before? N/A 

Chrome version: 51.0.2704.103  Channel: n/a
OS Version: OS X 10.11.6
Flash Version: Shockwave Flash 22.0 r0

Originally reported to node.js: https://github.com/nodejs/node/issues/7953
 

Comment 1 by ahaas@chromium.org, Aug 3 2016

Cc: titzer@chromium.org fran...@chromium.org
Components: -Blink Blink>JavaScript>WebAssembly
Owner: ahaas@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 2 by ahaas@chromium.org, Aug 3 2016

Cc: rossberg@chromium.org

Comment 3 by ahaas@chromium.org, Aug 16 2016

Status: Fixed (was: Assigned)
Fixed in https://codereview.chromium.org/2208703002

Sign in to add a comment