Make ASM skip code when reading class structures

Pass the SKIP_CODE flag to ASM's ClassReader to make ASM skip decoding
the opcodes of each method's code on the first pass through the input
classes where we only build up the class structure of the program.
Since our subclass of ClassVisitor does not implement any of the
instruction visit methods, there is no reason for ASM to decode
instructions and call the default empty visit*() implementations.

Change-Id: I10f4f9b3dd4d7c3c2201bfd879c367e0812edbae
diff --git a/src/main/java/com/android/tools/r8/graph/JarClassFileReader.java b/src/main/java/com/android/tools/r8/graph/JarClassFileReader.java
index 02f0801..7ddf8c6 100644
--- a/src/main/java/com/android/tools/r8/graph/JarClassFileReader.java
+++ b/src/main/java/com/android/tools/r8/graph/JarClassFileReader.java
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 package com.android.tools.r8.graph;
 
+import static org.objectweb.asm.ClassReader.SKIP_CODE;
 import static org.objectweb.asm.ClassReader.SKIP_FRAMES;
 import static org.objectweb.asm.Opcodes.ACC_DEPRECATED;
 import static org.objectweb.asm.Opcodes.ASM6;
@@ -90,7 +91,7 @@
     ClassReader reader = new ClassReader(input);
     reader.accept(
         new CreateDexClassVisitor(origin, classKind, reader.b, application, classConsumer),
-        SKIP_FRAMES);
+        SKIP_FRAMES | SKIP_CODE);
   }
 
   private static int cleanAccessFlags(int access) {
@@ -560,6 +561,11 @@
 
     @Override
     public void visitCode() {
+      throw new Unreachable("visitCode() should not be called when SKIP_CODE is set");
+    }
+
+    @Override
+    public void visitEnd() {
       if (!flags.isAbstract() && !flags.isNative() && parent.classKind == ClassKind.PROGRAM) {
         if (parent.application.options.enableCfFrontend) {
           code = new LazyCfCode(method, parent.origin, parent.context, parent.application);
@@ -567,12 +573,6 @@
           code = new JarCode(method, parent.origin, parent.context, parent.application);
         }
       }
-    }
-
-    @Override
-    public void visitEnd() {
-      assert flags.isAbstract() || flags.isNative() || parent.classKind != ClassKind.PROGRAM
-          || code != null;
       ParameterAnnotationsList annotationsList;
       if (parameterAnnotationsLists == null) {
         annotationsList = ParameterAnnotationsList.empty();