diff options
author | jhugunin <jhugunin> | 2004-01-24 02:28:54 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2004-01-24 02:28:54 +0000 |
commit | 0c833438dadeeb26659cd901870d18d2c103658b (patch) | |
tree | cbe369e1ea2e90cdfabf09f9b343da4e9a930621 /org.aspectj.ajdt.core/testsrc | |
parent | 2b4e2512530a5d0a12e92071eb2e3198722dcd6b (diff) | |
download | aspectj-0c833438dadeeb26659cd901870d18d2c103658b.tar.gz aspectj-0c833438dadeeb26659cd901870d18d2c103658b.zip |
Implemented feature for Bugzilla Bug 48091
Lazy instantiation of thisJoinPoint
Speed-ups of 10-100X are measured even when running a small test case with minimal GC issues.
The actual feature implemented is that thisJoinPoint objects are only created just before calling the method for advice that requires them. To take advantage of this feature you must use an if PCD or some other dynamic test that occurs in the PCD not the advice body to guard the expensive creation of the thisJoinPoint object.
-XlazyTjp flag must be passed to compiler to enable this feature.
If any around advice is present on the joinpoint then lazy instantiation
will be disabled. An Xlint warning will be displayed in this case.
As a related optimization, several helper methods were added to
Factory.makeJP to reduce the code size when thisJoinPoint is used.
Diffstat (limited to 'org.aspectj.ajdt.core/testsrc')
3 files changed, 52 insertions, 1 deletions
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java index 8075e9888..80710268c 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/AjdtBatchTests.java @@ -25,7 +25,8 @@ public class AjdtBatchTests extends TestCase { //$JUnit-BEGIN$ suite.addTestSuite(BasicCommandTestCase.class); suite.addTestSuite(BinaryFormsTestCase.class); - suite.addTestSuite(CompileAndRunTestCase.class); + suite.addTestSuite(CompileAndRunTestCase.class); + suite.addTestSuite(PerformanceTestCase.class); suite.addTestSuite(ImageTestCase.class); suite.addTestSuite(MultipleCompileTestCase.class); // XXX suite.addTestSuite(VerifyWeaveTestCase.class); diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java index c50ac5c89..a508e512c 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/CommandTestCase.java @@ -45,6 +45,10 @@ public abstract class CommandTestCase extends TestCase { public static void checkCompile(String source, int[] expectedErrors) { + checkCompile(source, new String[0], expectedErrors); + } + + public static void checkCompile(String source, String[] extraArgs, int[] expectedErrors) { List args = new ArrayList(); args.add("-verbose"); @@ -58,6 +62,10 @@ public abstract class CommandTestCase extends TestCase { args.add("-g"); //XXX need this to get sourcefile and line numbers, shouldn't + for (int i = 0; i < extraArgs.length; i++) { + args.add(extraArgs[i]); + } + args.add(AjdtAjcTests.TESTDATA_PATH + "/" + source); runCompiler(args, expectedErrors); diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java new file mode 100644 index 000000000..527fe9304 --- /dev/null +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/PerformanceTestCase.java @@ -0,0 +1,42 @@ +/* ******************************************************************* + * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Common Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * PARC initial implementation + * ******************************************************************/ + +package org.aspectj.ajdt.internal.compiler.batch; + +import java.io.IOException; + +import org.aspectj.testing.util.TestUtil; + + +public class PerformanceTestCase extends CommandTestCase { + + public PerformanceTestCase(String name) { + super(name); + } + + + // this is a nice test, but not strictly needed + public void xxx_testLazyTjpOff() throws IOException { + checkCompile("src1/LazyTjp.aj", NO_ERRORS); + try { + TestUtil.runMain("out", "LazyTjp"); + fail("expected an exception when running without -XlazyTjp"); + } catch (IllegalStateException e) { + // expected exception thrown when no -XlazyTjp + } + } + + public void testLazyTjp() throws IOException { + checkCompile("src1/LazyTjp.aj", new String[] {"-XlazyTjp","-Xlint:error"}, new int[] {97}); + TestUtil.runMain("out", "LazyTjp"); + } +} |