More accurate CFG for local class constructors (now they are not considered unconditionally executed) #KT-10042 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-03-21 17:35:53 +03:00
parent 8756cba2f5
commit b975b7d26e
15 changed files with 155 additions and 36 deletions
@@ -17,6 +17,7 @@ L0:
2 mark({ "before" class A(val x: Int) { init { val a = x } fun foo() { val b = x } } "after" })
mark("before")
r("before") -> <v0>
jmp?(L2)
v(val x: Int) INIT: in: {} out: {x=D}
magic[FAKE_INITIALIZER](val x: Int) -> <v1> INIT: in: {x=D} out: {x=D}
w(x|<v1>) INIT: in: {x=D} out: {x=ID}
@@ -25,9 +26,10 @@ L0:
magic[IMPLICIT_RECEIVER](x) -> <v2> INIT: in: {a=D, x=ID} out: {a=D, x=ID}
r(x|<v2>) -> <v3>
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
2 jmp?(L2) INIT: in: {x=ID} out: {x=ID}
2 jmp?(L3) INIT: in: {x=ID} out: {x=ID}
d(fun foo() { val b = x }) USE: in: {x=READ} out: {x=READ}
L2 [after local declaration]:
L2 [after local class]:
L3 [after local declaration]:
mark("after")
r("after") -> <v4>
L1:
@@ -42,14 +44,14 @@ fun foo() {
val b = x
}
---------------------
L3:
L4:
3 <START> INIT: in: {x=ID} out: {x=ID}
4 mark({ val b = x })
v(val b = x) INIT: in: {x=ID} out: {b=D, x=ID}
magic[IMPLICIT_RECEIVER](x) -> <v0> INIT: in: {b=D, x=ID} out: {b=D, x=ID} USE: in: {x=READ} out: {x=READ}
r(x|<v0>) -> <v1> USE: in: {} out: {x=READ}
w(b|<v1>) INIT: in: {b=D, x=ID} out: {b=ID, x=ID}
L4:
L5:
3 <END> INIT: in: {x=ID} out: {x=ID}
error:
<ERROR> INIT: in: {} out: {}
@@ -17,13 +17,15 @@ L0:
2 mark({ "before" object A { init { val a = 1 } fun foo() { val b = 2 } } "after" })
mark("before")
r("before") -> <v0>
jmp?(L2)
3 mark({ val a = 1 })
v(val a = 1) INIT: in: {} out: {a=D}
r(1) -> <v1> INIT: in: {a=D} out: {a=D}
w(a|<v1>) INIT: in: {a=D} out: {a=ID}
2 jmp?(L2) INIT: in: {} out: {}
2 jmp?(L3) INIT: in: {} out: {}
d(fun foo() { val b = 2 })
L2 [after local declaration]:
L2 [after local class]:
L3 [after local declaration]:
mark("after")
r("after") -> <v2>
L1:
@@ -38,13 +40,13 @@ fun foo() {
val b = 2
}
---------------------
L3:
L4:
3 <START> INIT: in: {} out: {}
4 mark({ val b = 2 })
v(val b = 2) INIT: in: {} out: {b=D}
r(2) -> <v0> INIT: in: {b=D} out: {b=D}
w(b|<v0>) INIT: in: {b=D} out: {b=ID}
L4:
L5:
3 <END> INIT: in: {} out: {}
error:
<ERROR>
@@ -14,14 +14,16 @@ fun foo() {
L0:
1 <START> INIT: in: {} out: {}
2 mark({ class A { var a : Int get() { return field } set(v: Int) { field = v } } })
jmp?(L2)
v(var a : Int get() { return field } set(v: Int) { field = v }) INIT: in: {} out: {a=D}
jmp?(L2) INIT: in: {a=D} out: {a=D} USE: in: {field=ONLY_WRITTEN_NEVER_READ, field=READ} out: {field=ONLY_WRITTEN_NEVER_READ, field=READ}
jmp?(L3) INIT: in: {a=D} out: {a=D} USE: in: {field=ONLY_WRITTEN_NEVER_READ, field=READ} out: {field=ONLY_WRITTEN_NEVER_READ, field=READ}
d(get() { return field }) USE: in: {field=READ} out: {field=READ}
L2 [after local declaration]:
jmp?(L5)
L3 [after local declaration]:
jmp?(L6)
d(set(v: Int) { field = v }) INIT: in: {a=D, field=I} out: {a=D, field=I} USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ}
L1:
L5 [after local declaration]:
L2 [after local class]:
L6 [after local declaration]:
1 <END> INIT: in: {} out: {}
error:
<ERROR>
@@ -33,12 +35,12 @@ get() {
return field
}
---------------------
L3:
L4:
3 <START> INIT: in: {a=D} out: {a=D}
4 mark({ return field }) USE: in: {field=READ} out: {field=READ}
r(field) -> <v0> USE: in: {} out: {field=READ}
ret(*|<v0>) L4
L4:
ret(*|<v0>) L5
L5:
3 <END>
error:
<ERROR> INIT: in: {} out: {}
@@ -50,7 +52,7 @@ set(v: Int) {
field = v
}
---------------------
L6:
L7:
3 <START> INIT: in: {a=D} out: {a=D}
v(v: Int) INIT: in: {a=D} out: {a=D, v=D}
magic[FAKE_INITIALIZER](v: Int) -> <v0> INIT: in: {a=D, v=D} out: {a=D, v=D}
@@ -58,7 +60,7 @@ L6:
4 mark({ field = v }) INIT: in: {a=D, v=ID} out: {a=D, v=ID} USE: in: {field=ONLY_WRITTEN_NEVER_READ, v=READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
r(v) -> <v1> USE: in: {field=ONLY_WRITTEN_NEVER_READ} out: {field=ONLY_WRITTEN_NEVER_READ, v=READ}
w(field|<v1>) INIT: in: {a=D, v=ID} out: {a=D, field=I, v=ID} USE: in: {} out: {field=ONLY_WRITTEN_NEVER_READ}
L7:
L8:
3 <END> INIT: in: {a=D, field=I, v=ID} out: {a=D, field=I, v=ID}
error:
<ERROR> INIT: in: {} out: {}