Files
kotlin-fork/compiler/testData/cfg/bugs/jumpToOuterScope.instructions
T
Denis Zharkov 02b40326cc Fix incorrect coroutines codegen behavior
If all the suspension calls in a suspend function were "hidden"
under the for-convention (iterator/next/hasNext) calls,
control-flow didn't find them, thus supposing that there is no
suspension points and there is no need to generate a coroutine state machine

The solution is to add relevant calls to CFG

 #KT-15824 Fixed
2017-01-25 13:54:01 +03:00

64 lines
1.8 KiB
Plaintext
Vendored

== foo ==
fun foo(c: Collection<Int>) {
for (e in c) {
{
break
}
}
}
---------------------
L0:
1 <START>
v(c: Collection<Int>)
magic[FAKE_INITIALIZER](c: Collection<Int>) -> <v0>
w(c|<v0>)
2 mark({ for (e in c) { { break } } })
3 r(c) -> <v1>
mark(c)
call(c, iterator|<v1>) -> <v2>
v(e)
L2 [loop entry point]:
L6 [condition entry point]:
mark(c) PREV:[v(e), jmp(L2)]
call(c, hasNext) -> <v3>
jmp?(L3) NEXT:[read (Unit), mark(c)]
mark(c)
call(c, next) -> <v4>
magic[LOOP_RANGE_ITERATION](c|<v4>) -> <v5>
w(e|<v5>)
mark(for (e in c) { { break } })
L4 [body entry point]:
4 mark({ { break } })
mark({ break })
jmp?(L7) NEXT:[r({ break }) -> <v6>, d({ break })]
d({ break }) NEXT:[<SINK>]
L7 [after local declaration]:
r({ break }) -> <v6> PREV:[jmp?(L7)]
3 jmp(L2) NEXT:[mark(c)]
L3 [loop exit point]:
L5 [body exit point]:
read (Unit) PREV:[jmp?(L3)]
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>, d({ break })]
=====================
== anonymous_0 ==
{
break
}
---------------------
L8:
5 <START>
6 mark(break)
5 ret(*|!<v0>) L9
L9:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================