Bug 48091 - Lazy instantiation of thisJoinPoint
Summary: Lazy instantiation of thisJoinPoint
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 1.2   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-04 12:18 EST by Adrian Colyer CLA
Modified: 2004-02-16 07:01 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Colyer CLA 2003-12-04 12:18:33 EST
In cases where the body of advice refers to a non-statically evaluable portion 
of thisJoinPoint (so that it can't be optimized by the compiler to 
thisJoinPointStaticPart), the JoinPoint object is currently always created 
before entering the advice body - even if the JoinPoint object would never 
actually be accessed (because of a test within the advice for example). Since
a) thisJoinPoint is often used in tracing applications
b) tracing applications tend to be very pervasive,
c) they must have low overhead when tracing is disabled, and 
d) creation of thisJoinPoint objects is expensive (v. expensive compared to just 
testing a flag)
it would be nice if there was a way to create JoinPoint objects lazily on first 
actual reference within the advice body.
Comment 1 Jim Hugunin CLA 2004-01-23 21:37:14 EST
Implemented in tree with unit test in ajdt.core test sources under 
PerformanceTestCase.  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.
Comment 2 Matthew Webster CLA 2004-02-16 07:01:08 EST
I discovered When trying to write a new logging aspect to exploit this 
enhancement that the new -X option is difficult to use. Although accepted by 
AJDT it is ignore and the Ant task also ignores it because it has its own 
option parsing. The only ways are to use the command line or an entry in an 
argfile. I was surprised at how many placed we police options.