author | Claus Gittinger <cg@exept.de> |
Wed, 07 Nov 2012 23:18:08 +0100 | |
changeset 2973 | 9de309c79d6c |
parent 2972 | 204f077ff866 |
child 2976 | 6e3f4e2b20f8 |
permissions | -rw-r--r-- |
2357 | 1 |
"{ Package: 'stx:libcomp' }" |
2 |
||
3 |
ByteCodeCompiler subclass:#InstrumentingCompiler |
|
2949 | 4 |
instanceVariableNames:'method methodEntryInfo blockInvocationInfo' |
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'System-Compiler-Instrumentation' |
|
2357 | 8 |
! |
9 |
||
2634 | 10 |
InstrumentationInfo subclass:#StatementExecutionInfo |
2949 | 11 |
instanceVariableNames:'startPosition count' |
12 |
classVariableNames:'' |
|
13 |
poolDictionaries:'' |
|
14 |
privateIn:InstrumentingCompiler |
|
2359 | 15 |
! |
16 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
17 |
InstrumentingCompiler::StatementExecutionInfo subclass:#StatementExecutionInfoForCoverageInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
18 |
instanceVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
19 |
classVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
20 |
poolDictionaries:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
21 |
privateIn:InstrumentingCompiler::StatementExecutionInfo |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
22 |
! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
23 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
24 |
InstrumentingCompiler::StatementExecutionInfo subclass:#StatementExecutionInfoInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
25 |
instanceVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
26 |
classVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
27 |
poolDictionaries:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
28 |
privateIn:InstrumentingCompiler::StatementExecutionInfo |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
29 |
! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
30 |
|
2635 | 31 |
InstrumentationInfo subclass:#MethodInvocationInfo |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
32 |
instanceVariableNames:'count recursiveEntry infoPerReceiverClass' |
2949 | 33 |
classVariableNames:'' |
34 |
poolDictionaries:'' |
|
35 |
privateIn:InstrumentingCompiler |
|
2357 | 36 |
! |
37 |
||
38 |
Object subclass:#MethodInvocationInfoPerReceiverClass |
|
2949 | 39 |
instanceVariableNames:'infoPerSendingMethod' |
40 |
classVariableNames:'' |
|
41 |
poolDictionaries:'' |
|
42 |
privateIn:InstrumentingCompiler::MethodInvocationInfo |
|
2357 | 43 |
! |
44 |
||
45 |
Object subclass:#MethodInvocationInfoPerSendingMethod |
|
2949 | 46 |
instanceVariableNames:'countPerSendersClass invokedViaPerform' |
47 |
classVariableNames:'' |
|
48 |
poolDictionaries:'' |
|
49 |
privateIn:InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass |
|
2948 | 50 |
! |
51 |
||
52 |
InstrumentingCompiler::MethodInvocationInfo subclass:#MethodInvocationInfoForCoverageInAlreadyEnteredState |
|
2949 | 53 |
instanceVariableNames:'' |
54 |
classVariableNames:'' |
|
55 |
poolDictionaries:'' |
|
56 |
privateIn:InstrumentingCompiler |
|
2357 | 57 |
! |
58 |
||
2711 | 59 |
InstrumentingCompiler::MethodInvocationInfo subclass:#MethodInvocationInfoInAlreadyEnteredState |
2949 | 60 |
instanceVariableNames:'' |
61 |
classVariableNames:'' |
|
62 |
poolDictionaries:'' |
|
63 |
privateIn:InstrumentingCompiler |
|
2711 | 64 |
! |
65 |
||
2715 | 66 |
InstrumentingCompiler::StatementExecutionInfo subclass:#VariableAccessExecutionInfo |
2949 | 67 |
instanceVariableNames:'' |
68 |
classVariableNames:'' |
|
69 |
poolDictionaries:'' |
|
70 |
privateIn:InstrumentingCompiler |
|
2715 | 71 |
! |
72 |
||
2390 | 73 |
InstrumentingCompiler::StatementExecutionInfo subclass:#BlockExecutionInfo |
2949 | 74 |
instanceVariableNames:'endPosition' |
75 |
classVariableNames:'' |
|
76 |
poolDictionaries:'' |
|
77 |
privateIn:InstrumentingCompiler |
|
2390 | 78 |
! |
79 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
80 |
InstrumentingCompiler::BlockExecutionInfo subclass:#BlockExecutionInfoForCoverageInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
81 |
instanceVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
82 |
classVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
83 |
poolDictionaries:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
84 |
privateIn:InstrumentingCompiler::BlockExecutionInfo |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
85 |
! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
86 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
87 |
InstrumentingCompiler::BlockExecutionInfo subclass:#BlockExecutionInfoInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
88 |
instanceVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
89 |
classVariableNames:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
90 |
poolDictionaries:'' |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
91 |
privateIn:InstrumentingCompiler::BlockExecutionInfo |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
92 |
! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
93 |
|
2715 | 94 |
InstrumentingCompiler::VariableAccessExecutionInfo subclass:#ReadAccessExecutionInfo |
2949 | 95 |
instanceVariableNames:'' |
96 |
classVariableNames:'' |
|
97 |
poolDictionaries:'' |
|
98 |
privateIn:InstrumentingCompiler |
|
2715 | 99 |
! |
100 |
||
101 |
InstrumentingCompiler::VariableAccessExecutionInfo subclass:#WriteAccessExecutionInfo |
|
2949 | 102 |
instanceVariableNames:'' |
103 |
classVariableNames:'' |
|
104 |
poolDictionaries:'' |
|
105 |
privateIn:InstrumentingCompiler |
|
2715 | 106 |
! |
107 |
||
2357 | 108 |
!InstrumentingCompiler class methodsFor:'documentation'! |
109 |
||
110 |
documentation |
|
111 |
" |
|
2632 | 112 |
an experiment - recompile classes using this compiler adds instrumentation code. |
113 |
This remembers who calls a method from where (methodInvocationInfo) what the receiver's types are |
|
114 |
(inherited classes) and how often basic blocks (blockExecutionInfo) and statements |
|
115 |
(statementExecutionInfo) are invoked . |
|
116 |
||
117 |
The who-calls and receiver type info may produce some overhead, which can be avoided by |
|
118 |
using the somewhat more naive InstrumentingForSimpleCoverageCompiler (that is what people are |
|
119 |
used to from the C/Java world, anyway). |
|
120 |
||
121 |
From the first bulk, we can compute the inheritanceCoverage info (which methods have been called for which |
|
122 |
subclass) in addition to the known line and block coverages. |
|
2357 | 123 |
" |
124 |
! ! |
|
125 |
||
126 |
!InstrumentingCompiler class methodsFor:'compilation-public'! |
|
127 |
||
128 |
compileClass:aClass |
|
129 |
"compile all methods of aClass with instrumentation" |
|
130 |
||
2958 | 131 |
aClass instAndClassMethodsDo:[:eachMethod | |
2357 | 132 |
self compileMethod:eachMethod |
133 |
]. |
|
134 |
! |
|
135 |
||
136 |
compileMethod:aMethod |
|
137 |
"compile a single method with instrumentation" |
|
138 |
||
2972
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
139 |
Class withoutUpdatingChangesDo:[ |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
140 |
self |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
141 |
compile:(aMethod source) |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
142 |
forClass:(aMethod mclass) |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
143 |
inCategory:(aMethod category) |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
144 |
] |
2958 | 145 |
! |
146 |
||
147 |
compilePackage:aPackageID |
|
148 |
"compile all classes of a package instrumentation" |
|
149 |
||
150 |
Smalltalk allClassesInPackage:aPackageID do:[:eachClass | |
|
151 |
self compileClass:eachClass |
|
152 |
]. |
|
153 |
||
154 |
" |
|
155 |
InstrumentingCompiler compilePackage:'exept:workflow'. |
|
156 |
InstrumentingCompiler compilePackage:'exept:expecco'. |
|
157 |
" |
|
2972
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
158 |
! |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
159 |
|
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
160 |
compilePackages:aCollectionOfPackageIDs |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
161 |
"compile all classes of some packages with instrumentation" |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
162 |
|
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
163 |
aCollectionOfPackageIDs do:[:eachPackage | |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
164 |
self compilePackage:eachPackage |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
165 |
]. |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
166 |
|
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
167 |
" |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
168 |
InstrumentingCompiler compilePackages:#( 'exept:workflow' 'exept:expecco' ). |
204f077ff866
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2967
diff
changeset
|
169 |
" |
2357 | 170 |
! ! |
171 |
||
172 |
!InstrumentingCompiler class methodsFor:'special'! |
|
173 |
||
174 |
allInstrumentedMethods |
|
175 |
^ InstrumentedMethod allInstances |
|
176 |
||
177 |
" |
|
178 |
self allInstrumentedMethods |
|
179 |
" |
|
180 |
||
181 |
"Modified: / 27-04-2010 / 13:37:51 / cg" |
|
182 |
! |
|
183 |
||
184 |
callersOf:aMethod do:aBlock |
|
2632 | 185 |
"enumerate all callers of aMethod into a block" |
186 |
||
2357 | 187 |
|info| |
188 |
||
189 |
info := aMethod methodInvocationInfo. |
|
190 |
info notNil ifTrue:[ |
|
191 |
info callingMethodsDo:[:callingMethod | |
|
192 |
aBlock value:callingMethod |
|
193 |
] |
|
194 |
] |
|
195 |
||
196 |
"Modified: / 27-04-2010 / 13:35:00 / cg" |
|
2632 | 197 |
"Modified (comment): / 07-08-2011 / 15:08:33 / cg" |
2357 | 198 |
! |
199 |
||
200 |
isInstrumented:aMethod |
|
201 |
^ aMethod isInstrumented |
|
202 |
||
203 |
" |
|
204 |
self methodInfoOf:aMethod |
|
205 |
" |
|
206 |
||
207 |
"Modified: / 27-04-2010 / 13:35:21 / cg" |
|
208 |
! |
|
209 |
||
210 |
methodInfoOf:aMethod |
|
211 |
<resource: #obsolete> |
|
212 |
||
213 |
self obsoleteMethodWarning:'please use Method >> methodInvocationInfo'. |
|
214 |
^ aMethod methodInvocationInfo |
|
215 |
||
216 |
" |
|
217 |
self methodInfoOf:aMethod |
|
218 |
" |
|
219 |
||
220 |
"Modified: / 27-04-2010 / 13:37:31 / cg" |
|
221 |
! |
|
222 |
||
223 |
methodInvocationInfoOf:aMethod |
|
224 |
self obsoleteMethodWarning:'please use method>>methodInvocationInfo'. |
|
225 |
^ aMethod methodInvocationInfo |
|
226 |
||
227 |
" |
|
228 |
self methodInfoOf:aMethod |
|
229 |
" |
|
230 |
||
231 |
"Created: / 27-04-2010 / 12:28:56 / cg" |
|
232 |
"Modified: / 27-04-2010 / 13:34:36 / cg" |
|
233 |
! ! |
|
234 |
||
235 |
!InstrumentingCompiler methodsFor:'code generation helpers'! |
|
236 |
||
237 |
addBlockCounterTo:aBlockNode |
|
2951 | 238 |
"called by the compiler to instrument a block node" |
239 |
||
2357 | 240 |
|countCode blockEntryInfo| |
241 |
||
242 |
blockInvocationInfo isNil ifTrue:[ |
|
243 |
blockInvocationInfo := OrderedCollection new. |
|
244 |
]. |
|
2632 | 245 |
blockEntryInfo := self blockExecutionInfoInstance. |
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
246 |
blockEntryInfo startPosition:aBlockNode startPosition endPosition:aBlockNode endPosition. |
2675
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
247 |
"/ Transcript show:aBlockNode startPosition; |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
248 |
"/ show:' -> '; |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
249 |
"/ showCR: aBlockNode endPosition. |
2357 | 250 |
blockInvocationInfo add:blockEntryInfo. |
251 |
||
252 |
countCode := |
|
253 |
StatementNode |
|
254 |
expression:(MessageNode |
|
255 |
receiver:(ConstantNode value:blockEntryInfo) |
|
256 |
selector:#entry: |
|
257 |
arg:(VariableNode type:#ThisContext context:contextToEvaluateIn)). |
|
258 |
||
259 |
aBlockNode isEmptyBlock ifTrue:[ |
|
260 |
"/ q: are we interested in empty blocks ? |
|
2665
2071b01a050f
changed: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2635
diff
changeset
|
261 |
countCode nextStatement:(StatementNode expression:(ConstantNode value:nil)). |
2357 | 262 |
aBlockNode statements:countCode. |
263 |
] ifFalse:[ |
|
264 |
countCode nextStatement:aBlockNode statements. |
|
265 |
aBlockNode statements:countCode. |
|
266 |
]. |
|
267 |
||
2675
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
268 |
"Modified: / 21-08-2011 / 16:02:52 / cg" |
2357 | 269 |
! |
270 |
||
271 |
addBlockCountersToEachBlockIn:aCollection |
|
2951 | 272 |
"called by the compiler to instrument a collection of block nodes" |
273 |
||
2357 | 274 |
aCollection do:[:eachNode | |
275 |
eachNode isBlockNode ifTrue:[ |
|
276 |
self addBlockCounterTo:eachNode |
|
277 |
] |
|
278 |
]. |
|
279 |
||
280 |
"Created: / 27-04-2010 / 11:47:56 / cg" |
|
281 |
! |
|
282 |
||
283 |
createMethod |
|
2951 | 284 |
"called by the compiler to instatiate a new method instance" |
285 |
||
2357 | 286 |
method := super createMethod. |
287 |
||
288 |
methodEntryInfo notNil ifTrue:[ |
|
289 |
methodEntryInfo owningMethod:method |
|
290 |
]. |
|
291 |
blockInvocationInfo notNil ifTrue:[ |
|
292 |
blockInvocationInfo do:[:eachInfo | eachInfo owningMethod:method] |
|
293 |
]. |
|
294 |
||
295 |
^ method |
|
296 |
||
297 |
"Modified: / 27-04-2010 / 14:04:50 / cg" |
|
298 |
! |
|
299 |
||
300 |
methodClass |
|
2951 | 301 |
"called by the compiler to ask for the method instance's class" |
302 |
||
2357 | 303 |
^ InstrumentedMethod |
304 |
||
305 |
"Created: / 27-04-2010 / 12:17:22 / cg" |
|
2390 | 306 |
! |
307 |
||
308 |
statementCounterBefore:aStatementNode |
|
2951 | 309 |
"called by the compiler to instrument a statement node (head of a basic block)" |
310 |
||
2390 | 311 |
|countCode statementEntryInfo| |
312 |
||
313 |
blockInvocationInfo isNil ifTrue:[ |
|
314 |
blockInvocationInfo := OrderedCollection new. |
|
315 |
]. |
|
2632 | 316 |
statementEntryInfo := self statementExecutionInfoInstance. |
2390 | 317 |
statementEntryInfo startPosition:aStatementNode startPosition. |
318 |
blockInvocationInfo add:statementEntryInfo. |
|
319 |
||
320 |
countCode := |
|
321 |
StatementNode |
|
322 |
expression:(MessageNode |
|
323 |
receiver:(ConstantNode value:statementEntryInfo) |
|
324 |
selector:#entry: |
|
325 |
arg:(VariableNode type:#ThisContext context:contextToEvaluateIn)). |
|
326 |
||
327 |
countCode nextStatement:aStatementNode. |
|
328 |
^ countCode |
|
2571 | 329 |
|
2632 | 330 |
"Modified: / 07-08-2011 / 15:32:45 / cg" |
2357 | 331 |
! ! |
332 |
||
2715 | 333 |
!InstrumentingCompiler methodsFor:'code generation hooks'! |
334 |
||
335 |
assignmentRewriteHookFor:anAssignmentNode |
|
336 |
"invoked whenever an assignment node has been generated" |
|
337 |
||
338 |
^ anAssignmentNode |
|
339 |
||
340 |
"Created: / 30-09-2011 / 12:28:09 / cg" |
|
341 |
! |
|
2357 | 342 |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
343 |
blockNodeRewriteHookFor:aBlockNode |
2715 | 344 |
"invoked whenever a block node has been generated" |
345 |
||
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
346 |
"/ add a counter for the block |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
347 |
self addBlockCounterTo:aBlockNode. |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
348 |
^ aBlockNode |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
349 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
350 |
"Created: / 28-04-2010 / 14:21:27 / cg" |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
351 |
! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
352 |
|
2357 | 353 |
messageNodeRewriteHookFor:aMessageNode |
2715 | 354 |
"invoked whenever a message send node has been generated" |
355 |
||
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
356 |
"/ see blockNodeRewriter... |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
357 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
358 |
"/ "/ argument could be a constantNode (due to contant-folding optimization) |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
359 |
"/ aMessageNode isConstant ifTrue:[^ aMessageNode]. |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
360 |
"/ ( |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
361 |
"/ #( |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
362 |
"/ ifTrue: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
363 |
"/ ifFalse: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
364 |
"/ ifTrue:ifFalse: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
365 |
"/ ifFalse:ifTrue: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
366 |
"/ ) |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
367 |
"/ includes:aMessageNode selector |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
368 |
"/ ) ifTrue:[ |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
369 |
"/ "/ add a counter for the block |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
370 |
"/ self addBlockCountersToEachBlockIn:(aMessageNode arguments) |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
371 |
"/ ]. |
2357 | 372 |
^ aMessageNode |
373 |
||
374 |
"Created: / 27-04-2010 / 11:43:22 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
375 |
"Modified: / 28-04-2010 / 14:22:05 / cg" |
2715 | 376 |
"Modified (comment): / 30-09-2011 / 12:16:56 / cg" |
2357 | 377 |
! |
378 |
||
379 |
startCodeGenerationHookOn:codeStream |
|
2715 | 380 |
"invoked before code is generated" |
381 |
||
2632 | 382 |
methodEntryInfo := self methodInvocationInfoInstance. |
2357 | 383 |
|
384 |
(StatementNode |
|
385 |
expression:(MessageNode |
|
386 |
receiver:(ConstantNode value:methodEntryInfo) |
|
387 |
selector:#entry: |
|
388 |
arg:(VariableNode type:#ThisContext context:contextToEvaluateIn))) |
|
389 |
codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
390 |
||
2632 | 391 |
"Modified: / 07-08-2011 / 15:34:09 / cg" |
2715 | 392 |
"Modified (comment): / 30-09-2011 / 12:16:05 / cg" |
2390 | 393 |
! |
394 |
||
395 |
statementListRewriteHookFor:firstStatement |
|
2715 | 396 |
"invoked whenever a statement list node has been generated" |
397 |
||
2390 | 398 |
"/ care for blocks which return... |
399 |
|thisStatement prevStatement countStatement mustInsertExecutionInfo| |
|
400 |
||
401 |
mustInsertExecutionInfo := false. |
|
402 |
prevStatement := nil. |
|
403 |
||
404 |
thisStatement := firstStatement. |
|
405 |
thisStatement isNil ifTrue:[^ firstStatement]. |
|
406 |
||
407 |
[true] whileTrue:[ |
|
408 |
mustInsertExecutionInfo ifTrue:[ |
|
409 |
"/ prev-stat had a return in it (a block with a return); |
|
410 |
"/ insert a statement-entry here. |
|
411 |
thisStatement notNil ifTrue:[ |
|
412 |
countStatement := self statementCounterBefore:thisStatement. |
|
413 |
prevStatement nextStatement:countStatement. |
|
414 |
mustInsertExecutionInfo := false. |
|
415 |
prevStatement := countStatement. |
|
416 |
] |
|
417 |
]. |
|
418 |
thisStatement isNil ifTrue:[^ firstStatement]. |
|
419 |
||
420 |
thisStatement isReturnNode ifFalse:[ |
|
421 |
thisStatement containsReturn ifTrue:[ |
|
422 |
mustInsertExecutionInfo := true |
|
423 |
] |
|
424 |
]. |
|
425 |
prevStatement := thisStatement. |
|
426 |
thisStatement := thisStatement nextStatement. |
|
427 |
]. |
|
2715 | 428 |
|
429 |
"Modified (comment): / 30-09-2011 / 12:15:52 / cg" |
|
430 |
! |
|
431 |
||
432 |
variableReadRewriteHookFor:aVariableNode |
|
433 |
"invoked whenever a variable access node has been generated" |
|
434 |
||
435 |
^ aVariableNode |
|
436 |
||
437 |
"Created: / 30-09-2011 / 12:27:47 / cg" |
|
2357 | 438 |
! ! |
439 |
||
2632 | 440 |
!InstrumentingCompiler methodsFor:'redefinable'! |
2357 | 441 |
|
2632 | 442 |
blockExecutionInfoInstance |
443 |
"one instance is generated for every block, |
|
444 |
and called at execution time with entry:" |
|
2357 | 445 |
|
2632 | 446 |
^ BlockExecutionInfo new cleanInfoWithChange:false. |
447 |
||
448 |
"Created: / 07-08-2011 / 15:13:42 / cg" |
|
2357 | 449 |
! |
450 |
||
2632 | 451 |
methodInvocationInfoInstance |
452 |
"one instance is generated for every method, |
|
453 |
and called at execution time with entry:" |
|
2357 | 454 |
|
2632 | 455 |
^ MethodInvocationInfo new. |
2357 | 456 |
|
2632 | 457 |
"Created: / 07-08-2011 / 15:33:57 / cg" |
458 |
! |
|
2357 | 459 |
|
2632 | 460 |
statementExecutionInfoInstance |
461 |
"one instance is generated for every statement, |
|
462 |
and called at execution time with entry:" |
|
2357 | 463 |
|
2632 | 464 |
^ StatementExecutionInfo new cleanInfoWithChange:false. |
2357 | 465 |
|
2632 | 466 |
"Created: / 07-08-2011 / 15:32:36 / cg" |
2357 | 467 |
! ! |
468 |
||
2715 | 469 |
!InstrumentingCompiler::StatementExecutionInfo class methodsFor:'documentation'! |
470 |
||
471 |
documentation |
|
472 |
" |
|
473 |
(sub)instances of me are updated by instrumented code when statements are executed. |
|
474 |
" |
|
475 |
! ! |
|
476 |
||
2390 | 477 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'accessing'! |
2359 | 478 |
|
479 |
callCount |
|
480 |
^ count |
|
481 |
||
482 |
"Created: / 27-04-2010 / 13:45:15 / cg" |
|
483 |
! |
|
484 |
||
485 |
characterPosition |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
486 |
^ startPosition |
2359 | 487 |
|
488 |
"Created: / 23-06-2006 / 13:31:19 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
489 |
"Modified: / 28-04-2010 / 15:54:24 / cg" |
2359 | 490 |
! |
491 |
||
492 |
characterPosition:something |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
493 |
startPosition := something. |
2359 | 494 |
|
495 |
"Created: / 23-06-2006 / 13:31:19 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
496 |
"Modified: / 28-04-2010 / 15:54:30 / cg" |
2359 | 497 |
! |
498 |
||
499 |
count |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
500 |
"how often have I been called" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
501 |
|
2359 | 502 |
^ count |
503 |
||
504 |
"Created: / 23-06-2006 / 13:31:28 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
505 |
! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
506 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
507 |
startPosition |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
508 |
^ startPosition |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
509 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
510 |
"Created: / 28-04-2010 / 15:54:26 / cg" |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
511 |
! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
512 |
|
2390 | 513 |
startPosition:something |
514 |
startPosition := something. |
|
2359 | 515 |
! ! |
516 |
||
2390 | 517 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'cleanup'! |
2359 | 518 |
|
2571 | 519 |
cleanInfoWithChange:withChange |
2569 | 520 |
count := 0. |
2571 | 521 |
withChange ifTrue:[ |
522 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
523 |
]. |
|
2569 | 524 |
|
2570 | 525 |
"Modified: / 20-07-2011 / 17:55:49 / cg" |
2571 | 526 |
"Created: / 20-07-2011 / 18:59:01 / cg" |
2359 | 527 |
! ! |
528 |
||
2390 | 529 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'instrumentation calls'! |
2359 | 530 |
|
531 |
entry:callingContext |
|
2528
e57cc8caf6f9
dont instrument the instrumentation code
Claus Gittinger <cg@exept.de>
parents:
2391
diff
changeset
|
532 |
"invoked by instrumented code; |
2632 | 533 |
called whenever the block/statment is entered" |
534 |
||
535 |
|context| |
|
2359 | 536 |
|
2632 | 537 |
context := InstrumentationContext current. |
538 |
context isNil ifTrue:[^ self]. |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
539 |
context inInstrumentedCode ifTrue:[^ self]. |
2711 | 540 |
context coverageOnly ifTrue:[ |
541 |
self hasBeenExecuted ifTrue:[^ self]. |
|
542 |
]. |
|
2632 | 543 |
context enabledAndNotInInstrumentedCode ifFalse:[^ self]. |
2528
e57cc8caf6f9
dont instrument the instrumentation code
Claus Gittinger <cg@exept.de>
parents:
2391
diff
changeset
|
544 |
|
2359 | 545 |
count := count + 1. |
546 |
count == 1 ifTrue:[ |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
547 |
"/ the very first time, send a change notification, so the browsers update the coloring |
2632 | 548 |
|
2944 | 549 |
[ |
550 |
context inInstrumentedCode:true. |
|
551 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
552 |
context coverageOnly ifTrue:[ |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
553 |
self changeClassToCoverageAndAlreadyEntered. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
554 |
] ifFalse:[ |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
555 |
self changeClassToAlreadyEntered. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
556 |
]. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
557 |
"/ attention: no self sends here - class has changed!! |
2944 | 558 |
] ensure:[ |
559 |
context inInstrumentedCode:false. |
|
560 |
] |
|
2359 | 561 |
]. |
562 |
||
563 |
"Created: / 23-06-2006 / 13:31:16 / cg" |
|
2711 | 564 |
"Modified: / 23-08-2011 / 21:29:39 / cg" |
2359 | 565 |
! ! |
566 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
567 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'private'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
568 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
569 |
changeClassToAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
570 |
self class == InstrumentingCompiler::StatementExecutionInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
571 |
self changeClassTo: StatementExecutionInfoInAlreadyEnteredState |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
572 |
]. |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
573 |
! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
574 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
575 |
changeClassToCoverageAndAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
576 |
self class == InstrumentingCompiler::StatementExecutionInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
577 |
self changeClassTo: StatementExecutionInfoForCoverageInAlreadyEnteredState |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
578 |
]. |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
579 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
580 |
|
2390 | 581 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'queries'! |
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
582 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
583 |
hasBeenExecuted |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
584 |
^ count > 0 |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
585 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
586 |
"Created: / 28-04-2010 / 14:39:46 / cg" |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
587 |
! ! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
588 |
|
2632 | 589 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'testing'! |
590 |
||
591 |
isStatementExecutionInfo |
|
592 |
^ true |
|
593 |
||
594 |
"Created: / 08-08-2011 / 14:40:51 / cg" |
|
595 |
! ! |
|
596 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
597 |
!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
598 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
599 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
600 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
601 |
self changeClassTo:InstrumentingCompiler::StatementExecutionInfo. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
602 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
603 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
604 |
!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation calls'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
605 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
606 |
entry:callingContext |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
607 |
"already been invoked - nothing to record" |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
608 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
609 |
^ self |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
610 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
611 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
612 |
!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'queries'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
613 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
614 |
hasBeenExecuted |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
615 |
^ true |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
616 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
617 |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
618 |
!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoInAlreadyEnteredState methodsFor:'cleanup'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
619 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
620 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
621 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
622 |
self changeClassTo:InstrumentingCompiler::StatementExecutionInfo. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
623 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
624 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
625 |
!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoInAlreadyEnteredState methodsFor:'instrumentation calls'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
626 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
627 |
entry:callingContext |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
628 |
"already been invoked - no update notifications to browsers" |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
629 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
630 |
count := count + 1. |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
631 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
632 |
|
2357 | 633 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'accessing'! |
634 |
||
635 |
callingMethodsDo:aBlock |
|
636 |
infoPerReceiverClass notNil ifTrue:[ |
|
2949 | 637 |
infoPerReceiverClass ~~ true ifTrue:[ |
638 |
infoPerReceiverClass do:[:each | |
|
639 |
each callingMethodsDo:aBlock |
|
640 |
] |
|
2357 | 641 |
] |
642 |
] |
|
643 |
! |
|
644 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
645 |
count |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
646 |
"how often have I been called" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
647 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
648 |
^ count |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
649 |
! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
650 |
|
2357 | 651 |
hasBeenCalled |
652 |
^ infoPerReceiverClass notEmptyOrNil |
|
653 |
||
654 |
"Created: / 27-04-2010 / 13:43:15 / cg" |
|
655 |
! |
|
656 |
||
2368 | 657 |
invokedViaPerform |
658 |
^ infoPerReceiverClass contains:[:someInfo | someInfo invokedViaPerform]. |
|
659 |
||
660 |
"Created: / 27-04-2010 / 18:21:56 / cg" |
|
661 |
! |
|
662 |
||
2357 | 663 |
invokingMethods |
664 |
|setOfMethods| |
|
665 |
||
666 |
setOfMethods := IdentitySet new. |
|
667 |
self invokingMethodsDo:[:m | setOfMethods add:m]. |
|
668 |
^ setOfMethods. |
|
669 |
! |
|
670 |
||
671 |
invokingMethodsDo:aBlock |
|
672 |
infoPerReceiverClass isNil ifTrue:[ ^ self]. |
|
673 |
^ infoPerReceiverClass do:[:eachInfo | eachInfo invokingMethodsDo:aBlock]. |
|
674 |
! |
|
675 |
||
676 |
numberOfInvocations |
|
677 |
infoPerReceiverClass isNil ifTrue:[ ^ 0]. |
|
2951 | 678 |
infoPerReceiverClass == true ifTrue:[ ^ 0]. |
2357 | 679 |
^ infoPerReceiverClass inject:0 into:[:sumSoFar :info | sumSoFar + info numberOfInvocations] |
680 |
! |
|
681 |
||
682 |
numberOfInvocationsFromExternalOf:aClass |
|
683 |
|sum| |
|
684 |
||
685 |
infoPerReceiverClass isNil ifTrue:[ ^ 0]. |
|
686 |
||
687 |
sum := 0. |
|
688 |
infoPerReceiverClass keysAndValuesDo:[:recClass :info | |
|
689 |
sum := sum + (info numberOfInvocationsFromExternalOf:aClass) |
|
690 |
]. |
|
691 |
^ sum |
|
692 |
! |
|
693 |
||
694 |
numberOfInvocationsFromInternalOf:aClass |
|
695 |
|sum| |
|
696 |
||
697 |
infoPerReceiverClass isNil ifTrue:[ ^ 0]. |
|
698 |
||
699 |
sum := 0. |
|
700 |
infoPerReceiverClass keysAndValuesDo:[:recClass :info | |
|
701 |
sum := sum + (info numberOfInvocationsFromInternalOf:aClass) |
|
702 |
]. |
|
703 |
^ sum |
|
704 |
! ! |
|
705 |
||
706 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'cleanup'! |
|
707 |
||
2571 | 708 |
cleanInfoWithChange:withChange |
2357 | 709 |
infoPerReceiverClass := nil. |
2571 | 710 |
withChange ifTrue:[ |
711 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
712 |
] |
|
2569 | 713 |
|
2570 | 714 |
"Modified: / 20-07-2011 / 17:55:35 / cg" |
2571 | 715 |
"Created: / 20-07-2011 / 18:59:22 / cg" |
2357 | 716 |
! ! |
717 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
718 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'instrumentation calls'! |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
719 |
|
2357 | 720 |
entry:aContext |
721 |
"invoked by instrumented compiled code, upon method entry" |
|
722 |
||
2948 | 723 |
|context receiversClass infoPerReceiver firstEntry coverageOnly| |
2357 | 724 |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
725 |
recursiveEntry == true ifTrue:[ |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
726 |
"/ hurry, get out of here |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
727 |
]. |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
728 |
|
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
729 |
"/ this is a hack - we have to be very careful to avoid recursive |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
730 |
"/ instrumentation entries when instrumenting collection classes!! |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
731 |
"/ Do not change without extensive testing. |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
732 |
recursiveEntry := true. |
2632 | 733 |
context := InstrumentationContext current. |
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
734 |
context isNil ifTrue:[recursiveEntry := false. ^ self]. |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
735 |
context enabledAndNotInInstrumentedCode ifFalse:[recursiveEntry := false. ^ self]. |
2632 | 736 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
737 |
count := (count ? 0) + 1. |
2944 | 738 |
[ |
739 |
context inInstrumentedCode:true. |
|
740 |
||
2875 | 741 |
firstEntry := false. |
742 |
||
2948 | 743 |
(coverageOnly := context coverageOnly) ifTrue:[ |
744 |
"/ only interested in entry, but not in a per-receiver statistics |
|
745 |
"/ that is the normal coverage usage |
|
746 |
infoPerReceiverClass isNil ifTrue:[ |
|
2949 | 747 |
infoPerReceiverClass := true. |
2948 | 748 |
firstEntry := true. |
749 |
]. |
|
750 |
] ifFalse:[ |
|
751 |
"/ interested in a per-receiver statistics (remembering with which receiver-class a method has been invoked). |
|
752 |
"/ that is used by the OOM package |
|
753 |
infoPerReceiverClass isNil ifTrue:[ |
|
754 |
infoPerReceiverClass := IdentityDictionary new. |
|
755 |
firstEntry := true. |
|
756 |
]. |
|
2944 | 757 |
receiversClass := aContext receiver class. |
758 |
infoPerReceiver := infoPerReceiverClass |
|
759 |
at:receiversClass |
|
760 |
ifAbsentPut:[MethodInvocationInfoPerReceiverClass new]. |
|
761 |
infoPerReceiver entry:aContext. |
|
762 |
]. |
|
2569 | 763 |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
764 |
"/ the very first time, send a change notification, so the browsers update the coloring |
2944 | 765 |
firstEntry ifTrue:[ |
766 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
767 |
]. |
|
2948 | 768 |
coverageOnly ifTrue:[ |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
769 |
self changeClassToCoverageAndAlreadyEntered. |
2948 | 770 |
] ifFalse:[ |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
771 |
self changeClassToAlreadyEntered. |
2948 | 772 |
]. |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
773 |
"/ attention: no self sends here - class has changed!! |
2944 | 774 |
] ensure:[ |
775 |
context inInstrumentedCode:false. |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
776 |
recursiveEntry := false. |
2632 | 777 |
]. |
2528
e57cc8caf6f9
dont instrument the instrumentation code
Claus Gittinger <cg@exept.de>
parents:
2391
diff
changeset
|
778 |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
779 |
"Modified (comment): / 26-10-2012 / 12:59:44 / cg" |
2632 | 780 |
! ! |
781 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
782 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'private'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
783 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
784 |
changeClassToAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
785 |
self class == InstrumentingCompiler::MethodInvocationInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
786 |
self changeClassTo: InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
787 |
]. |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
788 |
! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
789 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
790 |
changeClassToCoverageAndAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
791 |
self class == InstrumentingCompiler::MethodInvocationInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
792 |
self changeClassTo: InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
793 |
]. |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
794 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
795 |
|
2632 | 796 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'testing'! |
797 |
||
798 |
isMethodInvocationInfo |
|
799 |
^ true |
|
800 |
||
801 |
"Created: / 08-08-2011 / 14:37:58 / cg" |
|
2357 | 802 |
! ! |
803 |
||
804 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass methodsFor:'accessing'! |
|
805 |
||
806 |
callingMethodsDo:aBlock |
|
807 |
infoPerSendingMethod keysAndValuesDo:[:m :eachInfo | |
|
808 |
aBlock value:m |
|
809 |
] |
|
810 |
! |
|
811 |
||
2368 | 812 |
invokedViaPerform |
813 |
^ infoPerSendingMethod contains:[:someInfo | someInfo invokedViaPerform]. |
|
814 |
||
815 |
"Created: / 27-04-2010 / 18:21:36 / cg" |
|
816 |
! |
|
817 |
||
2357 | 818 |
invokingMethodsDo:aBlock |
819 |
infoPerSendingMethod isNil ifTrue:[ ^ self]. |
|
820 |
^ infoPerSendingMethod keysDo:aBlock. |
|
821 |
! |
|
822 |
||
823 |
numberOfInvocations |
|
824 |
infoPerSendingMethod isNil ifTrue:[ ^ 0]. |
|
825 |
^ infoPerSendingMethod inject:0 into:[:sumSoFar :info | sumSoFar + info numberOfInvocations] |
|
826 |
! |
|
827 |
||
828 |
numberOfInvocationsFromExternalOf:aClass |
|
829 |
|sum| |
|
830 |
||
831 |
infoPerSendingMethod isNil ifTrue:[ ^ 0]. |
|
832 |
||
833 |
sum := 0. |
|
834 |
infoPerSendingMethod keysAndValuesDo:[:sendingMethod :info | |
|
835 |
|sendingMethodsClass| |
|
836 |
||
837 |
sendingMethodsClass := sendingMethod mclass. |
|
838 |
sendingMethodsClass notNil ifTrue:[ |
|
839 |
((sendingMethodsClass isSubclassOf:aClass) |
|
840 |
or:[(aClass isSubclassOf:sendingMethodsClass )]) ifFalse:[ |
|
841 |
sum := sum + (info numberOfInvocations) |
|
842 |
] |
|
843 |
] |
|
844 |
]. |
|
845 |
^ sum |
|
846 |
! |
|
847 |
||
848 |
numberOfInvocationsFromInternalOf:aClass |
|
849 |
|sum| |
|
850 |
||
851 |
infoPerSendingMethod isNil ifTrue:[ ^ 0]. |
|
852 |
||
853 |
sum := 0. |
|
854 |
infoPerSendingMethod keysAndValuesDo:[:sendingMethod :info | |
|
855 |
|sendingMethodsClass| |
|
856 |
||
857 |
sendingMethodsClass := sendingMethod mclass. |
|
858 |
sendingMethodsClass notNil ifTrue:[ |
|
859 |
((sendingMethodsClass isSubclassOf:aClass) |
|
860 |
or:[(aClass isSubclassOf:sendingMethodsClass)]) ifTrue:[ |
|
861 |
sum := sum + (info numberOfInvocations) |
|
862 |
] |
|
863 |
] |
|
864 |
]. |
|
865 |
^ sum |
|
866 |
! ! |
|
867 |
||
868 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass methodsFor:'instrumentation calls'! |
|
869 |
||
870 |
entry:aContext |
|
871 |
"invoked by instrumented compiled code, upon method entry" |
|
872 |
||
2368 | 873 |
|sender sendingMethod infoPerMethod viaPerform| |
2357 | 874 |
|
2391 | 875 |
aContext selector == #doesNotUnderstand: ifTrue:[ |
876 |
sender := aContext sender sender methodHome. |
|
877 |
] ifFalse:[ |
|
878 |
sender := aContext sender methodHome. |
|
879 |
]. |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
880 |
sender isNil ifTrue:[ |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
881 |
^ self. |
2569 | 882 |
]. |
883 |
sendingMethod := sender method. |
|
884 |
sendingMethod isNil ifTrue:[^ self]. |
|
2391 | 885 |
|
2569 | 886 |
viaPerform := false. |
887 |
(sendingMethod mclass == Object |
|
888 |
and:[ sendingMethod selector startsWith:'perform:'] ) ifTrue:[ |
|
889 |
"/ Transcript showCR:('%1 [info]: skipping #perform' bindWith:self class nameWithoutPrefix). |
|
890 |
sender := sender sender methodHome. |
|
891 |
sendingMethod := sender method. |
|
892 |
viaPerform := true. |
|
2357 | 893 |
]. |
894 |
||
895 |
infoPerSendingMethod isNil ifTrue:[ |
|
896 |
infoPerSendingMethod := IdentityDictionary new. |
|
897 |
]. |
|
898 |
infoPerMethod := infoPerSendingMethod |
|
899 |
at:sendingMethod |
|
900 |
ifAbsentPut:[ MethodInvocationInfoPerSendingMethod new ]. |
|
901 |
||
2368 | 902 |
infoPerMethod entry:aContext viaPerform:viaPerform |
903 |
||
2569 | 904 |
"Modified: / 20-07-2011 / 17:26:31 / cg" |
2357 | 905 |
! ! |
906 |
||
907 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass::MethodInvocationInfoPerSendingMethod methodsFor:'accessing'! |
|
908 |
||
2368 | 909 |
invokedViaPerform |
910 |
^ invokedViaPerform ? false |
|
911 |
||
912 |
"Created: / 27-04-2010 / 18:20:05 / cg" |
|
913 |
! |
|
914 |
||
2357 | 915 |
numberOfInvocations |
916 |
countPerSendersClass isNil ifTrue:[ ^ 0]. |
|
917 |
^ countPerSendersClass inject:0 into:[:sumSoFar :count | sumSoFar + count] |
|
918 |
! ! |
|
919 |
||
920 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass::MethodInvocationInfoPerSendingMethod methodsFor:'instrumentation calls'! |
|
921 |
||
2368 | 922 |
entry:aContext viaPerform:viaPerformBoolean |
2357 | 923 |
"invoked by instrumented compiled code, upon method entry" |
924 |
||
925 |
|sendersClass count| |
|
926 |
||
927 |
sendersClass := aContext sender receiver class. |
|
928 |
||
929 |
countPerSendersClass isNil ifTrue:[ |
|
930 |
countPerSendersClass := IdentityDictionary new. |
|
931 |
]. |
|
932 |
count := countPerSendersClass at:sendersClass ifAbsentPut:0. |
|
2368 | 933 |
countPerSendersClass at:sendersClass put:(count + 1). |
934 |
viaPerformBoolean ifTrue:[ invokedViaPerform := true ]. |
|
935 |
||
936 |
"Created: / 27-04-2010 / 18:17:27 / cg" |
|
2357 | 937 |
! ! |
938 |
||
2948 | 939 |
!InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'! |
940 |
||
941 |
cleanInfoWithChange:withChange |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
942 |
super cleanInfoWithChange:withChange. |
2948 | 943 |
self changeClassTo:InstrumentingCompiler::MethodInvocationInfo. |
944 |
! ! |
|
945 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
946 |
!InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation calls'! |
2948 | 947 |
|
948 |
entry:aContext |
|
949 |
"already been invoked - nothing to record" |
|
950 |
||
951 |
^ self |
|
952 |
! ! |
|
953 |
||
2711 | 954 |
!InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState methodsFor:'cleanup'! |
955 |
||
956 |
cleanInfoWithChange:withChange |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
957 |
super cleanInfoWithChange:withChange. |
2711 | 958 |
self changeClassTo:InstrumentingCompiler::MethodInvocationInfo. |
959 |
||
960 |
"Modified: / 20-07-2011 / 17:55:35 / cg" |
|
961 |
"Created: / 24-08-2011 / 11:10:29 / cg" |
|
962 |
! ! |
|
963 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
964 |
!InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState methodsFor:'instrumentation calls'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
965 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
966 |
entry:aContext |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
967 |
"already been invoked - no notifications to send" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
968 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
969 |
count := count + 1 |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
970 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
971 |
|
2715 | 972 |
!InstrumentingCompiler::VariableAccessExecutionInfo class methodsFor:'documentation'! |
973 |
||
974 |
documentation |
|
975 |
" |
|
976 |
(sub)instances of me are updated by instrumented code when a variable is accessed |
|
977 |
" |
|
978 |
! ! |
|
979 |
||
980 |
!InstrumentingCompiler::BlockExecutionInfo class methodsFor:'documentation'! |
|
981 |
||
982 |
documentation |
|
983 |
" |
|
984 |
(sub)instances of me are updated by instrumented code when a block is executed. |
|
985 |
" |
|
986 |
! ! |
|
987 |
||
2390 | 988 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'accessing'! |
989 |
||
990 |
endPosition |
|
991 |
^ endPosition |
|
992 |
||
993 |
"Created: / 28-04-2010 / 15:57:14 / cg" |
|
994 |
! |
|
995 |
||
996 |
startPosition:startArg endPosition:endArg |
|
997 |
startPosition := startArg. |
|
998 |
endPosition := endArg. |
|
999 |
||
1000 |
"Created: / 28-04-2010 / 15:54:47 / cg" |
|
1001 |
! ! |
|
1002 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1003 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'entry'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1004 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1005 |
changeClassToAlreadyEntered |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1006 |
self class == InstrumentingCompiler::BlockExecutionInfo ifTrue:[ |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1007 |
self changeClassTo: BlockExecutionInfoInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1008 |
]. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1009 |
! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1010 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1011 |
changeClassToCoverageAndAlreadyEntered |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1012 |
self class == InstrumentingCompiler::BlockExecutionInfo ifTrue:[ |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1013 |
self changeClassTo: BlockExecutionInfoForCoverageInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1014 |
]. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1015 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1016 |
|
2675
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1017 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'printing'! |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1018 |
|
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1019 |
printOn:aStream |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1020 |
aStream nextPutAll:'['. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1021 |
startPosition printOn:aStream. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1022 |
aStream nextPutAll:'...'. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1023 |
endPosition printOn:aStream. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1024 |
aStream nextPutAll:']'. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1025 |
|
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1026 |
"Created: / 21-08-2011 / 14:02:01 / cg" |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1027 |
! ! |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1028 |
|
2632 | 1029 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'testing'! |
1030 |
||
1031 |
isBlockExecutionInfo |
|
1032 |
^ true |
|
1033 |
||
1034 |
"Created: / 07-08-2011 / 17:06:39 / cg" |
|
1035 |
! ! |
|
1036 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1037 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1038 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1039 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1040 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1041 |
self changeClassTo:InstrumentingCompiler::BlockExecutionInfo. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1042 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1043 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1044 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation probe calls'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1045 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1046 |
entry:callingContext |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1047 |
"already been invoked - nothing to do" |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1048 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1049 |
^ self |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1050 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1051 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1052 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'queries'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1053 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1054 |
hasBeenExecuted |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1055 |
^ true |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1056 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1057 |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1058 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoInAlreadyEnteredState methodsFor:'cleanup'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1059 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1060 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1061 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1062 |
self changeClassTo:InstrumentingCompiler::BlockExecutionInfo. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1063 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1064 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1065 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoInAlreadyEnteredState methodsFor:'instrumentation probe calls'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1066 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1067 |
entry:callingContext |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1068 |
"already been invoked - no update notification for browsers" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1069 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1070 |
count := count + 1. |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1071 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1072 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1073 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoInAlreadyEnteredState methodsFor:'queries'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1074 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1075 |
hasBeenExecuted |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1076 |
^ true |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1077 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1078 |
|
2715 | 1079 |
!InstrumentingCompiler::ReadAccessExecutionInfo class methodsFor:'documentation'! |
1080 |
||
1081 |
documentation |
|
1082 |
" |
|
1083 |
(sub)instances of me are updated by instrumented code when a variable is read |
|
1084 |
" |
|
1085 |
! ! |
|
1086 |
||
1087 |
!InstrumentingCompiler::WriteAccessExecutionInfo class methodsFor:'documentation'! |
|
1088 |
||
1089 |
documentation |
|
1090 |
" |
|
1091 |
(sub)instances of me are updated by instrumented code when a variable is written |
|
1092 |
" |
|
1093 |
! ! |
|
1094 |
||
2357 | 1095 |
!InstrumentingCompiler class methodsFor:'documentation'! |
1096 |
||
2570 | 1097 |
version |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1098 |
^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.28 2012-11-07 22:18:08 cg Exp $' |
2570 | 1099 |
! |
1100 |
||
2357 | 1101 |
version_CVS |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1102 |
^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.28 2012-11-07 22:18:08 cg Exp $' |
2357 | 1103 |
! ! |