Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: test/mjsunit/wasm/asm-wasm-stdlib.js

Issue 2267633002: [wasm] asm.js - Check stdlib functions are valid. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/asm-wasm-stdlib.js
diff --git a/test/mjsunit/wasm/asm-wasm-stdlib.js b/test/mjsunit/wasm/asm-wasm-stdlib.js
index 55a244b58d7f999751b02b2fa9ccd48540be8521..82c27d4da99253b70330fa41688768d2326c52a4 100644
--- a/test/mjsunit/wasm/asm-wasm-stdlib.js
+++ b/test/mjsunit/wasm/asm-wasm-stdlib.js
@@ -47,29 +47,91 @@ var stdlib = this;
})();
-(function TestBadNaNStdlib() {
+var stdlib = this;
+var stdlib_root_members = [
+ 'Infinity',
+ 'NaN',
+];
+var stdlib_math_members = [
+ 'E',
+ 'LN10',
+ 'LN2',
+ 'LOG2E',
+ 'LOG10E',
+ 'PI',
+ 'SQRT1_2',
+ 'SQRT2',
+ 'ceil',
+ 'clz32',
+ 'floor',
+ 'sqrt',
+ 'abs',
+ 'min',
+ 'max',
+ 'acos',
+ 'asin',
+ 'atan',
+ 'cos',
+ 'sin',
+ 'tan',
+ 'exp',
+ 'log',
+ 'atan2',
+ 'pow',
+ 'imul',
+ 'fround',
+];
+
+
+(function TestBadStdlib() {
function Module(stdlib) {
"use asm";
- var StdlibNaN = stdlib.NaN;
- function foo() { return +StdlibNaN; }
+ var foo = stdlib.NaN;
return {};
}
- assertThrows(function() {
- Wasm.instantiateModuleFromAsm(Module.toString(), { NaN: 0 });
- });
+ for (var i = 0; i < stdlib_root_members.length; ++i) {
+ var member = stdlib_root_members[i];
+ var stdlib = {};
+ stdlib[member] = 0;
+ print(member);
+ var code = Module.toString().replace('NaN', member);
+ assertThrows(function() {
+ Wasm.instantiateModuleFromAsm(code, stdlib);
+ });
+ }
+ for (var i = 0; i < stdlib_math_members.length; ++i) {
+ var member = stdlib_math_members[i];
+ var stdlib = {Math:{}};
+ stdlib['Math'][member] = 0;
+ print(member);
+ var code = Module.toString().replace('NaN', 'Math.' + member);
+ assertThrows(function() {
+ Wasm.instantiateModuleFromAsm(code, stdlib);
+ });
+ }
})();
(function TestMissingNaNStdlib() {
function Module(stdlib) {
"use asm";
- var StdlibNaN = stdlib.NaN;
- function foo() { return +StdlibNaN; }
+ var foo = stdlib.NaN;
return {};
}
- assertThrows(function() {
- Wasm.instantiateModuleFromAsm(Module.toString(), {});
- });
+ for (var i = 0; i < stdlib_root_members.length; ++i) {
+ var member = stdlib_root_members[i];
+ var code = Module.toString().replace('NaN', member);
+ assertThrows(function() {
+ Wasm.instantiateModuleFromAsm(code, {});
+ });
+ }
+ for (var i = 0; i < stdlib_math_members.length; ++i) {
+ var member = stdlib_math_members[i];
+ var code = Module.toString().replace('NaN', 'Math.' + member);
+ assertThrows(function() {
+ Wasm.instantiateModuleFromAsm(code, {});
+ });
+ }
})();
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698