mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
340 lines
28 KiB
Plaintext
Vendored
340 lines
28 KiB
Plaintext
Vendored
== myRun ==
|
|
inline fun <T> myRun(block: () -> T): T {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
return block()
|
|
}
|
|
---------------------
|
|
L0:
|
|
1 <START> INIT: in: {} out: {}
|
|
v(block: () -> T) INIT: in: {} out: {}
|
|
magic[FAKE_INITIALIZER](block: () -> T) -> <v0> INIT: in: {} out: {}
|
|
w(block|<v0>) INIT: in: {} out: {}
|
|
2 mark({ contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() }) INIT: in: {} out: {}
|
|
mark({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
|
|
jmp?(L2)
|
|
d({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
|
|
L2 [after local declaration]:
|
|
r({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) -> <v1>
|
|
mark(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
|
|
call(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }, contract|<v1>) -> <v2>
|
|
r(block) -> <v3>
|
|
mark(block())
|
|
call(block(), invoke|<v3>) -> <v4>
|
|
ret(*|<v4>) L1
|
|
L1:
|
|
1 <END>
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== anonymous_0 ==
|
|
{
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
---------------------
|
|
L3:
|
|
3 <START> INIT: in: {} out: {}
|
|
4 mark(callsInPlace(block, InvocationKind.EXACTLY_ONCE))
|
|
magic[IMPLICIT_RECEIVER](callsInPlace(block, InvocationKind.EXACTLY_ONCE)) -> <v0>
|
|
r(block) -> <v1>
|
|
mark(InvocationKind.EXACTLY_ONCE)
|
|
r(EXACTLY_ONCE) -> <v2>
|
|
mark(callsInPlace(block, InvocationKind.EXACTLY_ONCE))
|
|
call(callsInPlace(block, InvocationKind.EXACTLY_ONCE), callsInPlace|<v0>, <v1>, <v2>) -> <v3>
|
|
L4:
|
|
3 <END>
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== innerComputation ==
|
|
fun innerComputation(): Int = 42
|
|
---------------------
|
|
L0:
|
|
1 <START> INIT: in: {} out: {}
|
|
r(42) -> <v0>
|
|
ret(*|<v0>) L1
|
|
L1:
|
|
<END>
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== outerComputation ==
|
|
fun outerComputation(): Int = 52
|
|
---------------------
|
|
L0:
|
|
1 <START> INIT: in: {} out: {}
|
|
r(52) -> <v0>
|
|
ret(*|<v0>) L1
|
|
L1:
|
|
<END>
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== log ==
|
|
fun log() = Unit
|
|
---------------------
|
|
L0:
|
|
1 <START> INIT: in: {} out: {}
|
|
r(Unit) -> <v0>
|
|
ret(*|<v0>) L1
|
|
L1:
|
|
<END>
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== outerFinallyInitializes ==
|
|
fun outerFinallyInitializes() {
|
|
val x: Int
|
|
|
|
try {
|
|
myRun {
|
|
try {
|
|
x = innerComputation()
|
|
} catch (e: java.lang.Exception) {
|
|
log()
|
|
}
|
|
// possible reassignment if innerComputation finished
|
|
x = 42
|
|
}
|
|
|
|
// Definite reassignment here, cause can get here only if myRun finished
|
|
x = outerComputation()
|
|
} catch (e: java.lang.Exception) {
|
|
// can catch exception thrown by the inner, so x can be not initalized
|
|
log()
|
|
} finally {
|
|
// Possible reassignment (e.g. if everything finished)
|
|
x = 42
|
|
}
|
|
|
|
// Properly initialized
|
|
x.inc()
|
|
}
|
|
---------------------
|
|
L0:
|
|
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
|
2 mark({ val x: Int try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initalized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 } // Properly initialized x.inc() })
|
|
v(val x: Int) INIT: in: {} out: {x=D}
|
|
mark(try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initalized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 }) INIT: in: {x=D} out: {x=D}
|
|
jmp?(L2)
|
|
jmp?(L3)
|
|
3 mark({ myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() })
|
|
mark({ try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 })
|
|
r({ try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }) -> <v0>
|
|
mark(myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 })
|
|
call(myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }, myRun|<v0>) -> <v1>
|
|
L4 [before inlined declaration]:
|
|
inlined({ try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 }) INIT: in: {x=ID} out: {x=ID}
|
|
L5 [after inlined declaration]:
|
|
mark(outerComputation())
|
|
call(outerComputation(), outerComputation) -> <v2>
|
|
w(x|<v2>)
|
|
2 jmp?(L2)
|
|
jmp?(L3)
|
|
jmp(L10)
|
|
L2 [onException]:
|
|
3 v(e: java.lang.Exception) INIT: in: {x=I?D} out: {x=I?D}
|
|
magic[FAKE_INITIALIZER](e: java.lang.Exception) -> <v4> INIT: in: {x=I?D} out: {x=I?D}
|
|
w(e|<v4>) INIT: in: {x=I?D} out: {x=I?D}
|
|
4 mark({ // can catch exception thrown by the inner, so x can be not initalized log() }) INIT: in: {x=I?D} out: {x=I?D}
|
|
mark(log())
|
|
call(log(), log) -> <v5>
|
|
3 jmp(L10)
|
|
L10 [afterCatches]:
|
|
2 jmp(L11) USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
L3 [onExceptionToFinallyBlock]:
|
|
L12 [start finally]:
|
|
3 mark({ // Possible reassignment (e.g. if everything finished) x = 42 })
|
|
r(42) -> <v6> USE: in: {x=ONLY_WRITTEN_NEVER_READ} out: {x=ONLY_WRITTEN_NEVER_READ}
|
|
w(x|<v6>) INIT: in: {x=I?D} out: {x=ID} USE: in: {} out: {x=ONLY_WRITTEN_NEVER_READ}
|
|
L13 [finish finally]:
|
|
2 jmp(error) INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
|
|
L11 [skipFinallyToErrorBlock]:
|
|
L14 [copy of L3, onExceptionToFinallyBlock]:
|
|
3 mark({ // Possible reassignment (e.g. if everything finished) x = 42 }) INIT: in: {x=I?D} out: {x=I?D}
|
|
r(42) -> <v6> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
w(x|<v6>) INIT: in: {x=I?D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ}
|
|
2 merge(try { myRun { try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42 } // Definite reassignment here, cause can get here only if myRun finished x = outerComputation() } catch (e: java.lang.Exception) { // can catch exception thrown by the inner, so x can be not initalized log() } finally { // Possible reassignment (e.g. if everything finished) x = 42 }|!<v3>, <v5>) -> <v8> INIT: in: {x=ID} out: {x=ID}
|
|
mark(x.inc()) USE: in: {x=READ} out: {x=READ}
|
|
r(x) -> <v9> USE: in: {} out: {x=READ}
|
|
mark(inc())
|
|
call(inc(), inc|<v9>) -> <v10>
|
|
L1:
|
|
1 <END> INIT: in: {} out: {}
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== inlined anonymous_1 ==
|
|
{
|
|
try {
|
|
x = innerComputation()
|
|
} catch (e: java.lang.Exception) {
|
|
log()
|
|
}
|
|
// possible reassignment if innerComputation finished
|
|
x = 42
|
|
}
|
|
---------------------
|
|
L6:
|
|
4 <START> INIT: in: {x=D} out: {x=D}
|
|
5 mark(try { x = innerComputation() } catch (e: java.lang.Exception) { log() } // possible reassignment if innerComputation finished x = 42)
|
|
mark(try { x = innerComputation() } catch (e: java.lang.Exception) { log() })
|
|
jmp?(L8)
|
|
6 mark({ x = innerComputation() })
|
|
mark(innerComputation())
|
|
call(innerComputation(), innerComputation) -> <v0>
|
|
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
|
5 jmp?(L8) INIT: in: {x=ID} out: {x=ID}
|
|
jmp(L9)
|
|
L8 [onException]:
|
|
6 v(e: java.lang.Exception) INIT: in: {x=I?D} out: {x=I?D}
|
|
magic[FAKE_INITIALIZER](e: java.lang.Exception) -> <v2> INIT: in: {x=I?D} out: {x=I?D}
|
|
w(e|<v2>) INIT: in: {x=I?D} out: {x=I?D}
|
|
7 mark({ log() }) INIT: in: {x=I?D} out: {x=I?D}
|
|
mark(log())
|
|
call(log(), log) -> <v3>
|
|
6 jmp(L9)
|
|
L9 [afterCatches]:
|
|
5 merge(try { x = innerComputation() } catch (e: java.lang.Exception) { log() }|!<v1>, <v3>) -> <v4>
|
|
r(42) -> <v5>
|
|
w(x|<v5>) INIT: in: {x=I?D} out: {x=ID}
|
|
L7:
|
|
4 <END> INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
error:
|
|
- <ERROR>
|
|
sink:
|
|
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
=====================
|
|
== innerFinalltInitializes ==
|
|
fun innerFinalltInitializes() {
|
|
val x: Int
|
|
try {
|
|
myRun {
|
|
try {
|
|
innerComputation()
|
|
} catch (e: java.lang.Exception) {
|
|
log()
|
|
} finally {
|
|
x = 42
|
|
}
|
|
}
|
|
|
|
// Properly initialized
|
|
x.inc()
|
|
} catch (e: java.lang.Exception) {
|
|
log()
|
|
}
|
|
|
|
// Still can be non-initialized (e.g. if x.inc() threw an exception)
|
|
x.inc()
|
|
}
|
|
---------------------
|
|
L0:
|
|
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
|
2 mark({ val x: Int try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() } // Still can be non-initialized (e.g. if x.inc() threw an exception) x.inc() })
|
|
v(val x: Int) INIT: in: {} out: {x=D}
|
|
mark(try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() }) INIT: in: {x=D} out: {x=D}
|
|
jmp?(L2) USE: in: {x=READ} out: {x=READ}
|
|
3 mark({ myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() })
|
|
mark({ try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } })
|
|
r({ try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }) -> <v0>
|
|
mark(myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } })
|
|
call(myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }, myRun|<v0>) -> <v1>
|
|
L3 [before inlined declaration]:
|
|
inlined({ try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } }) INIT: in: {x=ID} out: {x=ID} USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
L4 [after inlined declaration]:
|
|
mark(x.inc())
|
|
r(x) -> <v2>
|
|
mark(inc())
|
|
call(inc(), inc|<v2>) -> <v3>
|
|
2 jmp?(L2)
|
|
jmp(L14)
|
|
L2 [onException]:
|
|
3 v(e: java.lang.Exception) INIT: in: {x=I?D} out: {x=I?D}
|
|
magic[FAKE_INITIALIZER](e: java.lang.Exception) -> <v4> INIT: in: {x=I?D} out: {x=I?D}
|
|
w(e|<v4>) INIT: in: {x=I?D} out: {x=I?D}
|
|
4 mark({ log() }) INIT: in: {x=I?D} out: {x=I?D}
|
|
mark(log())
|
|
call(log(), log) -> <v5>
|
|
3 jmp(L14)
|
|
L14 [afterCatches]:
|
|
2 merge(try { myRun { try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 } } // Properly initialized x.inc() } catch (e: java.lang.Exception) { log() }|<v3>, <v5>) -> <v6>
|
|
mark(x.inc()) USE: in: {x=READ} out: {x=READ}
|
|
r(x) -> <v7> USE: in: {} out: {x=READ}
|
|
mark(inc())
|
|
call(inc(), inc|<v7>) -> <v8>
|
|
L1:
|
|
1 <END> INIT: in: {} out: {}
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {} out: {}
|
|
=====================
|
|
== inlined anonymous_2 ==
|
|
{
|
|
try {
|
|
innerComputation()
|
|
} catch (e: java.lang.Exception) {
|
|
log()
|
|
} finally {
|
|
x = 42
|
|
}
|
|
}
|
|
---------------------
|
|
L5:
|
|
4 <START> INIT: in: {x=D} out: {x=D}
|
|
5 mark(try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 })
|
|
mark(try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 })
|
|
jmp?(L7)
|
|
jmp?(L8)
|
|
6 mark({ innerComputation() })
|
|
mark(innerComputation())
|
|
call(innerComputation(), innerComputation) -> <v0>
|
|
5 jmp?(L7)
|
|
jmp?(L8)
|
|
jmp(L9)
|
|
L7 [onException]:
|
|
6 v(e: java.lang.Exception) INIT: in: {x=D} out: {x=D}
|
|
magic[FAKE_INITIALIZER](e: java.lang.Exception) -> <v1> INIT: in: {x=D} out: {x=D}
|
|
w(e|<v1>) INIT: in: {x=D} out: {x=D}
|
|
7 mark({ log() }) INIT: in: {x=D} out: {x=D}
|
|
mark(log())
|
|
call(log(), log) -> <v2>
|
|
6 jmp(L9)
|
|
L9 [afterCatches]:
|
|
5 jmp(L10)
|
|
L8 [onExceptionToFinallyBlock]:
|
|
L11 [start finally]:
|
|
6 mark({ x = 42 })
|
|
r(42) -> <v3> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
w(x|<v3>) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ}
|
|
L12 [finish finally]:
|
|
5 jmp(error) INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ}
|
|
L10 [skipFinallyToErrorBlock]:
|
|
L13 [copy of L8, onExceptionToFinallyBlock]:
|
|
6 mark({ x = 42 }) INIT: in: {x=D} out: {x=D}
|
|
r(42) -> <v3> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
|
w(x|<v3>) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ}
|
|
5 merge(try { innerComputation() } catch (e: java.lang.Exception) { log() } finally { x = 42 }|<v0>, <v2>) -> <v5> INIT: in: {x=ID} out: {x=ID}
|
|
4 ret(*|<v5>) L6
|
|
L6:
|
|
<END>
|
|
error:
|
|
<ERROR>
|
|
sink:
|
|
<SINK> USE: in: {x=READ} out: {x=READ}
|
|
=====================
|