InstrumentingCompiler.st
changeset 2967 33ec78ee2aa9
parent 2960 8adc66fe55fb
child 2972 204f077ff866
--- a/InstrumentingCompiler.st	Thu Nov 01 12:10:58 2012 +0100
+++ b/InstrumentingCompiler.st	Thu Nov 01 12:11:33 2012 +0100
@@ -14,6 +14,20 @@
 	privateIn:InstrumentingCompiler
 !
 
+InstrumentingCompiler::StatementExecutionInfo subclass:#StatementExecutionInfoForCoverageInAlreadyEnteredState
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:InstrumentingCompiler::StatementExecutionInfo
+!
+
+InstrumentingCompiler::StatementExecutionInfo subclass:#StatementExecutionInfoInAlreadyEnteredState
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:InstrumentingCompiler::StatementExecutionInfo
+!
+
 InstrumentationInfo subclass:#MethodInvocationInfo
 	instanceVariableNames:'recursiveEntry infoPerReceiverClass'
 	classVariableNames:''
@@ -63,6 +77,20 @@
 	privateIn:InstrumentingCompiler
 !
 
+InstrumentingCompiler::BlockExecutionInfo subclass:#BlockExecutionInfoForCoverageInAlreadyEnteredState
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:InstrumentingCompiler::BlockExecutionInfo
+!
+
+InstrumentingCompiler::BlockExecutionInfo subclass:#BlockExecutionInfoInAlreadyEnteredState
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:InstrumentingCompiler::BlockExecutionInfo
+!
+
 InstrumentingCompiler::VariableAccessExecutionInfo subclass:#ReadAccessExecutionInfo
 	instanceVariableNames:''
 	classVariableNames:''
@@ -484,6 +512,18 @@
 
 !InstrumentingCompiler::StatementExecutionInfo methodsFor:'instrumentation calls'!
 
+changeClassToAlreadyEntered
+    self class == InstrumentingCompiler::StatementExecutionInfo ifTrue:[
+        self changeClassTo: StatementExecutionInfoInAlreadyEnteredState
+    ].
+!
+
+changeClassToCoverageAndAlreadyEntered
+    self class == InstrumentingCompiler::StatementExecutionInfo ifTrue:[
+        self changeClassTo: StatementExecutionInfoForCoverageInAlreadyEnteredState
+    ].
+!
+
 entry:callingContext
     "invoked by instrumented code;
      called whenever the block/statment is entered"
@@ -505,6 +545,12 @@
         [
             context inInstrumentedCode:true.
             Smalltalk changed:#methodCoverageInfo with:owningMethod.
+            context coverageOnly ifTrue:[
+                self changeClassToCoverageAndAlreadyEntered.
+            ] ifFalse:[
+                self changeClassToAlreadyEntered.
+            ].
+            "/ attention: no self sends here - class has changed!!
         ] ensure:[
             context inInstrumentedCode:false.
         ]
@@ -530,6 +576,36 @@
     "Created: / 08-08-2011 / 14:40:51 / cg"
 ! !
 
+!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'!
+
+cleanInfoWithChange:withChange
+    super cleanInfoWithChange:withChange.
+    self changeClassTo:InstrumentingCompiler::StatementExecutionInfo.
+! !
+
+!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation calls'!
+
+entry:callingContext
+    "already been invoked - nothing to record"
+
+    ^ self
+! !
+
+!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoInAlreadyEnteredState methodsFor:'cleanup'!
+
+cleanInfoWithChange:withChange
+    super cleanInfoWithChange:withChange.
+    self changeClassTo:InstrumentingCompiler::StatementExecutionInfo.
+! !
+
+!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoInAlreadyEnteredState methodsFor:'instrumentation calls'!
+
+entry:callingContext
+    "already been invoked - nothing to record"
+
+    ^ self
+! !
+
 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'accessing'!
 
 callingMethodsDo:aBlock
@@ -611,6 +687,18 @@
 
 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'instrumentation probe calls'!
 
+changeClassToAlreadyEntered
+    self class == InstrumentingCompiler::MethodInvocationInfo ifTrue:[
+        self changeClassTo: InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState
+    ].
+!
+
+changeClassToCoverageAndAlreadyEntered
+    self class == InstrumentingCompiler::MethodInvocationInfo ifTrue:[
+        self changeClassTo: InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState
+    ].
+!
+
 entry:aContext
     "invoked by instrumented compiled code, upon method entry"
 
@@ -659,10 +747,11 @@
             Smalltalk changed:#methodCoverageInfo with:owningMethod.
         ].
         coverageOnly ifTrue:[
-            self changeClassTo:(InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState).
+            self changeClassToCoverageAndAlreadyEntered.
         ] ifFalse:[
-            self changeClassTo:(InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState).
+            self changeClassToAlreadyEntered.
         ].
+        "/ attention: no self sends here - class has changed!!
     ] ensure:[
         context inInstrumentedCode:false.
         recursiveEntry := false.
@@ -817,14 +906,8 @@
 !InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'!
 
 cleanInfoWithChange:withChange
+    super cleanInfoWithChange:withChange.
     self changeClassTo:InstrumentingCompiler::MethodInvocationInfo.
-    infoPerReceiverClass := nil.
-    withChange ifTrue:[
-        Smalltalk changed:#methodCoverageInfo with:owningMethod.
-    ]
-
-    "Modified: / 20-07-2011 / 17:55:35 / cg"
-    "Created: / 24-08-2011 / 11:10:29 / cg"
 ! !
 
 !InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation probe calls'!
@@ -838,11 +921,8 @@
 !InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState methodsFor:'cleanup'!
 
 cleanInfoWithChange:withChange
+    super cleanInfoWithChange:withChange.
     self changeClassTo:InstrumentingCompiler::MethodInvocationInfo.
-    infoPerReceiverClass := nil.
-    withChange ifTrue:[
-        Smalltalk changed:#methodCoverageInfo with:owningMethod.
-    ]
 
     "Modified: / 20-07-2011 / 17:55:35 / cg"
     "Created: / 24-08-2011 / 11:10:29 / cg"
@@ -879,6 +959,20 @@
     "Created: / 28-04-2010 / 15:54:47 / cg"
 ! !
 
+!InstrumentingCompiler::BlockExecutionInfo methodsFor:'entry'!
+
+changeClassToAlreadyEntered
+    self class == InstrumentingCompiler::BlockExecutionInfo ifTrue:[
+        self changeClassTo: BlockExecutionInfoInAlreadyEnteredState
+    ].
+!
+
+changeClassToCoverageAndAlreadyEntered
+    self class == InstrumentingCompiler::BlockExecutionInfo ifTrue:[
+        self changeClassTo: BlockExecutionInfoForCoverageInAlreadyEnteredState
+    ].
+! !
+
 !InstrumentingCompiler::BlockExecutionInfo methodsFor:'printing'!
 
 printOn:aStream 
@@ -899,6 +993,28 @@
     "Created: / 07-08-2011 / 17:06:39 / cg"
 ! !
 
+!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'!
+
+cleanInfoWithChange:withChange
+    super cleanInfoWithChange:withChange.
+    self changeClassTo:InstrumentingCompiler::BlockExecutionInfo.
+! !
+
+!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation probe calls'!
+
+entry:callingContext
+    "already been invoked - nothing to record"
+
+    ^ self
+! !
+
+!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoInAlreadyEnteredState methodsFor:'cleanup'!
+
+cleanInfoWithChange:withChange
+    super cleanInfoWithChange:withChange.
+    self changeClassTo:InstrumentingCompiler::BlockExecutionInfo.
+! !
+
 !InstrumentingCompiler::ReadAccessExecutionInfo class methodsFor:'documentation'!
 
 documentation
@@ -918,9 +1034,9 @@
 !InstrumentingCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.25 2012-10-29 10:32:25 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.26 2012-11-01 11:11:33 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.25 2012-10-29 10:32:25 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.26 2012-11-01 11:11:33 cg Exp $'
 ! !