diff options
author | Daniel Wirtz <dcode@dcode.io> | 2017-06-07 20:28:08 +0200 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-06-07 11:28:08 -0700 |
commit | 2c220f5cebd915447e786f0b365b0bac1e2f719f (patch) | |
tree | 103ed218e637ff868e7ee067d51c25bdeb1a6f9a /test | |
parent | 3f0db5a7aafaaa4de713ff3ba3c3bbeb59fe566e (diff) | |
download | binaryen-2c220f5cebd915447e786f0b365b0bac1e2f719f.tar.gz binaryen-2c220f5cebd915447e786f0b365b0bac1e2f719f.tar.bz2 binaryen-2c220f5cebd915447e786f0b365b0bac1e2f719f.zip |
Update binaryen-c/binaryen.js, fixes #1028, fixes #1029 (#1030)
This PR adds global variable support (addGlobal, getGlobal, setGlobal), host operations (currentMemory, growMemory), a few utility functions (removeImport, removeExport, getFunctionTypeBySignature with the latter being scheduled for removal once a better alternative is in place) and it introduces an additional argument to specify the result type in BinaryenBlock (effectively breaking the C-API but retaining previous behaviour by introducing the BinaryenUndefined() type for this purpose). Additionally, it enables compilation with exception support in build-js.sh as exceptions are thrown and caught when optimizing endless loops, intentionally resulting in an unreachable opcode. Affected test cases have been updated accordingly.
Diffstat (limited to 'test')
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 10 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 24 | ||||
-rw-r--r-- | test/example/c-api-relooper-unreachable-if.cpp | 62 | ||||
-rw-r--r-- | test/example/c-api-unused-mem.cpp | 10 | ||||
-rw-r--r-- | test/example/relooper-fuzz.c | 22 | ||||
-rw-r--r-- | test/example/relooper-fuzz1.c | 36 |
6 files changed, 88 insertions, 76 deletions
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index b2218993c..726dc9ce8 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -182,7 +182,7 @@ void test_core() { makeBinary(module, BinaryenGtFloat64(), 4), makeBinary(module, BinaryenGeFloat32(), 3), // All the rest - BinaryenBlock(module, NULL, NULL, 0), // block with no name + BinaryenBlock(module, NULL, NULL, 0, -1), // block with no name and no type BinaryenIf(module, temp1, temp2, temp3), BinaryenIf(module, temp4, temp5, NULL), BinaryenLoop(module, "in", makeInt32(module, 0)), @@ -224,11 +224,11 @@ void test_core() { BinaryenExpressionPrint(valueList[3]); // test printing a standalone expression // Make the main body of the function. and one block with a return value, one without - BinaryenExpressionRef value = BinaryenBlock(module, "the-value", valueList, sizeof(valueList) / sizeof(BinaryenExpressionRef)); + BinaryenExpressionRef value = BinaryenBlock(module, "the-value", valueList, sizeof(valueList) / sizeof(BinaryenExpressionRef), -1); BinaryenExpressionRef droppedValue = BinaryenDrop(module, value); - BinaryenExpressionRef nothing = BinaryenBlock(module, "the-nothing", &droppedValue, 1); + BinaryenExpressionRef nothing = BinaryenBlock(module, "the-nothing", &droppedValue, 1, -1); BinaryenExpressionRef bodyList[] = { nothing, makeInt32(module, 42) }; - BinaryenExpressionRef body = BinaryenBlock(module, "the-body", bodyList, 2); + BinaryenExpressionRef body = BinaryenBlock(module, "the-body", bodyList, 2, -1); // Create the function BinaryenType localTypes[] = { BinaryenInt32() }; @@ -460,7 +460,7 @@ void test_relooper() { { // return in a block RelooperRef relooper = RelooperCreate(); BinaryenExpressionRef listList[] = { makeCallCheck(module, 42), BinaryenReturn(module, makeInt32(module, 1337)) }; - BinaryenExpressionRef list = BinaryenBlock(module, "the-list", listList, 2); + BinaryenExpressionRef list = BinaryenBlock(module, "the-list", listList, 2, -1); RelooperBlockRef block = RelooperAddBlock(relooper, list); BinaryenExpressionRef body = RelooperRenderAndDispose(relooper, block, 0, module); BinaryenFunctionRef sinker = BinaryenAddFunction(module, "return", i, localTypes, 1, body); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 2c25a70ab..a5275bad5 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -1091,7 +1091,7 @@ int main() { expressions[11] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3)); expressions[12] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7)); { - BinaryenIndex paramTypes[] = { 1, 2, 3, 4 }; + BinaryenType paramTypes[] = { 1, 2, 3, 4 }; functionTypes[0] = BinaryenAddFunctionType(the_module, "iiIfF", 1, paramTypes, 4); } expressions[13] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); @@ -1280,7 +1280,7 @@ int main() { expressions[196] = BinaryenBinary(the_module, 62, expressions[195], expressions[194]); { BinaryenExpressionRef children[] = { 0 }; - expressions[197] = BinaryenBlock(the_module, NULL, children, 0); + expressions[197] = BinaryenBlock(the_module, NULL, children, 0, BinaryenUndefined()); } expressions[198] = BinaryenIf(the_module, expressions[13], expressions[14], expressions[15]); expressions[199] = BinaryenIf(the_module, expressions[16], expressions[17], expressions[0]); @@ -1348,24 +1348,24 @@ int main() { ) { BinaryenExpressionRef children[] = { expressions[30], expressions[32], expressions[34], expressions[36], expressions[38], expressions[40], expressions[42], expressions[44], expressions[46], expressions[48], expressions[50], expressions[52], expressions[54], expressions[56], expressions[58], expressions[60], expressions[62], expressions[64], expressions[66], expressions[68], expressions[70], expressions[72], expressions[74], expressions[76], expressions[78], expressions[80], expressions[82], expressions[84], expressions[86], expressions[88], expressions[90], expressions[92], expressions[94], expressions[96], expressions[98], expressions[100], expressions[103], expressions[106], expressions[109], expressions[112], expressions[115], expressions[118], expressions[121], expressions[124], expressions[127], expressions[130], expressions[133], expressions[136], expressions[139], expressions[142], expressions[145], expressions[148], expressions[151], expressions[154], expressions[157], expressions[160], expressions[163], expressions[166], expressions[169], expressions[172], expressions[175], expressions[178], expressions[181], expressions[184], expressions[187], expressions[190], expressions[193], expressions[196], expressions[197], expressions[198], expressions[199], expressions[201], expressions[203], expressions[204], expressions[206], expressions[208], expressions[209], expressions[210], expressions[212], expressions[214], expressions[217], expressions[220], expressions[222], expressions[224], expressions[227], expressions[229], expressions[231], expressions[233], expressions[235], expressions[236], expressions[237], expressions[238], expressions[240], expressions[241], expressions[242] }; - expressions[243] = BinaryenBlock(the_module, "the-value", children, 95); + expressions[243] = BinaryenBlock(the_module, "the-value", children, 95, BinaryenUndefined()); } expressions[244] = BinaryenDrop(the_module, expressions[243]); { BinaryenExpressionRef children[] = { expressions[244] }; - expressions[245] = BinaryenBlock(the_module, "the-nothing", children, 1); + expressions[245] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenUndefined()); } expressions[246] = BinaryenConst(the_module, BinaryenLiteralInt32(42)); { BinaryenExpressionRef children[] = { expressions[245], expressions[246] }; - expressions[247] = BinaryenBlock(the_module, "the-body", children, 2); + expressions[247] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenUndefined()); } { BinaryenType varTypes[] = { 1 }; functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[247]); } { - BinaryenIndex paramTypes[] = { 1, 4 }; + BinaryenType paramTypes[] = { 1, 4 }; functionTypes[1] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); } BinaryenAddImport(the_module, "an-imported", "module", "base", functionTypes[1]); @@ -1383,7 +1383,7 @@ int main() { BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentOffsets, segmentSizes, 1); } { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } expressions[249] = BinaryenNop(the_module); @@ -1393,7 +1393,7 @@ int main() { } BinaryenSetStart(the_module, functions[1]); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); @@ -1937,11 +1937,11 @@ int main() { the_module = BinaryenModuleCreate(); expressions[size_t(NULL)] = BinaryenExpressionRef(NULL); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[0] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } { - BinaryenIndex paramTypes[] = { 1 }; + BinaryenType paramTypes[] = { 1 }; functionTypes[1] = BinaryenAddFunctionType(the_module, "vi", 0, paramTypes, 1); } BinaryenAddImport(the_module, "check", "module", "check", functionTypes[1]); @@ -2367,7 +2367,7 @@ int main() { functions[13] = BinaryenAddFunction(the_module, "duffs-device", functionTypes[0], varTypes, 7, expressions[135]); } { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "i", 1, paramTypes, 0); } the_relooper = RelooperCreate(); @@ -2380,7 +2380,7 @@ int main() { expressions[139] = BinaryenReturn(the_module, expressions[138]); { BinaryenExpressionRef children[] = { expressions[137], expressions[139] }; - expressions[140] = BinaryenBlock(the_module, "the-list", children, 2); + expressions[140] = BinaryenBlock(the_module, "the-list", children, 2, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[140]); expressions[141] = RelooperRenderAndDispose(the_relooper, relooperBlocks[0], 0, the_module); diff --git a/test/example/c-api-relooper-unreachable-if.cpp b/test/example/c-api-relooper-unreachable-if.cpp index 590db8e67..b6f7f8b04 100644 --- a/test/example/c-api-relooper-unreachable-if.cpp +++ b/test/example/c-api-relooper-unreachable-if.cpp @@ -25,11 +25,11 @@ int main() { expressions[4] = BinaryenReturn(the_module, expressions[0]); { BinaryenExpressionRef children[] = { expressions[3], expressions[4] }; - expressions[5] = BinaryenBlock(the_module, "bb0", children, 2); + expressions[5] = BinaryenBlock(the_module, "bb0", children, 2, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[5]); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[0] = BinaryenAddFunctionType(the_module, "rustfn-0-40", 0, paramTypes, 0); } expressions[6] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -50,7 +50,7 @@ int main() { expressions[13] = BinaryenReturn(the_module, expressions[0]); { BinaryenExpressionRef children[] = { expressions[12], expressions[13] }; - expressions[14] = BinaryenBlock(the_module, "bb0", children, 2); + expressions[14] = BinaryenBlock(the_module, "bb0", children, 2, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[14]); expressions[15] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -67,18 +67,18 @@ int main() { the_relooper = RelooperCreate(); { BinaryenExpressionRef children[] = { 0 }; - expressions[19] = BinaryenBlock(the_module, "bb0", children, 0); + expressions[19] = BinaryenBlock(the_module, "bb0", children, 0, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[19]); { BinaryenExpressionRef children[] = { 0 }; - expressions[20] = BinaryenBlock(the_module, "bb1", children, 0); + expressions[20] = BinaryenBlock(the_module, "bb1", children, 0, BinaryenUndefined()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[20]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[1], relooperBlocks[1], expressions[0], expressions[0]); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[1] = BinaryenAddFunctionType(the_module, "rustfn-0-42", 0, paramTypes, 0); } expressions[21] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -99,7 +99,7 @@ int main() { expressions[28] = BinaryenReturn(the_module, expressions[0]); { BinaryenExpressionRef children[] = { expressions[27], expressions[28] }; - expressions[29] = BinaryenBlock(the_module, "bb0", children, 2); + expressions[29] = BinaryenBlock(the_module, "bb0", children, 2, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[29]); expressions[30] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -120,7 +120,7 @@ int main() { expressions[37] = BinaryenReturn(the_module, expressions[0]); { BinaryenExpressionRef children[] = { expressions[36], expressions[37] }; - expressions[38] = BinaryenBlock(the_module, "bb0", children, 2); + expressions[38] = BinaryenBlock(the_module, "bb0", children, 2, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[38]); expressions[39] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -140,7 +140,7 @@ int main() { expressions[45] = BinaryenGetLocal(the_module, 1, 1); expressions[46] = BinaryenSetLocal(the_module, 2, expressions[45]); { - BinaryenIndex paramTypes[] = { 1 }; + BinaryenType paramTypes[] = { 1 }; functionTypes[2] = BinaryenAddFunctionType(the_module, "print_i32", 0, paramTypes, 1); } BinaryenAddImport(the_module, "print_i32", "spectest", "print", functionTypes[2]); @@ -151,7 +151,7 @@ int main() { } { BinaryenExpressionRef children[] = { expressions[44], expressions[46], expressions[48] }; - expressions[49] = BinaryenBlock(the_module, "bb0", children, 3); + expressions[49] = BinaryenBlock(the_module, "bb0", children, 3, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[49]); expressions[50] = BinaryenGetLocal(the_module, 3, 1); @@ -160,12 +160,12 @@ int main() { expressions[53] = BinaryenReturn(the_module, expressions[0]); { BinaryenExpressionRef children[] = { expressions[52], expressions[53] }; - expressions[54] = BinaryenBlock(the_module, "bb1", children, 2); + expressions[54] = BinaryenBlock(the_module, "bb1", children, 2, BinaryenUndefined()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[54]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); { - BinaryenIndex paramTypes[] = { 1 }; + BinaryenType paramTypes[] = { 1 }; functionTypes[3] = BinaryenAddFunctionType(the_module, "rustfn-0-49", 0, paramTypes, 1); } expressions[55] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -207,7 +207,7 @@ int main() { expressions[83] = BinaryenStore(the_module, 4, 4, 0, expressions[81], expressions[74], 1); { BinaryenExpressionRef children[] = { expressions[60], expressions[62], expressions[68], expressions[80], expressions[82], expressions[83] }; - expressions[84] = BinaryenBlock(the_module, "bb0", children, 6); + expressions[84] = BinaryenBlock(the_module, "bb0", children, 6, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[84]); expressions[85] = BinaryenGetLocal(the_module, 3, 1); @@ -224,7 +224,7 @@ int main() { expressions[96] = BinaryenReturn(the_module, expressions[95]); { BinaryenExpressionRef children[] = { expressions[87], expressions[89], expressions[91], expressions[94], expressions[96] }; - expressions[97] = BinaryenBlock(the_module, "bb1", children, 5); + expressions[97] = BinaryenBlock(the_module, "bb1", children, 5, BinaryenUndefined()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[97]); expressions[98] = BinaryenGetLocal(the_module, 3, 1); @@ -234,7 +234,7 @@ int main() { relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[100]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[0]); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[4] = BinaryenAddFunctionType(the_module, "rustfn-0-54", 1, paramTypes, 0); } expressions[101] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -258,7 +258,7 @@ int main() { expressions[108] = BinaryenSetLocal(the_module, 4, expressions[107]); { BinaryenExpressionRef children[] = { expressions[106], expressions[108] }; - expressions[109] = BinaryenBlock(the_module, "bb0", children, 2); + expressions[109] = BinaryenBlock(the_module, "bb0", children, 2, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[109]); expressions[110] = BinaryenGetLocal(the_module, 4, 1); @@ -284,7 +284,7 @@ int main() { expressions[130] = BinaryenStore(the_module, 4, 4, 0, expressions[128], expressions[121], 1); { BinaryenExpressionRef children[] = { expressions[115], expressions[127], expressions[129], expressions[130] }; - expressions[131] = BinaryenBlock(the_module, "bb1", children, 4); + expressions[131] = BinaryenBlock(the_module, "bb1", children, 4, BinaryenUndefined()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[131]); expressions[132] = BinaryenGetLocal(the_module, 5, 1); @@ -299,7 +299,7 @@ int main() { } { BinaryenExpressionRef children[] = { expressions[134], expressions[136], expressions[138] }; - expressions[139] = BinaryenBlock(the_module, "bb2", children, 3); + expressions[139] = BinaryenBlock(the_module, "bb2", children, 3, BinaryenUndefined()); } relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[139]); expressions[140] = BinaryenGetLocal(the_module, 3, 1); @@ -313,7 +313,7 @@ int main() { expressions[148] = BinaryenReturn(the_module, expressions[147]); { BinaryenExpressionRef children[] = { expressions[141], expressions[143], expressions[146], expressions[148] }; - expressions[149] = BinaryenBlock(the_module, "bb3", children, 4); + expressions[149] = BinaryenBlock(the_module, "bb3", children, 4, BinaryenUndefined()); } relooperBlocks[3] = RelooperAddBlock(the_relooper, expressions[149]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); @@ -325,7 +325,7 @@ int main() { RelooperAddBranch(relooperBlocks[1], relooperBlocks[4], expressions[0], expressions[0]); RelooperAddBranch(relooperBlocks[2], relooperBlocks[3], expressions[0], expressions[0]); { - BinaryenIndex paramTypes[] = { 1, 1 }; + BinaryenType paramTypes[] = { 1, 1 }; functionTypes[5] = BinaryenAddFunctionType(the_module, "rustfn-0-57", 1, paramTypes, 2); } expressions[153] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -340,7 +340,7 @@ int main() { } BinaryenAddExport(the_module, "main", "main"); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[6] = BinaryenAddFunctionType(the_module, "__wasm_start", 0, paramTypes, 0); } { @@ -361,7 +361,7 @@ int main() { expressions[163] = BinaryenDrop(the_module, expressions[162]); { BinaryenExpressionRef children[] = { expressions[159], expressions[163] }; - expressions[164] = BinaryenBlock(the_module, NULL, children, 2); + expressions[164] = BinaryenBlock(the_module, NULL, children, 2, BinaryenUndefined()); } BinaryenAddExport(the_module, "__wasm_start", "rust_entry"); { @@ -401,7 +401,7 @@ int main() { expressions[193] = BinaryenStore(the_module, 4, 4, 0, expressions[191], expressions[184], 1); { BinaryenExpressionRef children[] = { expressions[166], expressions[168], expressions[170], expressions[172], expressions[178], expressions[190], expressions[192], expressions[193] }; - expressions[194] = BinaryenBlock(the_module, "bb0", children, 8); + expressions[194] = BinaryenBlock(the_module, "bb0", children, 8, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[194]); expressions[195] = BinaryenGetLocal(the_module, 6, 1); @@ -414,7 +414,7 @@ int main() { expressions[202] = BinaryenReturn(the_module, expressions[201]); { BinaryenExpressionRef children[] = { expressions[197], expressions[200], expressions[202] }; - expressions[203] = BinaryenBlock(the_module, "bb1", children, 3); + expressions[203] = BinaryenBlock(the_module, "bb1", children, 3, BinaryenUndefined()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[203]); expressions[204] = BinaryenGetLocal(the_module, 6, 1); @@ -424,7 +424,7 @@ int main() { relooperBlocks[2] = RelooperAddBlock(the_relooper, expressions[206]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[2], expressions[0], expressions[0]); { - BinaryenIndex paramTypes[] = { 1, 1 }; + BinaryenType paramTypes[] = { 1, 1 }; functionTypes[7] = BinaryenAddFunctionType(the_module, "rustfn-0-13", 1, paramTypes, 2); } expressions[207] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -453,11 +453,11 @@ int main() { expressions[222] = BinaryenReturn(the_module, expressions[221]); { BinaryenExpressionRef children[] = { expressions[212], expressions[214], expressions[217], expressions[220], expressions[222] }; - expressions[223] = BinaryenBlock(the_module, "bb0", children, 5); + expressions[223] = BinaryenBlock(the_module, "bb0", children, 5, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[223]); { - BinaryenIndex paramTypes[] = { 1 }; + BinaryenType paramTypes[] = { 1 }; functionTypes[8] = BinaryenAddFunctionType(the_module, "rustfn-0-22", 1, paramTypes, 1); } expressions[224] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -491,11 +491,11 @@ int main() { expressions[244] = BinaryenReturn(the_module, expressions[243]); { BinaryenExpressionRef children[] = { expressions[229], expressions[231], expressions[233], expressions[235], expressions[239], expressions[242], expressions[244] }; - expressions[245] = BinaryenBlock(the_module, "bb0", children, 7); + expressions[245] = BinaryenBlock(the_module, "bb0", children, 7, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[245]); { - BinaryenIndex paramTypes[] = { 1, 1 }; + BinaryenType paramTypes[] = { 1, 1 }; functionTypes[9] = BinaryenAddFunctionType(the_module, "rustfn-0-33", 1, paramTypes, 2); } expressions[246] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -529,11 +529,11 @@ int main() { expressions[266] = BinaryenReturn(the_module, expressions[265]); { BinaryenExpressionRef children[] = { expressions[251], expressions[253], expressions[255], expressions[257], expressions[261], expressions[264], expressions[266] }; - expressions[267] = BinaryenBlock(the_module, "bb0", children, 7); + expressions[267] = BinaryenBlock(the_module, "bb0", children, 7, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[267]); { - BinaryenIndex paramTypes[] = { 1, 1 }; + BinaryenType paramTypes[] = { 1, 1 }; functionTypes[10] = BinaryenAddFunctionType(the_module, "rustfn-0-37", 1, paramTypes, 2); } expressions[268] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); diff --git a/test/example/c-api-unused-mem.cpp b/test/example/c-api-unused-mem.cpp index 69bee351f..a0de5637b 100644 --- a/test/example/c-api-unused-mem.cpp +++ b/test/example/c-api-unused-mem.cpp @@ -22,7 +22,7 @@ int main() { the_relooper = RelooperCreate(); { BinaryenExpressionRef children[] = { 0 }; - expressions[1] = BinaryenBlock(the_module, "bb0", children, 0); + expressions[1] = BinaryenBlock(the_module, "bb0", children, 0, BinaryenUndefined()); } relooperBlocks[0] = RelooperAddBlock(the_relooper, expressions[1]); expressions[2] = BinaryenGetLocal(the_module, 0, 1); @@ -31,12 +31,12 @@ int main() { expressions[5] = BinaryenReturn(the_module, expressions[0]); { BinaryenExpressionRef children[] = { expressions[4], expressions[5] }; - expressions[6] = BinaryenBlock(the_module, "bb1", children, 2); + expressions[6] = BinaryenBlock(the_module, "bb1", children, 2, BinaryenUndefined()); } relooperBlocks[1] = RelooperAddBlock(the_relooper, expressions[6]); RelooperAddBranch(relooperBlocks[0], relooperBlocks[1], expressions[0], expressions[0]); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[0] = BinaryenAddFunctionType(the_module, "rustfn-0-3", 0, paramTypes, 0); } expressions[7] = BinaryenConst(the_module, BinaryenLiteralInt32(0)); @@ -51,7 +51,7 @@ int main() { } BinaryenAddExport(the_module, "main", "main"); { - BinaryenIndex paramTypes[] = { 0 }; + BinaryenType paramTypes[] = { 0 }; functionTypes[1] = BinaryenAddFunctionType(the_module, "__wasm_start", 0, paramTypes, 0); } { @@ -69,7 +69,7 @@ int main() { } { BinaryenExpressionRef children[] = { expressions[13], expressions[14] }; - expressions[15] = BinaryenBlock(the_module, NULL, children, 2); + expressions[15] = BinaryenBlock(the_module, NULL, children, 2, BinaryenUndefined()); } BinaryenAddExport(the_module, "__wasm_start", "rust_entry"); { diff --git a/test/example/relooper-fuzz.c b/test/example/relooper-fuzz.c index 9fd11096f..d813c76a9 100644 --- a/test/example/relooper-fuzz.c +++ b/test/example/relooper-fuzz.c @@ -56,7 +56,7 @@ int main() { BinaryenLoad(module, 4, 0, 0, 0, BinaryenInt32(), BinaryenConst(module, BinaryenLiteralInt32(4))) ); BinaryenExpressionRef checkBodyList[] = { halter, incer, debugger, returner }; - BinaryenExpressionRef checkBody = BinaryenBlock(module, NULL, checkBodyList, sizeof(checkBodyList) / sizeof(BinaryenExpressionRef)); + BinaryenExpressionRef checkBody = BinaryenBlock(module, NULL, checkBodyList, sizeof(checkBodyList) / sizeof(BinaryenExpressionRef), BinaryenUndefined()); BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", BinaryenInt32(), NULL, 0); BinaryenAddFunction(module, "check", i, NULL, 0, checkBody); @@ -72,7 +72,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b0 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b0 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b1; @@ -82,7 +82,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b1 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b1 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b2; @@ -92,7 +92,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b2 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b2 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b3; @@ -102,7 +102,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b3 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b3 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b4; @@ -112,7 +112,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b4 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b4 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b5; @@ -122,7 +122,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b5 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b5 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b6; @@ -132,7 +132,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b6 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b6 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b7; @@ -142,7 +142,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b7 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b7 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperBlockRef b8; @@ -152,7 +152,7 @@ int main() { BinaryenCallImport(module, "print", args, 1, BinaryenNone()), BinaryenSetLocal(module, 0, BinaryenCall(module, "check", NULL, 0, BinaryenInt32())) }; - b8 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b8 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, BinaryenUndefined())); } RelooperAddBranch(b0, b5, BinaryenBinary(module, @@ -242,7 +242,7 @@ int main() { } } full[numDecisions] = body; - BinaryenExpressionRef all = BinaryenBlock(module, NULL, full, numDecisions + 1); + BinaryenExpressionRef all = BinaryenBlock(module, NULL, full, numDecisions + 1, BinaryenUndefined()); BinaryenFunctionTypeRef v = BinaryenAddFunctionType(module, "v", BinaryenNone(), NULL, 0); BinaryenType localTypes[] = { BinaryenInt32(), BinaryenInt32() }; // state, free-for-label diff --git a/test/example/relooper-fuzz1.c b/test/example/relooper-fuzz1.c index cca61e4f4..4293044f2 100644 --- a/test/example/relooper-fuzz1.c +++ b/test/example/relooper-fuzz1.c @@ -64,7 +64,8 @@ int main() { BinaryenExpressionRef checkBodyList[] = { halter, incer, debugger, returner }; BinaryenExpressionRef checkBody = BinaryenBlock(module, - NULL, checkBodyList, sizeof(checkBodyList) / sizeof(BinaryenExpressionRef) + NULL, checkBodyList, sizeof(checkBodyList) / sizeof(BinaryenExpressionRef), + BinaryenUndefined() ); BinaryenFunctionTypeRef i = BinaryenAddFunctionType(module, "i", BinaryenInt32(), @@ -87,7 +88,8 @@ int main() { BinaryenInt32())) }; - b0 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b0 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -102,7 +104,8 @@ int main() { BinaryenInt32())) }; - b1 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b1 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -117,7 +120,8 @@ int main() { BinaryenInt32())) }; - b2 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b2 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -132,7 +136,8 @@ int main() { BinaryenInt32())) }; - b3 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b3 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -147,7 +152,8 @@ int main() { BinaryenInt32())) }; - b4 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b4 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -162,7 +168,8 @@ int main() { BinaryenInt32())) }; - b5 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b5 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -177,7 +184,8 @@ int main() { BinaryenInt32())) }; - b6 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b6 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -192,7 +200,8 @@ int main() { BinaryenInt32())) }; - b7 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b7 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -207,7 +216,8 @@ int main() { BinaryenInt32())) }; - b8 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b8 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -222,7 +232,8 @@ int main() { BinaryenInt32())) }; - b9 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2)); + b9 = RelooperAddBlock(relooper, BinaryenBlock(module, NULL, list, 2, + BinaryenUndefined())); } @@ -296,7 +307,8 @@ int main() { } full[numDecisions] = body; BinaryenExpressionRef all = BinaryenBlock(module, NULL, full, - numDecisions + 1); + numDecisions + 1, + BinaryenUndefined()); BinaryenFunctionTypeRef v = BinaryenAddFunctionType(module, "v", BinaryenNone(), |