diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-01-24 13:03:22 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-01-24 13:03:22 +0100 |
commit | b0831e774e290148ce28cb7957794542dffe0366 (patch) | |
tree | 1380b224b4fe31598b07b3ddee9a46ff2e3eaf10 /test/files/pos/inliner2.scala | |
parent | 1a9e649e34cda4306537d74ab425c33d5f6a77db (diff) | |
parent | 1081e718f8f8e174dbf615e42b157e187d3d3886 (diff) | |
download | scala-b0831e774e290148ce28cb7957794542dffe0366.tar.gz scala-b0831e774e290148ce28cb7957794542dffe0366.tar.bz2 scala-b0831e774e290148ce28cb7957794542dffe0366.zip |
Merge remote-tracking branch 'upstream/2.12.x' into opt/elimBoxes
Diffstat (limited to 'test/files/pos/inliner2.scala')
-rw-r--r-- | test/files/pos/inliner2.scala | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/test/files/pos/inliner2.scala b/test/files/pos/inliner2.scala deleted file mode 100644 index bc83e04312..0000000000 --- a/test/files/pos/inliner2.scala +++ /dev/null @@ -1,57 +0,0 @@ -// 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 |