From: aclement Date: Wed, 22 Feb 2006 16:22:26 +0000 (+0000) Subject: optimization: dont capture lowest level context info unless -Xset:captureAllContext... X-Git-Tag: POST_MEMORY_CHANGES~31 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c1a21a5d3328d80aed9ec4f6a80b8b298c10c886;p=aspectj.git optimization: dont capture lowest level context info unless -Xset:captureAllContext=true - see 128650, optimization 8 --- diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index f01b4001c..5f9cf6d01 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -702,6 +702,8 @@ public abstract class World implements Dump.INode { public Properties getExtraConfiguration() { return extraConfiguration; } + public final static String xsetCAPTURE_ALL_CONTEXT = "captureAllContext"; // default false + public boolean isInJava5Mode() { return behaveInJava5Way; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index b40fa9b93..63a916ca1 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -23,6 +23,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Set; import org.aspectj.apache.bcel.Constants; @@ -61,6 +62,7 @@ import org.aspectj.apache.bcel.generic.annotation.AnnotationGen; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; +import org.aspectj.bridge.MessageUtil; import org.aspectj.bridge.WeaveMessage; import org.aspectj.bridge.context.CompilationAndWeavingContext; import org.aspectj.bridge.context.ContextToken; @@ -88,6 +90,7 @@ 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; import org.aspectj.weaver.patterns.ExactTypePattern; @@ -167,6 +170,16 @@ class BcelClassWeaver implements IClassWeaver { fastMatchShadowMungers(shadowMungers); initializeSuperInitializerMap(ty.getResolvedTypeX()); + if (!checkedXsetForLowLevelContextCapturing) { + Properties p = world.getExtraConfiguration(); + if (p!=null) { + String s = p.getProperty(World.xsetCAPTURE_ALL_CONTEXT,"false"); + captureLowLevelContext = s.equalsIgnoreCase("true"); + if (captureLowLevelContext) + world.getMessageHandler().handleMessage(MessageUtil.info("["+World.xsetCAPTURE_ALL_CONTEXT+"=true] Enabling collection of low level context for debug/crash messages")); + } + checkedXsetForLowLevelContextCapturing=true; + } } @@ -2148,31 +2161,49 @@ class BcelClassWeaver implements IClassWeaver { } } + // static ... so all worlds will share the config for the first one created... + private static boolean checkedXsetForLowLevelContextCapturing = false; + private static boolean captureLowLevelContext = false; + private boolean match(BcelShadow shadow, List shadowAccumulator) { //System.err.println("match: " + shadow); - ContextToken shadowMatchToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MATCHING_SHADOW, shadow); - boolean isMatched = false; - for (Iterator i = shadowMungers.iterator(); i.hasNext(); ) { - 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); - } - - if (isMatched) shadowAccumulator.add(shadow); - CompilationAndWeavingContext.leavingPhase(shadowMatchToken); - return isMatched; + if (captureLowLevelContext) { // duplicate blocks - one with context capture, one without, seems faster than multiple 'ifs()' + ContextToken shadowMatchToken = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.MATCHING_SHADOW, shadow); + boolean isMatched = false; + for (Iterator i = shadowMungers.iterator(); i.hasNext(); ) { + 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); + } + + if (isMatched) shadowAccumulator.add(shadow); + CompilationAndWeavingContext.leavingPhase(shadowMatchToken); + return isMatched; + } else { + boolean isMatched = false; + for (Iterator i = shadowMungers.iterator(); i.hasNext(); ) { + ShadowMunger munger = (ShadowMunger)i.next(); + if (munger.match(shadow, world)) { + shadow.addMunger(munger); + isMatched = true; + if (shadow.getKind() == Shadow.StaticInitialization) { + clazz.warnOnAddedStaticInitializer(shadow,munger.getSourceLocation()); + } + } + } + if (isMatched) shadowAccumulator.add(shadow); + return isMatched; + } } // ----