diff options
author | Simon Ochsenreither <simon@ochsenreither.de> | 2015-09-16 17:31:02 +0200 |
---|---|---|
committer | Simon Ochsenreither <simon@ochsenreither.de> | 2015-10-27 15:43:08 +0100 |
commit | 1a8daa2d6cbf46a7cdd9180c11c641adabcf6d92 (patch) | |
tree | b7014fdfe397864c621322bfe00ff3307df5017e /test/pending/pos | |
parent | 4321ea458ad1258f273ee22a4c6a7606ab054501 (diff) | |
download | scala-1a8daa2d6cbf46a7cdd9180c11c641adabcf6d92.tar.gz scala-1a8daa2d6cbf46a7cdd9180c11c641adabcf6d92.tar.bz2 scala-1a8daa2d6cbf46a7cdd9180c11c641adabcf6d92.zip |
Remove GenASM, merge remaining common code snippets
With GenBCode being the default and only supported backend for Java 8,
we can get rid of GenASM.
This commit also fixes/migrates/moves to pending/deletes tests which
depended on GenASM before.
Diffstat (limited to 'test/pending/pos')
-rw-r--r-- | test/pending/pos/inliner2.flags | 35 | ||||
-rw-r--r-- | test/pending/pos/inliner2.scala | 57 | ||||
-rw-r--r-- | test/pending/pos/sealed-final.flags | 41 | ||||
-rw-r--r-- | test/pending/pos/sealed-final.scala | 14 |
4 files changed, 147 insertions, 0 deletions
diff --git a/test/pending/pos/inliner2.flags b/test/pending/pos/inliner2.flags new file mode 100644 index 0000000000..4bf93a9c2a --- /dev/null +++ b/test/pending/pos/inliner2.flags @@ -0,0 +1,35 @@ +-optimise -Ybackend:GenASM -Xfatal-warnings +/* +This is what we get with 2.11.2-M3 and -Yopt:l:project: + + public final int bob1(); + Code: + 0: aload_0 + 1: aload_0 + 2: astore 6 + 4: aload 6 + 6: invokedynamic #62, 0 // InvokeDynamic #0:apply$mcZ$sp:(LA;)Lscala/runtime/java8/JFunction0$mcZ$sp; + 11: checkcast #29 // class scala/Function0 + 14: invokedynamic #71, 0 // InvokeDynamic #1:apply$mcI$sp:()Lscala/runtime/java8/JFunction0$mcI$sp; + 19: checkcast #29 // class scala/Function0 + 22: invokedynamic #76, 0 // InvokeDynamic #2:apply$mcI$sp:()Lscala/runtime/java8/JFunction0$mcI$sp; + 27: checkcast #29 // class scala/Function0 + 30: astore 4 + 32: astore_3 + 33: astore_2 + 34: astore_1 + 35: aload_2 + 36: pop + 37: aload 6 + 39: invokevirtual #53 // Method A$$$anonfun$1:()Z + 42: ifeq 54 + 45: aload_3 + 46: invokeinterface #36, 1 // InterfaceMethod scala/Function0.apply:()Ljava/lang/Object; + 51: goto 61 + 54: aload 4 + 56: invokeinterface #36, 1 // InterfaceMethod scala/Function0.apply:()Ljava/lang/Object; + 61: astore 5 + 63: aload 5 + 65: invokestatic #82 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I + 68: ireturn +*/
\ No newline at end of file diff --git a/test/pending/pos/inliner2.scala b/test/pending/pos/inliner2.scala new file mode 100644 index 0000000000..bc83e04312 --- /dev/null +++ b/test/pending/pos/inliner2.scala @@ -0,0 +1,57 @@ +// This isn't actually testing much, because no warning is emitted in versions +// before the fix which comes with this because the method isn't even considered +// for inlining due to the bug. +class A { + private var debug = false + @inline private def ifelse[T](cond: => Boolean, ifPart: => T, elsePart: => T): T = + if (cond) ifPart else elsePart + + final def bob1() = ifelse(debug, 1, 2) + final def bob2() = if (debug) 1 else 2 +} +// Cool: +// +// % ls -1 /tmp/2901/ +// A$$anonfun$bob1$1.class +// A$$anonfun$bob1$2.class +// A$$anonfun$bob1$3.class +// A.class +// % ls -1 /tmp/trunk +// A.class +// +// Observations: +// +// (1) The inlined version accesses the field: the explicit one calls the accessor. +// (2) The inlined version fails to eliminate boxing. With reference types it emits +// an unneeded checkcast. +// (3) The private var debug is mangled to A$$debug, but after inlining it is never accessed +// from outside of the class and doesn't need mangling. +// (4) We could forego emitting bytecode for ifelse entirely if it has been +// inlined at all sites. +// +// Generated bytecode for the above: +// +// public final int bob1(); +// Code: +// Stack=1, Locals=1, Args_size=1 +// 0: aload_0 +// 1: getfield #11; //Field A$$debug:Z +// 4: ifeq 14 +// 7: iconst_1 +// 8: invokestatic #41; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer; +// 11: goto 18 +// 14: iconst_2 +// 15: invokestatic #41; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer; +// 18: invokestatic #45; //Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I +// 21: ireturn +// +// public final int bob2(); +// Code: +// Stack=1, Locals=1, Args_size=1 +// 0: aload_0 +// 1: invokevirtual #48; //Method A$$debug:()Z +// 4: ifeq 11 +// 7: iconst_1 +// 8: goto 12 +// 11: iconst_2 +// 12: ireturn diff --git a/test/pending/pos/sealed-final.flags b/test/pending/pos/sealed-final.flags new file mode 100644 index 0000000000..63d024a0ba --- /dev/null +++ b/test/pending/pos/sealed-final.flags @@ -0,0 +1,41 @@ +-Xfatal-warnings -Yinline-warnings -Ybackend:GenASM -optimise +/* +The new flag settings could be + -Yopt-warnings -Yopt:l:project + +The issue here is that things are being inlined, but a lot of +redundant load/store instructions are left behind: + +2.11.7: + + public int f(); + Code: + 0: getstatic #19 // Field Foo$.MODULE$:LFoo$; + 3: invokevirtual #23 // Method Foo$.mkFoo:()LFoo; + 6: pop + 7: bipush 10 + 9: iconst_1 + 10: iadd + 11: ireturn + + +2.12.0-M3: + + public int f(); + Code: + 0: getstatic #19 // Field Foo$.MODULE$:LFoo$; + 3: invokevirtual #23 // Method Foo$.mkFoo:()LFoo; + 6: bipush 10 + 8: istore_2 + 9: dup + 10: ifnonnull 15 + 13: aconst_null + 14: athrow + 15: astore_1 + 16: iload_2 + 17: iconst_1 + 18: iadd + 19: istore_3 + 20: iload_3 + 21: ireturn +*/
\ No newline at end of file diff --git a/test/pending/pos/sealed-final.scala b/test/pending/pos/sealed-final.scala new file mode 100644 index 0000000000..bdedb5c1f6 --- /dev/null +++ b/test/pending/pos/sealed-final.scala @@ -0,0 +1,14 @@ +sealed abstract class Foo { + @inline def bar(x: Int) = x + 1 +} +object Foo { + def mkFoo(): Foo = new Baz2 +} + +object Baz1 extends Foo +final class Baz2 extends Foo + +object Test { + // bar should be inlined now + def f = Foo.mkFoo() bar 10 +} |