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

Side by Side Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1729833002: Add wasm internal opcodes for asm.js stdlib functions we're missing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 9 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/wasm/wasm-opcodes.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 function EmptyTest() { 7 function EmptyTest() {
8 "use asm"; 8 "use asm";
9 function caller() { 9 function caller() {
10 empty(); 10 empty();
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 var m =_WASMEXP_.instantiateModuleFromAsm(Module.toString()); 1294 var m =_WASMEXP_.instantiateModuleFromAsm(Module.toString());
1295 assertEquals(1, m.caller()); 1295 assertEquals(1, m.caller());
1296 assertTrue(isNaN(m.nanCheck())); 1296 assertTrue(isNaN(m.nanCheck()));
1297 })(); 1297 })();
1298 1298
1299 1299
1300 (function TestStdlibFunctions() { 1300 (function TestStdlibFunctions() {
1301 function Module(stdlib) { 1301 function Module(stdlib) {
1302 "use asm"; 1302 "use asm";
1303 1303
1304 var StdlibMathCeil = stdlib.Math.ceil;
1305 var StdlibMathFloor = stdlib.Math.floor;
1306 var StdlibMathSqrt = stdlib.Math.sqrt;
1307 var StdlibMathAbs = stdlib.Math.abs;
1308 var StdlibMathMin = stdlib.Math.min;
1309 var StdlibMathMax = stdlib.Math.max;
1310
1304 var StdlibMathAcos = stdlib.Math.acos; 1311 var StdlibMathAcos = stdlib.Math.acos;
1305 var StdlibMathAsin = stdlib.Math.asin; 1312 var StdlibMathAsin = stdlib.Math.asin;
1306 var StdlibMathAtan = stdlib.Math.atan; 1313 var StdlibMathAtan = stdlib.Math.atan;
1307 var StdlibMathCos = stdlib.Math.cos; 1314 var StdlibMathCos = stdlib.Math.cos;
1308 var StdlibMathSin = stdlib.Math.sin; 1315 var StdlibMathSin = stdlib.Math.sin;
1309 var StdlibMathTan = stdlib.Math.tan; 1316 var StdlibMathTan = stdlib.Math.tan;
1310 var StdlibMathExp = stdlib.Math.exp; 1317 var StdlibMathExp = stdlib.Math.exp;
1311 var StdlibMathLog = stdlib.Math.log; 1318 var StdlibMathLog = stdlib.Math.log;
1312 var StdlibMathCeil = stdlib.Math.ceil; 1319
1313 var StdlibMathFloor = stdlib.Math.floor;
1314 var StdlibMathSqrt = stdlib.Math.sqrt;
1315 var StdlibMathAbs = stdlib.Math.abs;
1316 var StdlibMathMin = stdlib.Math.min;
1317 var StdlibMathMax = stdlib.Math.max;
1318 var StdlibMathAtan2 = stdlib.Math.atan2; 1320 var StdlibMathAtan2 = stdlib.Math.atan2;
1319 var StdlibMathPow = stdlib.Math.pow; 1321 var StdlibMathPow = stdlib.Math.pow;
1320 var StdlibMathImul = stdlib.Math.imul; 1322 var StdlibMathImul = stdlib.Math.imul;
1323
1321 var fround = stdlib.Math.fround; 1324 var fround = stdlib.Math.fround;
1322 1325
1326 function deltaEqual(x, y) {
1327 x = +x;
1328 y = +y;
1329 var t = 0.0;
1330 t = x - y;
1331 if (t < 0.0) {
1332 t = t * -1.0;
1333 }
1334 return (t < 1.0e-13) | 0;
1335 }
1336
1323 function caller() { 1337 function caller() {
1324 // TODO(bradnelson): Test transendentals when implemented. 1338 if (!deltaEqual(StdlibMathSqrt(123.0), 11.090536506409418)) return 0;
1325 if (StdlibMathSqrt(123.0) != 11.090536506409418) return 0;
1326 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0; 1339 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0;
1327 if (StdlibMathCeil(123.7) != 124.0) return 0; 1340 if (StdlibMathCeil(123.7) != 124.0) return 0;
1328 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0; 1341 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0;
1329 if (StdlibMathFloor(123.7) != 123.0) return 0; 1342 if (StdlibMathFloor(123.7) != 123.0) return 0;
1330 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0; 1343 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0;
1331 if (StdlibMathAbs(-123.0) != 123.0) return 0; 1344 if (StdlibMathAbs(-123.0) != 123.0) return 0;
1332 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0; 1345 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0;
1333 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0; 1346 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0;
1334 if (StdlibMathMin(fround(123.4), 1347 if (StdlibMathMin(fround(123.4),
1335 fround(1236.4)) != fround(123.4)) return 0; 1348 fround(1236.4)) != fround(123.4)) return 0;
1336 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0; 1349 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0;
1337 if (StdlibMathMax(fround(123.4), fround(1236.4)) 1350 if (StdlibMathMax(fround(123.4), fround(1236.4))
1338 != fround(1236.4)) return 0; 1351 != fround(1236.4)) return 0;
1352
1353 if (!deltaEqual(StdlibMathAcos(0.1), 1.4706289056333368)) return 0;
1354 if (!deltaEqual(StdlibMathAsin(0.2), 0.2013579207903308)) return 0;
1355 if (!deltaEqual(StdlibMathAtan(0.2), 0.19739555984988078)) return 0;
1356 if (!deltaEqual(StdlibMathCos(0.2), 0.9800665778412416)) return 0;
1357 if (!deltaEqual(StdlibMathSin(0.2), 0.19866933079506122)) return 0;
1358 if (!deltaEqual(StdlibMathTan(0.2), 0.20271003550867250)) return 0;
1359 if (!deltaEqual(StdlibMathExp(0.2), 1.2214027581601699)) return 0;
1360 if (!deltaEqual(StdlibMathLog(0.2), -1.6094379124341003)) return 0;
1361
1339 if (StdlibMathImul(6, 7) != 42) return 0; 1362 if (StdlibMathImul(6, 7) != 42) return 0;
1363 if (!deltaEqual(StdlibMathAtan2(6.0, 7.0), 0.7086262721276703)) return 0;
1364 if (StdlibMathPow(6.0, 7.0) != 279936.0) return 0;
1365
1340 return 1; 1366 return 1;
1341 } 1367 }
1342 1368
1343 return {caller:caller}; 1369 return {caller:caller};
1344 } 1370 }
1345 1371
1346 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString()); 1372 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString());
1347 assertEquals(1, m.caller()); 1373 assertEquals(1, m.caller());
1348 })(); 1374 })();
1349 1375
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 var a = 0; 1581 var a = 0;
1556 f = 5616315000.000001; 1582 f = 5616315000.000001;
1557 a = ~~f >>>0; 1583 a = ~~f >>>0;
1558 return a | 0; 1584 return a | 0;
1559 } 1585 }
1560 return { main : aaa }; 1586 return { main : aaa };
1561 } 1587 }
1562 var wasm = _WASMEXP_.instantiateModuleFromAsm(asmModule.toString()); 1588 var wasm = _WASMEXP_.instantiateModuleFromAsm(asmModule.toString());
1563 assertEquals(1321347704, wasm.main()); 1589 assertEquals(1321347704, wasm.main());
1564 })(); 1590 })();
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698