summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-04-26 07:02:55 -0700
committerPaul Phillips <paulp@improving.org>2012-04-26 10:04:33 -0700
commit2aa44c230c96b0ceb8e2b84c8095620a1be5a77f (patch)
tree2b0d6e52c9d99bb8a90e9f7498e6cd6aee04f8ea /tools
parent99388a81d42cde0cb0e8ecd57f290f6df25b9bdd (diff)
downloadscala-2aa44c230c96b0ceb8e2b84c8095620a1be5a77f.tar.gz
scala-2aa44c230c96b0ceb8e2b84c8095620a1be5a77f.tar.bz2
scala-2aa44c230c96b0ceb8e2b84c8095620a1be5a77f.zip
A brand new, fast classfile parser.
Try it: ./tools/dump-class ./build/quick/classes The output is intended to be easy to filter on the command line. This is a starting point for lots of interesting bytecode analysis for which we have waited too long. Example. All generic signatures we produce. // almost 20K classfiles % find build/quick/classes -name '*.class' |wc -l 18519 // fully parsed in 6 seconds tools/dump-class build/quick/classes |grep "^ signature" | wc -l 50802 real 0m6.230s It's designed to be easy to make faster if you don't care about particular classfile bits; you can override those methods to jump forward in the input stream rather than building a structure. For just a little sampling, here are our most frequently repeated name/signature combinations. 194 signature <init> ()V // this one is weird, wonder why there's a generic signature 115 signature $div$colon$bslash <A1:Ljava/lang/Object;>(TA1;Lscala/Function2<TA1;TA1;TA1;>;)TA1; 105 signature applyOrElse <A1:Ljava/lang/Object;B1:Ljava/lang/Object;>(TA1;Lscala/Function1<TA1;TB1;>;)TB1; 103 signature view ()Ljava/lang/Object; 101 signature toSet <B:Ljava/lang/Object;>()Lscala/collection/immutable/Set<TB;>; And the top five name/descriptor combinations. 11170 descriptor <clinit> ()V 10155 descriptor serialVersionUID J 7130 descriptor apply (Ljava/lang/Object;)Ljava/lang/Object; 3028 descriptor apply ()Ljava/lang/Object; 2426 descriptor <init> ()V
Diffstat (limited to 'tools')
-rwxr-xr-xtools/dump-class6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/dump-class b/tools/dump-class
new file mode 100755
index 0000000000..0b4f2a73fa
--- /dev/null
+++ b/tools/dump-class
@@ -0,0 +1,6 @@
+#!/bin/sh
+#
+
+classpath=$($(dirname $BASH_SOURCE)/quickcp)
+
+java -cp "$classpath" scala.tools.nsc.MainGenericRunner -usejavacp scala.tools.cmd.program.DumpClass "$@" \ No newline at end of file