summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild-js.sh2
-rw-r--r--scripts/fuzz_opt.py3
-rw-r--r--src/binaryen-c.cpp73
-rw-r--r--src/binaryen-c.h12
-rw-r--r--src/js/binaryen.js-post.js10
-rw-r--r--test/binaryen.js/kitchen-sink.js3
-rw-r--r--test/binaryen.js/kitchen-sink.js.txt120
-rw-r--r--test/example/c-api-kitchen-sink.c12
-rw-r--r--test/example/c-api-kitchen-sink.txt82
-rw-r--r--test/example/c-api-kitchen-sink.txt.txt17
10 files changed, 261 insertions, 73 deletions
diff --git a/build-js.sh b/build-js.sh
index 1b3695fcd..21b45b2c4 100755
--- a/build-js.sh
+++ b/build-js.sh
@@ -542,6 +542,8 @@ export_function "_BinaryenBreak"
export_function "_BinaryenSwitch"
export_function "_BinaryenCall"
export_function "_BinaryenCallIndirect"
+export_function "_BinaryenReturnCall"
+export_function "_BinaryenReturnCallIndirect"
export_function "_BinaryenLocalGet"
export_function "_BinaryenLocalSet"
export_function "_BinaryenLocalTee"
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index 666a7e8e6..6aadcd21b 100644
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -33,10 +33,11 @@ NANS = True
# simd: known issues with d8
# atomics, bulk memory: doesn't work in wasm2js
# truncsat: https://github.com/WebAssembly/binaryen/issues/2198
+# tail-call: WIP
CONSTANT_FEATURE_OPTS = ['--all-features']
# possible feature options that are sometimes passed to the tools.
-POSSIBLE_FEATURE_OPTS = ['--disable-exception-handling', '--disable-simd', '--disable-threads', '--disable-bulk-memory', '--disable-nontrapping-float-to-int']
+POSSIBLE_FEATURE_OPTS = ['--disable-exception-handling', '--disable-simd', '--disable-threads', '--disable-bulk-memory', '--disable-nontrapping-float-to-int', '--disable-tail-call']
FUZZ_OPTS = []
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index c22ab4411..fd0ac889a 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -977,11 +977,12 @@ BinaryenExpressionRef BinaryenSwitch(BinaryenModuleRef module,
ret->finalize();
return static_cast<Expression*>(ret);
}
-BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module,
- const char* target,
- BinaryenExpressionRef* operands,
- BinaryenIndex numOperands,
- BinaryenType returnType) {
+static BinaryenExpressionRef makeBinaryenCall(BinaryenModuleRef module,
+ const char* target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ BinaryenType returnType,
+ bool isReturn) {
auto* ret = ((Module*)module)->allocator.alloc<Call>();
if (tracing) {
@@ -999,7 +1000,7 @@ BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module,
}
std::cout << " };\n ";
traceExpression(ret,
- "BinaryenCall",
+ (isReturn ? "BinaryenReturnCall" : "BinaryenCall"),
StringLit(target),
"operands",
numOperands,
@@ -1012,14 +1013,33 @@ BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module,
ret->operands.push_back((Expression*)operands[i]);
}
ret->type = Type(returnType);
+ ret->isReturn = isReturn;
ret->finalize();
return static_cast<Expression*>(ret);
}
-BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module,
- BinaryenExpressionRef target,
- BinaryenExpressionRef* operands,
- BinaryenIndex numOperands,
- const char* type) {
+BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module,
+ const char* target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ BinaryenType returnType) {
+ return makeBinaryenCall(
+ module, target, operands, numOperands, returnType, false);
+}
+BinaryenExpressionRef BinaryenReturnCall(BinaryenModuleRef module,
+ const char* target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ BinaryenType returnType) {
+ return makeBinaryenCall(
+ module, target, operands, numOperands, returnType, true);
+}
+static BinaryenExpressionRef
+makeBinaryenCallIndirect(BinaryenModuleRef module,
+ BinaryenExpressionRef target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ const char* type,
+ bool isReturn) {
auto* wasm = (Module*)module;
auto* ret = wasm->allocator.alloc<CallIndirect>();
@@ -1037,12 +1057,13 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module,
std::cout << "0";
}
std::cout << " };\n ";
- traceExpression(ret,
- "BinaryenCallIndirect",
- target,
- "operands",
- numOperands,
- StringLit(type));
+ traceExpression(
+ ret,
+ (isReturn ? "BinaryenReturnCallIndirect" : "BinaryenCallIndirect"),
+ target,
+ "operands",
+ numOperands,
+ StringLit(type));
std::cout << " }\n";
}
@@ -1052,9 +1073,27 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module,
}
ret->fullType = type;
ret->type = wasm->getFunctionType(ret->fullType)->result;
+ ret->isReturn = isReturn;
ret->finalize();
return static_cast<Expression*>(ret);
}
+BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module,
+ BinaryenExpressionRef target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ const char* type) {
+ return makeBinaryenCallIndirect(
+ module, target, operands, numOperands, type, false);
+}
+BinaryenExpressionRef
+BinaryenReturnCallIndirect(BinaryenModuleRef module,
+ BinaryenExpressionRef target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ const char* type) {
+ return makeBinaryenCallIndirect(
+ module, target, operands, numOperands, type, true);
+}
BinaryenExpressionRef BinaryenLocalGet(BinaryenModuleRef module,
BinaryenIndex index,
BinaryenType type) {
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index b186032f5..db49c45c9 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -545,6 +545,18 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module,
BinaryenExpressionRef* operands,
BinaryenIndex numOperands,
const char* type);
+BinaryenExpressionRef BinaryenReturnCall(BinaryenModuleRef module,
+ const char* target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ BinaryenType returnType);
+BinaryenExpressionRef
+BinaryenReturnCallIndirect(BinaryenModuleRef module,
+ BinaryenExpressionRef target,
+ BinaryenExpressionRef* operands,
+ BinaryenIndex numOperands,
+ const char* type);
+
// LocalGet: Note the 'type' parameter. It might seem redundant, since the
// local at that index must have a type. However, this API lets you
// build code "top-down": create a node, then its parents, and so
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 1760f6359..5b24f3a8f 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -450,6 +450,16 @@ function wrapModule(module, self) {
return Module['_BinaryenCallIndirect'](module, target, i32sToStack(operands), operands.length, strToStack(type));
});
};
+ self['returnCall'] = function(name, operands, type) {
+ return preserveStack(function() {
+ return Module['_BinaryenReturnCall'](module, strToStack(name), i32sToStack(operands), operands.length, type);
+ });
+ };
+ self['returnCallIndirect'] = function(target, operands, type) {
+ return preserveStack(function() {
+ return Module['_BinaryenReturnCallIndirect'](module, target, i32sToStack(operands), operands.length, strToStack(type));
+ });
+ };
self['local'] = {
'get': function(index, type) {
diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js
index a9d0e4ef5..2723be7cb 100644
--- a/test/binaryen.js/kitchen-sink.js
+++ b/test/binaryen.js/kitchen-sink.js
@@ -396,6 +396,9 @@ function test_core() {
module.i64.store(2, 4, temp15, temp16),
module.select(temp10, temp11, temp12),
module.return(makeInt32(1337)),
+ // Tail Call
+ module.returnCall("kitchen()sinker", [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], Binaryen.i32),
+ module.returnCallIndirect(makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], "iiIfF"),
// TODO: Host
module.nop(),
module.unreachable(),
diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt
index 0a1724532..3ec65d02b 100644
--- a/test/binaryen.js/kitchen-sink.js.txt
+++ b/test/binaryen.js/kitchen-sink.js.txt
@@ -1416,6 +1416,23 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
(return
(i32.const 1337)
)
+ (drop
+ (return_call "$kitchen()sinker"
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ )
+ )
+ (drop
+ (return_call_indirect (type $iiIfF)
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ (i32.const 2449)
+ )
+ )
(nop)
(unreachable)
)
@@ -3256,8 +3273,25 @@ int main() {
expressions[642] = BinaryenSelect(the_module, expressions[16], expressions[17], expressions[18]);
expressions[643] = BinaryenConst(the_module, BinaryenLiteralInt32(1337));
expressions[644] = BinaryenReturn(the_module, expressions[643]);
- expressions[645] = BinaryenNop(the_module);
- expressions[646] = BinaryenUnreachable(the_module);
+ expressions[645] = BinaryenConst(the_module, BinaryenLiteralInt32(13));
+ expressions[646] = BinaryenConst(the_module, BinaryenLiteralInt64(37));
+ expressions[647] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3));
+ expressions[648] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7));
+ {
+ BinaryenExpressionRef operands[] = { expressions[645], expressions[646], expressions[647], expressions[648] };
+ expressions[649] = BinaryenReturnCall(the_module, "kitchen()sinker", operands, 4, 1);
+ }
+ expressions[650] = BinaryenConst(the_module, BinaryenLiteralInt32(2449));
+ expressions[651] = BinaryenConst(the_module, BinaryenLiteralInt32(13));
+ expressions[652] = BinaryenConst(the_module, BinaryenLiteralInt64(37));
+ expressions[653] = BinaryenConst(the_module, BinaryenLiteralFloat32(1.3));
+ expressions[654] = BinaryenConst(the_module, BinaryenLiteralFloat64(3.7));
+ {
+ BinaryenExpressionRef operands[] = { expressions[651], expressions[652], expressions[653], expressions[654] };
+ expressions[655] = BinaryenReturnCallIndirect(the_module, expressions[650], operands, 4, "iiIfF");
+ }
+ expressions[656] = BinaryenNop(the_module);
+ expressions[657] = BinaryenUnreachable(the_module);
BinaryenExpressionGetId(expressions[30]);
BinaryenExpressionGetType(expressions[30]);
BinaryenUnaryGetOp(expressions[30]);
@@ -3268,26 +3302,26 @@ getExpressionInfo={"id":15,"type":3,"op":6}
(f32.const -33.61199951171875)
)
- expressions[647] = BinaryenConst(the_module, BinaryenLiteralInt32(5));
- BinaryenExpressionGetId(expressions[647]);
- BinaryenExpressionGetType(expressions[647]);
- BinaryenConstGetValueI32(expressions[647]);
+ expressions[658] = BinaryenConst(the_module, BinaryenLiteralInt32(5));
+ BinaryenExpressionGetId(expressions[658]);
+ BinaryenExpressionGetType(expressions[658]);
+ BinaryenConstGetValueI32(expressions[658]);
getExpressionInfo(i32.const)={"id":14,"type":1,"value":5}
- expressions[648] = BinaryenConst(the_module, BinaryenLiteralInt64(30064771078));
- BinaryenExpressionGetId(expressions[648]);
- BinaryenExpressionGetType(expressions[648]);
- BinaryenConstGetValueI64Low(expressions[648]);
- BinaryenConstGetValueI64High(expressions[648]);
+ expressions[659] = BinaryenConst(the_module, BinaryenLiteralInt64(30064771078));
+ BinaryenExpressionGetId(expressions[659]);
+ BinaryenExpressionGetType(expressions[659]);
+ BinaryenConstGetValueI64Low(expressions[659]);
+ BinaryenConstGetValueI64High(expressions[659]);
getExpressionInfo(i64.const)={"id":14,"type":2,"value":{"low":6,"high":7}}
- expressions[649] = BinaryenConst(the_module, BinaryenLiteralFloat32(8.5));
- BinaryenExpressionGetId(expressions[649]);
- BinaryenExpressionGetType(expressions[649]);
- BinaryenConstGetValueF32(expressions[649]);
+ expressions[660] = BinaryenConst(the_module, BinaryenLiteralFloat32(8.5));
+ BinaryenExpressionGetId(expressions[660]);
+ BinaryenExpressionGetType(expressions[660]);
+ BinaryenConstGetValueF32(expressions[660]);
getExpressionInfo(f32.const)={"id":14,"type":3,"value":8.5}
- expressions[650] = BinaryenConst(the_module, BinaryenLiteralFloat64(9.5));
- BinaryenExpressionGetId(expressions[650]);
- BinaryenExpressionGetType(expressions[650]);
- BinaryenConstGetValueF64(expressions[650]);
+ expressions[661] = BinaryenConst(the_module, BinaryenLiteralFloat64(9.5));
+ BinaryenExpressionGetId(expressions[661]);
+ BinaryenExpressionGetType(expressions[661]);
+ BinaryenConstGetValueF64(expressions[661]);
getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
{
BinaryenExpressionRef children[] = { expressions[24], expressions[26], expressions[28], expressions[30], expressions[32],
@@ -3330,25 +3364,26 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
expressions[597], expressions[598], expressions[600], expressions[602], expressions[603], expressions[604],
expressions[606], expressions[612], expressions[617], expressions[624], expressions[626], expressions[628],
expressions[631], expressions[633], expressions[635], expressions[637], expressions[639], expressions[640],
- expressions[641], expressions[642], expressions[644], expressions[645], expressions[646] };
- expressions[651] = BinaryenBlock(the_module, "the-value", children, 244, 0);
+ expressions[641], expressions[642], expressions[644], expressions[649], expressions[655], expressions[656],
+ expressions[657] };
+ expressions[662] = BinaryenBlock(the_module, "the-value", children, 246, 0);
}
- expressions[652] = BinaryenDrop(the_module, expressions[651]);
+ expressions[663] = BinaryenDrop(the_module, expressions[662]);
{
- BinaryenExpressionRef children[] = { expressions[652] };
- expressions[653] = BinaryenBlock(the_module, "the-nothing", children, 1, 0);
+ BinaryenExpressionRef children[] = { expressions[663] };
+ expressions[664] = BinaryenBlock(the_module, "the-nothing", children, 1, 0);
}
- expressions[654] = BinaryenConst(the_module, BinaryenLiteralInt32(42));
+ expressions[665] = BinaryenConst(the_module, BinaryenLiteralInt32(42));
{
- BinaryenExpressionRef children[] = { expressions[653], expressions[654] };
- expressions[655] = BinaryenBlock(the_module, "the-body", children, 2, 0);
+ BinaryenExpressionRef children[] = { expressions[664], expressions[665] };
+ expressions[666] = BinaryenBlock(the_module, "the-body", children, 2, 0);
}
{
BinaryenType varTypes[] = { 1 };
- functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[655]);
+ functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[666]);
}
- expressions[656] = BinaryenConst(the_module, BinaryenLiteralInt32(1));
- globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[656]);
+ expressions[667] = BinaryenConst(the_module, BinaryenLiteralInt32(1));
+ globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[667]);
{
BinaryenType paramTypes[] = { 1 };
functionTypes[1] = BinaryenAddFunctionType(the_module, "vi", 0, paramTypes, 1);
@@ -3381,13 +3416,13 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
const char* funcNames[] = { "kitchen()sinker" };
BinaryenSetFunctionTable(the_module, 1, 4294967295, funcNames, 1);
}
- expressions[657] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
+ expressions[668] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
{
const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 };
const char segment1[] = { 73, 32, 97, 109, 32, 112, 97, 115, 115, 105, 118, 101 };
const char* segments[] = { segment0, segment1 };
int8_t segmentPassive[] = { 0, 1 };
- BinaryenExpressionRef segmentOffsets[] = { expressions[657], expressions[0] };
+ BinaryenExpressionRef segmentOffsets[] = { expressions[668], expressions[0] };
BinaryenIndex segmentSizes[] = { 12, 12 };
BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 0);
}
@@ -3395,10 +3430,10 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
BinaryenType paramTypes[] = { 0 };
functionTypes[3] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0);
}
- expressions[658] = BinaryenNop(the_module);
+ expressions[669] = BinaryenNop(the_module);
{
BinaryenType varTypes[] = { 0 };
- functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[658]);
+ functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[669]);
}
BinaryenSetStart(the_module, functions[1]);
{
@@ -4765,6 +4800,23 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5}
(return
(i32.const 1337)
)
+ (drop
+ (return_call "$kitchen()sinker"
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ )
+ )
+ (drop
+ (return_call_indirect (type $iiIfF)
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ (i32.const 2449)
+ )
+ )
(nop)
(unreachable)
)
diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c
index f686a1493..8b2d3ae8d 100644
--- a/test/example/c-api-kitchen-sink.c
+++ b/test/example/c-api-kitchen-sink.c
@@ -459,12 +459,20 @@ void test_core() {
BinaryenDrop(module, BinaryenLocalTee(module, 0, makeInt32(module, 102))),
BinaryenLoad(module, 4, 0, 0, 0, BinaryenTypeInt32(), makeInt32(module, 1)),
BinaryenLoad(module, 2, 1, 2, 1, BinaryenTypeInt64(), makeInt32(module, 8)),
- BinaryenLoad(module, 4, 0, 0, 0, BinaryenTypeFloat32(), makeInt32(module, 2)),
- BinaryenLoad(module, 8, 0, 2, 8, BinaryenTypeFloat64(), makeInt32(module, 9)),
+ BinaryenLoad(
+ module, 4, 0, 0, 0, BinaryenTypeFloat32(), makeInt32(module, 2)),
+ BinaryenLoad(
+ module, 8, 0, 2, 8, BinaryenTypeFloat64(), makeInt32(module, 9)),
BinaryenStore(module, 4, 0, 0, temp13, temp14, BinaryenTypeInt32()),
BinaryenStore(module, 8, 2, 4, temp15, temp16, BinaryenTypeInt64()),
BinaryenSelect(module, temp10, temp11, temp12),
BinaryenReturn(module, makeInt32(module, 1337)),
+ // Tail call
+ BinaryenReturnCall(
+ module, "kitchen()sinker", callOperands4, 4, BinaryenTypeInt32()),
+ BinaryenReturnCallIndirect(
+ module, makeInt32(module, 2449), callOperands4b, 4, "iiIfF"),
+
// TODO: Host
BinaryenNop(module),
BinaryenUnreachable(module),
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 44b1c1cd8..d18e1728e 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -1380,6 +1380,23 @@ BinaryenFeatureAll: 255
(return
(i32.const 1337)
)
+ (drop
+ (return_call "$kitchen()sinker"
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ )
+ )
+ (drop
+ (return_call_indirect (type $iiIfF)
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ (i32.const 2449)
+ )
+ )
(nop)
(unreachable)
)
@@ -3242,8 +3259,17 @@ int main() {
expressions[643] = BinaryenSelect(the_module, expressions[27], expressions[28], expressions[29]);
expressions[644] = BinaryenConst(the_module, BinaryenLiteralInt32(1337));
expressions[645] = BinaryenReturn(the_module, expressions[644]);
- expressions[646] = BinaryenNop(the_module);
- expressions[647] = BinaryenUnreachable(the_module);
+ {
+ BinaryenExpressionRef operands[] = { expressions[10], expressions[11], expressions[12], expressions[13] };
+ expressions[646] = BinaryenReturnCall(the_module, "kitchen()sinker", operands, 4, 1);
+ }
+ expressions[647] = BinaryenConst(the_module, BinaryenLiteralInt32(2449));
+ {
+ BinaryenExpressionRef operands[] = { expressions[14], expressions[15], expressions[16], expressions[17] };
+ expressions[648] = BinaryenReturnCallIndirect(the_module, expressions[647], operands, 4, "iiIfF");
+ }
+ expressions[649] = BinaryenNop(the_module);
+ expressions[650] = BinaryenUnreachable(the_module);
BinaryenExpressionPrint(expressions[41]);
(f32.neg
(f32.const -33.61199951171875)
@@ -3289,27 +3315,28 @@ int main() {
expressions[608], expressions[609], expressions[611], expressions[613], expressions[614], expressions[615],
expressions[617], expressions[619], expressions[622], expressions[625], expressions[627], expressions[629],
expressions[632], expressions[634], expressions[636], expressions[638], expressions[640], expressions[641],
- expressions[642], expressions[643], expressions[645], expressions[646], expressions[647] };
- expressions[648] = BinaryenBlock(the_module, "the-value", children, 244, BinaryenTypeAuto());
+ expressions[642], expressions[643], expressions[645], expressions[646], expressions[648], expressions[649],
+ expressions[650] };
+ expressions[651] = BinaryenBlock(the_module, "the-value", children, 246, BinaryenTypeAuto());
}
- expressions[649] = BinaryenDrop(the_module, expressions[648]);
+ expressions[652] = BinaryenDrop(the_module, expressions[651]);
{
- BinaryenExpressionRef children[] = { expressions[649] };
- expressions[650] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenTypeAuto());
+ BinaryenExpressionRef children[] = { expressions[652] };
+ expressions[653] = BinaryenBlock(the_module, "the-nothing", children, 1, BinaryenTypeAuto());
}
- expressions[651] = BinaryenConst(the_module, BinaryenLiteralInt32(42));
+ expressions[654] = BinaryenConst(the_module, BinaryenLiteralInt32(42));
{
- BinaryenExpressionRef children[] = { expressions[650], expressions[651] };
- expressions[652] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto());
+ BinaryenExpressionRef children[] = { expressions[653], expressions[654] };
+ expressions[655] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto());
}
{
BinaryenType varTypes[] = { 1 };
- functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[652]);
+ functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 1, expressions[655]);
}
- expressions[653] = BinaryenConst(the_module, BinaryenLiteralInt32(7));
- globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[653]);
- expressions[654] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5));
- globals[1] = BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[654]);
+ expressions[656] = BinaryenConst(the_module, BinaryenLiteralInt32(7));
+ globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[656]);
+ expressions[657] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5));
+ globals[1] = BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[657]);
{
BinaryenType paramTypes[] = { 1 };
functionTypes[1] = BinaryenAddFunctionType(the_module, "vi", 0, paramTypes, 1);
@@ -3326,13 +3353,13 @@ int main() {
const char* funcNames[] = { "kitchen()sinker" };
BinaryenSetFunctionTable(the_module, 1, 1, funcNames, 1);
}
- expressions[655] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
+ expressions[658] = BinaryenConst(the_module, BinaryenLiteralInt32(10));
{
const char segment0[] = { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100 };
const char segment1[] = { 73, 32, 97, 109, 32, 112, 97, 115, 115, 105, 118, 101 };
const char* segments[] = { segment0, segment1 };
int8_t segmentPassive[] = { 0, 1 };
- BinaryenExpressionRef segmentOffsets[] = { expressions[655], expressions[0] };
+ BinaryenExpressionRef segmentOffsets[] = { expressions[658], expressions[0] };
BinaryenIndex segmentSizes[] = { 12, 12 };
BinaryenSetMemory(the_module, 1, 256, "mem", segments, segmentPassive, segmentOffsets, segmentSizes, 2, 0);
}
@@ -3340,10 +3367,10 @@ int main() {
BinaryenType paramTypes[] = { 0 };
functionTypes[3] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0);
}
- expressions[656] = BinaryenNop(the_module);
+ expressions[659] = BinaryenNop(the_module);
{
BinaryenType varTypes[] = { 0 };
- functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[656]);
+ functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[659]);
}
BinaryenSetStart(the_module, functions[1]);
{
@@ -4716,6 +4743,23 @@ int main() {
(return
(i32.const 1337)
)
+ (drop
+ (return_call "$kitchen()sinker"
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ )
+ )
+ (drop
+ (return_call_indirect (type $iiIfF)
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ (i32.const 2449)
+ )
+ )
(nop)
(unreachable)
)
diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt
index 679ae534c..c73646727 100644
--- a/test/example/c-api-kitchen-sink.txt.txt
+++ b/test/example/c-api-kitchen-sink.txt.txt
@@ -1362,6 +1362,23 @@
(return
(i32.const 1337)
)
+ (drop
+ (return_call "$kitchen()sinker"
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ )
+ )
+ (drop
+ (return_call_indirect (type $iiIfF)
+ (i32.const 13)
+ (i64.const 37)
+ (f32.const 1.2999999523162842)
+ (f64.const 3.7)
+ (i32.const 2449)
+ )
+ )
(nop)
(unreachable)
)