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

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
« src/assembler.cc ('K') | « 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;
1319
1312 var StdlibMathCeil = stdlib.Math.ceil; 1320 var StdlibMathCeil = stdlib.Math.ceil;
1313 var StdlibMathFloor = stdlib.Math.floor; 1321 var StdlibMathFloor = stdlib.Math.floor;
1314 var StdlibMathSqrt = stdlib.Math.sqrt; 1322 var StdlibMathSqrt = stdlib.Math.sqrt;
1315 var StdlibMathAbs = stdlib.Math.abs; 1323 var StdlibMathAbs = stdlib.Math.abs;
1316 var StdlibMathMin = stdlib.Math.min; 1324 var StdlibMathMin = stdlib.Math.min;
1317 var StdlibMathMax = stdlib.Math.max; 1325 var StdlibMathMax = stdlib.Math.max;
1326
1318 var StdlibMathAtan2 = stdlib.Math.atan2; 1327 var StdlibMathAtan2 = stdlib.Math.atan2;
1319 var StdlibMathPow = stdlib.Math.pow; 1328 var StdlibMathPow = stdlib.Math.pow;
1320 var StdlibMathImul = stdlib.Math.imul; 1329 var StdlibMathImul = stdlib.Math.imul;
1330
1321 var fround = stdlib.Math.fround; 1331 var fround = stdlib.Math.fround;
1322 1332
1323 function caller() { 1333 function caller() {
1324 // TODO(bradnelson): Test transendentals when implemented. 1334 // TODO(bradnelson): Test transendentals when implemented.
1325 if (StdlibMathSqrt(123.0) != 11.090536506409418) return 0; 1335 if (StdlibMathSqrt(123.0) != 11.090536506409418) return 0;
1326 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0; 1336 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0;
1327 if (StdlibMathCeil(123.7) != 124.0) return 0; 1337 if (StdlibMathCeil(123.7) != 124.0) return 0;
1328 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0; 1338 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0;
1329 if (StdlibMathFloor(123.7) != 123.0) return 0; 1339 if (StdlibMathFloor(123.7) != 123.0) return 0;
1330 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0; 1340 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0;
1331 if (StdlibMathAbs(-123.0) != 123.0) return 0; 1341 if (StdlibMathAbs(-123.0) != 123.0) return 0;
1332 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0; 1342 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0;
1333 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0; 1343 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0;
1334 if (StdlibMathMin(fround(123.4), 1344 if (StdlibMathMin(fround(123.4),
1335 fround(1236.4)) != fround(123.4)) return 0; 1345 fround(1236.4)) != fround(123.4)) return 0;
1336 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0; 1346 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0;
1337 if (StdlibMathMax(fround(123.4), fround(1236.4)) 1347 if (StdlibMathMax(fround(123.4), fround(1236.4))
1338 != fround(1236.4)) return 0; 1348 != fround(1236.4)) return 0;
1349
1350 if (StdlibMathAcos(0.1) != 1.4706289056333368) return 0;
1351 if (StdlibMathAsin(0.2) != 0.2013579207903308) return 0;
1352 if (StdlibMathAtan(0.2) != 0.19739555984988078) return 0;
1353 if (StdlibMathCos(0.2) != 0.9800665778412416) return 0;
1354 if (StdlibMathSin(0.2) != 0.19866933079506122) return 0;
1355 if (StdlibMathTan(0.2) != 0.2027100355086725) return 0;
1356 if (StdlibMathExp(0.2) != 1.2214027581601699) return 0;
1357 if (StdlibMathLog(0.2) != -1.6094379124341003) return 0;
1358
1339 if (StdlibMathImul(6, 7) != 42) return 0; 1359 if (StdlibMathImul(6, 7) != 42) return 0;
1360 if (StdlibMathAtan2(6.0, 7.0) != 0.7086262721276703) return 0;
1361 if (StdlibMathPow(6.0, 7.0) != 279936.0) return 0;
1362
1340 return 1; 1363 return 1;
1341 } 1364 }
1342 1365
1343 return {caller:caller}; 1366 return {caller:caller};
1344 } 1367 }
1345 1368
1346 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString()); 1369 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString());
1347 assertEquals(1, m.caller()); 1370 assertEquals(1, m.caller());
1348 })(); 1371 })();
1349 1372
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 var a = 0; 1578 var a = 0;
1556 f = 5616315000.000001; 1579 f = 5616315000.000001;
1557 a = ~~f >>>0; 1580 a = ~~f >>>0;
1558 return a | 0; 1581 return a | 0;
1559 } 1582 }
1560 return { main : aaa }; 1583 return { main : aaa };
1561 } 1584 }
1562 var wasm = _WASMEXP_.instantiateModuleFromAsm(asmModule.toString()); 1585 var wasm = _WASMEXP_.instantiateModuleFromAsm(asmModule.toString());
1563 assertEquals(1321347704, wasm.main()); 1586 assertEquals(1321347704, wasm.main());
1564 })(); 1587 })();
OLDNEW
« src/assembler.cc ('K') | « src/wasm/wasm-opcodes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698