50
Silvia Breu University of Cambridge Thomas Zimmermann Saarland University Christian Lindig Saarland University HAM: Aspect Mining

Aspect Mining for Large Systems

Embed Size (px)

DESCRIPTION

Demonstrated at OOPSLA 2006.

Citation preview

Page 1: Aspect Mining for Large Systems

Silvia BreuUniversity of Cambridge

Thomas ZimmermannSaarland University

Christian LindigSaarland University

HAM:Aspect Mining

Page 2: Aspect Mining for Large Systems

Aspectscreate()

fork()

connect()

close()

serve()

Page 3: Aspect Mining for Large Systems

Aspectscreate()

fork()

connect()

close()

serve()

Page 4: Aspect Mining for Large Systems

Aspectscreate()

fork()

connect()

close()

serve()

Typical Aspectsenter()/leave()log()lock()/unlock()

lock()

Page 5: Aspect Mining for Large Systems

Aspectscreate()

fork()

connect()

close()

serve()

AOP

Typical Aspectsenter()/leave()log()lock()/unlock()

lock()

Page 6: Aspect Mining for Large Systems

Aspectscreate()

fork()

connect()

close()

serve()

AOP

Aspect Mining:Identifying Aspectsin Legacy Code

Typical Aspectsenter()/leave()log()lock()/unlock()

lock()

Page 7: Aspect Mining for Large Systems

Research Hypothesis

Cross-cutting concerns emerge over time.

Page 8: Aspect Mining for Large Systems

Cross-cutting concerns emerge over time.

Page 9: Aspect Mining for Large Systems

Demo #1

Page 10: Aspect Mining for Large Systems

Modelling History142Transactions

Page 11: Aspect Mining for Large Systems

MODIFICATIONS

Modelling History142Transactions

Page 12: Aspect Mining for Large Systems

MODIFICATIONS

Modelling History142Transactions

DELETIONS

Page 13: Aspect Mining for Large Systems

MODIFICATIONS

Modelling History142Transactions

DELETIONSADDITIONS

Page 14: Aspect Mining for Large Systems

MODIFICATIONS

Modelling History142Transactions

DELETIONSADDITIONS

143

Page 15: Aspect Mining for Large Systems

Code Additions

public void _aload_0(int pc) { dumpPcNumber(pc); buffer.append(OpcodeStringValues .BYTECODE_NAMES [IOpcodeMnemonics.ALOAD_0]); writeNewLine();}

Location: _aload_0

Page 16: Aspect Mining for Large Systems

public void _aload_0(int pc) { dumpPcNumber(pc); buffer.append(OpcodeStringValues .BYTECODE_NAMES [IOpcodeMnemonics.ALOAD_0]); writeNewLine();}

Location: _aload_1

Code Additions

Location: println

public void _aload_0(int pc) { dumpPcNumber(pc); buffer.append(OpcodeStringValues .BYTECODE_NAMES [IOpcodeMnemonics.ALOAD_0]); writeNewLine();}

Location: _aload_0

Page 17: Aspect Mining for Large Systems

142 143141

Co-Addition of Calls

config()connect()

serve()close()

init()

Page 18: Aspect Mining for Large Systems

142 143141

Co-Addition of Calls

config()connect()

serve()close()

init()

lock()

Page 19: Aspect Mining for Large Systems

142 143141

Co-Addition of Calls

config()connect()

serve()close()

init()

lock()

unlock()

Page 20: Aspect Mining for Large Systems

142 143141

Co-Addition of Calls

config()connect()

serve()close()

init()

lock()

unlock()

“fixed bug#1234 by adding proper locks”

lock()unlock()

Cross-Cutting Change

Page 21: Aspect Mining for Large Systems

Transaction as a Table

calls

loca

tions

Page 22: Aspect Mining for Large Systems

Transaction as a Table

calls

loca

tions

charA

t

runDFAThis Tx added among others a call to charAt in location runDFA

Page 23: Aspect Mining for Large Systems

Blocks = Aspect Candidates

calls

loca

tions

lockun

lock

fgh

sync

method sync is called from locations d, e, f, g, h, i, k

{sync} is an aspect candidate

ed

ik

Page 24: Aspect Mining for Large Systems

Computing all Blocks

Page 25: Aspect Mining for Large Systems

Computing all Blocks

Page 26: Aspect Mining for Large Systems

Concept Analysis

calls

loca

tions

Concept Analysis computes all blocks.

Page 27: Aspect Mining for Large Systems

Concept Analysis

calls

loca

tions

Concept Analysis computes all blocks.

Page 28: Aspect Mining for Large Systems

Concept Analysis

calls

loca

tions

Concept Analysis computes all blocks.

Page 29: Aspect Mining for Large Systems

Concept Analysis

calls

loca

tions

Concept Analysis computes all blocks.

Page 30: Aspect Mining for Large Systems

Example from Eclipse2004-03-01

Page 31: Aspect Mining for Large Systems

Example from Eclipse2004-03-01

nodes reflect size of cross-cutting concern

# locations

# methods

Page 32: Aspect Mining for Large Systems

Example from Eclipse2004-03-01

14 locations callunsupportedIn2()

nodes reflect size of cross-cutting concern

# locations

# methods

Page 33: Aspect Mining for Large Systems

Example from Eclipse2004-03-01

History contains cross-cutting changes.

14 locations callunsupportedIn2()

nodes reflect size of cross-cutting concern

# locations

# methods

Page 34: Aspect Mining for Large Systems

Demo #2

Page 35: Aspect Mining for Large Systems

Reinforcement

connect()close()

METHOD: lock()

Aspect Candidate

LOCATIONS: init()serve()

METHOD: lock()

Aspect Candidate

LOCATIONS:

Page 36: Aspect Mining for Large Systems

Reinforcement

connect()close()

METHOD: lock()

Aspect Candidate

LOCATIONS: init()serve()

METHOD: lock()

Aspect Candidate

LOCATIONS:

connect()close()

METHOD: lock()

Aspect Candidate

LOCATIONS:

init()serve()

+

Page 37: Aspect Mining for Large Systems

Locality

Page 38: Aspect Mining for Large Systems

Locality

41 4239 40 43 44 45

christom silvichrischris chrissilvi

Page 39: Aspect Mining for Large Systems

Locality

41 4239 40 43 44 45

christom silvichrischris chrissilvi42

Page 40: Aspect Mining for Large Systems

Locality

41 4239 40 43 44 45

christom silvichrischris chrissilvi42

Temporal locality

Page 41: Aspect Mining for Large Systems

christom silvichrischris chrissilvi

Locality

41 4239 40 43 44 4542

Temporal locality

Page 42: Aspect Mining for Large Systems

Locality

41 4239 40 43 44 4542

Temporal locality

christom silvichrischris chrissilvi

Page 43: Aspect Mining for Large Systems

Locality

41 4239 40 43 44 4542

Temporal locality

Possessionallocality

christom silvichrischris chrissilvi

Page 44: Aspect Mining for Large Systems

Locality

41 4239 40 43 44 4542

Temporal locality

Possessionallocality

christom silvichrischris chrissilvi

➡ merging transactions and running concept analysis.

Page 45: Aspect Mining for Large Systems

Results for Eclipse

max

Transactions (43270)

avg

blocks

locations

methods

1235 3.7

1287 3.8

1236 5.4

The average transactionis small. It adds 5 calls in 4 locations.

Page 46: Aspect Mining for Large Systems

Results for Eclipse

max

Transactions (43270)

avg

blocks

locations

methods

1235 3.7

1287 3.8

1236 5.4

The average transactionis small. It adds 5 calls in 4 locations.

112 candidates add3 calls or more.

1

Aspect Candidates*

methods

362 88 24candidates 1878

2 3 ≥4

* selected from 159448 blocks

Page 47: Aspect Mining for Large Systems

public static final native void _XFree(int address);public static final void XFree(int /*long*/ address) { lock.lock(); try { _XFree(address); } finally { lock.unlock(); }}

Locking Mechanism

Page 48: Aspect Mining for Large Systems

public static final native void _XFree(int address);public static final void XFree(int /*long*/ address) { lock.lock(); try { _XFree(address); } finally { lock.unlock(); }}

Locking Mechanism

crosscuts 1284

locations

Page 49: Aspect Mining for Large Systems

Future work

• Evolution of cross-cutting concerns.Refactor only those that actually change.

• Relation between cross-cutting concerns

• Refactoring of concerns.

• Package and ship HAM.

Page 50: Aspect Mining for Large Systems

Conclusions

• Cross-cutting concerns emerge over time.

• Cross-cutting changes point to aspect candidates.

• HAM scales to industrial-sized systems.

• http://www.st.cs.uni-sb.de/softevo/