From 42054a1bebcc2155f773787ffda781b497d4178b Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Mon, 23 Feb 2015 20:43:21 +0100 Subject: Emit the ScalaInlineInfo attribute under GenASM The goal of this commit is to allow the new inliner (in GenBCode, coming soon) to inline methods generated by the GenASM backend of 2.11.6. The ScalaInlineInfo attribute is added to every classfile generated by GenASM. It contains metadata about the class and its methods that will be used by the new inliner. Storing this metadata to the classfile prevents the need to look up a class symbol for a certain class file name, a process that is known to be brittle due to name mangling. Also, some symbols are not exactly the same when originating in a class being compiled or an unpickled one. For example, method symbols for mixed-in members are only added to classes being compiled. The classfile attribute is relatively small, because all strings it references (class internal names, method names, method descriptors) would exist anyway in the constant pool. It just adds a few references and bits for each method in the classfile. Jar sizes before: 480142 scala-actors.jar 15531408 scala-compiler.jar 5543249 scala-library.jar 4663078 scala-reflect.jar 785953 scalap.jar After: 490491 scala-actors.jar (102.1%) 15865500 scala-compiler.jar (102.1%) 5722504 scala-library.jar (103.2%) 4788370 scala-reflect.jar (102.7%) 805890 scalap.jar (102.5%) --- test/files/run/t7974.check | 23 ++++++----------------- test/files/run/t7974/Test.scala | 14 ++++---------- 2 files changed, 10 insertions(+), 27 deletions(-) (limited to 'test/files/run') diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check index d8152d3286..4eae5eb152 100644 --- a/test/files/run/t7974.check +++ b/test/files/run/t7974.check @@ -1,19 +1,3 @@ -public class Symbols { - - - - - // access flags 0x12 - private final Lscala/Symbol; someSymbol3 - - // access flags 0xA - private static Lscala/Symbol; symbol$1 - - // access flags 0xA - private static Lscala/Symbol; symbol$2 - - // access flags 0xA - private static Lscala/Symbol; symbol$3 // access flags 0x9 public static ()V @@ -33,6 +17,7 @@ public class Symbols { MAXSTACK = 2 MAXLOCALS = 0 + // access flags 0x1 public someSymbol1()Lscala/Symbol; GETSTATIC Symbols.symbol$1 : Lscala/Symbol; @@ -40,6 +25,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public someSymbol2()Lscala/Symbol; GETSTATIC Symbols.symbol$2 : Lscala/Symbol; @@ -47,6 +33,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public sameSymbol1()Lscala/Symbol; GETSTATIC Symbols.symbol$1 : Lscala/Symbol; @@ -54,6 +41,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public someSymbol3()Lscala/Symbol; ALOAD 0 @@ -62,6 +50,7 @@ public class Symbols { MAXSTACK = 1 MAXLOCALS = 1 + // access flags 0x1 public ()V ALOAD 0 @@ -72,4 +61,4 @@ public class Symbols { RETURN MAXSTACK = 2 MAXLOCALS = 1 -} + diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala index 29d2b9cb64..296ec32ee2 100644 --- a/test/files/run/t7974/Test.scala +++ b/test/files/run/t7974/Test.scala @@ -1,20 +1,14 @@ -import java.io.PrintWriter; +import java.io.PrintWriter import scala.tools.partest.BytecodeTest +import scala.tools.nsc.backend.jvm.AsmUtils import scala.tools.asm.util._ import scala.tools.nsc.util.stringFromWriter +import scala.collection.convert.decorateAsScala._ object Test extends BytecodeTest { def show { val classNode = loadClassNode("Symbols", skipDebugInfo = true) - val textifier = new Textifier - classNode.accept(new TraceClassVisitor(null, textifier, null)) - - val classString = stringFromWriter(w => textifier.print(w)) - val result = - classString.split('\n') - .dropWhile(elem => elem != "public class Symbols {") - .filterNot(elem => elem.startsWith(" @Lscala/reflect/ScalaSignature") || elem.startsWith(" ATTRIBUTE ScalaSig")) - result foreach println + classNode.methods.asScala.foreach(m => println(AsmUtils.textify(m))) } } -- cgit v1.2.3