diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-05-15 15:12:56 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-05-21 22:47:43 +0200 |
commit | 88d63f2d6b0864c86c7ebfcca78cb94cb9347639 (patch) | |
tree | 3bab59dfc9ce08462db546fedf0076eb1e7fe8d2 /src/compiler | |
parent | 6c99037952766c7075b48171fe65a6077cf6b9f5 (diff) | |
download | scala-88d63f2d6b0864c86c7ebfcca78cb94cb9347639.tar.gz scala-88d63f2d6b0864c86c7ebfcca78cb94cb9347639.tar.bz2 scala-88d63f2d6b0864c86c7ebfcca78cb94cb9347639.zip |
Cleanups for tracing in GenBCode, improve some comments
Diffstat (limited to 'src/compiler')
4 files changed, 17 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala b/src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala index 856f85d9e3..2af2037fec 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/AsmUtils.scala @@ -8,6 +8,7 @@ package scala.tools.nsc.backend.jvm import scala.tools.asm.tree.{ClassNode, MethodNode} import java.io.PrintWriter import scala.tools.asm.util.{TraceClassVisitor, TraceMethodVisitor, Textifier} +import scala.tools.asm.ClassReader object AsmUtils { @@ -50,4 +51,11 @@ object AsmUtils { w.flush() } + def traceClass(bytes: Array[Byte]): Unit = traceClass(readClass(bytes)) + + def readClass(bytes: Array[Byte]): ClassNode = { + val node = new ClassNode() + new ClassReader(bytes).accept(node, 0) + node + } } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index 13a5c6413d..988c04f514 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -1401,7 +1401,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { // TODO param names: (m.params map (p => javaName(p.sym))) - // typestate: entering mode with valid call sequences: + // typestate: entering mode with valid call sequences: (see ASM Guide, 3.2.1) // [ visitAnnotationDefault ] ( visitAnnotation | visitParameterAnnotation | visitAttribute )* emitAnnotations(jmethod, others) @@ -1446,7 +1446,10 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM { val hasStaticBitSet = ((flags & asm.Opcodes.ACC_STATIC) != 0) genCode(m, emitVars, hasStaticBitSet) - jmethod.visitMaxs(0, 0) // just to follow protocol, dummy arguments + // visitMaxs needs to be called according to the protocol. The arguments will be ignored + // since maximums (and stack map frames) are computed. See ASM Guide, Section 3.2.1, + // section "ClassWriter options" + jmethod.visitMaxs(0, 0) } jmethod.visitEnd() diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala index 61cf76f524..9b292fee7f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenBCode.scala @@ -244,14 +244,9 @@ abstract class GenBCode extends BCodeSyncAndTry { val beanC = if (bean == null) null else SubItem3(bean.name, getByteArray(bean)) if (AsmUtils.traceSerializedClassEnabled && plain.name.contains(AsmUtils.traceSerializedClassPattern)) { - def readClass(bytes: Array[Byte]): asm.tree.ClassNode = { - val node = new asm.tree.ClassNode() - new asm.ClassReader(bytes).accept(node, 0) - node - } - if (mirrorC != null) AsmUtils.traceClass(readClass(mirrorC.jclassBytes)) - AsmUtils.traceClass(readClass(plainC.jclassBytes)) - if (beanC != null) AsmUtils.traceClass(readClass(beanC.jclassBytes)) + if (mirrorC != null) AsmUtils.traceClass(mirrorC.jclassBytes) + AsmUtils.traceClass(plainC.jclassBytes) + if (beanC != null) AsmUtils.traceClass(beanC.jclassBytes) } q3 add Item3(arrivalPos, mirrorC, plainC, beanC, outFolder) diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 33e8e47c76..3ef85728da 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -391,7 +391,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { else { sourceModule setPos sym.pos if (sourceModule.flags != MODULE) { - log("!!! Directly setting sourceModule flags from %s to MODULE".format(sourceModule.flagString)) + log("!!! Directly setting sourceModule flags for $sourceModule from %s to MODULE".format(sourceModule.flagString)) sourceModule.flags = MODULE } } |