From 916ce6f1a9f7c85102a8c69f593b301c8df5d19d Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Wed, 9 Sep 2020 03:40:09 +0200 Subject: Update reference types (#3084) Align with the current state of the reference types proposal: * Remove `nullref` * Remove `externref` and `funcref` subtyping * A `Literal` of a nullable reference type can now represent `null` (previously was type `nullref`) * Update the tests and temporarily comment out those tests relying on subtyping --- test/example/c-api-kitchen-sink.c | 22 +++++++--------------- test/example/c-api-kitchen-sink.txt | 24 ++++++++---------------- 2 files changed, 15 insertions(+), 31 deletions(-) (limited to 'test/example') diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index b1dbae7d5..b0a3ad302 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -205,12 +205,6 @@ void test_types() { BinaryenTypeExpand(externref, &valueType); assert(valueType == externref); - BinaryenType nullref = BinaryenTypeNullref(); - printf(" // BinaryenTypeNullref: %d\n", nullref); - assert(BinaryenTypeArity(nullref) == 1); - BinaryenTypeExpand(nullref, &valueType); - assert(valueType == nullref); - BinaryenType exnref = BinaryenTypeExnref(); printf(" // BinaryenTypeExnref: %d\n", exnref); assert(BinaryenTypeArity(exnref) == 1); @@ -294,9 +288,10 @@ void test_core() { temp10 = makeInt32(module, 1), temp11 = makeInt32(module, 3), temp12 = makeInt32(module, 5), temp13 = makeInt32(module, 10), temp14 = makeInt32(module, 11), temp15 = makeInt32(module, 110), temp16 = makeInt64(module, 111); - BinaryenExpressionRef nullrefExpr = BinaryenRefNull(module); - BinaryenExpressionRef funcrefExpr = - BinaryenRefFunc(module, "kitchen()sinker"); + BinaryenExpressionRef externrefExpr = BinaryenRefNull(module, BinaryenTypeExternref()); + BinaryenExpressionRef funcrefExpr = BinaryenRefNull(module, BinaryenTypeFuncref()); + funcrefExpr = BinaryenRefFunc(module, "kitchen()sinker"); + BinaryenExpressionRef exnrefExpr = BinaryenRefNull(module, BinaryenTypeExnref()); // Events BinaryenAddEvent( @@ -718,10 +713,11 @@ void test_core() { iIfF, BinaryenTypeInt32()), // Reference types - BinaryenRefIsNull(module, nullrefExpr), + BinaryenRefIsNull(module, externrefExpr), BinaryenRefIsNull(module, funcrefExpr), + BinaryenRefIsNull(module, exnrefExpr), BinaryenSelect( - module, temp10, nullrefExpr, funcrefExpr, BinaryenTypeFuncref()), + module, temp10, BinaryenRefNull(module, BinaryenTypeFuncref()), BinaryenRefFunc(module, "kitchen()sinker"), BinaryenTypeFuncref()), // Exception handling BinaryenTry(module, tryBody, catchBody), // Atomics @@ -748,10 +744,6 @@ void test_core() { BinaryenPop(module, BinaryenTypeFloat64()), BinaryenPop(module, BinaryenTypeFuncref()), BinaryenPop(module, BinaryenTypeExternref()), - BinaryenPop(module, BinaryenTypeNullref()), - BinaryenPop(module, BinaryenTypeExnref()), - BinaryenPop(module, BinaryenTypeFuncref()), - BinaryenPop(module, BinaryenTypeNullref()), BinaryenPop(module, BinaryenTypeExnref()), // TODO: Host diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index b0aae7f3b..288174b99 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -7,8 +7,7 @@ // BinaryenTypeVec128: 6 // BinaryenTypeFuncref: 7 // BinaryenTypeExternref: 8 - // BinaryenTypeNullref: 9 - // BinaryenTypeExnref: 10 + // BinaryenTypeExnref: 9 // BinaryenTypeAuto: -1 BinaryenFeatureMVP: 0 BinaryenFeatureAtomics: 1 @@ -1753,7 +1752,7 @@ BinaryenFeatureAll: 1023 ) (drop (ref.is_null - (ref.null) + (ref.null extern) ) ) (drop @@ -1761,9 +1760,14 @@ BinaryenFeatureAll: 1023 (ref.func "$kitchen()sinker") ) ) + (drop + (ref.is_null + (ref.null exn) + ) + ) (drop (select (result funcref) - (ref.null) + (ref.null func) (ref.func "$kitchen()sinker") (i32.const 1) ) @@ -1845,18 +1849,6 @@ BinaryenFeatureAll: 1023 (drop (externref.pop) ) - (drop - (nullref.pop) - ) - (drop - (exnref.pop) - ) - (drop - (funcref.pop) - ) - (drop - (nullref.pop) - ) (drop (exnref.pop) ) -- cgit v1.2.3