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

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: merge Created 4 years, 10 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
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/asm-wasm-builder.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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 var m =_WASMEXP_.instantiateModuleFromAsm(Module.toString()); 1305 var m =_WASMEXP_.instantiateModuleFromAsm(Module.toString());
1306 assertEquals(1, m.caller()); 1306 assertEquals(1, m.caller());
1307 assertTrue(isNaN(m.nanCheck())); 1307 assertTrue(isNaN(m.nanCheck()));
1308 })(); 1308 })();
1309 1309
1310 1310
1311 (function TestStdlibFunctions() { 1311 (function TestStdlibFunctions() {
1312 function Module(stdlib) { 1312 function Module(stdlib) {
1313 "use asm"; 1313 "use asm";
1314 1314
1315 var StdlibMathCeil = stdlib.Math.ceil;
1316 var StdlibMathFloor = stdlib.Math.floor;
1317 var StdlibMathSqrt = stdlib.Math.sqrt;
1318 var StdlibMathAbs = stdlib.Math.abs;
1319 var StdlibMathMin = stdlib.Math.min;
1320 var StdlibMathMax = stdlib.Math.max;
1321
1315 var StdlibMathAcos = stdlib.Math.acos; 1322 var StdlibMathAcos = stdlib.Math.acos;
1316 var StdlibMathAsin = stdlib.Math.asin; 1323 var StdlibMathAsin = stdlib.Math.asin;
1317 var StdlibMathAtan = stdlib.Math.atan; 1324 var StdlibMathAtan = stdlib.Math.atan;
1318 var StdlibMathCos = stdlib.Math.cos; 1325 var StdlibMathCos = stdlib.Math.cos;
1319 var StdlibMathSin = stdlib.Math.sin; 1326 var StdlibMathSin = stdlib.Math.sin;
1320 var StdlibMathTan = stdlib.Math.tan; 1327 var StdlibMathTan = stdlib.Math.tan;
1321 var StdlibMathExp = stdlib.Math.exp; 1328 var StdlibMathExp = stdlib.Math.exp;
1322 var StdlibMathLog = stdlib.Math.log; 1329 var StdlibMathLog = stdlib.Math.log;
1330
1323 var StdlibMathCeil = stdlib.Math.ceil; 1331 var StdlibMathCeil = stdlib.Math.ceil;
1324 var StdlibMathFloor = stdlib.Math.floor; 1332 var StdlibMathFloor = stdlib.Math.floor;
1325 var StdlibMathSqrt = stdlib.Math.sqrt; 1333 var StdlibMathSqrt = stdlib.Math.sqrt;
1326 var StdlibMathAbs = stdlib.Math.abs; 1334 var StdlibMathAbs = stdlib.Math.abs;
1327 var StdlibMathMin = stdlib.Math.min; 1335 var StdlibMathMin = stdlib.Math.min;
1328 var StdlibMathMax = stdlib.Math.max; 1336 var StdlibMathMax = stdlib.Math.max;
1337
1329 var StdlibMathAtan2 = stdlib.Math.atan2; 1338 var StdlibMathAtan2 = stdlib.Math.atan2;
1330 var StdlibMathPow = stdlib.Math.pow; 1339 var StdlibMathPow = stdlib.Math.pow;
1331 var StdlibMathImul = stdlib.Math.imul; 1340 var StdlibMathImul = stdlib.Math.imul;
1341
1332 var fround = stdlib.Math.fround; 1342 var fround = stdlib.Math.fround;
1333 1343
1334 function caller() { 1344 function caller() {
1335 // TODO(bradnelson): Test transendentals when implemented. 1345 // TODO(bradnelson): Test transendentals when implemented.
1336 if (StdlibMathSqrt(123.0) != 11.090536506409418) return 0; 1346 if (StdlibMathSqrt(123.0) != 11.090536506409418) return 0;
1337 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0; 1347 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0;
1338 if (StdlibMathCeil(123.7) != 124.0) return 0; 1348 if (StdlibMathCeil(123.7) != 124.0) return 0;
1339 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0; 1349 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0;
1340 if (StdlibMathFloor(123.7) != 123.0) return 0; 1350 if (StdlibMathFloor(123.7) != 123.0) return 0;
1341 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0; 1351 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0;
1342 if (StdlibMathAbs(-123.0) != 123.0) return 0; 1352 if (StdlibMathAbs(-123.0) != 123.0) return 0;
1343 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0; 1353 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0;
1344 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0; 1354 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0;
1345 if (StdlibMathMin(fround(123.4), 1355 if (StdlibMathMin(fround(123.4),
1346 fround(1236.4)) != fround(123.4)) return 0; 1356 fround(1236.4)) != fround(123.4)) return 0;
1347 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0; 1357 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0;
1348 if (StdlibMathMax(fround(123.4), fround(1236.4)) 1358 if (StdlibMathMax(fround(123.4), fround(1236.4))
1349 != fround(1236.4)) return 0; 1359 != fround(1236.4)) return 0;
1360
1361 if (StdlibMathAcos(0.1) != 1.4706289056333368) return 0;
1362 if (StdlibMathAsin(0.2) != 0.2013579207903308) return 0;
1363 if (StdlibMathAtan(0.2) != 0.19739555984988078) return 0;
1364 if (StdlibMathCos(0.2) != 0.9800665778412416) return 0;
1365 if (StdlibMathSin(0.2) != 0.19866933079506122) return 0;
1366 if (StdlibMathTan(0.2) != 0.2027100355086725) return 0;
1367 if (StdlibMathExp(0.2) != 1.2214027581601699) return 0;
1368 if (StdlibMathLog(0.2) != -1.6094379124341003) return 0;
1369
1350 if (StdlibMathImul(6, 7) != 42) return 0; 1370 if (StdlibMathImul(6, 7) != 42) return 0;
1371 if (StdlibMathAtan2(6.0, 7.0) != 0.7086262721276703) return 0;
1372 if (StdlibMathPow(6.0, 7.0) != 279936.0) return 0;
1373
1351 return 1; 1374 return 1;
1352 } 1375 }
1353 1376
1354 return {caller:caller}; 1377 return {caller:caller};
1355 } 1378 }
1356 1379
1357 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString()); 1380 var env = {
1381 _acos: Math.acos,
1382 _asin: Math.asin,
1383 _atan: Math.atan,
1384 _cos: Math.cos,
1385 _sin: Math.sin,
1386 _tan: Math.tan,
1387 _exp: Math.exp,
1388 _log: Math.log,
1389 _atan2: Math.atan2,
1390 _pow: Math.pow,
1391 };
1392 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString(), env);
1358 assertEquals(1, m.caller()); 1393 assertEquals(1, m.caller());
1359 })(); 1394 })();
1360 1395
1361 1396
1362 (function TestOr() { 1397 (function TestOr() {
1363 function Module() { 1398 function Module() {
1364 "use asm"; 1399 "use asm";
1365 function func() { 1400 function func() {
1366 var x = 1; 1401 var x = 1;
1367 var y = 2; 1402 var y = 2;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 var x = 0; 1568 var x = 0;
1534 x = HEAP32[0] & -1; 1569 x = HEAP32[0] & -1;
1535 return x | 0; 1570 return x | 0;
1536 } 1571 }
1537 return {func: func}; 1572 return {func: func};
1538 } 1573 }
1539 1574
1540 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString()); 1575 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString());
1541 assertEquals(0, m.func()); 1576 assertEquals(0, m.func());
1542 })(); 1577 })();
OLDNEW
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/asm-wasm-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698