From e994c1c0becddc0d91fd4428f0d673bfac8941a3 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 26 Sep 2016 09:47:49 +1000 Subject: SD-233 synchronized blocks are JIT-friendly again GenBCode, the new backend in Scala 2.12, subtly changed the way that synchronized blocks are emitted. It used `java/lang/Throwable` as an explicitly named exception type, rather than implying the same by omitting this in bytecode. This appears to confuse HotSpot JIT, which reports a error parsing the bytecode into its IR which leaves the enclosing method stuck in interpreted mode. This commit passes a `null` descriptor to restore the old pattern (the same one used by javac.) I've checked that the JIT warnings are gone and that the method can be compiled again. --- test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala b/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala index b09a41969e..00b6d1cc42 100644 --- a/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala +++ b/test/junit/scala/tools/nsc/backend/jvm/BytecodeTest.scala @@ -187,4 +187,12 @@ class BytecodeTest extends BytecodeTesting { List(Label(0), LineNumber(2, Label(0)), VarOp(ALOAD, 0), Invoke(INVOKESPECIAL, "T", "t", "()V", true), Op(RETURN), Label(4)) ) } + + @Test + def sd233(): Unit = { + val code = "def f = { println(1); synchronized(println(2)) }" + val m = compileMethod(code) + val List(ExceptionHandler(_, _, _, desc)) = m.handlers + assert(desc == None, desc) + } } -- cgit v1.2.3