| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function createTestBuffers(limit) { |
| 6 let builder = new WasmModuleBuilder(); |
| 7 let body = []; |
| 8 var fct = builder.addFunction("f", kSig_v_v); |
| 9 |
| 10 var l = builder.toBuffer().byteLength; |
| 11 |
| 12 // in the bare bones buffer, the size of the function f |
| 13 // is 0, which is encoded in 1 byte. For the 2^12 case, |
| 14 // we need 2 bytes. Then, the function ends in kExprEnd, |
| 15 // so we need that accounted, too. |
| 16 var remaining = limit - l - 3; |
| 17 |
| 18 for (var i = 0; i < remaining; ++i) body.push(kExprNop); |
| 19 fct.addBody(body); |
| 20 |
| 21 var small_buffer = builder.toBuffer(); |
| 22 // body is now 1 larger than before, because it has the kExpEnd at the end. |
| 23 // replace that with kExprNop, and generate a new buffer. |
| 24 body[body.length-1] = kExprNop; |
| 25 fct.addBody(body); |
| 26 var large_buffer = builder.toBuffer(); |
| 27 return {small: small_buffer, large: large_buffer}; |
| 28 } |
| OLD | NEW |