]> source.dussan.org Git - aspectj.git/commitdiff
231396: refactoring: removed WeaverMetrics/LTWeaver, changed UnwovenClassFile to...
authoraclement <aclement>
Tue, 13 May 2008 17:40:12 +0000 (17:40 +0000)
committeraclement <aclement>
Tue, 13 May 2008 17:40:12 +0000 (17:40 +0000)
weaver/src/org/aspectj/weaver/AjcMemberMaker.java
weaver/src/org/aspectj/weaver/WeaverMetrics.java [deleted file]
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
weaver/src/org/aspectj/weaver/ltw/LTWeaver.java [deleted file]
weaver/src/org/aspectj/weaver/tools/FuzzyBoolean.java
weaver/src/org/aspectj/weaver/tools/package.html [deleted file]

index 8ca2c511b7939f9509b6ad1acbb7b6a677ad5ac5..cd1eb769b06c206c20b10d8806aa7d18ade37c52 100644 (file)
@@ -252,9 +252,7 @@ public class AjcMemberMaker {
 
        
        public static ResolvedMember perSingletonAspectOfMethod(UnresolvedType declaringType) {
-               return new ResolvedMemberImpl(Member.METHOD,
-                       declaringType, PUBLIC_STATIC, "aspectOf", 
-                       "()" + declaringType.getSignature());           
+               return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, "aspectOf", "()" + declaringType.getSignature());
        }
        
        public static ResolvedMember perSingletonHasAspectMethod(UnresolvedType declaringType) {
diff --git a/weaver/src/org/aspectj/weaver/WeaverMetrics.java b/weaver/src/org/aspectj/weaver/WeaverMetrics.java
deleted file mode 100644 (file)
index ca4df91..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. 
- * This program and the accompanying materials are made available 
- * under the terms of the Eclipse Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://www.eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
- *     Andy Clement         initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import org.aspectj.util.FuzzyBoolean;
-
-
-/**
- * Records stats about the weaver.  Information like 'how many types are dismissed during fast match' that
- * may be useful for trying to tune pointcuts.  Not publicised.
- */
-public class WeaverMetrics {
-    
-       // Level 1 of matching is at the type level, which types can be dismissed?
-       public static int fastMatchOnTypeAttempted = 0;
-       public static int fastMatchOnTypeTrue = 0;
-       public static int fastMatchOnTypeFalse = 0;
-
-       // Level 2 of matching is fast matching on the shadows in the remaining types
-       public static int fastMatchOnShadowsAttempted = 0;
-       public static int fastMatchOnShadowsTrue = 0;
-       public static int fastMatchOnShadowsFalse = 0;
-       
-    // Level 3 of matching is slow matching on the shadows (more shadows than were fast matched on!)
-       public static int matchTrue = 0;
-       public static int matchAttempted = 0;
-
-
-       
-       public static void reset() {
-
-               fastMatchOnShadowsAttempted = 0;
-               fastMatchOnShadowsTrue = 0;
-               fastMatchOnShadowsFalse = 0;
-
-               fastMatchOnTypeAttempted = 0;
-               fastMatchOnTypeTrue = 0;
-               fastMatchOnTypeFalse = 0;
-       
-               matchTrue = 0;
-               matchAttempted = 0;
-       }       
-
-       
-       public static void dumpInfo() {
-               System.err.println("Match summary:");
-               int fastMatchOnTypeMaybe = (fastMatchOnTypeAttempted-fastMatchOnTypeTrue-fastMatchOnTypeFalse);
-               System.err.print("At the type level, we attempted #"+fastMatchOnTypeAttempted+" fast matches:");
-               System.err.println("   YES/NO/MAYBE = "+fastMatchOnTypeTrue+"/"+fastMatchOnTypeFalse+"/"+fastMatchOnTypeMaybe);
-               int fastMatchMaybe = (fastMatchOnShadowsAttempted-fastMatchOnShadowsFalse-fastMatchOnShadowsTrue);
-               System.err.print("Within those #"+(fastMatchOnTypeTrue+fastMatchOnTypeMaybe)+" possible types, ");
-               System.err.print("we fast matched on #"+fastMatchOnShadowsAttempted+" shadows:");
-               System.err.println("   YES/NO/MAYBE = "+fastMatchOnShadowsTrue+"/"+fastMatchOnShadowsFalse+"/"+fastMatchMaybe);
-               System.err.println("Shadow (non-fast) matches attempted #"+matchAttempted+" of which "+matchTrue+" successful");
-       }
-       
-
-       public static void recordFastMatchTypeResult(FuzzyBoolean fb) {
-               fastMatchOnTypeAttempted++;
-               if (fb.alwaysTrue()) fastMatchOnTypeTrue++;
-               if (fb.alwaysFalse()) fastMatchOnTypeFalse++;
-       }
-       
-       public static void recordFastMatchResult(FuzzyBoolean fb) {
-               fastMatchOnShadowsAttempted++;
-               if (fb.alwaysTrue())  fastMatchOnShadowsTrue++;
-               if (fb.alwaysFalse()) fastMatchOnShadowsFalse++;
-       }
-       
-       public static void recordMatchResult(boolean b) {
-               matchAttempted++;
-               if (b) matchTrue++;
-       }
-
-}
index 87c8b390afd343fc39c9237488c92ad666626e06..98e7314903652cd44461313adb1f9fcba8a2a38b 100644 (file)
@@ -95,7 +95,6 @@ import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.WeaverMessages;
-import org.aspectj.weaver.WeaverMetrics;
 import org.aspectj.weaver.WeaverStateInfo;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.patterns.DeclareAnnotation;
@@ -2814,15 +2813,12 @@ class BcelClassWeaver implements IClassWeaver {
                    ShadowMunger munger = (ShadowMunger)i.next();
                    ContextToken mungerMatchToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MATCHING_POINTCUT, munger.getPointcut());
                    if (munger.match(shadow, world)) {
-                                       WeaverMetrics.recordMatchResult(true);// Could pass: munger
                        shadow.addMunger(munger);
                        isMatched = true;
                                    if (shadow.getKind() == Shadow.StaticInitialization) {
                                          clazz.warnOnAddedStaticInitializer(shadow,munger.getSourceLocation());
                                    }
-                   } else {
-                       WeaverMetrics.recordMatchResult(false); // Could pass: munger
-                       }
+                   }
                    CompilationAndWeavingContext.leavingPhase(mungerMatchToken);
                }       
        
index 820ff77c4ed24170dd9d79305feb6fb953d92690..e329c2af92926756e0fbef5377b103970efde68c 100644 (file)
@@ -77,7 +77,6 @@ import org.aspectj.weaver.Shadow;
 import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.WeaverMessages;
-import org.aspectj.weaver.WeaverMetrics;
 import org.aspectj.weaver.WeaverStateInfo;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.patterns.AndPointcut;
@@ -114,7 +113,6 @@ public class BcelWeaver implements IWeaver {
     public BcelWeaver(BcelWorld world) {
         super();
         if (trace.isTraceEnabled()) trace.enter("<init>",this,world);
-        WeaverMetrics.reset();
         this.world = world;
         this.xcutSet = world.getCrosscuttingMembersSet();
         if (trace.isTraceEnabled()) trace.exit("<init>");
@@ -1386,6 +1384,11 @@ public class BcelWeaver implements IWeaver {
                //clazz is null if the classfile was unchanged by weaving...
                if (clazz != null) {
                        UnwovenClassFile[] newClasses = getClassFilesFor(clazz);
+                       // OPTIMIZE can we avoid using the string name at all in UnwovenClassFile instances?
+                       // Copy the char[] across as it means the WeaverAdapter.removeFromMap() can be fast!
+                       if (newClasses[0].getClassName().equals(classFile.getClassName())) {
+                               newClasses[0].setClassNameAsChars(classFile.getClassNameAsChars());
+                       }
                        for (int i = 0; i < newClasses.length; i++) {
                                requestor.acceptResult(newClasses[i]);
                        }
@@ -1759,7 +1762,6 @@ public class BcelWeaver implements IWeaver {
                while (iter.hasNext()) {
                        ShadowMunger munger = (ShadowMunger)iter.next();
                        FuzzyBoolean fb = munger.getPointcut().fastMatch(info);
-                       WeaverMetrics.recordFastMatchTypeResult(fb); // Could pass: munger.getPointcut().toString(),info
                        if (fb.maybeTrue()) {
                                result.add(munger);
                        }
index 09e5f48c390e66bfba7b3fbbe1d1a95bf57d62a1..697124151319b3ecc01036323e0f43f96081a4dc 100644 (file)
@@ -27,6 +27,7 @@ import org.aspectj.util.FileUtil;
 
 public class UnwovenClassFile {
        protected String filename;
+       protected char[] charfilename;
        protected byte[] bytes;
 //     protected JavaClass javaClass = null;
        //protected byte[] writtenBytes = null;
@@ -149,9 +150,15 @@ public class UnwovenClassFile {
                return true;
        }
 
+       public char[] getClassNameAsChars() {
+               if (charfilename==null) {
+                       charfilename = getClassName().replace('.', '/').toCharArray();
+               }
+               return charfilename;
+       }
        
        public String getClassName() {
-               if (className == null) className = getJavaClass().getClassName();
+               if (className == null) className = getJavaClass().getClassName(); // OPTIMIZE quicker way to determine name??? surely?
                return className;
        }
        
@@ -184,6 +191,7 @@ public class UnwovenClassFile {
        }
 
        // record
+       // OPTIMIZE why is the 'short name' used here (the bit after the dollar) - seems we mess about a lot trimming it off only to put it back on!
        public static class ChildClass {
                public final String name;
                public final byte[] bytes;
@@ -206,6 +214,10 @@ public class UnwovenClassFile {
                        return "(ChildClass " + name + ")";
                }
        }
+
+       public void setClassNameAsChars(char[] classNameAsChars) {
+               this.charfilename = classNameAsChars;
+       }
 }
 
 
diff --git a/weaver/src/org/aspectj/weaver/ltw/LTWeaver.java b/weaver/src/org/aspectj/weaver/ltw/LTWeaver.java
deleted file mode 100644 (file)
index b69cb67..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved. 
- * This program and the accompanying materials are made available 
- * under the terms of the Eclipse Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
- *   Adrian Colyer                     Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver.ltw;
-
-import org.aspectj.weaver.IWeaver;
-
-/**
- * @author adrian
- *
- */
-public class LTWeaver implements IWeaver {
-
-}
index 059688c5b9c1ed31c0a33256ddcc245227d53333..4325c72faaeb9f9db1fddf30f5ae3981bb13f5c4 100644 (file)
@@ -12,7 +12,8 @@
 
 package org.aspectj.weaver.tools;
 
-/** This class implements a boolean that includes a "maybe"
+/** 
+ * This class implements a boolean that includes a "maybe"
  */
 public class FuzzyBoolean {
        
diff --git a/weaver/src/org/aspectj/weaver/tools/package.html b/weaver/src/org/aspectj/weaver/tools/package.html
deleted file mode 100644 (file)
index f8d3044..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<body>
-Provides a set of interfaces for third-parties wishing to integrate
-AspectJ weaving capabilities into their environments.
-</body>
-</html>