| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 m[2] = ((m[i >> 2]|0) + 1) | 0; | 384 m[2] = ((m[i >> 2]|0) + 1) | 0; |
| 385 return m[2] | 0; | 385 return m[2] | 0; |
| 386 } | 386 } |
| 387 | 387 |
| 388 return {caller: caller}; | 388 return {caller: caller}; |
| 389 } | 389 } |
| 390 | 390 |
| 391 assertEquals(7, _WASMEXP_.asmCompileRun(TestInt32HeapAccess.toString())); | 391 assertEquals(7, _WASMEXP_.asmCompileRun(TestInt32HeapAccess.toString())); |
| 392 | 392 |
| 393 | 393 |
| 394 function TestInt32HeapAccessExternal() { |
| 395 var memory = new ArrayBuffer(1024); |
| 396 var memory_int32 = new Int32Array(memory); |
| 397 var module = _WASMEXP_.instantiateModuleFromAsm( |
| 398 TestInt32HeapAccess.toString(), null, memory); |
| 399 module.__init__(); |
| 400 assertEquals(7, module.caller()); |
| 401 assertEquals(7, memory_int32[2]); |
| 402 } |
| 403 |
| 404 TestInt32HeapAccessExternal(); |
| 405 |
| 406 |
| 394 function TestHeapAccessIntTypes() { | 407 function TestHeapAccessIntTypes() { |
| 395 var types = [ | 408 var types = [ |
| 396 ['Int8Array', '>> 0'], | 409 [Int8Array, 'Int8Array', '>> 0'], |
| 397 ['Uint8Array', '>> 0'], | 410 [Uint8Array, 'Uint8Array', '>> 0'], |
| 398 ['Int16Array', '>> 1'], | 411 [Int16Array, 'Int16Array', '>> 1'], |
| 399 ['Uint16Array', '>> 1'], | 412 [Uint16Array, 'Uint16Array', '>> 1'], |
| 400 ['Int32Array', '>> 2'], | 413 [Int32Array, 'Int32Array', '>> 2'], |
| 401 ['Uint32Array', '>> 2'], | 414 [Uint32Array, 'Uint32Array', '>> 2'], |
| 402 ]; | 415 ]; |
| 403 for (var i = 0; i < types.length; i++) { | 416 for (var i = 0; i < types.length; i++) { |
| 404 var code = TestInt32HeapAccess.toString(); | 417 var code = TestInt32HeapAccess.toString(); |
| 405 code = code.replace('Int32Array', types[i][0]); | 418 code = code.replace('Int32Array', types[i][1]); |
| 406 code = code.replace(/>> 2/g, types[i][1]); | 419 code = code.replace(/>> 2/g, types[i][2]); |
| 420 var memory = new ArrayBuffer(1024); |
| 421 var memory_view = new types[i][0](memory); |
| 422 var module = _WASMEXP_.instantiateModuleFromAsm(code, null, memory); |
| 423 module.__init__(); |
| 424 assertEquals(7, module.caller()); |
| 425 assertEquals(7, memory_view[2]); |
| 407 assertEquals(7, _WASMEXP_.asmCompileRun(code)); | 426 assertEquals(7, _WASMEXP_.asmCompileRun(code)); |
| 408 } | 427 } |
| 409 } | 428 } |
| 410 | 429 |
| 411 TestHeapAccessIntTypes(); | 430 TestHeapAccessIntTypes(); |
| 412 | 431 |
| 413 | 432 |
| 414 function TestFloatHeapAccess(stdlib, foreign, buffer) { | 433 function TestFloatHeapAccess(stdlib, foreign, buffer) { |
| 415 "use asm"; | 434 "use asm"; |
| 416 | 435 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 429 i = +f64[i >> 3] == 9.0; | 448 i = +f64[i >> 3] == 9.0; |
| 430 return i|0; | 449 return i|0; |
| 431 } | 450 } |
| 432 | 451 |
| 433 return {caller: caller}; | 452 return {caller: caller}; |
| 434 } | 453 } |
| 435 | 454 |
| 436 assertEquals(1, _WASMEXP_.asmCompileRun(TestFloatHeapAccess.toString())); | 455 assertEquals(1, _WASMEXP_.asmCompileRun(TestFloatHeapAccess.toString())); |
| 437 | 456 |
| 438 | 457 |
| 458 function TestFloatHeapAccessExternal() { |
| 459 var memory = new ArrayBuffer(1024); |
| 460 var memory_float64 = new Float64Array(memory); |
| 461 var module = _WASMEXP_.instantiateModuleFromAsm( |
| 462 TestFloatHeapAccess.toString(), null, memory); |
| 463 module.__init__(); |
| 464 assertEquals(1, module.caller()); |
| 465 assertEquals(9.0, memory_float64[1]); |
| 466 } |
| 467 |
| 468 TestFloatHeapAccessExternal(); |
| 469 |
| 470 |
| 439 function TestConvertI32() { | 471 function TestConvertI32() { |
| 440 "use asm"; | 472 "use asm"; |
| 441 | 473 |
| 442 function caller() { | 474 function caller() { |
| 443 var a = 1.5; | 475 var a = 1.5; |
| 444 if ((~~(a + a)) == 3) { | 476 if ((~~(a + a)) == 3) { |
| 445 return 24; | 477 return 24; |
| 446 } | 478 } |
| 447 return 0; | 479 return 0; |
| 448 } | 480 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 function caller() { | 851 function caller() { |
| 820 return 55; | 852 return 55; |
| 821 } | 853 } |
| 822 return {alt_caller:caller}; | 854 return {alt_caller:caller}; |
| 823 } | 855 } |
| 824 | 856 |
| 825 var module = _WASMEXP_.instantiateModuleFromAsm( | 857 var module = _WASMEXP_.instantiateModuleFromAsm( |
| 826 TestExportNameDifferentFromFunctionName.toString()); | 858 TestExportNameDifferentFromFunctionName.toString()); |
| 827 module.__init__(); | 859 module.__init__(); |
| 828 assertEquals(55, module.alt_caller()); | 860 assertEquals(55, module.alt_caller()); |
| OLD | NEW |