diff --git a/src/IllimaniProfiler-Experiment-Tests/IllAnotherFakeClass.class.st b/src/IllimaniProfiler-Experiment-Tests/IllAnotherFakeClass.class.st deleted file mode 100644 index 1aeea78..0000000 --- a/src/IllimaniProfiler-Experiment-Tests/IllAnotherFakeClass.class.st +++ /dev/null @@ -1,22 +0,0 @@ -Class { - #name : 'IllAnotherFakeClass', - #superclass : 'Object', - #instVars : [ - 'aDictionary' - ], - #category : 'IllimaniProfiler-Experiment-Tests', - #package : 'IllimaniProfiler-Experiment-Tests' -} - -{ #category : 'accessing - token' } -IllAnotherFakeClass >> bar [ - - aDictionary at: 1 put: 3 -] - -{ #category : 'initialization' } -IllAnotherFakeClass >> initialize [ - - super initialize. - aDictionary := Dictionary new -] diff --git a/src/IllimaniProfiler-Experiment-Tests/IllCodeRewriterTest.class.st b/src/IllimaniProfiler-Experiment-Tests/IllCodeRewriterTest.class.st deleted file mode 100644 index 32459b9..0000000 --- a/src/IllimaniProfiler-Experiment-Tests/IllCodeRewriterTest.class.st +++ /dev/null @@ -1,113 +0,0 @@ -" -An IllRewriterTest is a test class for testing the behavior of IllRewriter -" -Class { - #name : 'IllCodeRewriterTest', - #superclass : 'TestCase', - #instVars : [ - 'rewriter', - 'senders', - 'initialCaller' - ], - #category : 'IllimaniProfiler-Experiment-Tests', - #package : 'IllimaniProfiler-Experiment-Tests' -} - -{ #category : 'running' } -IllCodeRewriterTest >> setUp [ - - super setUp. - - rewriter := IllCodeRewriter new. - initialCaller := IllRewriterMethodWithBytecode method: IllFakeClass >> #foo offset: 45. - senders := { - (IllRewriterMethodWithBytecode method: IllAnotherFakeClass >> #bar offset: 36). - (IllRewriterMethodWithBytecode method: Dictionary >> #at:put: offset: 82). - (IllRewriterMethodWithBytecode method: Association class >> #key:value: offset: 42) }. - - rewriter storeBackupSenders: senders caller: initialCaller -] - -{ #category : 'running' } -IllCodeRewriterTest >> tearDown [ - - rewriter restoreMethodsToOriginalState. - senders do: [ :illSender | - illSender method methodClass removeSelector: (rewriter tenureSelector: illSender selector) ]. - - super tearDown -] - -{ #category : 'tests' } -IllCodeRewriterTest >> testCloneMethodWithTenureSelector [ - - | illSender tenuredNewSelector clonedCompiledMethod | - illSender := senders first. - tenuredNewSelector := rewriter tenureSelector: #bar. - - "Method does not exist yet" - self should: [ IllAnotherFakeClass new perform: tenuredNewSelector ] raise: MessageNotUnderstood. - self deny: (IllAnotherFakeClass includesSelector: tenuredNewSelector). - - "Clone method with a different selector" - clonedCompiledMethod := rewriter cloneMethodWithTenureSelector: illSender. - rewriter installMethod: clonedCompiledMethod. - - self shouldnt: [ IllAnotherFakeClass new perform: tenuredNewSelector ] raise: MessageNotUnderstood. - self assert: clonedCompiledMethod selector equals: tenuredNewSelector. - self assert: (IllAnotherFakeClass includesSelector: tenuredNewSelector). - self assert: (IllAnotherFakeClass methodDict at: tenuredNewSelector) equals: clonedCompiledMethod. - - "Cloned method should have the same code but a different selector" - self assert: clonedCompiledMethod bytecodes equals: illSender method bytecodes. - self deny: clonedCompiledMethod selector equals: illSender method selector -] - -{ #category : 'tests' } -IllCodeRewriterTest >> testTenureCallingSendersInitialCaller [ - "Methods do not exist" - - self should: [ IllAnotherFakeClass new perform: (rewriter tenureSelector: #bar) ] raise: MessageNotUnderstood. - self - should: [ Dictionary new perform: (rewriter tenureSelector: #at:put:) withArguments: #( #key 2 ) ] - raise: MessageNotUnderstood. - self - should: [ Association perform: (rewriter tenureSelector: #key:value:) withArguments: #( #key #value ) ] - raise: MessageNotUnderstood. - - rewriter tenureCallingSenders: senders initialCaller: initialCaller. - - self shouldnt: [ IllAnotherFakeClass new perform: (rewriter tenureSelector: #bar) ] raise: MessageNotUnderstood. - self - shouldnt: [ Dictionary new perform: (rewriter tenureSelector: #at:put:) withArguments: #( #key 2 ) ] - raise: MessageNotUnderstood. - self - shouldnt: [ Association perform: (rewriter tenureSelector: #key:value:) withArguments: #( #key #value ) ] - raise: MessageNotUnderstood -] - -{ #category : 'tests' } -IllCodeRewriterTest >> testTenureMessageSendForOffset [ - - | illSender tenuredCompiledMethod symbolicMessageSendBytecode expectedSelector offset methodToTenure | - illSender := senders second. "Dictionary >> #at:put:" - methodToTenure := illSender method. - offset := illSender offset. - expectedSelector := rewriter tenureSelector: (illSender method sourceNodeForPC: offset) selector. - - self - shouldnt: [ methodToTenure valueWithReceiver: methodToTenure methodClass new arguments: #( #key #value ) ] - raise: PrimitiveFailed. - - tenuredCompiledMethod := rewriter tenureMessageSendFor: methodToTenure clone offset: offset. - - symbolicMessageSendBytecode := tenuredCompiledMethod symbolicBytecodes detect: [ :e | - e bytes includes: illSender bytecode ]. - self assert: symbolicMessageSendBytecode description equals: 'send: ' , expectedSelector. - "Method's selector remaine unchanged" - self assert: tenuredCompiledMethod selector equals: illSender selector. - "We pretenure one message send to a method that does not exists" - self - should: [ tenuredCompiledMethod valueWithReceiver: methodToTenure methodClass new arguments: #( #key #value ) ] - raise: MessageNotUnderstood -] diff --git a/src/IllimaniProfiler-Experiment-Tests/IllFakeClass.class.st b/src/IllimaniProfiler-Experiment-Tests/IllFakeClass.class.st deleted file mode 100644 index b455434..0000000 --- a/src/IllimaniProfiler-Experiment-Tests/IllFakeClass.class.st +++ /dev/null @@ -1,16 +0,0 @@ -Class { - #name : 'IllFakeClass', - #superclass : 'Object', - #instVars : [ - 'anotherFakeClass' - ], - #category : 'IllimaniProfiler-Experiment-Tests', - #package : 'IllimaniProfiler-Experiment-Tests' -} - -{ #category : 'accessing' } -IllFakeClass >> foo [ - - anotherFakeClass := IllAnotherFakeClass new. - anotherFakeClass bar -] diff --git a/src/IllimaniProfiler-Experiment-Tests/package.st b/src/IllimaniProfiler-Experiment-Tests/package.st deleted file mode 100644 index ce38a29..0000000 --- a/src/IllimaniProfiler-Experiment-Tests/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : 'IllimaniProfiler-Experiment-Tests' } diff --git a/src/IllimaniProfiler-Experiment/Array.extension.st b/src/IllimaniProfiler-Experiment/Array.extension.st deleted file mode 100644 index 35b160d..0000000 --- a/src/IllimaniProfiler-Experiment/Array.extension.st +++ /dev/null @@ -1,12 +0,0 @@ -Extension { #name : 'Array' } - -{ #category : '*IllimaniProfiler-Experiment' } -Array class >> newTenured: sizeRequested [ - "Answer an instance of this class with the number of indexable - variables specified by the argument, sizeRequested. - - This is a shortcut (direct call of primitive, no #initialize, for performance" - - "This method runs primitively if successful" - ^ self basicNewTenured: sizeRequested "Exceptional conditions will be handled in basicNew:" -] diff --git a/src/IllimaniProfiler-Experiment/IllCodeRewriter.class.st b/src/IllimaniProfiler-Experiment/IllCodeRewriter.class.st deleted file mode 100644 index 4f79e65..0000000 --- a/src/IllimaniProfiler-Experiment/IllCodeRewriter.class.st +++ /dev/null @@ -1,90 +0,0 @@ -Class { - #name : 'IllCodeRewriter', - #superclass : 'Object', - #instVars : [ - 'originalCaller', - 'originalSenders' - ], - #category : 'IllimaniProfiler-Experiment', - #package : 'IllimaniProfiler-Experiment' -} - -{ #category : 'private' } -IllCodeRewriter >> cloneMethodWithTenureSelector: anIllSender [ - - | clonedMethod newSelector | - clonedMethod := anIllSender method copy. - newSelector := self defaultTenureSelector: clonedMethod selector. - - clonedMethod selector: newSelector. - - ^ clonedMethod -] - -{ #category : 'private' } -IllCodeRewriter >> defaultTenureSelector: aByteSymbol [ - - ^ #_pretenured_ , aByteSymbol -] - -{ #category : 'private' } -IllCodeRewriter >> installMethod: aCompiledMethod [ - - aCompiledMethod methodClass methodDict at: aCompiledMethod selector put: aCompiledMethod -] - -{ #category : 'api' } -IllCodeRewriter >> restoreMethodsToOriginalState [ - - self installMethod: originalCaller. - originalSenders do: [ :aCompiledMethod | self installMethod: aCompiledMethod ] -] - -{ #category : 'private' } -IllCodeRewriter >> storeBackupSenders: senders caller: initialCaller [ - - originalCaller := initialCaller method copy. - originalSenders := senders collect: [ :illSender | illSender method copy ] -] - -{ #category : 'api' } -IllCodeRewriter >> tenureCallingSenders: senders initialCaller: initialCaller [ - - | clonedMethod | - self storeBackupSenders: senders caller: initialCaller. - - initialCaller method methodClass methodDict - at: initialCaller selector - put: (self tenureMessageSendFor: initialCaller method offset: initialCaller offset). - - senders do: [ :anIllSender | - clonedMethod := self cloneMethodWithTenureSelector: anIllSender. - clonedMethod := self tenureMessageSendFor: clonedMethod offset: anIllSender offset. - self installMethod: clonedMethod ] -] - -{ #category : 'private' } -IllCodeRewriter >> tenureMessageSendFor: compiledMethod offset: offset [ - - | messageSendSelector newMessageSendSelector irSendNode ir irSequences newCompiledMethod | - messageSendSelector := (compiledMethod sourceNode sourceNodeForPC: offset) selector. - newMessageSendSelector := self tenureSelector: messageSendSelector. - - ir := compiledMethod ir. - irSequences := ir allSequences flatCollect: #children. - irSendNode := (irSequences select: #isSend) detect: [ :e | e selector = messageSendSelector ]. - irSendNode selector: newMessageSendSelector. - - newCompiledMethod := ir generate selector: compiledMethod selector; yourself. - ^ newCompiledMethod -] - -{ #category : 'private' } -IllCodeRewriter >> tenureSelector: aByteSymbol [ - - aByteSymbol = #new ifTrue: [ ^ #newTenured ]. - aByteSymbol = #new: ifTrue: [ ^ #newTenured: ]. - aByteSymbol = #basicNew ifTrue: [ ^ #basicNewTenured ]. - aByteSymbol = #basicNew: ifTrue: [ ^ #basicNewTenured: ]. - ^ self defaultTenureSelector: aByteSymbol -] diff --git a/src/IllimaniProfiler-Experiment/IllRewriterMethodWithBytecode.class.st b/src/IllimaniProfiler-Experiment/IllRewriterMethodWithBytecode.class.st deleted file mode 100644 index 3ca4c8b..0000000 --- a/src/IllimaniProfiler-Experiment/IllRewriterMethodWithBytecode.class.st +++ /dev/null @@ -1,55 +0,0 @@ -Class { - #name : 'IllRewriterMethodWithBytecode', - #superclass : 'Object', - #instVars : [ - 'method', - 'offset' - ], - #category : 'IllimaniProfiler-Experiment', - #package : 'IllimaniProfiler-Experiment' -} - -{ #category : 'instance creation' } -IllRewriterMethodWithBytecode class >> method: aCompiledMethod offset: anInteger [ - - ^ self new - method: aCompiledMethod; - offset: anInteger; - yourself -] - -{ #category : 'accessing' } -IllRewriterMethodWithBytecode >> bytecode [ - - ^ method at: offset -] - -{ #category : 'accessing' } -IllRewriterMethodWithBytecode >> method [ - - ^ method -] - -{ #category : 'accessing' } -IllRewriterMethodWithBytecode >> method: aCompiledMethod [ - - method := aCompiledMethod -] - -{ #category : 'accessing' } -IllRewriterMethodWithBytecode >> offset [ - - ^ offset -] - -{ #category : 'accessing' } -IllRewriterMethodWithBytecode >> offset: anInt [ - - offset := anInt -] - -{ #category : 'accessing' } -IllRewriterMethodWithBytecode >> selector [ - - ^ method selector -] diff --git a/src/IllimaniProfiler-Experiment/package.st b/src/IllimaniProfiler-Experiment/package.st deleted file mode 100644 index c3e8883..0000000 --- a/src/IllimaniProfiler-Experiment/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : 'IllimaniProfiler-Experiment' }