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

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

Issue 1804243003: Fix conversion to float32, typing issue, split apart asm-wasm tests. (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 | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/wasm/asm-wasm-stdlib.js » ('j') | 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 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 1249
1250 return {ifunc: ifunc, dfunc: dfunc}; 1250 return {ifunc: ifunc, dfunc: dfunc};
1251 } 1251 }
1252 1252
1253 var m = Wasm.instantiateModuleFromAsm(CommaModule.toString()); 1253 var m = Wasm.instantiateModuleFromAsm(CommaModule.toString());
1254 assertEquals(123, m.ifunc(456.7, 123)); 1254 assertEquals(123, m.ifunc(456.7, 123));
1255 assertEquals(123.4, m.dfunc(456, 123.4)); 1255 assertEquals(123.4, m.dfunc(456, 123.4));
1256 })(); 1256 })();
1257 1257
1258 1258
1259 (function TestStdlibConstants() {
1260 function Module(stdlib) {
1261 "use asm";
1262
1263 var StdlibInfinity = stdlib.Infinity;
1264 var StdlibNaN = stdlib.NaN;
1265 var StdlibMathE = stdlib.Math.E;
1266 var StdlibMathLN10 = stdlib.Math.LN10;
1267 var StdlibMathLN2 = stdlib.Math.LN2;
1268 var StdlibMathLOG2E = stdlib.Math.LOG2E;
1269 var StdlibMathLOG10E = stdlib.Math.LOG10E;
1270 var StdlibMathPI = stdlib.Math.PI;
1271 var StdlibMathSQRT1_2 = stdlib.Math.SQRT1_2;
1272 var StdlibMathSQRT2 = stdlib.Math.SQRT2;
1273
1274 function caller() {
1275 if (StdlibInfinity != 1.0 / 0.0) return 0;
1276 if (StdlibMathE != 2.718281828459045) return 0;
1277 if (StdlibMathLN10 != 2.302585092994046) return 0;
1278 if (StdlibMathLN2 != 0.6931471805599453) return 0;
1279 if (StdlibMathLOG2E != 1.4426950408889634) return 0;
1280 if (StdlibMathLOG10E != 0.4342944819032518) return 0;
1281 if (StdlibMathPI != 3.141592653589793) return 0;
1282 if (StdlibMathSQRT1_2 != 0.7071067811865476) return 0;
1283 if (StdlibMathSQRT2 != 1.4142135623730951) return 0;
1284 return 1;
1285 }
1286
1287 function nanCheck() {
1288 return +StdlibNaN;
1289 }
1290
1291 return {caller:caller, nanCheck:nanCheck};
1292 }
1293
1294 var m =Wasm.instantiateModuleFromAsm(Module.toString());
1295 assertEquals(1, m.caller());
1296 assertTrue(isNaN(m.nanCheck()));
1297 })();
1298
1299
1300 (function TestStdlibFunctions() {
1301 function Module(stdlib) {
1302 "use asm";
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
1311 var StdlibMathAcos = stdlib.Math.acos;
1312 var StdlibMathAsin = stdlib.Math.asin;
1313 var StdlibMathAtan = stdlib.Math.atan;
1314 var StdlibMathCos = stdlib.Math.cos;
1315 var StdlibMathSin = stdlib.Math.sin;
1316 var StdlibMathTan = stdlib.Math.tan;
1317 var StdlibMathExp = stdlib.Math.exp;
1318 var StdlibMathLog = stdlib.Math.log;
1319
1320 var StdlibMathAtan2 = stdlib.Math.atan2;
1321 var StdlibMathPow = stdlib.Math.pow;
1322 var StdlibMathImul = stdlib.Math.imul;
1323
1324 var fround = stdlib.Math.fround;
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
1337 function caller() {
1338 if (!deltaEqual(StdlibMathSqrt(123.0), 11.090536506409418)) return 0;
1339 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0;
1340 if (StdlibMathCeil(123.7) != 124.0) return 0;
1341 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0;
1342 if (StdlibMathFloor(123.7) != 123.0) return 0;
1343 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0;
1344 if (StdlibMathAbs(-123.0) != 123.0) return 0;
1345 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0;
1346 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0;
1347 if (StdlibMathMin(fround(123.4),
1348 fround(1236.4)) != fround(123.4)) return 0;
1349 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0;
1350 if (StdlibMathMax(fround(123.4), fround(1236.4))
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
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
1366 return 1;
1367 }
1368
1369 return {caller:caller};
1370 }
1371
1372 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1373 assertEquals(1, m.caller());
1374 })();
1375
1376
1377 (function TestAbsInt() {
1378 function Module(stdlib) {
1379 "use asm";
1380 var abs = stdlib.Math.abs;
1381 function func(x) {
1382 x = x | 0;
1383 return abs(x|0)|0;
1384 }
1385 return {func:func};
1386 }
1387 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1388 var values = [0, 1, -1, 0x40000000, 0x7FFFFFFF, -0x80000000];
1389 for (var i = 0; i < values.length; i++) {
1390 var val = values[i];
1391 assertEquals(Math.abs(val) | 0, m.func(val));
1392 }
1393 })();
1394
1395
1396 (function TestAbsFloat() {
1397 function Module(stdlib) {
1398 "use asm";
1399 var fround = stdlib.Math.fround;
1400 var abs = stdlib.Math.abs;
1401 function func(x) {
1402 x = fround(x);
1403 x = abs(x);
1404 return fround(x);
1405 }
1406 return {func:func};
1407 }
1408 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1409 var values = [
1410 0, -0, 1, -1, 0.9, -0.9, 1.414, 0x7F, -0x80, -0x8000, -0x80000000,
1411 0x7FFF, 0x7FFFFFFF, Infinity, -Infinity, NaN
1412 ];
1413 for (var i = 0; i < values.length; i++) {
1414 var val = values[i];
1415 assertEquals(Math.fround(Math.abs(val)), m.func(val));
1416 }
1417 })();
1418
1419
1420 (function TestAbsDouble() {
1421 function Module(stdlib) {
1422 "use asm";
1423 var fround = stdlib.Math.fround;
1424 var abs = stdlib.Math.abs;
1425 function func(x) {
1426 x = +x;
1427 x = abs(x);
1428 return +x;
1429 }
1430 return {func:func};
1431 }
1432 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1433 var values = [
1434 0, -0, 1, -1, 0.9, -0.9, 1.414, 0x7F, -0x80, -0x8000, -0x80000000,
1435 0x7FFF, 0x7FFFFFFF, Infinity, -Infinity, NaN
1436 ];
1437 for (var i = 0; i < values.length; i++) {
1438 var val = values[i];
1439 assertEquals(Math.abs(val), m.func(val));
1440 }
1441 })();
1442
1443
1444 (function TestFloatAsDouble() { 1259 (function TestFloatAsDouble() {
1445 function Module(stdlib) { 1260 function Module(stdlib) {
1446 "use asm"; 1261 "use asm";
1447 var fround = stdlib.Math.fround; 1262 var fround = stdlib.Math.fround;
1448 var abs = stdlib.Math.abs;
1449 function func() { 1263 function func() {
1450 var x = fround(1.0); 1264 var x = fround(1.0);
1451 return +fround(x); 1265 return +fround(x);
1452 } 1266 }
1453 return {func:func}; 1267 return {func:func};
1454 } 1268 }
1455 var m = Wasm.instantiateModuleFromAsm(Module.toString()); 1269 var m = Wasm.instantiateModuleFromAsm(Module.toString());
1456 assertEquals(1, m.func()); 1270 assertEquals(1, m.func());
1457 })(); 1271 })();
1458 1272
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 var a = 0; 1478 var a = 0;
1665 f = 5616315000.000001; 1479 f = 5616315000.000001;
1666 a = ~~f >>>0; 1480 a = ~~f >>>0;
1667 return a | 0; 1481 return a | 0;
1668 } 1482 }
1669 return { main : aaa }; 1483 return { main : aaa };
1670 } 1484 }
1671 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); 1485 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString());
1672 assertEquals(1321347704, wasm.main()); 1486 assertEquals(1321347704, wasm.main());
1673 })(); 1487 })();
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/wasm/asm-wasm-stdlib.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698