author | Stefan Vogel <sv@exept.de> |
Wed, 19 Jun 2013 08:37:27 +0200 | |
changeset 3192 | 4a3a9fa54b94 |
parent 2981 | f82dd89f0459 |
child 3237 | a6b2f875bcc3 |
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 |
|
3192 | 224 |
<resource: #obsolete> |
2357 | 225 |
self obsoleteMethodWarning:'please use method>>methodInvocationInfo'. |
226 |
^ aMethod methodInvocationInfo |
|
227 |
||
228 |
" |
|
229 |
self methodInfoOf:aMethod |
|
230 |
" |
|
231 |
||
232 |
"Created: / 27-04-2010 / 12:28:56 / cg" |
|
233 |
"Modified: / 27-04-2010 / 13:34:36 / cg" |
|
234 |
! ! |
|
235 |
||
236 |
!InstrumentingCompiler methodsFor:'code generation helpers'! |
|
237 |
||
238 |
addBlockCounterTo:aBlockNode |
|
2951 | 239 |
"called by the compiler to instrument a block node" |
240 |
||
2357 | 241 |
|countCode blockEntryInfo| |
242 |
||
243 |
blockInvocationInfo isNil ifTrue:[ |
|
244 |
blockInvocationInfo := OrderedCollection new. |
|
245 |
]. |
|
2632 | 246 |
blockEntryInfo := self blockExecutionInfoInstance. |
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
247 |
blockEntryInfo startPosition:aBlockNode startPosition endPosition:aBlockNode endPosition. |
2675
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
248 |
"/ Transcript show:aBlockNode startPosition; |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
249 |
"/ show:' -> '; |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
250 |
"/ showCR: aBlockNode endPosition. |
2357 | 251 |
blockInvocationInfo add:blockEntryInfo. |
252 |
||
253 |
countCode := |
|
254 |
StatementNode |
|
255 |
expression:(MessageNode |
|
256 |
receiver:(ConstantNode value:blockEntryInfo) |
|
257 |
selector:#entry: |
|
258 |
arg:(VariableNode type:#ThisContext context:contextToEvaluateIn)). |
|
259 |
||
260 |
aBlockNode isEmptyBlock ifTrue:[ |
|
261 |
"/ q: are we interested in empty blocks ? |
|
2665
2071b01a050f
changed: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2635
diff
changeset
|
262 |
countCode nextStatement:(StatementNode expression:(ConstantNode value:nil)). |
2357 | 263 |
aBlockNode statements:countCode. |
264 |
] ifFalse:[ |
|
265 |
countCode nextStatement:aBlockNode statements. |
|
266 |
aBlockNode statements:countCode. |
|
267 |
]. |
|
268 |
||
2675
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
269 |
"Modified: / 21-08-2011 / 16:02:52 / cg" |
2357 | 270 |
! |
271 |
||
272 |
addBlockCountersToEachBlockIn:aCollection |
|
2951 | 273 |
"called by the compiler to instrument a collection of block nodes" |
274 |
||
2357 | 275 |
aCollection do:[:eachNode | |
276 |
eachNode isBlockNode ifTrue:[ |
|
277 |
self addBlockCounterTo:eachNode |
|
278 |
] |
|
279 |
]. |
|
280 |
||
281 |
"Created: / 27-04-2010 / 11:47:56 / cg" |
|
282 |
! |
|
283 |
||
284 |
createMethod |
|
2951 | 285 |
"called by the compiler to instatiate a new method instance" |
286 |
||
2357 | 287 |
method := super createMethod. |
288 |
||
289 |
methodEntryInfo notNil ifTrue:[ |
|
290 |
methodEntryInfo owningMethod:method |
|
291 |
]. |
|
292 |
blockInvocationInfo notNil ifTrue:[ |
|
293 |
blockInvocationInfo do:[:eachInfo | eachInfo owningMethod:method] |
|
294 |
]. |
|
295 |
||
296 |
^ method |
|
297 |
||
298 |
"Modified: / 27-04-2010 / 14:04:50 / cg" |
|
299 |
! |
|
300 |
||
301 |
methodClass |
|
2951 | 302 |
"called by the compiler to ask for the method instance's class" |
303 |
||
2357 | 304 |
^ InstrumentedMethod |
305 |
||
306 |
"Created: / 27-04-2010 / 12:17:22 / cg" |
|
2390 | 307 |
! |
308 |
||
309 |
statementCounterBefore:aStatementNode |
|
2951 | 310 |
"called by the compiler to instrument a statement node (head of a basic block)" |
311 |
||
2390 | 312 |
|countCode statementEntryInfo| |
313 |
||
314 |
blockInvocationInfo isNil ifTrue:[ |
|
315 |
blockInvocationInfo := OrderedCollection new. |
|
316 |
]. |
|
2632 | 317 |
statementEntryInfo := self statementExecutionInfoInstance. |
2390 | 318 |
statementEntryInfo startPosition:aStatementNode startPosition. |
319 |
blockInvocationInfo add:statementEntryInfo. |
|
320 |
||
321 |
countCode := |
|
322 |
StatementNode |
|
323 |
expression:(MessageNode |
|
324 |
receiver:(ConstantNode value:statementEntryInfo) |
|
325 |
selector:#entry: |
|
326 |
arg:(VariableNode type:#ThisContext context:contextToEvaluateIn)). |
|
327 |
||
328 |
countCode nextStatement:aStatementNode. |
|
329 |
^ countCode |
|
2571 | 330 |
|
2632 | 331 |
"Modified: / 07-08-2011 / 15:32:45 / cg" |
2357 | 332 |
! ! |
333 |
||
2715 | 334 |
!InstrumentingCompiler methodsFor:'code generation hooks'! |
335 |
||
336 |
assignmentRewriteHookFor:anAssignmentNode |
|
337 |
"invoked whenever an assignment node has been generated" |
|
338 |
||
339 |
^ anAssignmentNode |
|
340 |
||
341 |
"Created: / 30-09-2011 / 12:28:09 / cg" |
|
342 |
! |
|
2357 | 343 |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
344 |
blockNodeRewriteHookFor:aBlockNode |
2715 | 345 |
"invoked whenever a block node has been generated" |
346 |
||
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
347 |
"/ add a counter for the block |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
348 |
self addBlockCounterTo:aBlockNode. |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
349 |
^ aBlockNode |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
350 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
351 |
"Created: / 28-04-2010 / 14:21:27 / cg" |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
352 |
! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
353 |
|
2357 | 354 |
messageNodeRewriteHookFor:aMessageNode |
2715 | 355 |
"invoked whenever a message send node has been generated" |
356 |
||
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
357 |
"/ see blockNodeRewriter... |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
358 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
359 |
"/ "/ argument could be a constantNode (due to contant-folding optimization) |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
360 |
"/ aMessageNode isConstant ifTrue:[^ aMessageNode]. |
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 |
"/ #( |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
363 |
"/ ifTrue: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
364 |
"/ ifFalse: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
365 |
"/ ifTrue:ifFalse: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
366 |
"/ ifFalse:ifTrue: |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
367 |
"/ ) |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
368 |
"/ includes:aMessageNode selector |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
369 |
"/ ) ifTrue:[ |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
370 |
"/ "/ add a counter for the block |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
371 |
"/ self addBlockCountersToEachBlockIn:(aMessageNode arguments) |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
372 |
"/ ]. |
2357 | 373 |
^ aMessageNode |
374 |
||
375 |
"Created: / 27-04-2010 / 11:43:22 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
376 |
"Modified: / 28-04-2010 / 14:22:05 / cg" |
2715 | 377 |
"Modified (comment): / 30-09-2011 / 12:16:56 / cg" |
2357 | 378 |
! |
379 |
||
380 |
startCodeGenerationHookOn:codeStream |
|
2715 | 381 |
"invoked before code is generated" |
382 |
||
2632 | 383 |
methodEntryInfo := self methodInvocationInfoInstance. |
2357 | 384 |
|
385 |
(StatementNode |
|
386 |
expression:(MessageNode |
|
387 |
receiver:(ConstantNode value:methodEntryInfo) |
|
388 |
selector:#entry: |
|
389 |
arg:(VariableNode type:#ThisContext context:contextToEvaluateIn))) |
|
390 |
codeForSideEffectOn:codeStream inBlock:nil for:self. |
|
391 |
||
2632 | 392 |
"Modified: / 07-08-2011 / 15:34:09 / cg" |
2715 | 393 |
"Modified (comment): / 30-09-2011 / 12:16:05 / cg" |
2390 | 394 |
! |
395 |
||
396 |
statementListRewriteHookFor:firstStatement |
|
2715 | 397 |
"invoked whenever a statement list node has been generated" |
398 |
||
2390 | 399 |
"/ care for blocks which return... |
400 |
|thisStatement prevStatement countStatement mustInsertExecutionInfo| |
|
401 |
||
402 |
mustInsertExecutionInfo := false. |
|
403 |
prevStatement := nil. |
|
404 |
||
405 |
thisStatement := firstStatement. |
|
406 |
thisStatement isNil ifTrue:[^ firstStatement]. |
|
407 |
||
408 |
[true] whileTrue:[ |
|
409 |
mustInsertExecutionInfo ifTrue:[ |
|
410 |
"/ prev-stat had a return in it (a block with a return); |
|
411 |
"/ insert a statement-entry here. |
|
412 |
thisStatement notNil ifTrue:[ |
|
413 |
countStatement := self statementCounterBefore:thisStatement. |
|
414 |
prevStatement nextStatement:countStatement. |
|
415 |
mustInsertExecutionInfo := false. |
|
416 |
prevStatement := countStatement. |
|
417 |
] |
|
418 |
]. |
|
419 |
thisStatement isNil ifTrue:[^ firstStatement]. |
|
420 |
||
421 |
thisStatement isReturnNode ifFalse:[ |
|
422 |
thisStatement containsReturn ifTrue:[ |
|
423 |
mustInsertExecutionInfo := true |
|
424 |
] |
|
425 |
]. |
|
426 |
prevStatement := thisStatement. |
|
427 |
thisStatement := thisStatement nextStatement. |
|
428 |
]. |
|
2715 | 429 |
|
430 |
"Modified (comment): / 30-09-2011 / 12:15:52 / cg" |
|
431 |
! |
|
432 |
||
433 |
variableReadRewriteHookFor:aVariableNode |
|
434 |
"invoked whenever a variable access node has been generated" |
|
435 |
||
436 |
^ aVariableNode |
|
437 |
||
438 |
"Created: / 30-09-2011 / 12:27:47 / cg" |
|
2357 | 439 |
! ! |
440 |
||
2632 | 441 |
!InstrumentingCompiler methodsFor:'redefinable'! |
2357 | 442 |
|
2632 | 443 |
blockExecutionInfoInstance |
444 |
"one instance is generated for every block, |
|
445 |
and called at execution time with entry:" |
|
2357 | 446 |
|
2632 | 447 |
^ BlockExecutionInfo new cleanInfoWithChange:false. |
448 |
||
449 |
"Created: / 07-08-2011 / 15:13:42 / cg" |
|
2357 | 450 |
! |
451 |
||
2632 | 452 |
methodInvocationInfoInstance |
453 |
"one instance is generated for every method, |
|
454 |
and called at execution time with entry:" |
|
2357 | 455 |
|
2632 | 456 |
^ MethodInvocationInfo new. |
2357 | 457 |
|
2632 | 458 |
"Created: / 07-08-2011 / 15:33:57 / cg" |
459 |
! |
|
2357 | 460 |
|
2632 | 461 |
statementExecutionInfoInstance |
462 |
"one instance is generated for every statement, |
|
463 |
and called at execution time with entry:" |
|
2357 | 464 |
|
2632 | 465 |
^ StatementExecutionInfo new cleanInfoWithChange:false. |
2357 | 466 |
|
2632 | 467 |
"Created: / 07-08-2011 / 15:32:36 / cg" |
2357 | 468 |
! ! |
469 |
||
2715 | 470 |
!InstrumentingCompiler::StatementExecutionInfo class methodsFor:'documentation'! |
471 |
||
472 |
documentation |
|
473 |
" |
|
474 |
(sub)instances of me are updated by instrumented code when statements are executed. |
|
475 |
" |
|
476 |
! ! |
|
477 |
||
2390 | 478 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'accessing'! |
2359 | 479 |
|
480 |
callCount |
|
481 |
^ count |
|
482 |
||
483 |
"Created: / 27-04-2010 / 13:45:15 / cg" |
|
484 |
! |
|
485 |
||
486 |
characterPosition |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
487 |
^ startPosition |
2359 | 488 |
|
489 |
"Created: / 23-06-2006 / 13:31:19 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
490 |
"Modified: / 28-04-2010 / 15:54:24 / cg" |
2359 | 491 |
! |
492 |
||
493 |
characterPosition:something |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
494 |
startPosition := something. |
2359 | 495 |
|
496 |
"Created: / 23-06-2006 / 13:31:19 / cg" |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
497 |
"Modified: / 28-04-2010 / 15:54:30 / cg" |
2359 | 498 |
! |
499 |
||
500 |
count |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
501 |
"how often have I been called" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
502 |
|
2981 | 503 |
^ count ? 0 |
2359 | 504 |
|
505 |
"Created: / 23-06-2006 / 13:31:28 / cg" |
|
2370
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 |
|
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 |
^ startPosition |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
510 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
511 |
"Created: / 28-04-2010 / 15:54:26 / cg" |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
512 |
! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
513 |
|
2390 | 514 |
startPosition:something |
515 |
startPosition := something. |
|
2359 | 516 |
! ! |
517 |
||
2390 | 518 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'cleanup'! |
2359 | 519 |
|
2571 | 520 |
cleanInfoWithChange:withChange |
2569 | 521 |
count := 0. |
2571 | 522 |
withChange ifTrue:[ |
523 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
524 |
]. |
|
2569 | 525 |
|
2570 | 526 |
"Modified: / 20-07-2011 / 17:55:49 / cg" |
2571 | 527 |
"Created: / 20-07-2011 / 18:59:01 / cg" |
2359 | 528 |
! ! |
529 |
||
2390 | 530 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'instrumentation calls'! |
2359 | 531 |
|
532 |
entry:callingContext |
|
2528
e57cc8caf6f9
dont instrument the instrumentation code
Claus Gittinger <cg@exept.de>
parents:
2391
diff
changeset
|
533 |
"invoked by instrumented code; |
2632 | 534 |
called whenever the block/statment is entered" |
535 |
||
536 |
|context| |
|
2359 | 537 |
|
2632 | 538 |
context := InstrumentationContext current. |
539 |
context isNil ifTrue:[^ self]. |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
540 |
context inInstrumentedCode ifTrue:[^ self]. |
2711 | 541 |
context coverageOnly ifTrue:[ |
542 |
self hasBeenExecuted ifTrue:[^ self]. |
|
543 |
]. |
|
2632 | 544 |
context enabledAndNotInInstrumentedCode ifFalse:[^ self]. |
2528
e57cc8caf6f9
dont instrument the instrumentation code
Claus Gittinger <cg@exept.de>
parents:
2391
diff
changeset
|
545 |
|
2359 | 546 |
count := count + 1. |
547 |
count == 1 ifTrue:[ |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
548 |
"/ the very first time, send a change notification, so the browsers update the coloring |
2632 | 549 |
|
2944 | 550 |
[ |
551 |
context inInstrumentedCode:true. |
|
552 |
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
|
553 |
context coverageOnly ifTrue:[ |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
554 |
self changeClassToCoverageAndAlreadyEntered. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
555 |
] ifFalse:[ |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
556 |
self changeClassToAlreadyEntered. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
557 |
]. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
558 |
"/ attention: no self sends here - class has changed!! |
2944 | 559 |
] ensure:[ |
560 |
context inInstrumentedCode:false. |
|
561 |
] |
|
2359 | 562 |
]. |
563 |
||
564 |
"Created: / 23-06-2006 / 13:31:16 / cg" |
|
2711 | 565 |
"Modified: / 23-08-2011 / 21:29:39 / cg" |
2359 | 566 |
! ! |
567 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
568 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'private'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
569 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
570 |
changeClassToAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
571 |
self class == InstrumentingCompiler::StatementExecutionInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
572 |
self changeClassTo: StatementExecutionInfoInAlreadyEnteredState |
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 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
576 |
changeClassToCoverageAndAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
577 |
self class == InstrumentingCompiler::StatementExecutionInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
578 |
self changeClassTo: StatementExecutionInfoForCoverageInAlreadyEnteredState |
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 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
581 |
|
2390 | 582 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'queries'! |
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
583 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
584 |
hasBeenExecuted |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
585 |
^ count > 0 |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
586 |
|
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
587 |
"Created: / 28-04-2010 / 14:39:46 / cg" |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
588 |
! ! |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
589 |
|
2632 | 590 |
!InstrumentingCompiler::StatementExecutionInfo methodsFor:'testing'! |
591 |
||
592 |
isStatementExecutionInfo |
|
593 |
^ true |
|
594 |
||
595 |
"Created: / 08-08-2011 / 14:40:51 / cg" |
|
596 |
! ! |
|
597 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
598 |
!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
|
599 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
600 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
601 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
602 |
self changeClassTo:InstrumentingCompiler::StatementExecutionInfo. |
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 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
605 |
!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
|
606 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
607 |
entry:callingContext |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
608 |
"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
|
609 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
610 |
^ self |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
611 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
612 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
613 |
!InstrumentingCompiler::StatementExecutionInfo::StatementExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'queries'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
614 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
615 |
hasBeenExecuted |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
616 |
^ true |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
617 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
618 |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
619 |
!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
|
620 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
621 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
622 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
623 |
self changeClassTo:InstrumentingCompiler::StatementExecutionInfo. |
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 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
626 |
!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
|
627 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
628 |
entry:callingContext |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
629 |
"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
|
630 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
631 |
count := count + 1. |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
632 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
633 |
|
2357 | 634 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'accessing'! |
635 |
||
636 |
callingMethodsDo:aBlock |
|
637 |
infoPerReceiverClass notNil ifTrue:[ |
|
2949 | 638 |
infoPerReceiverClass ~~ true ifTrue:[ |
639 |
infoPerReceiverClass do:[:each | |
|
640 |
each callingMethodsDo:aBlock |
|
641 |
] |
|
2357 | 642 |
] |
643 |
] |
|
644 |
! |
|
645 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
646 |
count |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
647 |
"how often have I been called" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
648 |
|
2981 | 649 |
^ count ? 0 |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
650 |
! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
651 |
|
2357 | 652 |
hasBeenCalled |
653 |
^ infoPerReceiverClass notEmptyOrNil |
|
654 |
||
655 |
"Created: / 27-04-2010 / 13:43:15 / cg" |
|
656 |
! |
|
657 |
||
2368 | 658 |
invokedViaPerform |
659 |
^ infoPerReceiverClass contains:[:someInfo | someInfo invokedViaPerform]. |
|
660 |
||
661 |
"Created: / 27-04-2010 / 18:21:56 / cg" |
|
662 |
! |
|
663 |
||
2357 | 664 |
invokingMethods |
665 |
|setOfMethods| |
|
666 |
||
667 |
setOfMethods := IdentitySet new. |
|
668 |
self invokingMethodsDo:[:m | setOfMethods add:m]. |
|
669 |
^ setOfMethods. |
|
670 |
! |
|
671 |
||
672 |
invokingMethodsDo:aBlock |
|
673 |
infoPerReceiverClass isNil ifTrue:[ ^ self]. |
|
674 |
^ infoPerReceiverClass do:[:eachInfo | eachInfo invokingMethodsDo:aBlock]. |
|
675 |
! |
|
676 |
||
677 |
numberOfInvocations |
|
678 |
infoPerReceiverClass isNil ifTrue:[ ^ 0]. |
|
2951 | 679 |
infoPerReceiverClass == true ifTrue:[ ^ 0]. |
2357 | 680 |
^ infoPerReceiverClass inject:0 into:[:sumSoFar :info | sumSoFar + info numberOfInvocations] |
681 |
! |
|
682 |
||
683 |
numberOfInvocationsFromExternalOf:aClass |
|
684 |
|sum| |
|
685 |
||
686 |
infoPerReceiverClass isNil ifTrue:[ ^ 0]. |
|
687 |
||
688 |
sum := 0. |
|
689 |
infoPerReceiverClass keysAndValuesDo:[:recClass :info | |
|
690 |
sum := sum + (info numberOfInvocationsFromExternalOf:aClass) |
|
691 |
]. |
|
692 |
^ sum |
|
693 |
! |
|
694 |
||
695 |
numberOfInvocationsFromInternalOf:aClass |
|
696 |
|sum| |
|
697 |
||
698 |
infoPerReceiverClass isNil ifTrue:[ ^ 0]. |
|
699 |
||
700 |
sum := 0. |
|
701 |
infoPerReceiverClass keysAndValuesDo:[:recClass :info | |
|
702 |
sum := sum + (info numberOfInvocationsFromInternalOf:aClass) |
|
703 |
]. |
|
704 |
^ sum |
|
705 |
! ! |
|
706 |
||
707 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'cleanup'! |
|
708 |
||
2571 | 709 |
cleanInfoWithChange:withChange |
2357 | 710 |
infoPerReceiverClass := nil. |
2571 | 711 |
withChange ifTrue:[ |
712 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
713 |
] |
|
2569 | 714 |
|
2570 | 715 |
"Modified: / 20-07-2011 / 17:55:35 / cg" |
2571 | 716 |
"Created: / 20-07-2011 / 18:59:22 / cg" |
2357 | 717 |
! ! |
718 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
719 |
!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
|
720 |
|
2357 | 721 |
entry:aContext |
722 |
"invoked by instrumented compiled code, upon method entry" |
|
723 |
||
2948 | 724 |
|context receiversClass infoPerReceiver firstEntry coverageOnly| |
2357 | 725 |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
726 |
recursiveEntry == true ifTrue:[ |
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
727 |
"/ hurry, get out of here |
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 |
|
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
730 |
"/ 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
|
731 |
"/ 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
|
732 |
"/ 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
|
733 |
recursiveEntry := true. |
2632 | 734 |
context := InstrumentationContext current. |
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
735 |
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
|
736 |
context enabledAndNotInInstrumentedCode ifFalse:[recursiveEntry := false. ^ self]. |
2632 | 737 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
738 |
count := (count ? 0) + 1. |
2944 | 739 |
[ |
740 |
context inInstrumentedCode:true. |
|
741 |
||
2875 | 742 |
firstEntry := false. |
743 |
||
2948 | 744 |
(coverageOnly := context coverageOnly) ifTrue:[ |
745 |
"/ only interested in entry, but not in a per-receiver statistics |
|
746 |
"/ that is the normal coverage usage |
|
747 |
infoPerReceiverClass isNil ifTrue:[ |
|
2949 | 748 |
infoPerReceiverClass := true. |
2948 | 749 |
firstEntry := true. |
750 |
]. |
|
751 |
] ifFalse:[ |
|
752 |
"/ interested in a per-receiver statistics (remembering with which receiver-class a method has been invoked). |
|
753 |
"/ that is used by the OOM package |
|
754 |
infoPerReceiverClass isNil ifTrue:[ |
|
755 |
infoPerReceiverClass := IdentityDictionary new. |
|
756 |
firstEntry := true. |
|
757 |
]. |
|
2944 | 758 |
receiversClass := aContext receiver class. |
759 |
infoPerReceiver := infoPerReceiverClass |
|
760 |
at:receiversClass |
|
761 |
ifAbsentPut:[MethodInvocationInfoPerReceiverClass new]. |
|
762 |
infoPerReceiver entry:aContext. |
|
763 |
]. |
|
2569 | 764 |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
765 |
"/ the very first time, send a change notification, so the browsers update the coloring |
2944 | 766 |
firstEntry ifTrue:[ |
767 |
Smalltalk changed:#methodCoverageInfo with:owningMethod. |
|
768 |
]. |
|
2948 | 769 |
coverageOnly ifTrue:[ |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
770 |
self changeClassToCoverageAndAlreadyEntered. |
2948 | 771 |
] ifFalse:[ |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
772 |
self changeClassToAlreadyEntered. |
2948 | 773 |
]. |
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
774 |
"/ attention: no self sends here - class has changed!! |
2944 | 775 |
] ensure:[ |
776 |
context inInstrumentedCode:false. |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
777 |
recursiveEntry := false. |
2632 | 778 |
]. |
2528
e57cc8caf6f9
dont instrument the instrumentation code
Claus Gittinger <cg@exept.de>
parents:
2391
diff
changeset
|
779 |
|
2960
8adc66fe55fb
care for recursive entry (instrumenting code which is needed
Claus Gittinger <cg@exept.de>
parents:
2958
diff
changeset
|
780 |
"Modified (comment): / 26-10-2012 / 12:59:44 / cg" |
2632 | 781 |
! ! |
782 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
783 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'private'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
784 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
785 |
changeClassToAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
786 |
self class == InstrumentingCompiler::MethodInvocationInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
787 |
self changeClassTo: InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState |
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 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
791 |
changeClassToCoverageAndAlreadyEntered |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
792 |
self class == InstrumentingCompiler::MethodInvocationInfo ifTrue:[ |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
793 |
self changeClassTo: InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState |
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 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
796 |
|
2632 | 797 |
!InstrumentingCompiler::MethodInvocationInfo methodsFor:'testing'! |
798 |
||
799 |
isMethodInvocationInfo |
|
800 |
^ true |
|
801 |
||
802 |
"Created: / 08-08-2011 / 14:37:58 / cg" |
|
2357 | 803 |
! ! |
804 |
||
805 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass methodsFor:'accessing'! |
|
806 |
||
807 |
callingMethodsDo:aBlock |
|
808 |
infoPerSendingMethod keysAndValuesDo:[:m :eachInfo | |
|
809 |
aBlock value:m |
|
810 |
] |
|
811 |
! |
|
812 |
||
2368 | 813 |
invokedViaPerform |
814 |
^ infoPerSendingMethod contains:[:someInfo | someInfo invokedViaPerform]. |
|
815 |
||
816 |
"Created: / 27-04-2010 / 18:21:36 / cg" |
|
817 |
! |
|
818 |
||
2357 | 819 |
invokingMethodsDo:aBlock |
820 |
infoPerSendingMethod isNil ifTrue:[ ^ self]. |
|
821 |
^ infoPerSendingMethod keysDo:aBlock. |
|
822 |
! |
|
823 |
||
824 |
numberOfInvocations |
|
825 |
infoPerSendingMethod isNil ifTrue:[ ^ 0]. |
|
826 |
^ infoPerSendingMethod inject:0 into:[:sumSoFar :info | sumSoFar + info numberOfInvocations] |
|
827 |
! |
|
828 |
||
829 |
numberOfInvocationsFromExternalOf:aClass |
|
830 |
|sum| |
|
831 |
||
832 |
infoPerSendingMethod isNil ifTrue:[ ^ 0]. |
|
833 |
||
834 |
sum := 0. |
|
835 |
infoPerSendingMethod keysAndValuesDo:[:sendingMethod :info | |
|
836 |
|sendingMethodsClass| |
|
837 |
||
838 |
sendingMethodsClass := sendingMethod mclass. |
|
839 |
sendingMethodsClass notNil ifTrue:[ |
|
840 |
((sendingMethodsClass isSubclassOf:aClass) |
|
841 |
or:[(aClass isSubclassOf:sendingMethodsClass )]) ifFalse:[ |
|
842 |
sum := sum + (info numberOfInvocations) |
|
843 |
] |
|
844 |
] |
|
845 |
]. |
|
846 |
^ sum |
|
847 |
! |
|
848 |
||
849 |
numberOfInvocationsFromInternalOf:aClass |
|
850 |
|sum| |
|
851 |
||
852 |
infoPerSendingMethod isNil ifTrue:[ ^ 0]. |
|
853 |
||
854 |
sum := 0. |
|
855 |
infoPerSendingMethod keysAndValuesDo:[:sendingMethod :info | |
|
856 |
|sendingMethodsClass| |
|
857 |
||
858 |
sendingMethodsClass := sendingMethod mclass. |
|
859 |
sendingMethodsClass notNil ifTrue:[ |
|
860 |
((sendingMethodsClass isSubclassOf:aClass) |
|
861 |
or:[(aClass isSubclassOf:sendingMethodsClass)]) ifTrue:[ |
|
862 |
sum := sum + (info numberOfInvocations) |
|
863 |
] |
|
864 |
] |
|
865 |
]. |
|
866 |
^ sum |
|
867 |
! ! |
|
868 |
||
869 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass methodsFor:'instrumentation calls'! |
|
870 |
||
871 |
entry:aContext |
|
872 |
"invoked by instrumented compiled code, upon method entry" |
|
873 |
||
2368 | 874 |
|sender sendingMethod infoPerMethod viaPerform| |
2357 | 875 |
|
2391 | 876 |
aContext selector == #doesNotUnderstand: ifTrue:[ |
877 |
sender := aContext sender sender methodHome. |
|
878 |
] ifFalse:[ |
|
879 |
sender := aContext sender methodHome. |
|
880 |
]. |
|
2370
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
881 |
sender isNil ifTrue:[ |
a801cc4df234
added: #blockNodeRewriteHookFor:
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
882 |
^ self. |
2569 | 883 |
]. |
884 |
sendingMethod := sender method. |
|
885 |
sendingMethod isNil ifTrue:[^ self]. |
|
2391 | 886 |
|
2569 | 887 |
viaPerform := false. |
888 |
(sendingMethod mclass == Object |
|
889 |
and:[ sendingMethod selector startsWith:'perform:'] ) ifTrue:[ |
|
890 |
"/ Transcript showCR:('%1 [info]: skipping #perform' bindWith:self class nameWithoutPrefix). |
|
891 |
sender := sender sender methodHome. |
|
892 |
sendingMethod := sender method. |
|
893 |
viaPerform := true. |
|
2357 | 894 |
]. |
895 |
||
896 |
infoPerSendingMethod isNil ifTrue:[ |
|
897 |
infoPerSendingMethod := IdentityDictionary new. |
|
898 |
]. |
|
899 |
infoPerMethod := infoPerSendingMethod |
|
900 |
at:sendingMethod |
|
901 |
ifAbsentPut:[ MethodInvocationInfoPerSendingMethod new ]. |
|
902 |
||
2368 | 903 |
infoPerMethod entry:aContext viaPerform:viaPerform |
904 |
||
2569 | 905 |
"Modified: / 20-07-2011 / 17:26:31 / cg" |
2357 | 906 |
! ! |
907 |
||
908 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass::MethodInvocationInfoPerSendingMethod methodsFor:'accessing'! |
|
909 |
||
2368 | 910 |
invokedViaPerform |
911 |
^ invokedViaPerform ? false |
|
912 |
||
913 |
"Created: / 27-04-2010 / 18:20:05 / cg" |
|
914 |
! |
|
915 |
||
2357 | 916 |
numberOfInvocations |
917 |
countPerSendersClass isNil ifTrue:[ ^ 0]. |
|
918 |
^ countPerSendersClass inject:0 into:[:sumSoFar :count | sumSoFar + count] |
|
919 |
! ! |
|
920 |
||
921 |
!InstrumentingCompiler::MethodInvocationInfo::MethodInvocationInfoPerReceiverClass::MethodInvocationInfoPerSendingMethod methodsFor:'instrumentation calls'! |
|
922 |
||
2368 | 923 |
entry:aContext viaPerform:viaPerformBoolean |
2357 | 924 |
"invoked by instrumented compiled code, upon method entry" |
925 |
||
926 |
|sendersClass count| |
|
927 |
||
928 |
sendersClass := aContext sender receiver class. |
|
929 |
||
930 |
countPerSendersClass isNil ifTrue:[ |
|
931 |
countPerSendersClass := IdentityDictionary new. |
|
932 |
]. |
|
933 |
count := countPerSendersClass at:sendersClass ifAbsentPut:0. |
|
2368 | 934 |
countPerSendersClass at:sendersClass put:(count + 1). |
935 |
viaPerformBoolean ifTrue:[ invokedViaPerform := true ]. |
|
936 |
||
937 |
"Created: / 27-04-2010 / 18:17:27 / cg" |
|
2357 | 938 |
! ! |
939 |
||
2948 | 940 |
!InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState methodsFor:'cleanup'! |
941 |
||
942 |
cleanInfoWithChange:withChange |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
943 |
super cleanInfoWithChange:withChange. |
2948 | 944 |
self changeClassTo:InstrumentingCompiler::MethodInvocationInfo. |
945 |
! ! |
|
946 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
947 |
!InstrumentingCompiler::MethodInvocationInfoForCoverageInAlreadyEnteredState methodsFor:'instrumentation calls'! |
2948 | 948 |
|
949 |
entry:aContext |
|
950 |
"already been invoked - nothing to record" |
|
951 |
||
952 |
^ self |
|
953 |
! ! |
|
954 |
||
2711 | 955 |
!InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState methodsFor:'cleanup'! |
956 |
||
957 |
cleanInfoWithChange:withChange |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
958 |
super cleanInfoWithChange:withChange. |
2711 | 959 |
self changeClassTo:InstrumentingCompiler::MethodInvocationInfo. |
960 |
||
961 |
"Modified: / 20-07-2011 / 17:55:35 / cg" |
|
962 |
"Created: / 24-08-2011 / 11:10:29 / cg" |
|
963 |
! ! |
|
964 |
||
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
965 |
!InstrumentingCompiler::MethodInvocationInfoInAlreadyEnteredState methodsFor:'instrumentation calls'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
966 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
967 |
entry:aContext |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
968 |
"already been invoked - no notifications to send" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
969 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
970 |
count := count + 1 |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
971 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
972 |
|
2715 | 973 |
!InstrumentingCompiler::VariableAccessExecutionInfo class methodsFor:'documentation'! |
974 |
||
975 |
documentation |
|
976 |
" |
|
977 |
(sub)instances of me are updated by instrumented code when a variable is accessed |
|
978 |
" |
|
979 |
! ! |
|
980 |
||
2976
6e3f4e2b20f8
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2973
diff
changeset
|
981 |
!InstrumentingCompiler::VariableAccessExecutionInfo methodsFor:'testing'! |
6e3f4e2b20f8
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2973
diff
changeset
|
982 |
|
6e3f4e2b20f8
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2973
diff
changeset
|
983 |
isVariableAccessExecutionInfo |
6e3f4e2b20f8
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2973
diff
changeset
|
984 |
^ true |
6e3f4e2b20f8
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2973
diff
changeset
|
985 |
! ! |
6e3f4e2b20f8
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2973
diff
changeset
|
986 |
|
2715 | 987 |
!InstrumentingCompiler::BlockExecutionInfo class methodsFor:'documentation'! |
988 |
||
989 |
documentation |
|
990 |
" |
|
991 |
(sub)instances of me are updated by instrumented code when a block is executed. |
|
992 |
" |
|
993 |
! ! |
|
994 |
||
2390 | 995 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'accessing'! |
996 |
||
997 |
endPosition |
|
998 |
^ endPosition |
|
999 |
||
1000 |
"Created: / 28-04-2010 / 15:57:14 / cg" |
|
1001 |
! |
|
1002 |
||
1003 |
startPosition:startArg endPosition:endArg |
|
1004 |
startPosition := startArg. |
|
1005 |
endPosition := endArg. |
|
1006 |
||
1007 |
"Created: / 28-04-2010 / 15:54:47 / cg" |
|
1008 |
! ! |
|
1009 |
||
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1010 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'entry'! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1011 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1012 |
changeClassToAlreadyEntered |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1013 |
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
|
1014 |
self changeClassTo: BlockExecutionInfoInAlreadyEnteredState |
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 |
! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1017 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1018 |
changeClassToCoverageAndAlreadyEntered |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1019 |
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
|
1020 |
self changeClassTo: BlockExecutionInfoForCoverageInAlreadyEnteredState |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1021 |
]. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1022 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1023 |
|
2675
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1024 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'printing'! |
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 |
printOn:aStream |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1027 |
aStream nextPutAll:'['. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1028 |
startPosition printOn:aStream. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1029 |
aStream nextPutAll:'...'. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1030 |
endPosition printOn:aStream. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1031 |
aStream nextPutAll:']'. |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1032 |
|
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1033 |
"Created: / 21-08-2011 / 14:02:01 / cg" |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1034 |
! ! |
3e8368ea406e
comment/format in: #addBlockCounterTo:
Claus Gittinger <cg@exept.de>
parents:
2665
diff
changeset
|
1035 |
|
2632 | 1036 |
!InstrumentingCompiler::BlockExecutionInfo methodsFor:'testing'! |
1037 |
||
1038 |
isBlockExecutionInfo |
|
1039 |
^ true |
|
1040 |
||
1041 |
"Created: / 07-08-2011 / 17:06:39 / cg" |
|
1042 |
! ! |
|
1043 |
||
2967
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:'cleanup'! |
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 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1047 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1048 |
self changeClassTo:InstrumentingCompiler::BlockExecutionInfo. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1049 |
! ! |
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 |
!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
|
1052 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1053 |
entry:callingContext |
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1054 |
"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
|
1055 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1056 |
^ self |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1057 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1058 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1059 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoForCoverageInAlreadyEnteredState methodsFor:'queries'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1060 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1061 |
hasBeenExecuted |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1062 |
^ true |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1063 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1064 |
|
2967
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1065 |
!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
|
1066 |
|
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1067 |
cleanInfoWithChange:withChange |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1068 |
super cleanInfoWithChange:withChange. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1069 |
self changeClassTo:InstrumentingCompiler::BlockExecutionInfo. |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1070 |
! ! |
33ec78ee2aa9
tuning by changing the class to speedup entry into already
Claus Gittinger <cg@exept.de>
parents:
2960
diff
changeset
|
1071 |
|
2973
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1072 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoInAlreadyEnteredState methodsFor:'instrumentation probe calls'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1073 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1074 |
entry:callingContext |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1075 |
"already been invoked - no update notification for browsers" |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1076 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1077 |
count := count + 1. |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1078 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1079 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1080 |
!InstrumentingCompiler::BlockExecutionInfo::BlockExecutionInfoInAlreadyEnteredState methodsFor:'queries'! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1081 |
|
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1082 |
hasBeenExecuted |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1083 |
^ true |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1084 |
! ! |
9de309c79d6c
class: InstrumentingCompiler
Claus Gittinger <cg@exept.de>
parents:
2972
diff
changeset
|
1085 |
|
2715 | 1086 |
!InstrumentingCompiler::ReadAccessExecutionInfo class methodsFor:'documentation'! |
1087 |
||
1088 |
documentation |
|
1089 |
" |
|
1090 |
(sub)instances of me are updated by instrumented code when a variable is read |
|
1091 |
" |
|
1092 |
! ! |
|
1093 |
||
1094 |
!InstrumentingCompiler::WriteAccessExecutionInfo class methodsFor:'documentation'! |
|
1095 |
||
1096 |
documentation |
|
1097 |
" |
|
1098 |
(sub)instances of me are updated by instrumented code when a variable is written |
|
1099 |
" |
|
1100 |
! ! |
|
1101 |
||
2357 | 1102 |
!InstrumentingCompiler class methodsFor:'documentation'! |
1103 |
||
2570 | 1104 |
version |
3192 | 1105 |
^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.31 2013-06-19 06:37:27 stefan Exp $' |
2570 | 1106 |
! |
1107 |
||
2357 | 1108 |
version_CVS |
3192 | 1109 |
^ '$Header: /cvs/stx/stx/libcomp/InstrumentingCompiler.st,v 1.31 2013-06-19 06:37:27 stefan Exp $' |
2357 | 1110 |
! ! |
3192 | 1111 |