Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Parallelise JVM backend - Scala 2 port" to LTS #21161

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/backend/jvm/BTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ abstract class BTypes { self =>
* Concurrent because stack map frames are computed when in the class writer, which might run
* on multiple classes concurrently.
*/
protected def classBTypeFromInternalNameMap: collection.concurrent.Map[String, ClassBType]
// NOTE: Should be a lazy val but scalac does not allow abstract lazy vals (dotty does)
protected lazy val classBTypeFromInternalNameMap: collection.concurrent.Map[String, ClassBType]

/**
* Obtain a previously constructed ClassBType for a given internal name.
Expand Down
17 changes: 9 additions & 8 deletions compiler/src/dotty/tools/backend/jvm/BTypesFromSymbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce
(classSym != defn.NothingClass && classSym != defn.NullClass),
s"Cannot create ClassBType for special class symbol ${classSym.showFullName}")

convertedClasses.getOrElse(classSym, {
val internalName = classSym.javaBinaryName
// We first create and add the ClassBType to the hash map before computing its info. This
// allows initializing cylic dependencies, see the comment on variable ClassBType._info.
val classBType = new ClassBType(internalName)
convertedClasses(classSym) = classBType
setClassInfo(classSym, classBType)
})
convertedClasses.synchronized:
convertedClasses.getOrElse(classSym, {
val internalName = classSym.javaBinaryName
// We first create and add the ClassBType to the hash map before computing its info. This
// allows initializing cylic dependencies, see the comment on variable ClassBType._info.
val classBType = new ClassBType(internalName)
convertedClasses(classSym) = classBType
setClassInfo(classSym, classBType)
})
}

final def mirrorClassBTypeFromSymbol(moduleClassSym: Symbol): ClassBType = {
Expand Down
11 changes: 7 additions & 4 deletions compiler/src/dotty/tools/backend/jvm/BackendUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,10 @@ class BackendUtils(val postProcessor: PostProcessor) {
// stack map frames and invokes the `getCommonSuperClass` method. This method expects all
// ClassBTypes mentioned in the source code to exist in the map.

val serlamObjDesc = MethodBType(jliSerializedLambdaRef :: Nil, ObjectRef).descriptor

val mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC + ACC_SYNTHETIC, "$deserializeLambda$", serlamObjDesc, null, null)
val mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC + ACC_SYNTHETIC, "$deserializeLambda$", serializedLamdaObjDesc, null, null)
def emitLambdaDeserializeIndy(targetMethods: Seq[Handle]): Unit = {
mv.visitVarInsn(ALOAD, 0)
mv.visitInvokeDynamicInsn("lambdaDeserialize", serlamObjDesc, jliLambdaDeserializeBootstrapHandle, targetMethods: _*)
mv.visitInvokeDynamicInsn("lambdaDeserialize", serializedLamdaObjDesc, jliLambdaDeserializeBootstrapHandle, targetMethods: _*)
}

val targetMethodGroupLimit = 255 - 1 - 3 // JVM limit. See See MAX_MH_ARITY in CallSite.java
Expand All @@ -134,6 +132,11 @@ class BackendUtils(val postProcessor: PostProcessor) {
mv.visitInsn(ARETURN)
}

private lazy val serializedLamdaObjDesc = {
import coreBTypes.{ObjectRef, jliSerializedLambdaRef}
MethodBType(jliSerializedLambdaRef :: Nil, ObjectRef).descriptor
}

/**
* Visit the class node and collect all referenced nested classes.
*/
Expand Down
142 changes: 0 additions & 142 deletions compiler/src/dotty/tools/backend/jvm/ClassfileWriter.scala

This file was deleted.

Loading