| 1 |
// Generates large .wasm files for use in ../limits.js. |
| 2 |
// Make sure you are running this script from a release build or you will be sad. |
| 3 |
|
| 4 |
loadRelativeToScript("../wasm-binary.js"); |
| 5 |
|
| 6 |
function moduleNRecGroupNTypes(numRecs, numTypes) { |
| 7 |
let types = []; |
| 8 |
for (let i = 0; i < numTypes; i++) { |
| 9 |
types.push({ kind: FuncCode, args: [], ret: [] }); |
| 10 |
} |
| 11 |
let recs = []; |
| 12 |
for (let i = 0; i < numRecs; i++) { |
| 13 |
recs.push(recGroup(types)); |
| 14 |
} |
| 15 |
return new Uint8Array(compressLZ4(new Uint8Array(moduleWithSections([typeSection(recs)])).buffer)); |
| 16 |
} |
| 17 |
|
| 18 |
os.file.writeTypedArrayToFile("wasm-gc-limits-r1M-t1.wasm", moduleNRecGroupNTypes(1_000_000, 1)); |
| 19 |
os.file.writeTypedArrayToFile("wasm-gc-limits-r1M1-t1.wasm", moduleNRecGroupNTypes(1_000_001, 1)); |
| 20 |
os.file.writeTypedArrayToFile("wasm-gc-limits-r1-t1M.wasm", moduleNRecGroupNTypes(1, 1_000_000)); |
| 21 |
os.file.writeTypedArrayToFile("wasm-gc-limits-r1-t1M1.wasm", moduleNRecGroupNTypes(1, 1_000_001)); |
| 22 |
os.file.writeTypedArrayToFile("wasm-gc-limits-r2-t500K.wasm", moduleNRecGroupNTypes(2, 500_000)); |
| 23 |
os.file.writeTypedArrayToFile("wasm-gc-limits-r2-t500K1.wasm", moduleNRecGroupNTypes(2, 500_001)); |
| 24 |
|
| 25 |
function moduleLargeStruct(size) { |
| 26 |
let structInitializer = []; |
| 27 |
for (let i = 0; i < size; i++) { |
| 28 |
structInitializer.push(I64ConstCode); |
| 29 |
structInitializer.push(...varU32(0)); |
| 30 |
} |
| 31 |
return new Uint8Array(compressLZ4(new Uint8Array(moduleWithSections([ |
| 32 |
typeSection([ |
| 33 |
{ |
| 34 |
kind: StructCode, |
| 35 |
fields: Array(size).fill(I64Code) |
| 36 |
}, |
| 37 |
{ |
| 38 |
kind: FuncCode, |
| 39 |
args: [], |
| 40 |
ret: [AnyRefCode] |
| 41 |
} |
| 42 |
]), |
| 43 |
declSection([1, 1]), |
| 44 |
exportSection([ |
| 45 |
{name: "makeLargeStructDefault", funcIndex: 0}, |
| 46 |
{name: "makeLargeStruct", funcIndex: 1} |
| 47 |
]), |
| 48 |
bodySection([ |
| 49 |
funcBody({ |
| 50 |
locals: [], |
| 51 |
body: [ |
| 52 |
GcPrefix, |
| 53 |
StructNewDefault, |
| 54 |
...varU32(0) |
| 55 |
], |
| 56 |
}), |
| 57 |
funcBody({ |
| 58 |
locals: [], |
| 59 |
body: [ |
| 60 |
...structInitializer, |
| 61 |
GcPrefix, |
| 62 |
StructNew, |
| 63 |
...varU32(0) |
| 64 |
], |
| 65 |
}), |
| 66 |
]), |
| 67 |
])).buffer)); |
| 68 |
} |
| 69 |
|
| 70 |
os.file.writeTypedArrayToFile("wasm-gc-limits-s10K.wasm", moduleLargeStruct(10_000)); |
| 71 |
os.file.writeTypedArrayToFile("wasm-gc-limits-s10K1.wasm", moduleLargeStruct(10_001)); |