Skip to content

Commit 7cb7c0e

Browse files
committed
Upgrade to ASM 7.0
Catch up with Scala 2.13. The corresponding scalac PRs are scala/scala#6733 and scala/scala#7384 Most of the changes from these PRs aren't currently needed in Dotty since they only affect the Scala 2 backend optimizer.
1 parent 51853d6 commit 7cb7c0e

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package backend
33
package jvm
44

55
import scala.tools.asm
6+
import scala.tools.asm.ClassWriter
67
import scala.collection.mutable
78
import dotty.tools.io.AbstractFile
89

@@ -126,6 +127,20 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
126127
}
127128
}
128129

130+
/*
131+
* can-multi-thread
132+
*/
133+
def createJAttribute(name: String, b: Array[Byte], offset: Int, len: Int): asm.Attribute = {
134+
new asm.Attribute(name) {
135+
override def write(classWriter: ClassWriter, code: Array[Byte],
136+
codeLength: Int, maxStack: Int, maxLocals: Int): asm.ByteVector = {
137+
val byteVector = new asm.ByteVector(len)
138+
byteVector.putByteArray(b, offset, len)
139+
byteVector
140+
}
141+
}
142+
}
143+
129144
/*
130145
* Custom attribute (JVMS 4.7.1) "ScalaSig" used as marker only
131146
* i.e., the pickle is contained in a custom annotation, see:
@@ -151,15 +166,6 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
151166
vp
152167
}
153168

154-
/*
155-
* can-multi-thread
156-
*/
157-
def createJAttribute(name: String, b: Array[Byte], offset: Int, len: Int): asm.Attribute = {
158-
val dest = new Array[Byte](len)
159-
System.arraycopy(b, offset, dest, 0, len)
160-
new asm.CustomAttr(name, dest)
161-
}
162-
163169
/*
164170
* can-multi-thread
165171
*/

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import dotty.tools.dotc.core.Phases.Phase
77

88
import scala.collection.mutable
99
import scala.collection.JavaConverters._
10-
import scala.tools.asm.CustomAttr
1110
import dotty.tools.dotc.transform.SymUtils._
1211
import dotty.tools.dotc.interfaces
1312
import dotty.tools.dotc.util.SourceFile
@@ -240,7 +239,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
240239
getFileForClassfile(outF, store.name, ".hasTasty")
241240
binary
242241
}
243-
val dataAttr = new CustomAttr(nme.TASTYATTR.mangledString, tasty)
242+
val dataAttr = createJAttribute(nme.TASTYATTR.mangledString, tasty, 0, tasty.size)
244243
store.visitAttribute(dataAttr)
245244
}
246245

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ object Build {
481481

482482
// get libraries onboard
483483
libraryDependencies ++= Seq(
484-
"org.scala-lang.modules" % "scala-asm" % "6.0.0-scala-1", // used by the backend
484+
"org.scala-lang.modules" % "scala-asm" % "7.0.0-scala-1", // used by the backend
485485
// FIXME: Not needed, but should be on the compiler CP
486486
("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value),
487487
"org.scala-lang" % "scala-library" % scalacVersion % "test",

0 commit comments

Comments
 (0)