Pseudocode: Add debug information to magic instructions

This commit is contained in:
Alexey Sedunov
2014-06-26 13:06:28 +04:00
parent d636d362b7
commit 4707f4a5e9
125 changed files with 1204 additions and 1157 deletions
@@ -21,7 +21,7 @@ L3:
jmp?(L2) INIT: in: {i=D} out: {i=D}
L4 [loop entry point]:
L5 [body entry point]:
magic(1..10|<v3>) -> <v4>
magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>
w(i|<v4>) INIT: in: {i=D} out: {i=ID}
mark(for (i in 1..10) { val a = i }) INIT: in: {i=ID} out: {i=ID}
4 mark({ val a = i })
@@ -7,7 +7,7 @@ fun foo() {
"after"
}
---------------------
<v4>: Int NEW: magic(1..10|<v3>) -> <v4>
<v4>: Int NEW: magic[LOOP_RANGE_ITERATION](1..10|<v3>) -> <v4>
"before" <v0>: * NEW: r("before") -> <v0>
1 <v1>: Int NEW: r(1) -> <v1>
10 <v2>: Int NEW: r(10) -> <v2>
@@ -15,4 +15,4 @@ fun foo() {
i <v5>: Int NEW: r(i) -> <v5>
"after" <v6>: * NEW: r("after") -> <v6>
{ "before" for (i in 1..10) { val a = i } "after" } <v6>: * COPY
=====================
=====================
@@ -38,21 +38,21 @@ sink:
}
---------------------
L3:
3 <START> INIT: in: {} out: {}
v(x: Int) INIT: in: {} out: {x=D}
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
4 mark(val a = x + b) INIT: in: {x=ID} out: {x=ID}
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
3 <START> INIT: in: {} out: {}
v(x: Int) INIT: in: {} out: {x=D}
magic[FAKE_INITIALIZER](x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
4 mark(val a = x + b) INIT: in: {x=ID} out: {x=ID}
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
mark(x + b)
call(x + b, plus|<v1>, <v2>) -> <v3>
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
L4:
3 <END> INIT: in: {x=ID} out: {x=ID}
3 <END> INIT: in: {x=ID} out: {x=ID}
error:
<ERROR> INIT: in: {} out: {}
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
=====================
@@ -19,8 +19,8 @@ fun foo() {
val a = x + b
}
---------------------
<v0>: Int NEW: magic(x: Int) -> <v0>
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
x <v1>: Int NEW: r(x) -> <v1>
b <v2>: Int NEW: r(b) -> <v2>
x + b <v3>: Int NEW: call(x + b, plus|<v1>, <v2>) -> <v3>
=====================
=====================
@@ -18,11 +18,11 @@ L0:
mark("before")
r("before") -> <v0>
v(val x: Int) INIT: in: {} out: {x=D}
magic(val x: Int) -> <v1> INIT: in: {x=D} 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}
3 mark({ val a = x }) INIT: in: {x=ID} out: {x=ID}
v(val a = x) INIT: in: {x=ID} out: {a=D, x=ID}
magic(x) -> <v2> INIT: in: {a=D, x=ID} out: {a=D, x=ID}
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}
@@ -43,16 +43,16 @@ fun foo() {
}
---------------------
L3:
3 <START> INIT: in: {} out: {}
3 <START> INIT: in: {} out: {}
4 mark({ val b = x })
v(val b = x) INIT: in: {} out: {b=D}
magic(x) -> <v0> INIT: in: {b=D} out: {b=D} USE: in: {x=READ} out: {x=READ}
r(x|<v0>) -> <v1> USE: in: {} out: {x=READ}
w(b|<v1>) INIT: in: {b=D} out: {b=ID}
v(val b = x) INIT: in: {} out: {b=D}
magic[IMPLICIT_RECEIVER](x) -> <v0> INIT: in: {b=D} out: {b=D} USE: in: {x=READ} out: {x=READ}
r(x|<v0>) -> <v1> USE: in: {} out: {x=READ}
w(b|<v1>) INIT: in: {b=D} out: {b=ID}
L4:
3 <END> INIT: in: {} out: {}
3 <END> INIT: in: {} out: {}
error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
<SINK> USE: in: {} out: {}
=====================
@@ -12,8 +12,8 @@ fun foo() {
"after"
}
---------------------
<v1>: Int NEW: magic(val x: Int) -> <v1>
<v2>: A NEW: magic(x) -> <v2>
<v1>: Int NEW: magic[FAKE_INITIALIZER](val x: Int) -> <v1>
<v2>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v2>
"before" <v0>: * NEW: r("before") -> <v0>
x <v3>: Int NEW: r(x|<v2>) -> <v3>
"after" <v4>: * NEW: r("after") -> <v4>
@@ -24,6 +24,6 @@ fun foo() {
val b = x
}
---------------------
<v0>: A NEW: magic(x) -> <v0>
<v0>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v0>
x <v1>: Int NEW: r(x|<v0>) -> <v1>
=====================
=====================
@@ -34,21 +34,21 @@ fun local(x: Int) {
}
---------------------
L3:
3 <START> INIT: in: {} out: {}
v(x: Int) INIT: in: {} out: {x=D}
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
4 mark({ val a = x + b }) INIT: in: {x=ID} out: {x=ID}
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
3 <START> INIT: in: {} out: {}
v(x: Int) INIT: in: {} out: {x=D}
magic[FAKE_INITIALIZER](x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
4 mark({ val a = x + b }) INIT: in: {x=ID} out: {x=ID}
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
mark(x + b)
call(x + b, plus|<v1>, <v2>) -> <v3>
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
L4:
3 <END> INIT: in: {x=ID} out: {x=ID}
3 <END> INIT: in: {x=ID} out: {x=ID}
error:
<ERROR> INIT: in: {} out: {}
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
=====================
@@ -18,8 +18,8 @@ fun local(x: Int) {
val a = x + b
}
---------------------
<v0>: Int NEW: magic(x: Int) -> <v0>
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
x <v1>: Int NEW: r(x) -> <v1>
b <v2>: Int NEW: r(b) -> <v2>
x + b <v3>: Int NEW: call(x + b, plus|<v1>, <v2>) -> <v3>
=====================
=====================
@@ -30,19 +30,19 @@ sink:
fun local(x: Int) = x + b
---------------------
L3:
3 <START> INIT: in: {} out: {}
v(x: Int) INIT: in: {} out: {x=D}
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
w(x|<v0>) INIT: in: {x=D} out: {x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {x=ID} out: {x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
3 <START> INIT: in: {} out: {}
v(x: Int) INIT: in: {} out: {x=D}
magic[FAKE_INITIALIZER](x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
w(x|<v0>) INIT: in: {x=D} out: {x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
r(x) -> <v1> INIT: in: {x=ID} out: {x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
r(b) -> <v2> USE: in: {} out: {b=READ}
mark(x + b)
call(x + b, plus|<v1>, <v2>) -> <v3>
ret(*|<v3>) L4
L4:
<END>
error:
<ERROR> INIT: in: {} out: {}
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
<SINK> INIT: in: {x=ID} out: {x=ID} USE: in: {} out: {}
=====================
@@ -7,15 +7,15 @@ fun foo() {
}
---------------------
"before" <v0>: * NEW: r("before") -> <v0>
1 <v1>: Int NEW: r(1) -> <v1>
"after" <v2>: * NEW: r("after") -> <v2>
{ "before" val b = 1 fun local(x: Int) = x + b "after" } <v2>: * COPY
1 <v1>: Int NEW: r(1) -> <v1>
"after" <v2>: * NEW: r("after") -> <v2>
{ "before" val b = 1 fun local(x: Int) = x + b "after" } <v2>: * COPY
=====================
== local ==
fun local(x: Int) = x + b
---------------------
<v0>: Int NEW: magic(x: Int) -> <v0>
x <v1>: Int NEW: r(x) -> <v1>
b <v2>: Int NEW: r(b) -> <v2>
x + b <v3>: Int NEW: call(x + b, plus|<v1>, <v2>) -> <v3>
=====================
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
x <v1>: Int NEW: r(x) -> <v1>
b <v2>: Int NEW: r(b) -> <v2>
x + b <v3>: Int NEW: call(x + b, plus|<v1>, <v2>) -> <v3>
=====================
@@ -34,17 +34,17 @@ get() {
}
---------------------
L3:
3 <START> INIT: in: {} out: {}
3 <START> INIT: in: {} out: {}
4 mark({ return $a })
magic($a) -> <v0> USE: in: {a=READ} out: {a=READ}
r($a|<v0>) -> <v1> USE: in: {} out: {a=READ}
magic[IMPLICIT_RECEIVER]($a) -> <v0> USE: in: {a=READ} out: {a=READ}
r($a|<v0>) -> <v1> USE: in: {} out: {a=READ}
ret(*|<v1>) L4
L4:
3 <END>
error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
<SINK> USE: in: {} out: {}
=====================
== set_a ==
set(v: Int) {
@@ -52,18 +52,18 @@ set(v: Int) {
}
---------------------
L6:
3 <START> INIT: in: {} out: {}
v(v: Int) INIT: in: {} out: {v=D}
magic(v: Int) -> <v0> INIT: in: {v=D} out: {v=D}
w(v|<v0>) INIT: in: {v=D} out: {v=ID}
4 mark({ $a = v }) INIT: in: {v=ID} out: {v=ID}
magic($a) -> <v1> USE: in: {a=ONLY_WRITTEN_NEVER_READ, v=READ} out: {a=ONLY_WRITTEN_NEVER_READ, v=READ}
r(v) -> <v2> USE: in: {a=ONLY_WRITTEN_NEVER_READ} out: {a=ONLY_WRITTEN_NEVER_READ, v=READ}
w($a|<v1>, <v2>) INIT: in: {v=ID} out: {a=I, v=ID} USE: in: {} out: {a=ONLY_WRITTEN_NEVER_READ}
3 <START> INIT: in: {} out: {}
v(v: Int) INIT: in: {} out: {v=D}
magic[FAKE_INITIALIZER](v: Int) -> <v0> INIT: in: {v=D} out: {v=D}
w(v|<v0>) INIT: in: {v=D} out: {v=ID}
4 mark({ $a = v }) INIT: in: {v=ID} out: {v=ID}
magic[IMPLICIT_RECEIVER]($a) -> <v1> USE: in: {a=ONLY_WRITTEN_NEVER_READ, v=READ} out: {a=ONLY_WRITTEN_NEVER_READ, v=READ}
r(v) -> <v2> USE: in: {a=ONLY_WRITTEN_NEVER_READ} out: {a=ONLY_WRITTEN_NEVER_READ, v=READ}
w($a|<v1>, <v2>) INIT: in: {v=ID} out: {a=I, v=ID} USE: in: {} out: {a=ONLY_WRITTEN_NEVER_READ}
L7:
3 <END> INIT: in: {a=I, v=ID} out: {a=I, v=ID}
3 <END> INIT: in: {a=I, v=ID} out: {a=I, v=ID}
error:
<ERROR> INIT: in: {} out: {}
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {a=I, v=ID} out: {a=I, v=ID} USE: in: {} out: {}
<SINK> INIT: in: {a=I, v=ID} out: {a=I, v=ID} USE: in: {} out: {}
=====================
@@ -17,7 +17,7 @@ get() {
return $a
}
---------------------
<v0>: A NEW: magic($a) -> <v0>
<v0>: A NEW: magic[IMPLICIT_RECEIVER]($a) -> <v0>
$a <v1>: Int NEW: r($a|<v0>) -> <v1>
=====================
== set_a ==
@@ -25,7 +25,7 @@ set(v: Int) {
$a = v
}
---------------------
<v0>: Int NEW: magic(v: Int) -> <v0>
<v1>: A NEW: magic($a) -> <v1>
<v0>: Int NEW: magic[FAKE_INITIALIZER](v: Int) -> <v0>
<v1>: A NEW: magic[IMPLICIT_RECEIVER]($a) -> <v1>
v <v2>: Int NEW: r(v) -> <v2>
=====================
=====================
@@ -27,7 +27,7 @@ L0:
2 jmp(L4 [afterCatches]) USE: in: {} out: {}
L2 [onException]:
3 v(e: Exception) INIT: in: {} out: {e=D}
magic(e: Exception) -> <v2> INIT: in: {e=D} out: {e=D}
magic[FAKE_INITIALIZER](e: Exception) -> <v2> INIT: in: {e=D} out: {e=D}
w(e|<v2>) INIT: in: {e=D} out: {e=ID}
4 mark({ val a = e }) INIT: in: {e=ID} out: {e=ID}
v(val a = e) INIT: in: {e=ID} out: {a=D, e=ID} USE: in: {e=READ} out: {e=READ}
@@ -13,7 +13,7 @@ fun foo() {
"after"
}
---------------------
<v2>: {<: Exception} NEW: magic(e: Exception) -> <v2>
<v2>: {<: Exception} NEW: magic[FAKE_INITIALIZER](e: Exception) -> <v2>
"before" <v0>: * NEW: r("before") -> <v0>
foo() <v1>: * NEW: call(foo(), foo) -> <v1>
{ foo() } <v1>: * COPY
@@ -22,4 +22,4 @@ e
try { foo() } catch (e: Exception) { val a = e } finally { val a = 1 } <v1>: * COPY
"after" <v5>: * NEW: r("after") -> <v5>
{ "before" try { foo() } catch (e: Exception) { val a = e } finally { val a = 1 } "after" } <v5>: * COPY
=====================
=====================