mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 11:44:31 +01:00 
			
		
		
		
	* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import * as assert from '../assert.js';
 | |
| import Builder from '../Builder.js';
 | |
| 
 | |
| async function throwExn() {
 | |
|     throw new Error();
 | |
| }
 | |
| 
 | |
| async function test() {
 | |
|     const loopDepth = 10;
 | |
|     const numCompilations = 1;
 | |
|     const numVars = 30;
 | |
|     const params = [];
 | |
|     params.length = numVars;
 | |
|     params.fill("i32");
 | |
| 
 | |
|     let builder = (new Builder())
 | |
|           .Type().End()
 | |
|           .Function().End()
 | |
|           .Export()
 | |
|               .Function("foo")
 | |
|           .End()
 | |
|           .Code()
 | |
|           .Function("foo", { params, ret: "i32" });
 | |
| 
 | |
|     const makeLoop = (builder, depth) => {
 | |
|         if (depth === 0)
 | |
|             return builder;
 | |
| 
 | |
|         builder = builder
 | |
|             .Loop("i32", (b) => {
 | |
|                   b.GetLocal(0)
 | |
|                     .I32Const(1)
 | |
|                     .I32Sub()
 | |
|                     .TeeLocal(0)
 | |
|                     .GetLocal(0)
 | |
|                     .I32Eqz()
 | |
|                     .BrIf(1);
 | |
| 
 | |
|                 return makeLoop(b, depth - 1).Br(0);
 | |
|             });
 | |
|         return builder
 | |
| 
 | |
|     }
 | |
| 
 | |
|     builder = makeLoop(builder, loopDepth);
 | |
|     builder = builder.End().End();
 | |
| 
 | |
|     const bin = builder.WebAssembly().get();
 | |
| 
 | |
|     let compilations = [];
 | |
|     for (let i = 0; i < numCompilations; ++i) {
 | |
|         compilations.push(WebAssembly.compile(bin));
 | |
|     }
 | |
| 
 | |
|     await Promise.all(compilations);
 | |
| }
 | |
| 
 | |
| assert.asyncTest(test());
 |