Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 return {caller:caller}; | 1369 return {caller:caller}; |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 var m = Wasm.instantiateModuleFromAsm(Module.toString()); | 1372 var m = Wasm.instantiateModuleFromAsm(Module.toString()); |
| 1373 assertEquals(1, m.caller()); | 1373 assertEquals(1, m.caller()); |
| 1374 })(); | 1374 })(); |
| 1375 | 1375 |
| 1376 | 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 assertEquals(1, m.func(-1)); | |
|
titzer
2016/03/14 09:48:39
Can you add a couple more input values, e.g. aroun
bradn
2016/03/14 17:07:31
Done.
Actually, at this point I think I'm going t
| |
| 1389 })(); | |
| 1390 | |
| 1391 | |
| 1392 (function TestAbsFloat() { | |
| 1393 function Module(stdlib) { | |
| 1394 "use asm"; | |
| 1395 var fround = stdlib.Math.fround; | |
| 1396 var abs = stdlib.Math.abs; | |
| 1397 function func(x) { | |
| 1398 x = fround(x); | |
| 1399 x = abs(x); | |
| 1400 return +x; | |
| 1401 } | |
| 1402 return {func:func}; | |
| 1403 } | |
| 1404 var m = Wasm.instantiateModuleFromAsm(Module.toString()); | |
| 1405 assertEquals(1, m.func(-1)); | |
| 1406 })(); | |
| 1407 | |
| 1408 | |
| 1409 (function TestFloatAsDouble() { | |
| 1410 function Module(stdlib) { | |
| 1411 "use asm"; | |
| 1412 var fround = stdlib.Math.fround; | |
| 1413 var abs = stdlib.Math.abs; | |
| 1414 function func() { | |
| 1415 var x = fround(1.0); | |
| 1416 return +fround(x); | |
| 1417 } | |
| 1418 return {func:func}; | |
| 1419 } | |
| 1420 var m = Wasm.instantiateModuleFromAsm(Module.toString()); | |
| 1421 assertEquals(1, m.func()); | |
| 1422 })(); | |
| 1423 | |
| 1424 | |
| 1377 (function TestOr() { | 1425 (function TestOr() { |
| 1378 function Module() { | 1426 function Module() { |
| 1379 "use asm"; | 1427 "use asm"; |
| 1380 function func() { | 1428 function func() { |
| 1381 var x = 1; | 1429 var x = 1; |
| 1382 var y = 2; | 1430 var y = 2; |
| 1383 return (x | y) | 0; | 1431 return (x | y) | 0; |
| 1384 } | 1432 } |
| 1385 return {func: func}; | 1433 return {func: func}; |
| 1386 } | 1434 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 var a = 0; | 1629 var a = 0; |
| 1582 f = 5616315000.000001; | 1630 f = 5616315000.000001; |
| 1583 a = ~~f >>>0; | 1631 a = ~~f >>>0; |
| 1584 return a | 0; | 1632 return a | 0; |
| 1585 } | 1633 } |
| 1586 return { main : aaa }; | 1634 return { main : aaa }; |
| 1587 } | 1635 } |
| 1588 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); | 1636 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); |
| 1589 assertEquals(1321347704, wasm.main()); | 1637 assertEquals(1321347704, wasm.main()); |
| 1590 })(); | 1638 })(); |
| OLD | NEW |