Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit c8e7fdc

Browse files
committed
Default to delambdafy:method and backend:GenBCode
Switch the defaults of `-Ydelambdafy` and `-Ybackend`. Rewrite t6288b-jump-position test - no more icode Don't crash GenBCode beyond JVM code size limits A similar patch is in GenASM, see 3fa2c97 Fix check files for GenBCode / delambdafy:method defaults Force copy propagation test to ASM, see SI-9364 Force inline-ex-handlers test to GenASM, see SI-9364 Move t6613 test to pending - still broken in GenBCode Adding a `flags` file with `-Ybackend:GenASM` doesn't seem to have the desired effect. SI-6613 is re-opened. Force a few tests to GenASM, see SI-9364
1 parent f509731 commit c8e7fdc

26 files changed

+151
-202
lines changed

src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ abstract class GenBCode extends BCodeSyncAndTry {
242242
localOptimizations(item.plain)
243243
addToQ3(item)
244244
} catch {
245+
case e: java.lang.RuntimeException if e.getMessage != null && (e.getMessage contains "too large!") =>
246+
reporter.error(NoPosition,
247+
s"Could not write class ${item.plain.name} because it exceeds JVM code size limits. ${e.getMessage}")
245248
case ex: Throwable =>
246249
ex.printStackTrace()
247250
error(s"Error while emitting ${item.plain.name}\n${ex.getMessage}")

src/compiler/scala/tools/nsc/settings/ScalaSettings.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,8 @@ trait ScalaSettings extends AbsScalaSettings
222222
val YdisableUnreachablePrevention = BooleanSetting("-Ydisable-unreachable-prevention", "Disable the prevention of unreachable blocks in code generation.")
223223
val YnoLoadImplClass = BooleanSetting ("-Yno-load-impl-class", "Do not load $class.class files.")
224224

225-
val exposeEmptyPackage = BooleanSetting("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
226-
// the current standard is "inline" but we are moving towards "method"
227-
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "inline")
225+
val exposeEmptyPackage = BooleanSetting ("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly()
226+
val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "method")
228227

229228
val YskipInlineInfoAttribute = BooleanSetting("-Yskip-inline-info-attribute", "Do not add the ScalaInlineInfo attribute to classfiles generated by -Ybackend:GenASM")
230229

@@ -352,7 +351,7 @@ trait ScalaSettings extends AbsScalaSettings
352351
*/
353352
val Ybackend = ChoiceSetting ("-Ybackend", "choice of bytecode emitter", "Choice of bytecode emitter.",
354353
List("GenASM", "GenBCode"),
355-
"GenASM")
354+
"GenBCode")
356355
// Feature extensions
357356
val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.")
358357

test/files/jvm/innerClassAttribute.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#partest !-Ydelambdafy:method
1+
#partest -Ydelambdafy:inline
22
-- A4 --
33
A4$$anonfun$f$1 / null / null / 17
44
A4$$anonfun$f$1 / null / null / 17
@@ -35,7 +35,7 @@ A20 / null / null
3535
A20$$anonfun$4 / null / null
3636
A20$$anonfun$4 / null / null
3737
A20$$anonfun$4$$anonfun$apply$2 / null / null
38-
#partest -Ydelambdafy:method
38+
#partest !-Ydelambdafy:inline
3939
-- A4 --
4040
null / null / null
4141
-- A19 --

test/files/jvm/javaReflection.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#partest !-Ydelambdafy:method
1+
#partest -Ydelambdafy:inline
22
A$$anonfun$$lessinit$greater$1 / null (canon) / $anonfun$$lessinit$greater$1 (simple)
33
- declared cls: List()
44
- enclosing : null (declaring cls) / class A (cls) / public A(int) (constr) / null (meth)
@@ -39,7 +39,7 @@ AT$$anonfun$6 / null (canon) / $anonfun$6 (simple)
3939
- declared cls: List()
4040
- enclosing : null (declaring cls) / interface AT (cls) / null (constr) / null (meth)
4141
- properties : true (local) / false (member)
42-
#partest -Ydelambdafy:method
42+
#partest !-Ydelambdafy:inline
4343
A$D$lambda$1 / A$D$lambda$1 (canon) / A$D$lambda$1 (simple)
4444
- declared cls: List()
4545
- enclosing : null (declaring cls) / null (cls) / null (constr) / null (meth)

test/files/jvm/t9105.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#partest !-Ydelambdafy:method
1+
#partest -Ydelambdafy:inline
22
(class C$$anonfun$1$A$1,class C$$anonfun$1,null)
33
(class C$$anonfun$1$B$1,class C$$anonfun$1,private final java.lang.Object C$$anonfun$1.m$1())
44
(class C$$anonfun$1$C$1,class C$$anonfun$1,null)
@@ -7,7 +7,7 @@
77
(class C$$anonfun$met$1$F$1,class C$$anonfun$met$1,private final java.lang.Object C$$anonfun$met$1.m$2())
88
(class C$$anonfun$met$1$G$1,class C$$anonfun$met$1,null)
99
(class C$$anonfun$met$1$$anonfun$3$H$1,class C$$anonfun$met$1$$anonfun$3,null)
10-
#partest -Ydelambdafy:method
10+
#partest !-Ydelambdafy:inline
1111
(class C$A$1,class C,null)
1212
(class C$B$1,class C,private final java.lang.Object C.m$1())
1313
(class C$C$1,class C,null)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-Ydelambdafy:method
1+
-Ydelambdafy:method -Ybackend:GenASM

test/files/run/delambdafy_t6028.check

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package <empty> {
2121
def tryy(tryyParam: String): Function0 = {
2222
var tryyLocal: runtime.ObjectRef = scala.runtime.ObjectRef.create("");
2323
{
24-
(new <$anon: Function0>(T.this, tryyParam, tryyLocal): Function0)
24+
(() => T.this.$anonfun$2(tryyParam, tryyLocal)).$asInstanceOf[Function0]()
2525
}
2626
};
2727
final <artifact> private[this] def $anonfun$1(methodParam$1: String, methodLocal$1: String): String = T.this.classParam.+(T.this.field()).+(methodParam$1).+(methodLocal$1);
@@ -48,24 +48,9 @@ package <empty> {
4848
};
4949
scala.this.Predef.print(barParam$1)
5050
};
51-
@SerialVersionUID(value = 0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable {
52-
def <init>($outer: T, tryyParam$1: String, tryyLocal$1: runtime.ObjectRef): <$anon: Function0> = {
53-
$anonfun$tryy$1.super.<init>();
54-
()
55-
};
56-
final def apply(): Unit = $anonfun$tryy$1.this.apply$mcV$sp();
57-
<specialized> def apply$mcV$sp(): Unit = try {
58-
$anonfun$tryy$1.this.tryyLocal$1.elem = $anonfun$tryy$1.this.tryyParam$1
59-
} finally ();
60-
<synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _;
61-
<synthetic> <stable> <artifact> def $outer(): T = $anonfun$tryy$1.this.$outer;
62-
final <bridge> <artifact> def apply(): Object = {
63-
$anonfun$tryy$1.this.apply();
64-
scala.runtime.BoxedUnit.UNIT
65-
};
66-
<synthetic> <paramaccessor> private[this] val tryyParam$1: String = _;
67-
<synthetic> <paramaccessor> private[this] val tryyLocal$1: runtime.ObjectRef = _
68-
}
51+
final <artifact> private[this] def $anonfun$2(tryyParam$1: String, tryyLocal$1: runtime.ObjectRef): Unit = try {
52+
tryyLocal$1.elem = tryyParam$1
53+
} finally ()
6954
}
7055
}
7156

0 commit comments

Comments
 (0)