summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-03-30 22:44:34 +1000
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-03-30 12:11:02 -0700
commitaec2b940cfa04843efe2eab00272557823fd8dd2 (patch)
treef4b278e7fae6317f4f1da857c423a472e382a59f /test
parent3904c3216c741b387d81754e55aa079ce4218d06 (diff)
downloadscala-aec2b940cfa04843efe2eab00272557823fd8dd2.tar.gz
scala-aec2b940cfa04843efe2eab00272557823fd8dd2.tar.bz2
scala-aec2b940cfa04843efe2eab00272557823fd8dd2.zip
Keep SAM body in anonfun method in enclosing class
Rather than in implementation of the abstract method in the expanded anonymous class. This leads to more more efficient use of the constant pool, code shapes more amenable to SAM inlining, and is compatible with the old behaviour of `-Xexperimental` in Scala 2.11, which ScalaJS now relies upon. Manual test: ``` scala> :paste -raw // Entering paste mode (ctrl-D to finish) package p1; trait T { val x = 0; def apply(): Any }; class DelambdafyInline { def t: T = (() => "") } // Exiting paste mode, now interpreting. scala> :javap -c p1.DelambdafyInline Compiled from "<pastie>" public class p1.DelambdafyInline { public p1.T t(); Code: 0: new #10 // class p1/DelambdafyInline$$anonfun$t$1 3: dup 4: aload_0 5: invokespecial #16 // Method p1/DelambdafyInline$$anonfun$t$1."<init>":(Lp1/DelambdafyInline;)V 8: areturn public final java.lang.Object p1$DelambdafyInline$$$anonfun$1(); Code: 0: ldc #22 // String 2: areturn public p1.DelambdafyInline(); Code: 0: aload_0 1: invokespecial #25 // Method java/lang/Object."<init>":()V 4: return } scala> :javap -c p1.DelambdafyInline$$anonfun$t$1 Compiled from "<pastie>" public final class p1.DelambdafyInline$$anonfun$t$1 implements p1.T,scala.Serializable { public static final long serialVersionUID; public int x(); Code: 0: aload_0 1: getfield #25 // Field x:I 4: ireturn public void p1$T$_setter_$x_$eq(int); Code: 0: aload_0 1: iload_1 2: putfield #25 // Field x:I 5: return public final java.lang.Object apply(); Code: 0: aload_0 1: getfield #34 // Field $outer:Lp1/DelambdafyInline; 4: invokevirtual #37 // Method p1/DelambdafyInline.p1$DelambdafyInline$$$anonfun$1:()Ljava/lang/Object; 7: areturn public p1.DelambdafyInline$$anonfun$t$1(p1.DelambdafyInline); Code: 0: aload_1 1: ifnonnull 6 4: aconst_null 5: athrow 6: aload_0 7: aload_1 8: putfield #34 // Field $outer:Lp1/DelambdafyInline; 11: aload_0 12: invokespecial #42 // Method java/lang/Object."<init>":()V 15: aload_0 16: invokespecial #45 // Method p1/T.$init$:()V 19: return } scala> :quit ``` Adriaan is to `git blame` for `reflection-mem-typecheck.scala`.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/reflection-mem-typecheck.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/files/run/reflection-mem-typecheck.scala b/test/files/run/reflection-mem-typecheck.scala
index e3cabf689d..93ec1c937a 100644
--- a/test/files/run/reflection-mem-typecheck.scala
+++ b/test/files/run/reflection-mem-typecheck.scala
@@ -11,7 +11,9 @@ object Test extends MemoryTest {
cm.mkToolBox()
}
- override def maxDelta = 10
+ // I'm not sure this is a great way to test for memory leaks,
+ // since we're also testing how good the JVM's GC is, and this is not easily reproduced between machines/over time
+ override def maxDelta = 12
override def calcsPerIter = 8
override def calc() {
var snippet = """