Permalink
Browse files

SI-5313 Test clobbers on the back edge of a loop

I realized I was missing a test case for a local store early in a loop
that was unused but turned out to be a clobber of a store later in the
loop.
  • Loading branch information...
1 parent 9b4fa83 commit c7d489e21f234bf1a2ea04c6b68990c53b5b387d @JamesIry JamesIry committed Feb 2, 2013
Showing with 10 additions and 2 deletions.
  1. +2 −0 test/files/run/t5313.check
  2. +8 −2 test/files/run/t5313.scala
View
2 test/files/run/t5313.check
@@ -8,3 +8,5 @@ STORE_LOCAL(variable kept4)
STORE_LOCAL(variable kept4)
STORE_LOCAL(variable kept5)
STORE_LOCAL(variable kept5)
+STORE_LOCAL(variable kept6)
+STORE_LOCAL(variable kept6)
View
10 test/files/run/t5313.scala
@@ -7,7 +7,7 @@ object Test extends IcodeTest {
override def code =
"""class Foo {
- def foo = true
+ def randomBoolean = util.Random.nextInt % 2 == 0
def bar = {
var kept1 = new Object
val result = new java.lang.ref.WeakReference(kept1)
@@ -19,7 +19,7 @@ object Test extends IcodeTest {
var erased4 = erased2 // and this
val erased5 = erased4 // and this
var kept2: Object = new Object // ultimately can't be eliminated
- while(foo) {
+ while(randomBoolean) {
val kept3 = kept2
kept2 = null // this can't, because it clobbers kept2, which is used
erased4 = null // safe to eliminate
@@ -36,6 +36,12 @@ object Test extends IcodeTest {
kept5 = null // can't eliminate it's a clobber and it's used
print(kept5)
kept5 = null // can eliminate because we don't care about clobbers of nulls
+ while(randomBoolean) {
+ var kept6: AnyRef = null // not used, but have to keep because it clobbers the next used store
+ // on the back edge of the loop
+ kept6 = new Object // used
+ println(kept6)
+ }
result
}
}""".stripMargin

0 comments on commit c7d489e

Please sign in to comment.