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 function IntTest() { | 5 function IntTest() { |
6 "use asm"; | 6 "use asm"; |
7 function sum(a, b) { | 7 function sum(a, b) { |
8 a = a|0; | 8 a = a|0; |
9 b = b|0; | 9 b = b|0; |
10 var c = (b + 1)|0 | 10 var c = (b + 1)|0 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 } | 505 } |
506 return 0; | 506 return 0; |
507 } | 507 } |
508 | 508 |
509 return {caller:caller}; | 509 return {caller:caller}; |
510 } | 510 } |
511 | 511 |
512 assertEquals(28, WASM.asmCompileRun(TestModDoubleNegative.toString())); | 512 assertEquals(28, WASM.asmCompileRun(TestModDoubleNegative.toString())); |
513 */ | 513 */ |
514 | 514 |
515 function TestGlobals() { | 515 function TestNamedFunctions() { |
516 "use asm"; | |
517 | |
518 var a = 0.0; | |
519 var b = 0.0; | |
520 var c = 0.0; | |
521 | |
522 function add() { | |
523 c = a + b; | |
524 } | |
525 | |
526 function caller() { | |
527 a = 23.75; | |
528 b = 7.75; | |
529 add(); | |
530 return (~~c)|0; | |
531 } | |
532 | |
533 return {caller:caller}; | |
534 } | |
535 | |
536 assertEquals(31, WASM.asmCompileRun(TestGlobals.toString())); | |
537 | |
538 function TestGlobalsWithInit() { | |
539 "use asm"; | 516 "use asm"; |
540 | 517 |
541 var a = 0.0; | 518 var a = 0.0; |
542 var b = 0.0; | 519 var b = 0.0; |
543 | 520 |
544 function add() { | 521 function add() { |
545 return +(a + b); | 522 return +(a + b); |
546 } | 523 } |
547 | 524 |
548 function init() { | 525 function init() { |
549 a = 43.25; | 526 a = 43.25; |
550 b = 34.25; | 527 b = 34.25; |
551 } | 528 } |
552 | 529 |
553 return {init:init, | 530 return {init:init, |
554 add:add}; | 531 add:add}; |
555 } | 532 } |
556 | 533 |
557 var module = WASM.instantiateModuleFromAsm(TestGlobalsWithInit.toString()); | 534 var module = WASM.instantiateModuleFromAsm(TestNamedFunctions.toString()); |
558 module.init(); | 535 module.init(); |
559 assertEquals(77.5, module.add()); | 536 assertEquals(77.5, module.add()); |
| 537 |
| 538 function TestGlobalsWithInit() { |
| 539 "use asm"; |
| 540 |
| 541 var a = 43.25; |
| 542 var b = 34.25; |
| 543 |
| 544 function add() { |
| 545 return +(a + b); |
| 546 } |
| 547 |
| 548 return {add:add}; |
| 549 } |
| 550 |
| 551 var module = WASM.instantiateModuleFromAsm(TestGlobalsWithInit.toString()); |
| 552 module.__init__(); |
| 553 assertEquals(77.5, module.add()); |
OLD | NEW |