InstrumentingCompiler.st
changeset 2960 8adc66fe55fb
parent 2958 4bb6acd04cfe
child 2967 33ec78ee2aa9
--- a/InstrumentingCompiler.st	Fri Oct 26 12:53:40 2012 +0200
+++ b/InstrumentingCompiler.st	Mon Oct 29 11:32:25 2012 +0100
@@ -15,7 +15,7 @@
 !
 
 InstrumentationInfo subclass:#MethodInvocationInfo
-	instanceVariableNames:'infoPerReceiverClass'
+	instanceVariableNames:'recursiveEntry infoPerReceiverClass'
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:InstrumentingCompiler
@@ -492,6 +492,7 @@
 
     context := InstrumentationContext current.
     context isNil ifTrue:[^ self].
+    context inInstrumentedCode ifTrue:[^ self].
     context coverageOnly ifTrue:[
         self hasBeenExecuted ifTrue:[^ self].
     ].
@@ -499,7 +500,7 @@
 
     count := count + 1.
     count == 1 ifTrue:[
-        "/ the very first time, send a change notification, so the browsers update
+        "/ the very first time, send a change notification, so the browsers update the coloring
 
         [
             context inInstrumentedCode:true.
@@ -615,9 +616,17 @@
 
     |context receiversClass infoPerReceiver firstEntry coverageOnly|
 
+    recursiveEntry == true ifTrue:[
+        "/ hurry, get out of here
+    ].
+
+    "/ this is a hack - we have to be very careful to avoid recursive
+    "/ instrumentation entries when instrumenting collection classes!!
+    "/ Do not change without extensive testing.
+    recursiveEntry := true.
     context := InstrumentationContext current.
-    context isNil ifTrue:[^ self].
-    context enabledAndNotInInstrumentedCode ifFalse:[^ self].
+    context isNil ifTrue:[recursiveEntry := false. ^ self].
+    context enabledAndNotInInstrumentedCode ifFalse:[recursiveEntry := false. ^ self].
 
     [
         context inInstrumentedCode:true.
@@ -645,7 +654,7 @@
             infoPerReceiver entry:aContext.
         ].
 
-        "/ the very first time, send a change notification, so the browsers update
+        "/ the very first time, send a change notification, so the browsers update the coloring
         firstEntry ifTrue:[
             Smalltalk changed:#methodCoverageInfo with:owningMethod.
         ].
@@ -656,9 +665,10 @@
         ].
     ] ensure:[
         context inInstrumentedCode:false.
+        recursiveEntry := false.
     ].
 
-    "Modified: / 05-06-2012 / 23:51:53 / cg"
+    "Modified (comment): / 26-10-2012 / 12:59:44 / cg"
 ! !
 
 !InstrumentingCompiler::MethodInvocationInfo methodsFor:'testing'!
@@ -908,9 +918,9 @@
 !InstrumentingCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.24 2012-10-26 09:48:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.25 2012-10-29 10:32:25 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.24 2012-10-26 09:48:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.25 2012-10-29 10:32:25 cg Exp $'
 ! !