InstrumentingCompiler.st
changeset 2569 e9fcb54ac3d4
parent 2528 e57cc8caf6f9
child 2570 f0b8fc6cdabb
equal deleted inserted replaced
2568:44f3c6ce19f1 2569:e9fcb54ac3d4
   379 ! !
   379 ! !
   380 
   380 
   381 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'cleanup'!
   381 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'cleanup'!
   382 
   382 
   383 cleanInfo
   383 cleanInfo
   384     count := 0
   384     count := 0.
       
   385     Smalltalk changed:#methodTrap with:owningMethod.
       
   386 
       
   387     "Modified: / 20-07-2011 / 17:54:27 / cg"
   385 ! !
   388 ! !
   386 
   389 
   387 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'instrumentation calls'!
   390 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'instrumentation calls'!
   388 
   391 
   389 entry:callingContext
   392 entry:callingContext
   396     count == 1 ifTrue:[
   399     count == 1 ifTrue:[
   397         "/ the very first time, send a change notification
   400         "/ the very first time, send a change notification
   398         p := Processor activeProcess.
   401         p := Processor activeProcess.
   399         (p environmentAt:#inInstrument ifAbsent:false) ifFalse:[
   402         (p environmentAt:#inInstrument ifAbsent:false) ifFalse:[
   400             p withThreadVariable:#inInstrument boundTo:true do:[
   403             p withThreadVariable:#inInstrument boundTo:true do:[
   401                 owningMethod changed:#methodInfo
   404                 Smalltalk changed:#methodTrap with:owningMethod.
   402             ].
   405             ].
   403         ]
   406         ]
   404     ].
   407     ].
   405 
   408 
   406     "Created: / 23-06-2006 / 13:31:16 / cg"
   409     "Created: / 23-06-2006 / 13:31:16 / cg"
   407     "Modified: / 05-07-2011 / 13:35:25 / cg"
   410     "Modified: / 20-07-2011 / 17:53:40 / cg"
   408 ! !
   411 ! !
   409 
   412 
   410 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'queries'!
   413 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'queries'!
   411 
   414 
   412 hasBeenExecuted
   415 hasBeenExecuted
   481 
   484 
   482 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'cleanup'!
   485 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'cleanup'!
   483 
   486 
   484 cleanInfo
   487 cleanInfo
   485     infoPerReceiverClass := nil.
   488     infoPerReceiverClass := nil.
       
   489     Smalltalk changed:#methodTrap with:owningMethod.
       
   490 
       
   491     "Modified: / 20-07-2011 / 17:54:34 / cg"
   486 ! !
   492 ! !
   487 
   493 
   488 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'instrumentation probe calls'!
   494 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'instrumentation probe calls'!
   489 
   495 
   490 entry:aContext
   496 entry:aContext
   491     "invoked by instrumented compiled code, upon method entry"
   497     "invoked by instrumented compiled code, upon method entry"
   492 
   498 
   493     |p receiversClass infoPerReceiver|
   499     |p receiversClass infoPerReceiver firstEntry|
   494 
   500 
   495     p := Processor activeProcess.
   501     p := Processor activeProcess.
   496     (p environmentAt:#inInstrument ifAbsent:false) ifTrue:[^ self].
   502     (p environmentAt:#inInstrument ifAbsent:false) ifTrue:[^ self].
       
   503 
   497     p withThreadVariable:#inInstrument boundTo:true do:[
   504     p withThreadVariable:#inInstrument boundTo:true do:[
   498         receiversClass := aContext receiver class.
   505         receiversClass := aContext receiver class.
   499         infoPerReceiverClass isNil ifTrue:[
   506         infoPerReceiverClass isNil ifTrue:[
   500             infoPerReceiverClass := IdentityDictionary new.
   507             infoPerReceiverClass := IdentityDictionary new.
   501         ].
   508         ].
       
   509         firstEntry := false.
   502         infoPerReceiver := infoPerReceiverClass 
   510         infoPerReceiver := infoPerReceiverClass 
   503                             at:receiversClass 
   511                             at:receiversClass 
   504                             ifAbsentPut:[ MethodInvocationInfoPerReceiverClass new ].
   512                             ifAbsentPut:[ firstEntry := true.
   505         infoPerReceiver entry:aContext
   513                                           MethodInvocationInfoPerReceiverClass new ].
       
   514         infoPerReceiver entry:aContext.
       
   515 
       
   516         "/ the very first time, send a change notification
       
   517         firstEntry ifTrue:[
       
   518             Smalltalk changed:#methodTrap with:owningMethod.
       
   519         ]
   506     ]
   520     ]
   507 
   521 
   508     "Modified: / 05-07-2011 / 13:35:42 / cg"
   522     "Modified: / 20-07-2011 / 17:54:08 / cg"
   509 ! !
   523 ! !
   510 
   524 
   511 !InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass methodsFor:'accessing'!
   525 !InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass methodsFor:'accessing'!
   512 
   526 
   513 callingMethodsDo:aBlock
   527 callingMethodsDo:aBlock
   584     ] ifFalse:[
   598     ] ifFalse:[
   585         sender := aContext sender methodHome.
   599         sender := aContext sender methodHome.
   586     ].
   600     ].
   587     sender isNil ifTrue:[
   601     sender isNil ifTrue:[
   588         ^ self.
   602         ^ self.
   589     ] ifFalse:[
   603     ].
       
   604     sendingMethod := sender method.
       
   605     sendingMethod isNil ifTrue:[^ self].
       
   606 
       
   607     viaPerform := false.
       
   608     (sendingMethod mclass == Object 
       
   609     and:[ sendingMethod selector startsWith:'perform:'] ) ifTrue:[
       
   610         "/ Transcript showCR:('%1 [info]: skipping #perform' bindWith:self class nameWithoutPrefix).
       
   611         sender := sender sender methodHome.
   590         sendingMethod := sender method.
   612         sendingMethod := sender method.
   591         sendingMethod isNil ifTrue:[^ self].
   613         viaPerform := true.
   592 
       
   593         viaPerform := false.
       
   594         (sendingMethod mclass == Object 
       
   595         and:[ sendingMethod selector startsWith:'perform:'] ) ifTrue:[
       
   596             "/ Transcript showCR:('%1 [info]: skipping #perform' bindWith:self class nameWithoutPrefix).
       
   597             sender := sender sender methodHome.
       
   598             sendingMethod := sender method.
       
   599             viaPerform := true.
       
   600         ].
       
   601     ].
   614     ].
   602 
   615 
   603     infoPerSendingMethod isNil ifTrue:[
   616     infoPerSendingMethod isNil ifTrue:[
   604         infoPerSendingMethod := IdentityDictionary new.
   617         infoPerSendingMethod := IdentityDictionary new.
   605     ].
   618     ].
   607                         at:sendingMethod 
   620                         at:sendingMethod 
   608                         ifAbsentPut:[ MethodInvocationInfoPerSendingMethod new ].
   621                         ifAbsentPut:[ MethodInvocationInfoPerSendingMethod new ].
   609 
   622 
   610     infoPerMethod entry:aContext viaPerform:viaPerform
   623     infoPerMethod entry:aContext viaPerform:viaPerform
   611 
   624 
   612     "Modified: / 28-04-2010 / 16:09:04 / cg"
   625     "Modified: / 20-07-2011 / 17:26:31 / cg"
   613 ! !
   626 ! !
   614 
   627 
   615 !InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass::MethodInvocationInfoPerSendingMethod methodsFor:'accessing'!
   628 !InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass::MethodInvocationInfoPerSendingMethod methodsFor:'accessing'!
   616 
   629 
   617 invokedViaPerform
   630 invokedViaPerform
   660 ! !
   673 ! !
   661 
   674 
   662 !InstrumentingCompiler class methodsFor:'documentation'!
   675 !InstrumentingCompiler class methodsFor:'documentation'!
   663 
   676 
   664 version_CVS
   677 version_CVS
   665     ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.7 2011-07-05 11:36:04 cg Exp $'
   678     ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.8 2011-07-20 15:55:15 cg Exp $'
   666 ! !
   679 ! !