Issue 8064 in v8: Invalid asm.js - Function use doesn't match definition

567 views
Skip to first unread message

iigor.si… via monorail

unread,
Aug 16, 2018, 3:33:19 PM8/16/18
to v8-re...@googlegroups.com
Status: Untriaged
Owner: ----
Type: Bug

New issue 8064 by iigor.si...@gmail.com: Invalid asm.js - Function use doesn't match definition
https://bugs.chromium.org/p/v8/issues/detail?id=8064

Version: 7.0.237
OS: Ubuntu 16.04
Architecture: x64

Hi everyone, a warning message "Function use doesn't match definition" appears if we use a plus operator (eg. +sqrt()) on asm mode.

Step to reproduce:
function DiagModule(stdlib) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function square(x) {
x = +x;
return +(x*x);
}
function diag(x, y) {
x = +x;
y = +y;
return +sqrt(square(x) + square(y));
}
return { diag: diag };
}

var mod = DiagModule(this);
print(mod.diag(3, 4));


Actual results:
Invalid asm.js: Function use doesn't match definition
5

Expected results:
5

Chakra, SpiderMonkey and JavaScriptCore works as expected.

cinfuzz

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

n… via monorail

unread,
Aug 17, 2018, 7:28:04 AM8/17/18
to v8-re...@googlegroups.com
Updates:
Cc: mstar...@chromium.org

Comment #1 on issue 8064 by ne...@chromium.org: Invalid asm.js - Function use doesn't match definition
https://bugs.chromium.org/p/v8/issues/detail?id=8064#c1

(No comment was entered for this change.)

mstarzin… via monorail

unread,
Aug 17, 2018, 7:32:57 AM8/17/18
to v8-re...@googlegroups.com
Updates:
Cc: -mstar...@chromium.org
Labels: Hotlist-asm Priority-2
Owner: mstar...@chromium.org
Status: Assigned

Comment #2 on issue 8064 by mstar...@chromium.org: Invalid asm.js - Function use doesn't match definition
https://bugs.chromium.org/p/v8/issues/detail?id=8064#c2

mstarzin… via monorail

unread,
Aug 17, 2018, 7:47:54 AM8/17/18
to v8-re...@googlegroups.com
Updates:
Status: WontFix

Comment #3 on issue 8064 by mstar...@chromium.org: Invalid asm.js - Function use doesn't match definition
https://bugs.chromium.org/p/v8/issues/detail?id=8064#c3

As far as I can tell this is working as intended. I do indeed get the same warning (albeit with a more explanatory message in Firefox nightly) ...

TypeError: asm.js type error: all function calls must be calls to standard lib math functions, ignored (via f(); or comma-expression), coerced to signed (via f()|0), coerced to float (via fround(f())), or coerced to double (via +f())

The underlying problem is that the call to the {square} function is not properly type-annotated. It is missing the explicit coercion to double via the unary plus prefix. This is described in the second case in "6.8.7 UnaryExpression" of the asm.js spec. Please lets me know and/or reopen the issue if you disagree with my analysis. The following fixes the issue (for both Firefox and Chrome/V8):


function DiagModule(stdlib) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function square(x) {
x = +x;
return +(x*x);
}
function diag(x, y) {
x = +x;
y = +y;
return +sqrt(+square(x) + +square(y));
}
return { diag: diag };
Reply all
Reply to author
Forward
0 new messages