diff options
Diffstat (limited to 'test/files/run/bcodeInlinerMixed')
-rw-r--r-- | test/files/run/bcodeInlinerMixed/B_1.scala | 14 | ||||
-rw-r--r-- | test/files/run/bcodeInlinerMixed/Test.scala | 16 | ||||
-rw-r--r-- | test/files/run/bcodeInlinerMixed/Test_2.scala | 30 |
3 files changed, 36 insertions, 24 deletions
diff --git a/test/files/run/bcodeInlinerMixed/B_1.scala b/test/files/run/bcodeInlinerMixed/B_1.scala index 2aadeccb82..b26f2f1dd5 100644 --- a/test/files/run/bcodeInlinerMixed/B_1.scala +++ b/test/files/run/bcodeInlinerMixed/B_1.scala @@ -1,15 +1,13 @@ -// Partest does proper mixed compilation: +// Since 1.0.18, partest does mixed compilation only in two stages // 1. scalac *.scala *.java // 2. javac *.java -// 3. scalc *.scala -// -// In the second scalc round, the classfile for A_1 is on the classpath. -// Therefore the inliner has access to the bytecode of `bar`, which means -// it can verify that the invocation to `bar` can be safely inlined. // -// So both callsites of `flop` are inlined. +// Before it used to do a third stage +// 3. scalc *.scala // -// In a single mixed compilation, `flop` cannot be inlined, see JUnit InlinerTest.scala, def mixedCompilationNoInline. +// Because he inliner doesn't has access to the bytecode of `bar`, it cannot verify whether the +// invocation of `bar` can be safely copied to a differnet place, so `flop` is not inlined to `B.g` +// or `C.h`. class B { @inline final def flop = A_1.bar diff --git a/test/files/run/bcodeInlinerMixed/Test.scala b/test/files/run/bcodeInlinerMixed/Test.scala deleted file mode 100644 index c8c7a9fe2a..0000000000 --- a/test/files/run/bcodeInlinerMixed/Test.scala +++ /dev/null @@ -1,16 +0,0 @@ -import scala.tools.partest.{BytecodeTest, ASMConverters} -import ASMConverters._ - -object Test extends BytecodeTest { - def show: Unit = { - val gIns = instructionsFromMethod(getMethod(loadClassNode("B"), "g")) - val hIns = instructionsFromMethod(getMethod(loadClassNode("C"), "h")) - // val invocation = Invoke(INVOKESTATIC, A_1, bar, ()I, false) - for (i <- List(gIns, hIns)) { - assert(i exists { - case Invoke(_, _, "bar", "()I", _) => true - case _ => false - }, i mkString "\n") - } - } -} diff --git a/test/files/run/bcodeInlinerMixed/Test_2.scala b/test/files/run/bcodeInlinerMixed/Test_2.scala new file mode 100644 index 0000000000..db1ea14a8f --- /dev/null +++ b/test/files/run/bcodeInlinerMixed/Test_2.scala @@ -0,0 +1,30 @@ +import scala.tools.partest.{BytecodeTest, ASMConverters} +import ASMConverters._ + +class D { + // This is compiled with `A_1.class` on the classpath. When inlining `flop` (which invokes + // `A_1.bar`), the inliner can check that the call to `A_1.bar` can be safely inlined into a + // different classfile (D). See also comment in B_1.scala. + def m(b: B) = b.flop +} + +object Test extends BytecodeTest { + def show: Unit = { + val gIns = instructionsFromMethod(getMethod(loadClassNode("B"), "g")) + val hIns = instructionsFromMethod(getMethod(loadClassNode("C"), "h")) + for (i <- List(gIns, hIns)) { + assert(i exists { + // `flop` is not inlined + case Invoke(_, _, "flop", "()I", _) => true + case _ => false + }, i mkString "\n") + } + + val mIns = instructionsFromMethod(getMethod(loadClassNode("D"), "m")) + assert(mIns exists { + // `flop` is inlined, we get a call to `bar` + case Invoke(_, _, "bar", "()I", _) => true + case _ => false + }, mIns mkString "\n") + } +} |