diff --git a/.project b/.project new file mode 100644 index 0000000..81083cc --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory' : 'src' +} \ No newline at end of file diff --git a/src/.properties b/src/.properties new file mode 100644 index 0000000..ad0471d --- /dev/null +++ b/src/.properties @@ -0,0 +1,3 @@ +{ + #format : #tonel +} \ No newline at end of file diff --git a/src/MethodProxiesSebas/MpColorAllocationProfilerHandler.class.st b/src/MethodProxiesSebas/MpColorAllocationProfilerHandler.class.st new file mode 100644 index 0000000..64de887 --- /dev/null +++ b/src/MethodProxiesSebas/MpColorAllocationProfilerHandler.class.st @@ -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 } +] diff --git a/src/MethodProxiesSebas/package.st b/src/MethodProxiesSebas/package.st new file mode 100644 index 0000000..d39927a --- /dev/null +++ b/src/MethodProxiesSebas/package.st @@ -0,0 +1 @@ +Package { #name : #MethodProxiesSebas }