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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 var stdlib = this; 7 var stdlib = this;
8 8
9 (function TestStdlibConstants() { 9 (function TestStdlibConstants() {
10 function Module(stdlib) { 10 function Module(stdlib) {
(...skipping 29 matching lines...) Expand all
40 40
41 return {caller:caller, nanCheck:nanCheck}; 41 return {caller:caller, nanCheck:nanCheck};
42 } 42 }
43 43
44 var m = Wasm.instantiateModuleFromAsm(Module.toString(), stdlib); 44 var m = Wasm.instantiateModuleFromAsm(Module.toString(), stdlib);
45 assertEquals(1, m.caller()); 45 assertEquals(1, m.caller());
46 assertTrue(isNaN(m.nanCheck())); 46 assertTrue(isNaN(m.nanCheck()));
47 })(); 47 })();
48 48
49 49
50 (function TestBadNaNStdlib() { 50 var stdlib = this;
51 var stdlib_root_members = [
52 'Infinity',
53 'NaN',
54 ];
55 var stdlib_math_members = [
56 'E',
57 'LN10',
58 'LN2',
59 'LOG2E',
60 'LOG10E',
61 'PI',
62 'SQRT1_2',
63 'SQRT2',
64 'ceil',
65 'clz32',
66 'floor',
67 'sqrt',
68 'abs',
69 'min',
70 'max',
71 'acos',
72 'asin',
73 'atan',
74 'cos',
75 'sin',
76 'tan',
77 'exp',
78 'log',
79 'atan2',
80 'pow',
81 'imul',
82 'fround',
83 ];
84
85
86 (function TestBadStdlib() {
51 function Module(stdlib) { 87 function Module(stdlib) {
52 "use asm"; 88 "use asm";
53 var StdlibNaN = stdlib.NaN; 89 var foo = stdlib.NaN;
54 function foo() { return +StdlibNaN; }
55 return {}; 90 return {};
56 } 91 }
57 assertThrows(function() { 92 for (var i = 0; i < stdlib_root_members.length; ++i) {
58 Wasm.instantiateModuleFromAsm(Module.toString(), { NaN: 0 }); 93 var member = stdlib_root_members[i];
59 }); 94 var stdlib = {};
95 stdlib[member] = 0;
96 print(member);
97 var code = Module.toString().replace('NaN', member);
98 assertThrows(function() {
99 Wasm.instantiateModuleFromAsm(code, stdlib);
100 });
101 }
102 for (var i = 0; i < stdlib_math_members.length; ++i) {
103 var member = stdlib_math_members[i];
104 var stdlib = {Math:{}};
105 stdlib['Math'][member] = 0;
106 print(member);
107 var code = Module.toString().replace('NaN', 'Math.' + member);
108 assertThrows(function() {
109 Wasm.instantiateModuleFromAsm(code, stdlib);
110 });
111 }
60 })(); 112 })();
61 113
62 114
63 (function TestMissingNaNStdlib() { 115 (function TestMissingNaNStdlib() {
64 function Module(stdlib) { 116 function Module(stdlib) {
65 "use asm"; 117 "use asm";
66 var StdlibNaN = stdlib.NaN; 118 var foo = stdlib.NaN;
67 function foo() { return +StdlibNaN; }
68 return {}; 119 return {};
69 } 120 }
70 assertThrows(function() { 121 for (var i = 0; i < stdlib_root_members.length; ++i) {
71 Wasm.instantiateModuleFromAsm(Module.toString(), {}); 122 var member = stdlib_root_members[i];
72 }); 123 var code = Module.toString().replace('NaN', member);
124 assertThrows(function() {
125 Wasm.instantiateModuleFromAsm(code, {});
126 });
127 }
128 for (var i = 0; i < stdlib_math_members.length; ++i) {
129 var member = stdlib_math_members[i];
130 var code = Module.toString().replace('NaN', 'Math.' + member);
131 assertThrows(function() {
132 Wasm.instantiateModuleFromAsm(code, {});
133 });
134 }
73 })(); 135 })();
74 136
75 137
76 (function TestStdlibFunctionsInside() { 138 (function TestStdlibFunctionsInside() {
77 function Module(stdlib) { 139 function Module(stdlib) {
78 "use asm"; 140 "use asm";
79 141
80 var StdlibMathCeil = stdlib.Math.ceil; 142 var StdlibMathCeil = stdlib.Math.ceil;
81 var StdlibMathClz32 = stdlib.Math.clz32; 143 var StdlibMathClz32 = stdlib.Math.clz32;
82 var StdlibMathFloor = stdlib.Math.floor; 144 var StdlibMathFloor = stdlib.Math.floor;
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if (!compare(expected, actual)) { 442 if (!compare(expected, actual)) {
381 print(expected + ' !== ' + actual + ' for ' + name + 443 print(expected + ' !== ' + actual + ' for ' + name +
382 ' with input ' + val0 + ' ' + val1); 444 ' with input ' + val0 + ' ' + val1);
383 assertTrue(false); 445 assertTrue(false);
384 } 446 }
385 } 447 }
386 } 448 }
387 } 449 }
388 } 450 }
389 })(); 451 })();
OLDNEW
« 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