mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 19:53:50 +01:00 
			
		
		
		
	sourceRevisionAtLastExport: 33f2fb0e53d135f0ee17cfccd9d993eb2a6f47de targetRevisionAtLastExport: 31340cbd9add103f586d501b0c3354b7b182abc0
		
			
				
	
	
		
			86 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| // Copyright 2017 the V8 project authors. All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style license that can be
 | |
| // found in the LICENSE file.
 | |
| 
 | |
| // Flags: --allow-natives-syntax --validate-asm
 | |
| 
 | |
| // This file contains test cases that are particularly interesting because they
 | |
| // omit the usual call-site coercion of function calls that target well-known
 | |
| // stdlib functions.
 | |
| 
 | |
| (function SuccessStdlibWithoutAnnotation() {
 | |
|   function Module(stdlib, imports, heap) {
 | |
|     "use asm";
 | |
|     var imul = stdlib.Math.imul;
 | |
|     function f(a, b) {
 | |
|       a = a | 0;
 | |
|       b = b | 0;
 | |
|       var r = 0;
 | |
|       r = imul(a, b);
 | |
|       return r | 0;
 | |
|     }
 | |
|     return { f:f };
 | |
|   }
 | |
|   var m = Module(this);
 | |
|   assertTrue(%IsAsmWasmCode(Module));
 | |
|   assertEquals(966, m.f(23, 42));
 | |
|   assertEquals(-0x0fffffff, m.f(0x7ffffff, 0x7ffffff));
 | |
| })();
 | |
| 
 | |
| (function SuccessStdlibWithoutAnnotationThenRound() {
 | |
|   function Module(stdlib, imports, heap) {
 | |
|     "use asm";
 | |
|     var fround = stdlib.Math.fround;
 | |
|     var imul = stdlib.Math.imul;
 | |
|     function f(a, b) {
 | |
|       a = a | 0;
 | |
|       b = b | 0;
 | |
|       var r = fround(0);
 | |
|       r = fround(imul(a, b));
 | |
|       return fround(r);
 | |
|     }
 | |
|     return { f:f };
 | |
|   }
 | |
|   var m = Module(this);
 | |
|   assertTrue(%IsAsmWasmCode(Module));
 | |
|   assertEquals(966, m.f(23, 42));
 | |
|   assertEquals(-0x0fffffff - 1, m.f(0x7ffffff, 0x7ffffff));
 | |
| })();
 | |
| 
 | |
| (function FailureStdlibWithoutAnnotationMismatch() {
 | |
|   function Module(stdlib, imports, heap) {
 | |
|     "use asm";
 | |
|     var fround = stdlib.Math.fround;
 | |
|     var imul = stdlib.Math.imul;
 | |
|     function f(a, b) {
 | |
|       a = a | 0;
 | |
|       b = b | 0;
 | |
|       var r = fround(0);
 | |
|       r = imul(a, b);
 | |
|       return r | 0;
 | |
|     }
 | |
|     return { f:f };
 | |
|   }
 | |
|   var m = Module(this);
 | |
|   assertFalse(%IsAsmWasmCode(Module));
 | |
|   assertEquals(966, m.f(23, 42));
 | |
|   assertEquals(-0x0fffffff, m.f(0x7ffffff, 0x7ffffff));
 | |
| })();
 | |
| 
 | |
| (function SuccessStdlibWithoutAnnotationUsedInReturn() {
 | |
|   function Module(stdlib, imports, heap) {
 | |
|     "use asm";
 | |
|     var imul = stdlib.Math.imul;
 | |
|     function f(a, b) {
 | |
|       a = a | 0;
 | |
|       b = b | 0;
 | |
|       return imul(a, b);
 | |
|     }
 | |
|     return { f:f };
 | |
|   }
 | |
|   var m = Module(this);
 | |
|   assertTrue(%IsAsmWasmCode(Module));
 | |
|   assertEquals(966, m.f(23, 42));
 | |
|   assertEquals(-0x0fffffff, m.f(0x7ffffff, 0x7ffffff));
 | |
| })();
 |