-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created handler for recording the color creation
- Loading branch information
1 parent
a09f836
commit b94f5b5
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
'srcDirectory' : 'src' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
#format : #tonel | ||
} |
49 changes: 49 additions & 0 deletions
49
src/MethodProxiesSebas/MpColorAllocationProfilerHandler.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
" | ||
I am a handler that register when a color is created. I keep that of both the color and the creation context | ||
" | ||
Class { | ||
#name : #MpColorAllocationProfilerHandler, | ||
#superclass : #MpHandler, | ||
#instVars : [ | ||
'allocations', | ||
'classesToAvoid' | ||
], | ||
#category : #MethodProxiesSebas | ||
} | ||
|
||
{ #category : #evaluating } | ||
MpColorAllocationProfilerHandler >> afterExecutionWithReceiver: receiver arguments: arguments returnValue: returnValue [ | ||
|
||
returnValue class = Color ifTrue: [ | ||
allocations add: (self contextThatCreatesTheColor: thisContext) -> returnValue ]. | ||
^ returnValue | ||
] | ||
|
||
{ #category : #evaluating } | ||
MpColorAllocationProfilerHandler >> contextThatCreatesTheColor: aContext [ | ||
|
||
"(classToAvoid includes: aContext sender methodClass) ifFalse: [ | ||
^ aContext sender methodClass ]. | ||
^ self classThatCreatesTheColor: aContext sender" | ||
|
||
| sender | | ||
sender := aContext sender. | ||
[ classesToAvoid includes: sender methodClass ] whileTrue: [ | ||
sender := sender sender ]. | ||
^ sender | ||
] | ||
|
||
{ #category : #initialization } | ||
MpColorAllocationProfilerHandler >> initialize [ | ||
|
||
super initialize. | ||
allocations := OrderedCollection new. | ||
classesToAvoid := { | ||
Color class. | ||
Color. | ||
MpColorAllocationProfilerHandler. | ||
MpMethodProxy. | ||
BlockClosure. | ||
FullBlockClosure. | ||
CompiledBlock } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package { #name : #MethodProxiesSebas } |