diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala index c65fcbc961e6..463ff57f9a0f 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessor.scala @@ -18,7 +18,7 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes: import int.given val backendUtils = new BackendUtils(this) - lazy val classfileWriter = ClassfileWriter(frontendAccess) + val classfileWriter = ClassfileWriter(frontendAccess) def postProcessAndSendToDisk(generatedDefs: GeneratedDefs): Unit = { val GeneratedDefs(classes, tasty) = generatedDefs @@ -30,21 +30,18 @@ class PostProcessor(val frontendAccess: PostProcessorFrontendAccess, val bTypes: serializeClass(classNode) catch case e: java.lang.RuntimeException if e.getMessage != null && e.getMessage.nn.contains("too large!") => - backendReporting.error( - s"Could not write class ${classNode.name} because it exceeds JVM code size limits. ${e.getMessage}", - NoSourcePosition - ) + backendReporting.error(s"Could not write class ${classNode.name} because it exceeds JVM code size limits. ${e.getMessage}") null case ex: Throwable => ex.printStackTrace() - backendReporting.error(s"Error while emitting ${classNode.name}\n${ex.getMessage}",NoSourcePosition) + backendReporting.error(s"Error while emitting ${classNode.name}\n${ex.getMessage}") null if (bytes != null) { if (AsmUtils.traceSerializedClassEnabled && classNode.name.nn.contains(AsmUtils.traceSerializedClassPattern)) AsmUtils.traceClass(bytes) - val clsFile = classfileWriter.write(classNode.name.nn, bytes, sourceFile) + val clsFile = classfileWriter.writeClass(classNode.name.nn, bytes, sourceFile) if clsFile != null then onFileCreated(clsFile) } } diff --git a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala index 3ea81a35e438..c447dc7d4aa3 100644 --- a/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala +++ b/compiler/src/dotty/tools/backend/jvm/PostProcessorFrontendAccess.scala @@ -1,6 +1,6 @@ package dotty.tools.backend.jvm -import scala.collection.mutable.Clearable +import scala.collection.mutable.{Clearable, HashSet} import dotty.tools.dotc.util.* import dotty.tools.io.AbstractFile import java.util.{Collection => JCollection, Map => JMap} @@ -20,7 +20,7 @@ sealed abstract class PostProcessorFrontendAccess { def getEntryPoints: List[String] private val frontendLock: AnyRef = new Object() - @inline final def frontendSynch[T](x: => T): T = frontendLock.synchronized(x) + inline final def frontendSynch[T](inline x: => T): T = frontendLock.synchronized(x) } object PostProcessorFrontendAccess { @@ -35,11 +35,12 @@ object PostProcessorFrontendAccess { } sealed trait BackendReporting { - def error(message: String, pos: SourcePosition): Unit + def error(message: String): Unit + def warning(message: String): Unit def log(message: String): Unit } - class Impl[I <: DottyBackendInterface](val int: I) extends PostProcessorFrontendAccess { + class Impl[I <: DottyBackendInterface](val int: I, entryPoints: HashSet[String]) extends PostProcessorFrontendAccess { import int.given lazy val compilerSettings: CompilerSettings = buildCompilerSettings() @@ -67,13 +68,11 @@ object PostProcessorFrontendAccess { } object backendReporting extends BackendReporting { - def error(message: String, pos: SourcePosition): Unit = frontendSynch(report.error(message, pos)) + def error(message: String): Unit = frontendSynch(report.error(message, NoSourcePosition)) + def warning(message: String): Unit = frontendSynch(report.warning(message, NoSourcePosition)) def log(message: String): Unit = frontendSynch(report.log(message)) } - def getEntryPoints: List[String] = frontendSynch(Phases.genBCodePhase match { - case genBCode: GenBCode => genBCode.entryPoints.toList - case _ => Nil - }) + def getEntryPoints: List[String] = frontendSynch(entryPoints.toList) } } \ No newline at end of file