Skip to content

Commit

Permalink
Created handler for recording the color creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanmontt committed Sep 29, 2022
1 parent a09f836 commit b94f5b5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
'srcDirectory' : 'src'
}
3 changes: 3 additions & 0 deletions src/.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
#format : #tonel
}
49 changes: 49 additions & 0 deletions src/MethodProxiesSebas/MpColorAllocationProfilerHandler.class.st
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 }
]
1 change: 1 addition & 0 deletions src/MethodProxiesSebas/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #MethodProxiesSebas }

0 comments on commit b94f5b5

Please sign in to comment.