OBJECTSEMANTICS / SmallSuiteGenerator

Powered by SEMANTICS SRL
http://semantics.bo
MIT License
3 stars 2 forks source link

Profiling branch instrumentation fails #221

Open jpsandoval opened 4 years ago

jpsandoval commented 4 years ago

When the method has many closures and they are tight ... the probed method trigger an error... its seems that the order of probe insertion affects... so, inserting the probes first in bigger closures seems to help... but not sure we need to test in more methods.

installGhosts " This is decompiled code. No source was available"

| t1 sortedBlocks|
self originalMethod getSource size > 20000
    ifTrue: [self uninstall]
    ifFalse: [
        self uninstall.
        t1 := Refactory.Browser.RBParser parseMethod: self originalMethod getSource.
        blocks := (SLInstrumentor new) visitNode: t1; blocks.
        (self originalMethod isKindOf: ProbedCompiledMethod)
            ifTrue: [self originalMethod revert].
        probedMethod := self originalMethod newFullProbedMethod.
        sortedBlocks := blocks asSortedCollection:[ :a :b| a size > b size.].
        sortedBlocks
            do: 
                [:t2 | 
                | t3 |
                (t3 := SLCodeProbe new) record: (probedMethod probeRecordFor: (t2 start to: t2 start)).
                t3 block: t2.
                probedMethod addProbe: t3.
                ].
        self originalMethod mclass  addSelector: self selector withMethod: probedMethod.
        ].
^self

also i use a particular method to update the method in the instrumented class.

jpsandoval commented 4 years ago

SLBlock>>size ^ stop - start.