diff options
Diffstat (limited to 'test/pending')
29 files changed, 885 insertions, 432 deletions
diff --git a/test/pending/jvm/actor-executor4.check b/test/pending/jvm/actor-executor4.check deleted file mode 100644 index da78f45836..0000000000 --- a/test/pending/jvm/actor-executor4.check +++ /dev/null @@ -1,21 +0,0 @@ -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -Two: OK -One: OK -One exited diff --git a/test/pending/jvm/actor-executor4.scala b/test/pending/jvm/actor-executor4.scala deleted file mode 100644 index a912d76094..0000000000 --- a/test/pending/jvm/actor-executor4.scala +++ /dev/null @@ -1,64 +0,0 @@ -import scala.actors.{Actor, Exit} -import scala.actors.scheduler.ExecutorScheduler -import java.util.concurrent.Executors - -object One extends AdaptedActor { - def act() { - Two.start() - var i = 0 - loopWhile (i < Test.NUM_MSG) { - i += 1 - Two ! 'MsgForTwo - react { - case 'MsgForOne => - if (i % (Test.NUM_MSG/10) == 0) - println("One: OK") - } - } - } -} - -object Two extends AdaptedActor { - def act() { - var i = 0 - loopWhile (i < Test.NUM_MSG) { - i += 1 - react { - case 'MsgForTwo => - if (i % (Test.NUM_MSG/10) == 0) - println("Two: OK") - One ! 'MsgForOne - } - } - } -} - -trait AdaptedActor extends Actor { - override def scheduler = - Test.scheduler -} - -object Test { - val NUM_MSG = 100000 - - val scheduler = - ExecutorScheduler( - Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), - false) - - def main(args: Array[String]) { - (new AdaptedActor { - def act() { - trapExit = true - link(One) - One.start() - - receive { - case Exit(from, reason) => - println("One exited") - Test.scheduler.shutdown() - } - } - }).start() - } -} diff --git a/test/pending/jvm/actor-receive-sender.check b/test/pending/jvm/actor-receive-sender.check deleted file mode 100644 index 2c94e48371..0000000000 --- a/test/pending/jvm/actor-receive-sender.check +++ /dev/null @@ -1,2 +0,0 @@ -OK -OK diff --git a/test/pending/jvm/actor-receive-sender.scala b/test/pending/jvm/actor-receive-sender.scala deleted file mode 100644 index ea7c40cced..0000000000 --- a/test/pending/jvm/actor-receive-sender.scala +++ /dev/null @@ -1,51 +0,0 @@ -import scala.actors.{Actor, TIMEOUT, Exit} -import scala.actors.Actor._ - -object Test { - - val NUM = 2000 - - def main(args: Array[String]) { - var b: Actor = null - var c: Actor = null - - val a = actor { - for (_ <- 0 until NUM) - receive { - case 'hello if sender == b => // do nothing - } - b ! 'ok - for (_ <- 0 until NUM) - receiveWithin (1000) { - case 'bye if sender == b => // do nothing - case TIMEOUT => b ! 'fail - } - b ! 'ok - } - - b = actor { - self.trapExit = true - link(a) - - for (_ <- 0 until NUM) - a ! 'hello - - val proceed = receive { - case Exit(from, reason) => println("FAIL"); false - case 'ok => println("OK"); true - case other => println(other); false - } - - if (proceed) { - for (_ <- 0 until NUM) - a ! 'bye - receive { - case Exit(from, reason) => println("FAIL") - case 'ok => println("OK") - case other => println(other) - } - } - } - } - -} diff --git a/test/pending/jvm/actorgc_leak.check b/test/pending/jvm/actorgc_leak.check deleted file mode 100644 index a965a70ed4..0000000000 --- a/test/pending/jvm/actorgc_leak.check +++ /dev/null @@ -1 +0,0 @@ -Done diff --git a/test/pending/jvm/actorgc_leak.scala b/test/pending/jvm/actorgc_leak.scala deleted file mode 100644 index de3e04f1e8..0000000000 --- a/test/pending/jvm/actorgc_leak.scala +++ /dev/null @@ -1,63 +0,0 @@ - -import scala.actors.Actor - -object Test { - class FatActorFactory extends Actor { - def act() { - var cnt = 0 - Actor.loopWhile(cnt < fatActors) { - //if ((cnt % 5) == 0) println(cnt) - val fa = new FatActor() - fa.start() - cnt += 1 - if (cnt == fatActors) Monitor ! 'done - } - } - } - - class FatActor extends Actor { - def act() { - fat = new Array[Int](fatness) - react { - case 'hi => exit() - } - } - private var fat: Array[Int] = _ - } - - object Monitor extends Actor { - private var cnt = 0 - def act() { - Actor.loop { - react { - case 'done => { - cnt += 1 - if (cnt == factories) System.exit(0) // once GC pressure stops FatActors stop being collected, and as - } // a result ActorGC never finds out that they are defunct - } - } - } - } - - val factories = 4 // the number of factories to start - val fatActors = 50 // the number of FatActors for each factory to produce - val fatness = 1024*1024*10 - - def main(args: Array[String]) { - scala.actors.Scheduler.impl.shutdown() - val sched = { - val s = new scala.actors.FJTaskScheduler2 - s.start() - s - } - scala.actors.Scheduler.impl = sched - - Monitor.start() - for(i <- 1 to factories) { - //if ((i % 50) == 0) println(i) - val fa = new FatActorFactory() - fa.start() - } - println("Done") - } -} diff --git a/test/pending/jvm/constant-optimization/Foo_1.flags b/test/pending/jvm/constant-optimization/Foo_1.flags new file mode 100644 index 0000000000..9691c0985d --- /dev/null +++ b/test/pending/jvm/constant-optimization/Foo_1.flags @@ -0,0 +1 @@ +// constant otimization not there yet, -Yopt:nullness-tracking not enough. diff --git a/test/pending/jvm/constant-optimization/Foo_1.scala b/test/pending/jvm/constant-optimization/Foo_1.scala new file mode 100644 index 0000000000..6f408044d7 --- /dev/null +++ b/test/pending/jvm/constant-optimization/Foo_1.scala @@ -0,0 +1,9 @@ +class Foo_1 { + def foo() { + // constant optimization should eliminate all branches + val i = 1 + val x = if (i != 1) null else "good" + val y = if (x == null) "good" else x + "" + println(y) + } +}
\ No newline at end of file diff --git a/test/pending/jvm/constant-optimization/Test.scala b/test/pending/jvm/constant-optimization/Test.scala new file mode 100644 index 0000000000..dc0f8f6103 --- /dev/null +++ b/test/pending/jvm/constant-optimization/Test.scala @@ -0,0 +1,27 @@ + +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + val comparisons = Set(asm.Opcodes.IF_ACMPEQ, asm.Opcodes.IF_ACMPNE, asm.Opcodes.IF_ICMPEQ, asm.Opcodes.IF_ICMPGE, asm.Opcodes.IF_ICMPGT, asm.Opcodes.IF_ICMPLE, + asm.Opcodes.IF_ICMPLT, asm.Opcodes.IF_ICMPNE, asm.Opcodes.IFEQ, asm.Opcodes.IFGE, asm.Opcodes.IFGT, asm.Opcodes.IFLE, asm.Opcodes.IFLT, + asm.Opcodes.IFNE, asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL) + + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + // after optimization there should be no comparisons left + val expected = 0 + + val got = countComparisons(methodNode.instructions) + assert(got == expected, s"expected $expected but got $got comparisons") + } + + def countComparisons(insnList: InsnList): Int = { + def isComparison(node: asm.tree.AbstractInsnNode): Boolean = + (comparisons contains node.getOpcode) + insnList.iterator.asScala count isComparison + } +}
\ No newline at end of file diff --git a/test/pending/jvm/reactWithinZero.check b/test/pending/jvm/reactWithinZero.check deleted file mode 100644 index cf2a2facf9..0000000000 --- a/test/pending/jvm/reactWithinZero.check +++ /dev/null @@ -1,2 +0,0 @@ -TIMEOUT -'ack diff --git a/test/pending/jvm/reactWithinZero.scala b/test/pending/jvm/reactWithinZero.scala deleted file mode 100644 index 0786ce271d..0000000000 --- a/test/pending/jvm/reactWithinZero.scala +++ /dev/null @@ -1,18 +0,0 @@ -import scala.actors.{Actor, TIMEOUT} - -class A extends Actor { - def act() = reactWithin(0) { - case TIMEOUT => - println("TIMEOUT") - reply('ack) - act() - case x => println(x) - } -} - -object Test { - def main(args: Array[String]): Unit = { - val a = new A - a.start() - } -} diff --git a/test/pending/jvm/receiveWithinZero.check b/test/pending/jvm/receiveWithinZero.check deleted file mode 100644 index cf2a2facf9..0000000000 --- a/test/pending/jvm/receiveWithinZero.check +++ /dev/null @@ -1,2 +0,0 @@ -TIMEOUT -'ack diff --git a/test/pending/jvm/receiveWithinZero.scala b/test/pending/jvm/receiveWithinZero.scala deleted file mode 100644 index 315dd9c86a..0000000000 --- a/test/pending/jvm/receiveWithinZero.scala +++ /dev/null @@ -1,18 +0,0 @@ -import scala.actors.{Actor, TIMEOUT} - -class A extends Actor { - def act() = receiveWithin(0) { - case TIMEOUT => - println("TIMEOUT") - reply('ack) - act() - case x => println(x) - } -} - -object Test { - def main(args: Array[String]): Unit = { - val a = new A - a.start() - } -} diff --git a/test/pending/jvm/t1801.check b/test/pending/jvm/t1801.check deleted file mode 100644 index bf78a99db9..0000000000 --- a/test/pending/jvm/t1801.check +++ /dev/null @@ -1,6 +0,0 @@ -0 -100 -200 -300 -400 -done! diff --git a/test/pending/jvm/t1801.scala b/test/pending/jvm/t1801.scala deleted file mode 100644 index 6ed7c56336..0000000000 --- a/test/pending/jvm/t1801.scala +++ /dev/null @@ -1,31 +0,0 @@ -import scala.actors.Actor._ - -object Test { - val rt = Runtime.getRuntime() - val sender = actor { - var cnt = 0 - while(cnt < 500) { - if ((cnt % 100) == 0) println(cnt) - receiver ! new Array[Int] (148576) - cnt += 1 - //println ("Used Mem: " + (((rt.totalMemory() - rt.freeMemory()) / 1048576.) formatted "%.2f") + " Mb") - } - receiver ! 'exit - } - - val receiver = actor { - loop { - react { - case x: Array[Int] => ()//println ("received " + x.length) - case 'exit => { - println("done!") - exit() - } - } - } - } - - def main (args: Array[String]) { - sender - } -} diff --git a/test/pending/jvm/t2515.check b/test/pending/jvm/t2515.check deleted file mode 100644 index 8cb8bde11e..0000000000 --- a/test/pending/jvm/t2515.check +++ /dev/null @@ -1,10 +0,0 @@ -Iteration 1 succeeded -Iteration 2 succeeded -Iteration 3 succeeded -Iteration 4 succeeded -Iteration 5 succeeded -Iteration 6 succeeded -Iteration 7 succeeded -Iteration 8 succeeded -Iteration 9 succeeded -Iteration 10 succeeded diff --git a/test/pending/jvm/t2515.scala b/test/pending/jvm/t2515.scala deleted file mode 100644 index ee655967f3..0000000000 --- a/test/pending/jvm/t2515.scala +++ /dev/null @@ -1,43 +0,0 @@ -import scala.actors.{Futures, TIMEOUT} -import scala.actors.Actor._ - -object Test { - - def compute(): Option[Boolean] = { - val fts = for (j <- 0 until 5) yield Futures.future { - receiveWithin (100) { - case TIMEOUT => true - case other => false - } - } - val done = Futures.awaitAll(2000, fts.toArray: _*) // list to array, as varargs - if (done.contains(None)) - None - else - Some(true) - } - - def main(args:Array[String]) : Unit = { - val ft = Futures.future { - val format = new java.text.DecimalFormat("000.00'ms'") - var iter = 1 - val done = 11 - while (iter < done) { - val start = System.nanoTime() - val result = compute() - val time = System.nanoTime() - start - result match { - case Some(result) => - //printf("Iteration %2d succeeded after %s %n", iter, format.format(time / 1e6)) - printf("Iteration %2d succeeded%n", iter) - iter += 1 - case None => - printf(">>>> Iteration %2d failed after %s <<<<< %n", iter, format.format(time / 1e6)) - iter = done - } - } - } - ft() - } - -} diff --git a/test/pending/jvm/terminateLinked.check b/test/pending/jvm/terminateLinked.check deleted file mode 100644 index a965a70ed4..0000000000 --- a/test/pending/jvm/terminateLinked.check +++ /dev/null @@ -1 +0,0 @@ -Done diff --git a/test/pending/jvm/terminateLinked.scala b/test/pending/jvm/terminateLinked.scala deleted file mode 100644 index 2a3b7fb49e..0000000000 --- a/test/pending/jvm/terminateLinked.scala +++ /dev/null @@ -1,24 +0,0 @@ -import scala.actors.Actor -import Actor._ - -object Test { - def main(args: Array[String]) { - val a = actor { - for (_ <- 1 to 10) - receive { - case b: Actor => link(b) - } - throw new Exception - } - - for (_ <- 1 to 10) - actor { - a ! self - react { - case _ => - } - } - - println("Done") - } -} diff --git a/test/pending/jvm/timeout.check b/test/pending/jvm/timeout.check deleted file mode 100644 index d86bac9de5..0000000000 --- a/test/pending/jvm/timeout.check +++ /dev/null @@ -1 +0,0 @@ -OK diff --git a/test/pending/jvm/timeout.scala b/test/pending/jvm/timeout.scala deleted file mode 100644 index 8f29f8ddbe..0000000000 --- a/test/pending/jvm/timeout.scala +++ /dev/null @@ -1,38 +0,0 @@ -// Test is in pending because although it succeeds locally, -// it takes too long on the machine which runs nightly tests. -// -// [partest] EXPECTED: 100 < x < 900 -// [partest] ACTUAL: 1519 - -import scala.actors.Actor._ -import scala.actors.TIMEOUT - -object Test extends Application { - case class Timing(time: Long) - - actor { - val a = actor { - react { - case 'doTiming => - val s = sender - reactWithin(500) { - case TIMEOUT => - s ! Timing(System.currentTimeMillis) - } - } - } - - val start = System.currentTimeMillis - (a !? 'doTiming) match { - case Timing(end) => - val delay = end - start - - if (delay > 100 && delay < 900) - println("OK") - else { - println("EXPECTED: 100 < x < 900") - println("ACTUAL: "+delay) - } - } - } -} diff --git a/test/pending/run/inline-ex-handlers.check b/test/pending/run/inline-ex-handlers.check new file mode 100644 index 0000000000..fce32771b4 --- /dev/null +++ b/test/pending/run/inline-ex-handlers.check @@ -0,0 +1,491 @@ +--- a ++++ b +@@ -171,5 +171,5 @@ + def productElement(x$1: Int (INT)): Object { +- locals: value x$1, value x1 ++ locals: value x$1, value x1, variable boxed1 + startBlock: 1 +- blocks: [1,2,3,4] ++ blocks: [1,3,4] + +@@ -186,2 +186,4 @@ + 92 LOAD_LOCAL(value x$1) ++ 92 STORE_LOCAL(variable boxed1) ++ 92 LOAD_LOCAL(variable boxed1) + 92 BOX INT +@@ -194,5 +196,2 @@ + 92 CALL_METHOD MyException.message (dynamic) +- 92 JUMP 2 +- +- 2: + 92 RETURN(REF(class Object)) +@@ -246,3 +245,3 @@ + startBlock: 1 +- blocks: [1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18] ++ blocks: [1,2,3,4,5,6,8,11,12,13,14,15,16,17,18] + +@@ -257,5 +256,2 @@ + 92 SCOPE_ENTER value x1 +- 92 JUMP 7 +- +- 7: + 92 LOAD_LOCAL(value x1) +@@ -408,5 +404,5 @@ + def main(args: Array[String] (ARRAY[REF(class String)])): Unit { +- locals: value args, variable result, value ex6, value x4, value x5, value message, value x ++ locals: value args, variable result, value ex6, value x4, value x5, value x + startBlock: 1 +- blocks: [1,2,3,4,5,8,10,11,13] ++ blocks: [1,2,3,5,8,10,11,13,14] + +@@ -434,4 +430,13 @@ + 103 CALL_METHOD MyException.<init> (static-instance) +- 103 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 14 + ++ 14: ++ 101 LOAD_LOCAL(value ex6) ++ 101 STORE_LOCAL(value x4) ++ 101 SCOPE_ENTER value x4 ++ 106 LOAD_LOCAL(value x4) ++ 106 IS_INSTANCE REF(class MyException) ++ 106 CZJUMP (BOOL)NE ? 5 : 8 ++ + 13: +@@ -447,5 +452,2 @@ + 101 SCOPE_ENTER value x4 +- 101 JUMP 4 +- +- 4: + 106 LOAD_LOCAL(value x4) +@@ -459,8 +461,5 @@ + 106 SCOPE_ENTER value x5 +- 106 LOAD_LOCAL(value x5) +- 106 CALL_METHOD MyException.message (dynamic) +- 106 STORE_LOCAL(value message) +- 106 SCOPE_ENTER value message + 106 LOAD_MODULE object Predef +- 106 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 106 CALL_METHOD MyException.message (dynamic) + 106 CALL_METHOD scala.Predef.println (dynamic) +@@ -536,3 +535,3 @@ + startBlock: 1 +- blocks: [1,2,3,4,6,7,9,10] ++ blocks: [1,3,4,6,7,9,10,11,12,13] + +@@ -565,4 +564,9 @@ + 306 CALL_METHOD MyException.<init> (static-instance) +- 306 THROW(MyException) ++ ? JUMP 11 + ++ 11: ++ ? LOAD_LOCAL(variable monitor4) ++ 305 MONITOR_EXIT ++ ? JUMP 12 ++ + 9: +@@ -571,3 +575,3 @@ + 305 MONITOR_EXIT +- ? THROW(Throwable) ++ ? JUMP 12 + +@@ -577,4 +581,11 @@ + 304 MONITOR_EXIT +- ? THROW(Throwable) ++ ? STORE_LOCAL(value t) ++ ? JUMP 13 + ++ 12: ++ ? LOAD_LOCAL(variable monitor3) ++ 304 MONITOR_EXIT ++ ? STORE_LOCAL(value t) ++ ? JUMP 13 ++ + 3: +@@ -591,5 +602,14 @@ + 310 CALL_METHOD scala.Predef.println (dynamic) +- 310 JUMP 2 ++ 300 RETURN(UNIT) + +- 2: ++ 13: ++ 310 LOAD_MODULE object Predef ++ 310 CALL_PRIMITIVE(StartConcat) ++ 310 CONSTANT("Caught crash: ") ++ 310 CALL_PRIMITIVE(StringConcat(REF(class String))) ++ 310 LOAD_LOCAL(value t) ++ 310 CALL_METHOD java.lang.Throwable.toString (dynamic) ++ 310 CALL_PRIMITIVE(StringConcat(REF(class String))) ++ 310 CALL_PRIMITIVE(EndConcat) ++ 310 CALL_METHOD scala.Predef.println (dynamic) + 300 RETURN(UNIT) +@@ -601,6 +621,6 @@ + with finalizer: null +- catch (Throwable) in Vector(7, 9, 10) starting at: 6 ++ catch (Throwable) in Vector(7, 9, 10, 11) starting at: 6 + consisting of blocks: List(6) + with finalizer: null +- catch (Throwable) in Vector(4, 6, 7, 9, 10) starting at: 3 ++ catch (Throwable) in Vector(4, 6, 7, 9, 10, 11, 12) starting at: 3 + consisting of blocks: List(3) +@@ -636,3 +656,3 @@ + startBlock: 1 +- blocks: [1,3,4,5,6,8,9] ++ blocks: [1,3,4,5,6,8,9,10,11] + +@@ -660,4 +680,10 @@ + 78 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) +- 78 THROW(IllegalArgumentException) ++ ? STORE_LOCAL(value e) ++ ? JUMP 10 + ++ 10: ++ 81 LOAD_LOCAL(value e) ++ ? STORE_LOCAL(variable exc1) ++ ? JUMP 11 ++ + 8: +@@ -686,3 +712,4 @@ + 81 LOAD_LOCAL(value e) +- 81 THROW(Exception) ++ ? STORE_LOCAL(variable exc1) ++ ? JUMP 11 + +@@ -703,2 +730,15 @@ + ++ 11: ++ 83 LOAD_MODULE object Predef ++ 83 CONSTANT("finally") ++ 83 CALL_METHOD scala.Predef.println (dynamic) ++ 84 LOAD_LOCAL(variable result) ++ 84 CONSTANT(1) ++ 84 CALL_PRIMITIVE(Arithmetic(SUB,INT)) ++ 84 CONSTANT(2) ++ 84 CALL_PRIMITIVE(Arithmetic(DIV,INT)) ++ 84 STORE_LOCAL(variable result) ++ 84 LOAD_LOCAL(variable exc1) ++ 84 THROW(Throwable) ++ + } +@@ -708,3 +748,3 @@ + with finalizer: null +- catch (<none>) in Vector(4, 5, 6, 8) starting at: 3 ++ catch (<none>) in Vector(4, 5, 6, 8, 10) starting at: 3 + consisting of blocks: List(3) +@@ -732,5 +772,5 @@ + def main(args: Array[String] (ARRAY[REF(class String)])): Unit { +- locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value message, value x, value ex6, value x4, value x5, value message, value x ++ locals: value args, variable result, value ex6, variable exc2, value x4, value x5, value x, value ex6, value x4, value x5, value x + startBlock: 1 +- blocks: [1,3,4,5,6,9,13,14,15,18,20,21,23,24] ++ blocks: [1,3,4,5,6,9,13,14,15,18,20,21,23,24,25,26,27] + +@@ -758,4 +798,11 @@ + 172 CALL_METHOD MyException.<init> (static-instance) +- 172 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 25 + ++ 25: ++ 170 LOAD_LOCAL(value ex6) ++ 170 STORE_LOCAL(value x4) ++ 170 SCOPE_ENTER value x4 ++ 170 JUMP 14 ++ + 23: +@@ -798,8 +845,5 @@ + 175 SCOPE_ENTER value x5 +- 175 LOAD_LOCAL(value x5) +- 175 CALL_METHOD MyException.message (dynamic) +- 175 STORE_LOCAL(value message) +- 175 SCOPE_ENTER value message + 176 LOAD_MODULE object Predef +- 176 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 176 CALL_METHOD MyException.message (dynamic) + 176 CALL_METHOD scala.Predef.println (dynamic) +@@ -807,5 +851,7 @@ + 177 DUP(REF(class MyException)) +- 177 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 177 CALL_METHOD MyException.message (dynamic) + 177 CALL_METHOD MyException.<init> (static-instance) +- 177 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 26 + +@@ -813,3 +859,4 @@ + 170 LOAD_LOCAL(value ex6) +- 170 THROW(Throwable) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 26 + +@@ -823,2 +870,8 @@ + ++ 26: ++ 169 LOAD_LOCAL(value ex6) ++ 169 STORE_LOCAL(value x4) ++ 169 SCOPE_ENTER value x4 ++ 169 JUMP 5 ++ + 5: +@@ -833,8 +886,5 @@ + 180 SCOPE_ENTER value x5 +- 180 LOAD_LOCAL(value x5) +- 180 CALL_METHOD MyException.message (dynamic) +- 180 STORE_LOCAL(value message) +- 180 SCOPE_ENTER value message + 181 LOAD_MODULE object Predef +- 181 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 181 CALL_METHOD MyException.message (dynamic) + 181 CALL_METHOD scala.Predef.println (dynamic) +@@ -842,5 +892,7 @@ + 182 DUP(REF(class MyException)) +- 182 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 182 CALL_METHOD MyException.message (dynamic) + 182 CALL_METHOD MyException.<init> (static-instance) +- 182 THROW(MyException) ++ ? STORE_LOCAL(variable exc2) ++ ? JUMP 27 + +@@ -848,3 +900,4 @@ + 169 LOAD_LOCAL(value ex6) +- 169 THROW(Throwable) ++ ? STORE_LOCAL(variable exc2) ++ ? JUMP 27 + +@@ -865,2 +918,15 @@ + ++ 27: ++ 184 LOAD_MODULE object Predef ++ 184 CONSTANT("finally") ++ 184 CALL_METHOD scala.Predef.println (dynamic) ++ 185 LOAD_LOCAL(variable result) ++ 185 CONSTANT(1) ++ 185 CALL_PRIMITIVE(Arithmetic(SUB,INT)) ++ 185 CONSTANT(2) ++ 185 CALL_PRIMITIVE(Arithmetic(DIV,INT)) ++ 185 STORE_LOCAL(variable result) ++ 185 LOAD_LOCAL(variable exc2) ++ 185 THROW(Throwable) ++ + } +@@ -870,6 +936,6 @@ + with finalizer: null +- catch (Throwable) in Vector(13, 14, 15, 18, 20, 21, 23) starting at: 4 ++ catch (Throwable) in Vector(13, 14, 15, 18, 20, 21, 23, 25) starting at: 4 + consisting of blocks: List(9, 8, 6, 5, 4) + with finalizer: null +- catch (<none>) in Vector(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23) starting at: 3 ++ catch (<none>) in Vector(4, 5, 6, 9, 13, 14, 15, 18, 20, 21, 23, 25, 26) starting at: 3 + consisting of blocks: List(3) +@@ -897,5 +963,5 @@ + def main(args: Array[String] (ARRAY[REF(class String)])): Unit { +- locals: value args, variable result, value e, value ex6, value x4, value x5, value message, value x ++ locals: value args, variable result, value e, value ex6, value x4, value x5, value x + startBlock: 1 +- blocks: [1,2,3,6,7,8,11,13,14,16] ++ blocks: [1,2,3,6,7,8,11,13,14,16,17] + +@@ -923,4 +989,11 @@ + 124 CALL_METHOD MyException.<init> (static-instance) +- 124 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 17 + ++ 17: ++ 122 LOAD_LOCAL(value ex6) ++ 122 STORE_LOCAL(value x4) ++ 122 SCOPE_ENTER value x4 ++ 122 JUMP 7 ++ + 16: +@@ -948,8 +1021,5 @@ + 127 SCOPE_ENTER value x5 +- 127 LOAD_LOCAL(value x5) +- 127 CALL_METHOD MyException.message (dynamic) +- 127 STORE_LOCAL(value message) +- 127 SCOPE_ENTER value message + 127 LOAD_MODULE object Predef +- 127 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 127 CALL_METHOD MyException.message (dynamic) + 127 CALL_METHOD scala.Predef.println (dynamic) +@@ -982,3 +1052,3 @@ + with finalizer: null +- catch (IllegalArgumentException) in Vector(6, 7, 8, 11, 13, 14, 16) starting at: 3 ++ catch (IllegalArgumentException) in Vector(6, 7, 8, 11, 13, 14, 16, 17) starting at: 3 + consisting of blocks: List(3) +@@ -1006,5 +1076,5 @@ + def main(args: Array[String] (ARRAY[REF(class String)])): Unit { +- locals: value args, variable result, value ex6, value x4, value x5, value message, value x, value e ++ locals: value args, variable result, value ex6, value x4, value x5, value x, value e + startBlock: 1 +- blocks: [1,2,3,4,5,8,12,13,14,16] ++ blocks: [1,2,3,5,8,12,13,14,16,17] + +@@ -1032,4 +1102,13 @@ + 148 CALL_METHOD MyException.<init> (static-instance) +- 148 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 17 + ++ 17: ++ 145 LOAD_LOCAL(value ex6) ++ 145 STORE_LOCAL(value x4) ++ 145 SCOPE_ENTER value x4 ++ 154 LOAD_LOCAL(value x4) ++ 154 IS_INSTANCE REF(class MyException) ++ 154 CZJUMP (BOOL)NE ? 5 : 8 ++ + 16: +@@ -1053,5 +1132,2 @@ + 145 SCOPE_ENTER value x4 +- 145 JUMP 4 +- +- 4: + 154 LOAD_LOCAL(value x4) +@@ -1065,8 +1141,5 @@ + 154 SCOPE_ENTER value x5 +- 154 LOAD_LOCAL(value x5) +- 154 CALL_METHOD MyException.message (dynamic) +- 154 STORE_LOCAL(value message) +- 154 SCOPE_ENTER value message + 154 LOAD_MODULE object Predef +- 154 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 154 CALL_METHOD MyException.message (dynamic) + 154 CALL_METHOD scala.Predef.println (dynamic) +@@ -1287,3 +1360,3 @@ + startBlock: 1 +- blocks: [1,2,3,4,5,7] ++ blocks: [1,2,3,4,5,7,8] + +@@ -1311,4 +1384,11 @@ + 38 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) +- 38 THROW(IllegalArgumentException) ++ ? STORE_LOCAL(value e) ++ ? JUMP 8 + ++ 8: ++ 42 LOAD_MODULE object Predef ++ 42 CONSTANT("IllegalArgumentException") ++ 42 CALL_METHOD scala.Predef.println (dynamic) ++ 42 JUMP 2 ++ + 7: +@@ -1358,5 +1438,5 @@ + def main(args: Array[String] (ARRAY[REF(class String)])): Unit { +- locals: value args, variable result, value ex6, value x4, value x5, value message, value x ++ locals: value args, variable result, value ex6, value x4, value x5, value x + startBlock: 1 +- blocks: [1,2,3,4,5,8,10,11,13,14,16] ++ blocks: [1,2,3,5,8,10,11,13,14,16,17] + +@@ -1384,3 +1464,4 @@ + 203 CALL_METHOD MyException.<init> (static-instance) +- 203 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 17 + +@@ -1404,4 +1485,13 @@ + 209 CALL_METHOD MyException.<init> (static-instance) +- 209 THROW(MyException) ++ ? STORE_LOCAL(value ex6) ++ ? JUMP 17 + ++ 17: ++ 200 LOAD_LOCAL(value ex6) ++ 200 STORE_LOCAL(value x4) ++ 200 SCOPE_ENTER value x4 ++ 212 LOAD_LOCAL(value x4) ++ 212 IS_INSTANCE REF(class MyException) ++ 212 CZJUMP (BOOL)NE ? 5 : 8 ++ + 16: +@@ -1417,5 +1507,2 @@ + 200 SCOPE_ENTER value x4 +- 200 JUMP 4 +- +- 4: + 212 LOAD_LOCAL(value x4) +@@ -1429,8 +1516,5 @@ + 212 SCOPE_ENTER value x5 +- 212 LOAD_LOCAL(value x5) +- 212 CALL_METHOD MyException.message (dynamic) +- 212 STORE_LOCAL(value message) +- 212 SCOPE_ENTER value message + 213 LOAD_MODULE object Predef +- 213 LOAD_LOCAL(value message) ++ ? LOAD_LOCAL(value x5) ++ 213 CALL_METHOD MyException.message (dynamic) + 213 CALL_METHOD scala.Predef.println (dynamic) +@@ -1478,3 +1562,3 @@ + startBlock: 1 +- blocks: [1,2,3,4,5,7] ++ blocks: [1,2,3,4,5,7,8] + +@@ -1502,4 +1586,11 @@ + 58 CALL_METHOD java.lang.IllegalArgumentException.<init> (static-instance) +- 58 THROW(IllegalArgumentException) ++ ? STORE_LOCAL(value e) ++ ? JUMP 8 + ++ 8: ++ 62 LOAD_MODULE object Predef ++ 62 CONSTANT("RuntimeException") ++ 62 CALL_METHOD scala.Predef.println (dynamic) ++ 62 JUMP 2 ++ + 7: +@@ -1551,3 +1642,3 @@ + startBlock: 1 +- blocks: [1,3,4] ++ blocks: [1,3,4,5] + +@@ -1571,4 +1662,9 @@ + 229 CALL_METHOD MyException.<init> (static-instance) +- 229 THROW(MyException) ++ ? JUMP 5 + ++ 5: ++ ? LOAD_LOCAL(variable monitor1) ++ 228 MONITOR_EXIT ++ 228 THROW(Throwable) ++ + 3: +@@ -1577,3 +1673,3 @@ + 228 MONITOR_EXIT +- ? THROW(Throwable) ++ 228 THROW(Throwable) + +@@ -1605,5 +1701,5 @@ + def main(args: Array[String] (ARRAY[REF(class String)])): Unit { +- locals: value args, variable result, variable monitor2, variable monitorResult1 ++ locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 + startBlock: 1 +- blocks: [1,3,4] ++ blocks: [1,3,4,5] + +@@ -1630,4 +1726,12 @@ + 245 CALL_METHOD MyException.<init> (static-instance) +- 245 THROW(MyException) ++ ? STORE_LOCAL(value exception$1) ++ ? DROP ConcatClass ++ ? LOAD_LOCAL(value exception$1) ++ ? JUMP 5 + ++ 5: ++ ? LOAD_LOCAL(variable monitor2) ++ 244 MONITOR_EXIT ++ 244 THROW(Throwable) ++ + 3: +@@ -1636,3 +1740,3 @@ + 244 MONITOR_EXIT +- ? THROW(Throwable) ++ 244 THROW(Throwable) diff --git a/test/pending/run/inline-ex-handlers.scala b/test/pending/run/inline-ex-handlers.scala new file mode 100644 index 0000000000..964594d258 --- /dev/null +++ b/test/pending/run/inline-ex-handlers.scala @@ -0,0 +1,329 @@ +import scala.tools.partest.IcodeComparison + +object Test extends IcodeComparison { + override def printIcodeAfterPhase = "inlinehandlers" +} + +import scala.util.Random._ + +/** There should be no inlining taking place in this class */ +object TestInlineHandlersNoInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersNoInline") + var result = -1 + + try { + if (nextInt % 2 == 0) + throw new IllegalArgumentException("something") + result = 1 + } catch { + case e: StackOverflowError => + println("Stack overflow") + } + + result + } +} + +/** Just a simple inlining should take place in this class */ +object TestInlineHandlersSimpleInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersSimpleInline") + var result = -1 + + try { + if (nextInt % 2 == 0) + throw new IllegalArgumentException("something") + result = 1 + } catch { + case e: IllegalArgumentException => + println("IllegalArgumentException") + } + + result + } +} + +/** Inlining should take place because the handler is taking a superclass of the exception thrown */ +object TestInlineHandlersSubclassInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersSubclassInline") + var result = -1 + + try { + if (nextInt % 2 == 0) + throw new IllegalArgumentException("something") + result = 1 + } catch { + case e: RuntimeException => + println("RuntimeException") + } + + result + } +} + +/** For this class, the finally handler should be inlined */ +object TestInlineHandlersFinallyInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersFinallyInline") + var result = -1 + + try { + if (nextInt % 2 == 0) + throw new IllegalArgumentException("something") + result = 1 + } catch { + case e: Exception => throw e + } finally { + println("finally") + result = (result - 1) / 2 + } + + result + } +} + + +case class MyException(message: String) extends RuntimeException(message) + +/** For this class, we test inlining for a case class error */ +object TestInlineHandlersCaseClassExceptionInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersCaseClassExceptionInline") + var result = -1 + + try { + if (nextInt % 2 == 0) + throw new MyException("something") + result = 1 + } catch { + case MyException(message) => println(message) + } + + result + } +} + + +/** For this class, inline should take place in the inner handler */ +object TestInlineHandlersNestedHandlerInnerInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersNestedHandlersInnerInline") + var result = -1 + + try { + try { + if (nextInt % 2 == 0) + throw new MyException("something") + result = 1 + } catch { + case MyException(message) => println(message) + } + } catch { + case e: IllegalArgumentException => println("IllegalArgumentException") + } + + result + } +} + + +/** For this class, inline should take place in the outer handler */ +object TestInlineHandlersNestedHandlerOuterInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersNestedHandlersOuterInline") + var result = -1 + + try { + try { + if (nextInt % 2 == 0) + throw new MyException("something") + result = 1 + } catch { + case e: IllegalArgumentException => println("IllegalArgumentException") + } + } catch { + case MyException(message) => println(message) + } + + result + } +} + + +/** For this class, inline should take place in the all handlers (inner, outer and finally) */ +object TestInlineHandlersNestedHandlerAllInline { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersNestedHandlersOuterInline") + var result = -1 + + try { + try { + if (nextInt % 2 == 0) + throw new MyException("something") + result = 1 + } catch { + case MyException(message) => + println(message) + throw MyException(message) + } + } catch { + case MyException(message) => + println(message) + throw MyException(message) + } finally { + println("finally") + result = (result - 1) / 2 + } + + result + } +} + + +/** This class is meant to test whether the inline handler is copied only once for multiple inlines */ +object TestInlineHandlersSingleCopy { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersSingleCopy") + var result = -1 + + try { + + if (nextInt % 2 == 0) + throw new MyException("something") + + println("A side effect in the middle") + result = 3 // another one + + if (nextInt % 3 == 2) + throw new MyException("something else") + result = 1 + } catch { + case MyException(message) => + println(message) + } + + result + } +} + +/** This should test the special exception handler for synchronized blocks */ +object TestInlineHandlersSynchronized { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersSynchronized") + var result = "hello" + + // any exception thrown here will be caught by a default handler that does MONTIOR_EXIT on result :) + result.synchronized { + throw MyException(result) + } + + result.length + } +} + +/** This should test the special exception handler for synchronized blocks with stack */ +object TestInlineHandlersSynchronizedWithStack { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersSynchronizedWithStack") + var result = "hello" + + // any exception thrown here will be caught by a default handler that does MONTIOR_EXIT on result :) + result = "abc" + result.synchronized { + throw MyException(result) + } + + result.length + } +} + +/** This test should trigger a bug in the dead code elimination phase - it actually crashes ICodeCheckers +object TestInlineHandlersSynchronizedWithStackDoubleThrow { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersSynchronizedWithStackDoubleThrow") + var result = "a" + + // any exception thrown here will be caught by a default handler that does MONTIOR_EXIT on result :) + result += result.synchronized { throw MyException(result) } + result += result.synchronized { throw MyException(result) } + + result.length + } +} +*/ + +/** This test should check the preciseness of the inliner: it should not do any inlining here +* as it is not able to discern between the different exceptions +*/ +object TestInlineHandlersPreciseness { + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersCorrectHandler") + + try { + val exception: Throwable = + if (scala.util.Random.nextInt % 2 == 0) + new IllegalArgumentException("even") + else + new StackOverflowError("odd") + throw exception + } catch { + case e: IllegalArgumentException => + println("Correct, IllegalArgumentException") + case e: StackOverflowError => + println("Correct, StackOverflowException") + case t: Throwable => + println("WROOOONG, not Throwable!") + } + } +} + +/** This check should verify that the double no-local exception handler is duplicated correctly */ +object TestInlineHandlersDoubleNoLocal { + + val a1: String = "a" + val a2: String = "b" + + def main(args: Array[String]): Unit = { + println("TestInlineHandlersDoubleNoLocal") + + try { + a1.synchronized { + a2. synchronized { + throw new MyException("crash") + } + } + } catch { + case t: Throwable => println("Caught crash: " + t.toString) + } + + /* try { + val exception: Throwable = + if (scala.util.Random.nextInt % 2 == 0) + new IllegalArgumentException("even") + else + new StackOverflowError("odd") + throw exception + } catch { + case e: IllegalArgumentException => + println("Correct, IllegalArgumentException") + case e: StackOverflowError => + println("Correct, StackOverflowException") + case t: Throwable => + println("WROOOONG, not Throwable!") + }*/ + } +} diff --git a/test/pending/run/origins.check b/test/pending/run/origins.check new file mode 100644 index 0000000000..b12cb6e38f --- /dev/null +++ b/test/pending/run/origins.check @@ -0,0 +1,6 @@ + +>> Origins tag 'boop' logged 65 calls from 3 distinguished sources. + + 50 Test$$anonfun$f3$1.apply(origins.scala:16) + 10 Test$$anonfun$f2$1.apply(origins.scala:15) + 5 Test$$anonfun$f1$1.apply(origins.scala:14) diff --git a/test/pending/run/origins.flags b/test/pending/run/origins.flags new file mode 100644 index 0000000000..690753d807 --- /dev/null +++ b/test/pending/run/origins.flags @@ -0,0 +1 @@ +-no-specialization -Ydelambdafy:inline
\ No newline at end of file diff --git a/test/pending/run/origins.scala b/test/pending/run/origins.scala new file mode 100644 index 0000000000..6529351d3c --- /dev/null +++ b/test/pending/run/origins.scala @@ -0,0 +1,21 @@ +import scala.reflect.internal.util.Origins + +package goxbox { + object Socks { + val origins = Origins("boop") + + def boop(x: Int): Int = origins { 5 } + } +} + +object Test { + import goxbox.Socks.boop + + def f1() = 1 to 5 map boop + def f2() = 1 to 10 map boop + def f3() = 1 to 50 map boop + + def main(args: Array[String]): Unit = { + f1() ; f2() ; f3() + } +} diff --git a/test/pending/run/t5698/client.scala b/test/pending/run/t5698/client.scala deleted file mode 100644 index de672c1809..0000000000 --- a/test/pending/run/t5698/client.scala +++ /dev/null @@ -1,9 +0,0 @@ -package client - - - -object Client extends App { - val peer = actors.remote.Node("localhost", 23456) - val a = actors.remote.RemoteActor.select(peer, 'test) - a ! server.TestMsg -} diff --git a/test/pending/run/t5698/server.scala b/test/pending/run/t5698/server.scala deleted file mode 100644 index e8f3cea225..0000000000 --- a/test/pending/run/t5698/server.scala +++ /dev/null @@ -1,22 +0,0 @@ -package server - - - -object Server extends App { - - class ServerActor extends actors.Actor { - def act() { - actors.remote.RemoteActor.alive(23456) - actors.remote.RemoteActor.register('test, actors.Actor.self) - loop { - react { - case TestMsg => println("Yay!") - } - } - } - } - - val a = new ServerActor - a.start() - -} diff --git a/test/pending/run/t5698/testmsg.scala b/test/pending/run/t5698/testmsg.scala deleted file mode 100644 index 004ff0b8c7..0000000000 --- a/test/pending/run/t5698/testmsg.scala +++ /dev/null @@ -1,5 +0,0 @@ -package server - - - -case object TestMsg |