Bug 293620 - optimizing method lookup
Summary: optimizing method lookup
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.6   Edit
Hardware: PC Windows NT
: P2 normal (vote)
Target Milestone: 1.6.7   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-28 17:25 EDT by Andrew Clement CLA
Modified: 2009-11-17 11:30 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2009-10-28 17:25:03 EDT
In the old days we used a complex iterator to lookup methods in a type (it carefully didn't walk up the hierarchy unless it needed to).  It had a big fat bug in it but the complexity around the iterator behaviour made it impossible to work out.  Because of the bug we switched to a mode that fetches all the methods then looks through them - this is very expensive.

Due to the inclusion of generics in the iterator logic it was now possible to understand what on earth was going on and some bugs were resolved.  I'd like to see if we can go back to the iterator model.
Comment 1 Andrew Clement CLA 2009-10-28 17:27:11 EDT
benefits here will be:

- reduce memory usage
- reduced resolution (some supertypes may never be chased down and resolved)
- faster lookup for the common case of the type we are looking at containing the member
Comment 2 Andrew Clement CLA 2009-10-28 17:31:04 EDT
Right, the iterator still has a bug in it - but I'm developing some tests so I can properly explore it (can't believe this bit of code never had unit tests).

The primary bug appears to be that when using the iterator the methods directly on the type being asked about are returned *twice*.
Comment 3 Andrew Clement CLA 2009-10-28 18:22:57 EDT
Whoops!  Gotta love testing.  Now found a bug in the replacement code we are using instead of the buggy code...  it adds the methods from Object multiple times - this won't cause a failure but will slow things down and use more memory!
Comment 4 Andrew Clement CLA 2009-11-02 11:39:28 EST
this is turning into a bit of work... I'm also including other little enhancements here and there to speed things along and produce less transient garbage during matching.
- NamePattern will now match '*' without converting the target it is matching against from String to char array
- ThisOrTarget will match the common case of this(Object) very quickly, not calling into type pattern matching code.
Comment 5 Andrew Clement CLA 2009-11-02 11:54:10 EST
BcelObjectType - now holds a weak reference to the resolved superclass rather than resolving each time.
Comment 6 Andrew Clement CLA 2009-11-02 14:02:37 EST
ResolvedType.clearIntertypeMungers() - I wanted to change the 'new' to a 'clear()' but I can't as it introduces a ConcurrentModificationException (whilst iterating through the intertype mungers we call clearIntertypeMungers) - this is related to the faulting in of binary types.  I don't want to investigate this now - but should do at some point - there is a test that fails which shows the problem, just change 'new' to clear and run the test suite
Comment 7 Andrew Clement CLA 2009-11-17 11:30:10 EST
did a massive amount of refactoring and enhancements under this bug report - see the blog for more info: http://andrewclement.blogspot.com/2009/11/aspectj-how-much-faster-is-aspectj-167.html