summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2016-01-23 21:03:10 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2016-01-24 13:02:04 +0100
commit790ed59d9fe5ca396984b8a5135b7a091e4224f7 (patch)
treed201cf146983de404728ed6e0d2f46940f44496b /test/junit
parent8d3be4dc79cb4679fc4994c32b21e10847e5518f (diff)
downloadscala-790ed59d9fe5ca396984b8a5135b7a091e4224f7.tar.gz
scala-790ed59d9fe5ca396984b8a5135b7a091e4224f7.tar.bz2
scala-790ed59d9fe5ca396984b8a5135b7a091e4224f7.zip
SI-8601 Don't treat newarray as dead code
Otherwise we lose the side effect of a `NegativeArraySizeException`. A test for this case already exists (run/t8601b.scala), but it currently enforces `-optimize -Ybackend:GenASM`, so it didn't trigger on the new backend. However, PR #4814 was merged into 2.12.x and moved that test over to the new backend and optimizer. After merging the 2.12.x into the current optimizer branch (push-pop elimination), the test started failing. Also disable the optimizer for `jvm/bytecode-test-example`: it counts the number of null checks in a method, the optimizer (rightly) eliminates one of the two.
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
index 5ee52ff78f..ec063c6cb3 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/MethodLevelOptsTest.scala
@@ -161,7 +161,7 @@ class MethodLevelOptsTest extends ClearAfterClass {
| val b = (a, y) // Tuple2
| val c = (new Object, "krik", new String) // unused java/lang/Object, java/lang/String allocation and string constant is also eliminated
| val d = new java.lang.Integer(x)
- | val e = new String(new Array[Char](23))
+ | val e = new String(new Array[Char](23)) // array allocation not eliminated, as it may throw (negative size, SI-8601)
| val f = new scala.runtime.IntRef(11)
| x + y
| }
@@ -169,7 +169,7 @@ class MethodLevelOptsTest extends ClearAfterClass {
""".stripMargin
val List(c) = compileClasses(methodOptCompiler)(code)
assertEquals(getSingleMethod(c, "t").instructions.dropNonOp,
- List(VarOp(ILOAD, 1), VarOp(ILOAD, 2), Op(IADD), Op(IRETURN)))
+ List(IntOp(BIPUSH, 23), IntOp(NEWARRAY, 5), Op(POP), VarOp(ILOAD, 1), VarOp(ILOAD, 2), Op(IADD), Op(IRETURN)))
}
@Test