Skip to content

Commit f66b23f

Browse files
committed
Upgrade to scala-asm 6.2
See: scala/scala-asm#5 Upstream changes in ASM: scala/scala-asm@ASM_6_0...ASM_6_2 http://asm.ow2.io/versions.html The motivations, other than just keeping current, are: - support for Java 9/10/11 updates to the classfile format. - reducing needless String => Array[Char] conversions thanks to internal changes in ASM. This PR will fail to build until we publish artifact from scala/scala-asm. Includes a workaround for scala/bug#10418
1 parent da3d37f commit f66b23f

File tree

8 files changed

+25
-27
lines changed

8 files changed

+25
-27
lines changed

src/compiler/scala/tools/asm/LabelAccess.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,8 @@ abstract class BTypes {
765765
// finds the first common one.
766766
// MOST LIKELY the answer can be found here, see the comments and links by Miguel:
767767
// - https://github.com/scala/bug/issues/3872
768+
// @jz Wouldn't it be better to walk the superclass chain of both types in reverse (starting from Object), and
769+
// finding the last common link? That would be O(N), whereas this looks O(N^2)
768770
firstCommonSuffix(this :: this.superClassesTransitive.orThrow, other :: other.superClassesTransitive.orThrow)
769771
}
770772

src/compiler/scala/tools/nsc/backend/jvm/analysis/BackendUtils.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.tools.asm
1313
import scala.tools.asm.Opcodes._
1414
import scala.tools.asm.tree._
1515
import scala.tools.asm.tree.analysis._
16-
import scala.tools.asm.{Handle, LabelAccess, Type}
16+
import scala.tools.asm.{Handle, Label, Type}
1717
import scala.tools.nsc.backend.jvm.BTypes._
1818
import scala.tools.nsc.backend.jvm.GenBCode._
1919
import scala.tools.nsc.backend.jvm.analysis.BackendUtils._
@@ -587,9 +587,18 @@ object BackendUtils {
587587
def clearDceDone(method: MethodNode) = method.access &= ~ACC_DCE_DONE
588588

589589
private val LABEL_REACHABLE_STATUS = 0x1000000
590-
def isLabelReachable(label: LabelNode) = LabelAccess.isLabelFlagSet(label.getLabel, LABEL_REACHABLE_STATUS)
591-
def setLabelReachable(label: LabelNode) = LabelAccess.setLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
592-
def clearLabelReachable(label: LabelNode) = LabelAccess.clearLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
590+
private def isLabelFlagSet(l: Label, f: Int): Boolean = (l.flags & f) != 0
591+
592+
private def setLabelFlag(l: Label, f: Int): Unit = {
593+
l.flags |= f
594+
}
595+
596+
private def clearLabelFlag(l: Label, f: Int): Unit = {
597+
l.flags &= ~f
598+
}
599+
def isLabelReachable(label: LabelNode) = isLabelFlagSet(label.getLabel, LABEL_REACHABLE_STATUS)
600+
def setLabelReachable(label: LabelNode) = setLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
601+
def clearLabelReachable(label: LabelNode) = clearLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
593602

594603
abstract class NestedClassesCollector[T] extends GenericSignatureVisitor {
595604
val innerClasses = mutable.Set.empty[T]

src/compiler/scala/tools/nsc/backend/jvm/analysis/ProdConsAnalyzerImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ case class ParameterProducer(local: Int)
457457
case class UninitializedLocalProducer(local: Int) extends InitialProducer
458458
case class ExceptionProducer[V <: Value](handlerLabel: LabelNode, handlerStackTop: Int) extends InitialProducer
459459

460-
class InitialProducerSourceInterpreter extends SourceInterpreter {
460+
class InitialProducerSourceInterpreter extends SourceInterpreter(scala.tools.asm.Opcodes.ASM7_EXPERIMENTAL) {
461461
override def newParameterValue(isInstanceMethod: Boolean, local: Int, tp: Type): SourceValue = {
462462
new SourceValue(tp.getSize, ParameterProducer(local))
463463
}

src/compiler/scala/tools/nsc/backend/jvm/analysis/TypeFlowInterpreter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package analysis
55
import scala.tools.asm.Type
66
import scala.tools.asm.tree.analysis.{BasicValue, BasicInterpreter}
77

8-
abstract class TypeFlowInterpreter extends BasicInterpreter {
8+
abstract class TypeFlowInterpreter extends BasicInterpreter(scala.tools.asm.Opcodes.ASM7_EXPERIMENTAL) {
99
override def newValue(tp: Type) = {
1010
if (tp == null) super.newValue(tp)
1111
else if (isRef(tp)) new BasicValue(tp)

src/partest/scala/tools/partest/nest/StreamCapture.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ object StreamCapture {
4141
def withExtraProperties[A](extra: Map[String, String])(action: => A): A = {
4242
val saved = System.getProperties()
4343
val modified = new java.util.Properties()
44-
modified.putAll(saved)
44+
// on Java 9, we need to cast our way around this:
45+
// src/main/scala/scala/tools/partest/nest/StreamCapture.scala:44: ambiguous reference to overloaded definition,
46+
// both method putAll in class Properties of type (x$1: java.util.Map[_, _])Unit
47+
// and method putAll in class Hashtable of type (x$1: java.util.Map[_ <: Object, _ <: Object])Unit
48+
// match argument types (java.util.Properties)
49+
(modified: java.util.Hashtable[AnyRef, AnyRef]).putAll(saved)
4550
extra.foreach { case (k, v) => modified.setProperty(k, v) }
4651
// Trying to avoid other threads seeing the new properties object prior to the new entries
4752
// https://github.com/scala/scala/pull/6391#issuecomment-371346171

test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ class InlinerTest extends BytecodeTesting {
17201720
""".stripMargin
17211721
val warn =
17221722
"""T::m()I is annotated @inline but could not be inlined:
1723-
|The callee T::m()I contains the instruction INVOKESPECIAL T.impl$1 ()I
1723+
|The callee T::m()I contains the instruction INVOKESPECIAL T.impl$1 ()I (itf)
17241724
|that would cause an IllegalAccessError when inlined into class C.""".stripMargin
17251725
val List(a, c, t) = compileClasses(code, allowMessage = _.msg contains warn)
17261726
assertInvoke(getMethod(c, "t"), "T", "m$")

versions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ starr.version=2.13.0-M4
77
# Other usages:
88
# - scala-asm: jar content included in scala-compiler
99
# - jline: shaded with JarJar and included in scala-compiler
10-
scala-asm.version=6.0.0-scala-1
10+
scala-asm.version=6.2.0-scala-2
1111
jline.version=2.14.6

0 commit comments

Comments
 (0)