diff --git a/src/compiler/propagation/type_primitive_encoding.cc b/src/compiler/propagation/type_primitive_encoding.cc index f68b10a08..69fed52af 100644 --- a/src/compiler/propagation/type_primitive_encoding.cc +++ b/src/compiler/propagation/type_primitive_encoding.cc @@ -22,8 +22,13 @@ MODULE_TYPES(encoding, MODULE_ENCODING) TYPE_PRIMITIVE_ANY(base64_encode) TYPE_PRIMITIVE_ANY(base64_decode) -TYPE_PRIMITIVE_ANY(tison_encode) TYPE_PRIMITIVE_ANY(tison_decode) +TYPE_PRIMITIVE(tison_encode) { + result.add_byte_array(program); + failure.add_string(program); + failure.add_array(program); +} + } // namespace toit::compiler } // namespace toit diff --git a/src/compiler/propagation/type_primitive_programs_registry.cc b/src/compiler/propagation/type_primitive_programs_registry.cc index 895f6f66c..7ec1c41a3 100644 --- a/src/compiler/propagation/type_primitive_programs_registry.cc +++ b/src/compiler/propagation/type_primitive_programs_registry.cc @@ -21,12 +21,17 @@ namespace compiler { MODULE_TYPES(programs_registry, MODULE_PROGRAMS_REGISTRY) TYPE_PRIMITIVE_ANY(next_group_id) -TYPE_PRIMITIVE_ANY(spawn) TYPE_PRIMITIVE_ANY(is_running) TYPE_PRIMITIVE_ANY(kill) TYPE_PRIMITIVE_ANY(bundled_images) TYPE_PRIMITIVE_ANY(assets) TYPE_PRIMITIVE_ANY(config) +TYPE_PRIMITIVE(spawn) { + result.add_smi(program); + failure.add_string(program); + failure.add_array(program); +} + } // namespace toit::compiler } // namespace toit diff --git a/tests/finally-params-test.toit b/tests/finally-params-test.toit index b3fb71b0b..43446c84d 100644 --- a/tests/finally-params-test.toit +++ b/tests/finally-params-test.toit @@ -13,7 +13,7 @@ test0: expect-null exception test1: - // With local. (shifting the try/finally locals. + // With local (shifting the try/finally locals). was-in-finally := false try: null diff --git a/tests/type_propagation/default-arguments-test.toit b/tests/type_propagation/default-arguments-test.toit new file mode 100644 index 000000000..d8bd25d41 --- /dev/null +++ b/tests/type_propagation/default-arguments-test.toit @@ -0,0 +1,41 @@ +// Copyright (C) 2024 Toitware ApS. +// Use of this source code is governed by a Zero-Clause BSD license that can +// be found in the tests/LICENSE file. + +main: + test-default-true --x + test-default-true --x=false + test-default-true --x=true + test-default-true --no-x + test-default-true --x=null + + test-default-false --x + test-default-false --x=false + test-default-false --x=true + test-default-false --no-x + test-default-false --x=null + + test-non-default --x + test-non-default --x=true + test-non-default --no-x + test-non-default --x=false + + test-non-default-non-literal --x + test-non-default-non-literal --x=true + test-non-default-non-literal --no-x + test-non-default-non-literal --x=false + +test-default-true --x/bool=true: + return x + +test-default-false --x/bool=false: + return x + +test-non-default --x/bool=true: + return x + +test-non-default-non-literal --x/bool=gettrue: + return x + +gettrue: + return true diff --git a/tests/type_propagation/finally-test.toit b/tests/type_propagation/finally-test.toit index c3ba4185b..bdfdf2629 100644 --- a/tests/type_propagation/finally-test.toit +++ b/tests/type_propagation/finally-test.toit @@ -7,6 +7,13 @@ main: test-exception test-catchy test-nlb-out-of-try + test-throw-update-in-finally + test-break-update-in-finally + test-break-update-in-finally-block0 + test-break-update-in-finally-block1 + test-break-update-in-finally-block2 + test-break-update-in-finally-block3 + test-break-update-in-finally-nested test-is-exception: return-is-exception @@ -57,6 +64,85 @@ test-nlb-out-of-try: x = null finally: id x +test-throw-update-in-finally: + x := false + invoke-catch: + try: + throw "ugh" + finally: + x = true + id x + +test-break-update-in-finally: + x := false + while true: + try: + break + finally: + x = true + id x + +test-break-update-in-finally-block0: + x := false + while true: + invoke: + try: + break + finally: + x = true + id x + +test-break-update-in-finally-block1: + x := false + while true: + block := (: break) + try: + block.call + finally: + x = true + id x + +test-break-update-in-finally-block2: + x/any := null + while true: + block := (: break) + try: + block.call + finally: + x = true + try: + block.call + finally: + x = false + id x + +test-break-update-in-finally-block3: + x := false + y := null + while true: + block := (: break) + while true: + try: + if pick: block.call + else: break + finally: + x = true + y = x + id x + id y + +test-break-update-in-finally-nested: + x/any := null + while true: + try: + try: + x = 0 + break + finally: + x = true + finally: + x = "horse" + id x id x: return x @@ -66,3 +152,9 @@ pick: invoke [block]: block.call + +invoke-catch [block]: + try: + block.call + finally: + return diff --git a/tests/type_propagation/gold/default-arguments-test.gold b/tests/type_propagation/gold/default-arguments-test.gold new file mode 100644 index 000000000..2ac301afb --- /dev/null +++ b/tests/type_propagation/gold/default-arguments-test.gold @@ -0,0 +1,107 @@ +main tests/type_propagation/default-arguments-test.toit + 0[020] - load literal true + 2[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 5[041] - pop 1 + 6[020] - load literal false + 8[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 11[041] - pop 1 + 12[020] - load literal true + 14[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 17[041] - pop 1 + 18[020] - load literal false + 20[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 23[041] - pop 1 + 24[022] - load null + 25[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{Null_}] -> {True} + 28[041] - pop 1 + 29[020] - load literal true + 31[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{True}] -> {True|False} + 34[041] - pop 1 + 35[020] - load literal false + 37[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{False}] -> {False} + 40[041] - pop 1 + 41[020] - load literal true + 43[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{True}] -> {True|False} + 46[041] - pop 1 + 47[020] - load literal false + 49[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{False}] -> {False} + 52[041] - pop 1 + 53[022] - load null + 54[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{Null_}] -> {False} + 57[041] - pop 1 + 58[020] - load literal true + 60[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 63[041] - pop 1 + 64[020] - load literal true + 66[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 69[041] - pop 1 + 70[020] - load literal false + 72[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 75[041] - pop 1 + 76[020] - load literal false + 78[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 81[041] - pop 1 + 82[020] - load literal true + 84[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 87[041] - pop 1 + 88[020] - load literal true + 90[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 93[041] - pop 1 + 94[020] - load literal false + 96[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 99[041] - pop 1 +100[020] - load literal false +102[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} +105[090] - return null S1 0 + +test-default-true tests/type_propagation/default-arguments-test.toit + - argument 0: {Null_|True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T10 + 6[020] - load literal true + 8[004] - store local, pop S3 + 10[052] - load local, as class, pop 2 - True(21 - 23) // {True|False} + 12[016] - load local 2 + 13[089] - return S1 1 + +test-default-false tests/type_propagation/default-arguments-test.toit + - argument 0: {Null_|True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T10 + 6[020] - load literal false + 8[004] - store local, pop S3 + 10[052] - load local, as class, pop 2 - True(21 - 23) // {True|False} + 12[016] - load local 2 + 13[089] - return S1 1 + +test-non-default tests/type_propagation/default-arguments-test.toit + - argument 0: {True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T10 + 6[020] - load literal true + 8[004] - store local, pop S3 + 10[052] - load local, as class, pop 2 - True(21 - 23) // {True} + 12[016] - load local 2 + 13[089] - return S1 1 + +test-non-default-non-literal tests/type_propagation/default-arguments-test.toit + - argument 0: {True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T11 + 6[053] - invoke static gettrue tests/type_propagation/default-arguments-test.toit // {True} + 9[004] - store local, pop S3 + 11[052] - load local, as class, pop 2 - True(21 - 23) // {True} + 13[016] - load local 2 + 14[089] - return S1 1 + +gettrue tests/type_propagation/default-arguments-test.toit + 0[020] - load literal true + 2[089] - return S1 0 diff --git a/tests/type_propagation/gold/default-arguments-test.gold-O2 b/tests/type_propagation/gold/default-arguments-test.gold-O2 new file mode 100644 index 000000000..04a1d4215 --- /dev/null +++ b/tests/type_propagation/gold/default-arguments-test.gold-O2 @@ -0,0 +1,105 @@ +main tests/type_propagation/default-arguments-test.toit + 0[020] - load literal true + 2[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 5[041] - pop 1 + 6[020] - load literal false + 8[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 11[041] - pop 1 + 12[020] - load literal true + 14[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 17[041] - pop 1 + 18[020] - load literal false + 20[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 23[041] - pop 1 + 24[022] - load null + 25[053] - invoke static test-default-true tests/type_propagation/default-arguments-test.toit // [{Null_}] -> {True} + 28[041] - pop 1 + 29[020] - load literal true + 31[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{True}] -> {True|False} + 34[041] - pop 1 + 35[020] - load literal false + 37[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{False}] -> {False} + 40[041] - pop 1 + 41[020] - load literal true + 43[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{True}] -> {True|False} + 46[041] - pop 1 + 47[020] - load literal false + 49[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{False}] -> {False} + 52[041] - pop 1 + 53[022] - load null + 54[053] - invoke static test-default-false tests/type_propagation/default-arguments-test.toit // [{Null_}] -> {False} + 57[041] - pop 1 + 58[020] - load literal true + 60[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 63[041] - pop 1 + 64[020] - load literal true + 66[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 69[041] - pop 1 + 70[020] - load literal false + 72[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 75[041] - pop 1 + 76[020] - load literal false + 78[053] - invoke static test-non-default tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 81[041] - pop 1 + 82[020] - load literal true + 84[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 87[041] - pop 1 + 88[020] - load literal true + 90[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{True}] -> {True} + 93[041] - pop 1 + 94[020] - load literal false + 96[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} + 99[041] - pop 1 +100[020] - load literal false +102[053] - invoke static test-non-default-non-literal tests/type_propagation/default-arguments-test.toit // [{False}] -> {True|False} +105[090] - return null S1 0 + +test-default-true tests/type_propagation/default-arguments-test.toit + - argument 0: {Null_|True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T10 + 6[020] - load literal true + 8[004] - store local, pop S3 + 10[052] - load local, as class, pop 2 - True(18 - 20) // {True|False} + 12[016] - load local 2 + 13[089] - return S1 1 + +test-default-false tests/type_propagation/default-arguments-test.toit + - argument 0: {Null_|True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T10 + 6[020] - load literal false + 8[004] - store local, pop S3 + 10[052] - load local, as class, pop 2 - True(18 - 20) // {True|False} + 12[016] - load local 2 + 13[089] - return S1 1 + +test-non-default tests/type_propagation/default-arguments-test.toit + - argument 0: {True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T10 + 6[020] - load literal true + 8[004] - store local, pop S3 + 10[016] - load local 2 + 11[089] - return S1 1 + +test-non-default-non-literal tests/type_propagation/default-arguments-test.toit + - argument 0: {True|False} + 0[016] - load local 2 + 1[022] - load null + 2[094] - identical + 3[083] - branch if false T11 + 6[053] - invoke static gettrue tests/type_propagation/default-arguments-test.toit // {True} + 9[004] - store local, pop S3 + 11[016] - load local 2 + 12[089] - return S1 1 + +gettrue tests/type_propagation/default-arguments-test.toit + 0[020] - load literal true + 2[089] - return S1 0 diff --git a/tests/type_propagation/gold/finally-test.gold b/tests/type_propagation/gold/finally-test.gold index becf1494f..830e72bac 100644 --- a/tests/type_propagation/gold/finally-test.gold +++ b/tests/type_propagation/gold/finally-test.gold @@ -6,7 +6,21 @@ main tests/type_propagation/finally-test.toit 8[053] - invoke static test-catchy tests/type_propagation/finally-test.toit // {Null_} 11[041] - pop 1 12[053] - invoke static test-nlb-out-of-try tests/type_propagation/finally-test.toit // {Null_} - 15[090] - return null S1 0 + 15[041] - pop 1 + 16[053] - invoke static test-throw-update-in-finally tests/type_propagation/finally-test.toit // {Null_} + 19[041] - pop 1 + 20[053] - invoke static test-break-update-in-finally tests/type_propagation/finally-test.toit // {Null_} + 23[041] - pop 1 + 24[053] - invoke static test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit // {Null_} + 27[041] - pop 1 + 28[053] - invoke static test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit // {Null_} + 31[041] - pop 1 + 32[053] - invoke static test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit // {Null_} + 35[041] - pop 1 + 36[053] - invoke static test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit // {Null_} + 39[041] - pop 1 + 40[053] - invoke static test-break-update-in-finally-nested tests/type_propagation/finally-test.toit // {Null_} + 43[090] - return null S1 0 test-is-exception tests/type_propagation/finally-test.toit 0[053] - invoke static return-is-exception tests/type_propagation/finally-test.toit // {True|False} @@ -196,6 +210,264 @@ test-nlb-out-of-try tests/type_propagation/finally-test.toit 4[091] - non-local return 16 6[089] - return S1 1 +test-throw-update-in-finally tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + 7[038] - load block 0 + 9[053] - invoke static invoke-catch tests/type_propagation/finally-test.toit // [[block]] -> {Null_} + 12[041] - pop 1 + 13[002] - pop, load local S0 + 15[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 18[090] - return null S2 0 + +[block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in [block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[000] - load local S6 + 16[020] - load literal true + 18[006] - store outer S1 + 20[041] - pop 1 + 21[097] - unwind + 22[041] - pop 1 + 23[022] - load null + 24[089] - return S1 1 + +[block] in [block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[020] - load literal ugh + 2[053] - invoke static throw /core/exceptions.toit // [{String_}] -> {} + 5[089] - return S1 1 + +test-break-update-in-finally tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-break-update-in-finally tests/type_propagation/finally-test.toit + 7[095] - link try 0 + 9[038] - load block 4 + 11[055] - invoke block S1 // [[block]] -> {} + 13[041] - pop 1 + 14[096] - unlink try 0 + 16[020] - load literal true + 18[004] - store local, pop S5 + 20[097] - unwind + 21[041] - pop 1 + 22[084] - branch back T2 + 27[014] - load local 0 + 28[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 31[090] - return null S2 0 + +[block] in test-break-update-in-finally tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally:27} + 7[089] - return S1 1 + +test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + 7[038] - load block 0 + 9[053] - invoke static invoke tests/type_propagation/finally-test.toit // [[block]] -> {} + 12[040] - pop 2 + 14[084] - branch back T2 + 19[014] - load local 0 + 20[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 23[090] - return null S2 0 + +[block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in [block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[000] - load local S6 + 16[020] - load literal true + 18[006] - store outer S1 + 20[041] - pop 1 + 21[097] - unwind + 22[041] - pop 1 + 23[022] - load null + 24[089] - return S1 1 + +[block] in [block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[005] - load outer S3 // [block] + 3[093] - non-local branch {test-break-update-in-finally-block0:19} + 9[089] - return S1 1 + +test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + 7[029] - load method [block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + 12[095] - link try 0 + 14[038] - load block 4 + 16[055] - invoke block S1 // [[block]] -> {} + 18[041] - pop 1 + 19[096] - unlink try 0 + 21[020] - load literal true + 23[004] - store local, pop S6 + 25[097] - unwind + 26[040] - pop 2 + 28[084] - branch back T2 + 33[014] - load local 0 + 34[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 37[090] - return null S2 0 + +[block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally-block1:33} + 7[089] - return S1 1 + +[block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[039] - load outer block 1 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 + +test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 0[022] - load null + 1[029] - load method [block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 6[029] - load method [block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 11[095] - link try 0 + 13[038] - load block 4 + 15[055] - invoke block S1 // [[block]] -> {} + 17[041] - pop 1 + 18[096] - unlink try 0 + 20[020] - load literal true + 22[004] - store local, pop S6 + 24[029] - load method [block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 29[095] - link try 0 + 31[038] - load block 4 + 33[055] - invoke block S1 // [[block]] -> {} + 35[041] - pop 1 + 36[096] - unlink try 0 + 38[020] - load literal false + 40[004] - store local, pop S10 + 42[097] - unwind + 43[041] - pop 1 + 44[097] - unwind + 45[040] - pop 2 + 47[084] - branch back T1 + 52[014] - load local 0 + 53[053] - invoke static id tests/type_propagation/finally-test.toit // [{Null_|True}] -> {Null_|True} + 56[090] - return null S2 0 + +[block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally-block2:52} + 7[089] - return S1 1 + +[block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[039] - load outer block 1 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 + +[block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[039] - load outer block 5 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 + +test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[022] - load null + 3[029] - load method [block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + 8[029] - load method [block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + 13[095] - link try 0 + 15[038] - load block 4 + 17[055] - invoke block S1 // [[block]] -> {} + 19[041] - pop 1 + 20[096] - unlink try 0 + 22[020] - load literal true + 24[004] - store local, pop S7 + 26[097] - unwind + 27[041] - pop 1 + 28[084] - branch back T8 + 33[016] - load local 2 + 34[004] - store local, pop S2 + 36[041] - pop 1 + 37[084] - branch back T3 + 42[015] - load local 1 + 43[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 46[002] - pop, load local S0 + 48[053] - invoke static id tests/type_propagation/finally-test.toit // [{Null_|False}] -> {Null_|False} + 51[090] - return null S3 0 + +[block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally-block3:42} + 7[089] - return S1 1 + +[block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[053] - invoke static pick tests/type_propagation/finally-test.toit // {True|False} + 3[083] - branch if false T14 + 6[016] - load local 2 + 7[039] - load outer block 1 // [block] + 9[055] - invoke block S1 // [[block]] -> {} + 11[081] - branch T21 + 14[016] - load local 2 + 15[093] - non-local branch {test-break-update-in-finally-block3:33} + 21[089] - return S1 1 + +test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + 0[022] - load null + 1[029] - load method [block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + 6[095] - link try 0 + 8[038] - load block 4 + 10[055] - invoke block S1 // [[block]] -> {} + 12[041] - pop 1 + 13[096] - unlink try 0 + 15[020] - load literal horse + 17[004] - store local, pop S5 + 19[097] - unwind + 20[041] - pop 1 + 21[084] - branch back T1 + 26[014] - load local 0 + 27[053] - invoke static id tests/type_propagation/finally-test.toit // [{SmallInteger_}] -> {SmallInteger_} + 30[090] - return null S2 0 + +[block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in [block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[000] - load local S6 + 16[020] - load literal true + 18[006] - store outer S1 + 20[041] - pop 1 + 21[097] - unwind + 22[041] - pop 1 + 23[022] - load null + 24[089] - return S1 1 + +[block] in [block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[005] - load outer S3 // [block] + 3[023] - load smi 0 + 4[006] - store outer S1 + 6[002] - pop, load local S2 + 8[005] - load outer S3 // [block] + 10[093] - non-local branch {test-break-update-in-finally-nested:26} + 16[089] - return S1 1 + id tests/type_propagation/finally-test.toit - argument 0: {String_|Null_|True|False|SmallInteger_|Exception_} 0[016] - load local 2 @@ -213,3 +485,22 @@ invoke tests/type_propagation/finally-test.toit 0[016] - load local 2 1[055] - invoke block S1 // [[block]] -> {} 3[090] - return null S1 1 + +invoke-catch tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in invoke-catch tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[090] - return null S4 1 + 17[097] - unwind + 18[041] - pop 1 + +[block] in invoke-catch tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[005] - load outer S3 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 diff --git a/tests/type_propagation/gold/finally-test.gold-O2 b/tests/type_propagation/gold/finally-test.gold-O2 index 2c124dbf5..75acc4699 100644 --- a/tests/type_propagation/gold/finally-test.gold-O2 +++ b/tests/type_propagation/gold/finally-test.gold-O2 @@ -6,7 +6,21 @@ main tests/type_propagation/finally-test.toit 8[053] - invoke static test-catchy tests/type_propagation/finally-test.toit // {Null_} 11[041] - pop 1 12[053] - invoke static test-nlb-out-of-try tests/type_propagation/finally-test.toit // {Null_} - 15[090] - return null S1 0 + 15[041] - pop 1 + 16[053] - invoke static test-throw-update-in-finally tests/type_propagation/finally-test.toit // {Null_} + 19[041] - pop 1 + 20[053] - invoke static test-break-update-in-finally tests/type_propagation/finally-test.toit // {Null_} + 23[041] - pop 1 + 24[053] - invoke static test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit // {Null_} + 27[041] - pop 1 + 28[053] - invoke static test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit // {Null_} + 31[041] - pop 1 + 32[053] - invoke static test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit // {Null_} + 35[041] - pop 1 + 36[053] - invoke static test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit // {Null_} + 39[041] - pop 1 + 40[053] - invoke static test-break-update-in-finally-nested tests/type_propagation/finally-test.toit // {Null_} + 43[090] - return null S1 0 test-is-exception tests/type_propagation/finally-test.toit 0[053] - invoke static return-is-exception tests/type_propagation/finally-test.toit // {True|False} @@ -196,6 +210,264 @@ test-nlb-out-of-try tests/type_propagation/finally-test.toit 4[091] - non-local return 16 6[089] - return S1 1 +test-throw-update-in-finally tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + 7[038] - load block 0 + 9[053] - invoke static invoke-catch tests/type_propagation/finally-test.toit // [[block]] -> {Null_} + 12[041] - pop 1 + 13[002] - pop, load local S0 + 15[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 18[090] - return null S2 0 + +[block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in [block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[000] - load local S6 + 16[020] - load literal true + 18[006] - store outer S1 + 20[041] - pop 1 + 21[097] - unwind + 22[041] - pop 1 + 23[022] - load null + 24[089] - return S1 1 + +[block] in [block] in test-throw-update-in-finally tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[020] - load literal ugh + 2[053] - invoke static throw /core/exceptions.toit // [{String_}] -> {} + 5[089] - return S1 1 + +test-break-update-in-finally tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-break-update-in-finally tests/type_propagation/finally-test.toit + 7[095] - link try 0 + 9[038] - load block 4 + 11[055] - invoke block S1 // [[block]] -> {} + 13[041] - pop 1 + 14[096] - unlink try 0 + 16[020] - load literal true + 18[004] - store local, pop S5 + 20[097] - unwind + 21[041] - pop 1 + 22[084] - branch back T2 + 27[014] - load local 0 + 28[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 31[090] - return null S2 0 + +[block] in test-break-update-in-finally tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally:27} + 7[089] - return S1 1 + +test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + 7[038] - load block 0 + 9[053] - invoke static invoke tests/type_propagation/finally-test.toit // [[block]] -> {} + 12[040] - pop 2 + 14[084] - branch back T2 + 19[014] - load local 0 + 20[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 23[090] - return null S2 0 + +[block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in [block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[000] - load local S6 + 16[020] - load literal true + 18[006] - store outer S1 + 20[041] - pop 1 + 21[097] - unwind + 22[041] - pop 1 + 23[022] - load null + 24[089] - return S1 1 + +[block] in [block] in test-break-update-in-finally-block0 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[005] - load outer S3 // [block] + 3[093] - non-local branch {test-break-update-in-finally-block0:19} + 9[089] - return S1 1 + +test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[029] - load method [block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + 7[029] - load method [block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + 12[095] - link try 0 + 14[038] - load block 4 + 16[055] - invoke block S1 // [[block]] -> {} + 18[041] - pop 1 + 19[096] - unlink try 0 + 21[020] - load literal true + 23[004] - store local, pop S6 + 25[097] - unwind + 26[040] - pop 2 + 28[084] - branch back T2 + 33[014] - load local 0 + 34[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 37[090] - return null S2 0 + +[block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally-block1:33} + 7[089] - return S1 1 + +[block] in test-break-update-in-finally-block1 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[039] - load outer block 1 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 + +test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 0[022] - load null + 1[029] - load method [block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 6[029] - load method [block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 11[095] - link try 0 + 13[038] - load block 4 + 15[055] - invoke block S1 // [[block]] -> {} + 17[041] - pop 1 + 18[096] - unlink try 0 + 20[020] - load literal true + 22[004] - store local, pop S6 + 24[029] - load method [block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + 29[095] - link try 0 + 31[038] - load block 4 + 33[055] - invoke block S1 // [[block]] -> {} + 35[041] - pop 1 + 36[096] - unlink try 0 + 38[020] - load literal false + 40[004] - store local, pop S10 + 42[097] - unwind + 43[041] - pop 1 + 44[097] - unwind + 45[040] - pop 2 + 47[084] - branch back T1 + 52[014] - load local 0 + 53[053] - invoke static id tests/type_propagation/finally-test.toit // [{Null_|True}] -> {Null_|True} + 56[090] - return null S2 0 + +[block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally-block2:52} + 7[089] - return S1 1 + +[block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[039] - load outer block 1 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 + +[block] in test-break-update-in-finally-block2 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[039] - load outer block 5 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1 + +test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + 0[020] - load literal false + 2[022] - load null + 3[029] - load method [block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + 8[029] - load method [block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + 13[095] - link try 0 + 15[038] - load block 4 + 17[055] - invoke block S1 // [[block]] -> {} + 19[041] - pop 1 + 20[096] - unlink try 0 + 22[020] - load literal true + 24[004] - store local, pop S7 + 26[097] - unwind + 27[041] - pop 1 + 28[084] - branch back T8 + 33[016] - load local 2 + 34[004] - store local, pop S2 + 36[041] - pop 1 + 37[084] - branch back T3 + 42[015] - load local 1 + 43[053] - invoke static id tests/type_propagation/finally-test.toit // [{False}] -> {False} + 46[002] - pop, load local S0 + 48[053] - invoke static id tests/type_propagation/finally-test.toit // [{Null_|False}] -> {Null_|False} + 51[090] - return null S3 0 + +[block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[093] - non-local branch {test-break-update-in-finally-block3:42} + 7[089] - return S1 1 + +[block] in test-break-update-in-finally-block3 tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[053] - invoke static pick tests/type_propagation/finally-test.toit // {True|False} + 3[083] - branch if false T14 + 6[016] - load local 2 + 7[039] - load outer block 1 // [block] + 9[055] - invoke block S1 // [[block]] -> {} + 11[081] - branch T21 + 14[016] - load local 2 + 15[093] - non-local branch {test-break-update-in-finally-block3:33} + 21[089] - return S1 1 + +test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + 0[022] - load null + 1[029] - load method [block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + 6[095] - link try 0 + 8[038] - load block 4 + 10[055] - invoke block S1 // [[block]] -> {} + 12[041] - pop 1 + 13[096] - unlink try 0 + 15[020] - load literal horse + 17[004] - store local, pop S5 + 19[097] - unwind + 20[041] - pop 1 + 21[084] - branch back T1 + 26[014] - load local 0 + 27[053] - invoke static id tests/type_propagation/finally-test.toit // [{SmallInteger_}] -> {SmallInteger_} + 30[090] - return null S2 0 + +[block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in [block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[000] - load local S6 + 16[020] - load literal true + 18[006] - store outer S1 + 20[041] - pop 1 + 21[097] - unwind + 22[041] - pop 1 + 23[022] - load null + 24[089] - return S1 1 + +[block] in [block] in test-break-update-in-finally-nested tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[005] - load outer S3 // [block] + 3[023] - load smi 0 + 4[006] - store outer S1 + 6[002] - pop, load local S2 + 8[005] - load outer S3 // [block] + 10[093] - non-local branch {test-break-update-in-finally-nested:26} + 16[089] - return S1 1 + id tests/type_propagation/finally-test.toit - argument 0: {String_|Null_|True|False|SmallInteger_|Exception_} 0[016] - load local 2 @@ -213,3 +485,22 @@ invoke tests/type_propagation/finally-test.toit 0[016] - load local 2 1[055] - invoke block S1 // [[block]] -> {} 3[041] - pop 1 + +invoke-catch tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[029] - load method [block] in invoke-catch tests/type_propagation/finally-test.toit + 5[095] - link try 0 + 7[038] - load block 4 + 9[055] - invoke block S1 // [[block]] -> {} + 11[041] - pop 1 + 12[096] - unlink try 0 + 14[090] - return null S4 1 + 17[097] - unwind + 18[041] - pop 1 + +[block] in invoke-catch tests/type_propagation/finally-test.toit + - argument 0: [block] + 0[016] - load local 2 + 1[005] - load outer S3 // [block] + 3[055] - invoke block S1 // [[block]] -> {} + 5[089] - return S1 1