Skip to content

Commit

Permalink
Upgrade to scala-asm 6.2
Browse files Browse the repository at this point in the history
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
  • Loading branch information
retronym committed Jun 20, 2018
1 parent da3d37f commit f66b23f
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
18 changes: 0 additions & 18 deletions src/compiler/scala/tools/asm/LabelAccess.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala
Expand Up @@ -765,6 +765,8 @@ abstract class BTypes {
// finds the first common one.
// MOST LIKELY the answer can be found here, see the comments and links by Miguel:
// - https://github.com/scala/bug/issues/3872
// @jz Wouldn't it be better to walk the superclass chain of both types in reverse (starting from Object), and
// finding the last common link? That would be O(N), whereas this looks O(N^2)
firstCommonSuffix(this :: this.superClassesTransitive.orThrow, other :: other.superClassesTransitive.orThrow)
}

Expand Down
Expand Up @@ -13,7 +13,7 @@ import scala.tools.asm
import scala.tools.asm.Opcodes._
import scala.tools.asm.tree._
import scala.tools.asm.tree.analysis._
import scala.tools.asm.{Handle, LabelAccess, Type}
import scala.tools.asm.{Handle, Label, Type}
import scala.tools.nsc.backend.jvm.BTypes._
import scala.tools.nsc.backend.jvm.GenBCode._
import scala.tools.nsc.backend.jvm.analysis.BackendUtils._
Expand Down Expand Up @@ -587,9 +587,18 @@ object BackendUtils {
def clearDceDone(method: MethodNode) = method.access &= ~ACC_DCE_DONE

private val LABEL_REACHABLE_STATUS = 0x1000000
def isLabelReachable(label: LabelNode) = LabelAccess.isLabelFlagSet(label.getLabel, LABEL_REACHABLE_STATUS)
def setLabelReachable(label: LabelNode) = LabelAccess.setLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
def clearLabelReachable(label: LabelNode) = LabelAccess.clearLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
private def isLabelFlagSet(l: Label, f: Int): Boolean = (l.flags & f) != 0

private def setLabelFlag(l: Label, f: Int): Unit = {
l.flags |= f
}

private def clearLabelFlag(l: Label, f: Int): Unit = {
l.flags &= ~f
}
def isLabelReachable(label: LabelNode) = isLabelFlagSet(label.getLabel, LABEL_REACHABLE_STATUS)
def setLabelReachable(label: LabelNode) = setLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)
def clearLabelReachable(label: LabelNode) = clearLabelFlag(label.getLabel, LABEL_REACHABLE_STATUS)

abstract class NestedClassesCollector[T] extends GenericSignatureVisitor {
val innerClasses = mutable.Set.empty[T]
Expand Down
Expand Up @@ -457,7 +457,7 @@ case class ParameterProducer(local: Int)
case class UninitializedLocalProducer(local: Int) extends InitialProducer
case class ExceptionProducer[V <: Value](handlerLabel: LabelNode, handlerStackTop: Int) extends InitialProducer

class InitialProducerSourceInterpreter extends SourceInterpreter {
class InitialProducerSourceInterpreter extends SourceInterpreter(scala.tools.asm.Opcodes.ASM7_EXPERIMENTAL) {
override def newParameterValue(isInstanceMethod: Boolean, local: Int, tp: Type): SourceValue = {
new SourceValue(tp.getSize, ParameterProducer(local))
}
Expand Down
Expand Up @@ -5,7 +5,7 @@ package analysis
import scala.tools.asm.Type
import scala.tools.asm.tree.analysis.{BasicValue, BasicInterpreter}

abstract class TypeFlowInterpreter extends BasicInterpreter {
abstract class TypeFlowInterpreter extends BasicInterpreter(scala.tools.asm.Opcodes.ASM7_EXPERIMENTAL) {
override def newValue(tp: Type) = {
if (tp == null) super.newValue(tp)
else if (isRef(tp)) new BasicValue(tp)
Expand Down
7 changes: 6 additions & 1 deletion src/partest/scala/tools/partest/nest/StreamCapture.scala
Expand Up @@ -41,7 +41,12 @@ object StreamCapture {
def withExtraProperties[A](extra: Map[String, String])(action: => A): A = {
val saved = System.getProperties()
val modified = new java.util.Properties()
modified.putAll(saved)
// on Java 9, we need to cast our way around this:
// src/main/scala/scala/tools/partest/nest/StreamCapture.scala:44: ambiguous reference to overloaded definition,
// both method putAll in class Properties of type (x$1: java.util.Map[_, _])Unit
// and method putAll in class Hashtable of type (x$1: java.util.Map[_ <: Object, _ <: Object])Unit
// match argument types (java.util.Properties)
(modified: java.util.Hashtable[AnyRef, AnyRef]).putAll(saved)
extra.foreach { case (k, v) => modified.setProperty(k, v) }
// Trying to avoid other threads seeing the new properties object prior to the new entries
// https://github.com/scala/scala/pull/6391#issuecomment-371346171
Expand Down
Expand Up @@ -1720,7 +1720,7 @@ class InlinerTest extends BytecodeTesting {
""".stripMargin
val warn =
"""T::m()I is annotated @inline but could not be inlined:
|The callee T::m()I contains the instruction INVOKESPECIAL T.impl$1 ()I
|The callee T::m()I contains the instruction INVOKESPECIAL T.impl$1 ()I (itf)
|that would cause an IllegalAccessError when inlined into class C.""".stripMargin
val List(a, c, t) = compileClasses(code, allowMessage = _.msg contains warn)
assertInvoke(getMethod(c, "t"), "T", "m$")
Expand Down
2 changes: 1 addition & 1 deletion versions.properties
Expand Up @@ -7,5 +7,5 @@ starr.version=2.13.0-M4
# Other usages:
# - scala-asm: jar content included in scala-compiler
# - jline: shaded with JarJar and included in scala-compiler
scala-asm.version=6.0.0-scala-1
scala-asm.version=6.2.0-scala-2
jline.version=2.14.6

0 comments on commit f66b23f

Please sign in to comment.