Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/InstrumentationNode.java @ 15779:8c34e2cc4add
Truffle/Instrumentation: significant reorganization of the instrumentation framework's implementation and connection to the runtime ExecutionContext, with some new features, including a Tag-based "trap" mechanisms.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 19 May 2014 17:14:36 -0700 |
parents | bb9473723904 |
children | 14ac87c56a27 |
comparison
equal
deleted
inserted
replaced
15632:dcaf3993ad17 | 15779:8c34e2cc4add |
---|---|
37 * <p> | 37 * <p> |
38 * Coordinates propagation of Truffle AST {@link ExecutionEvents}. | 38 * Coordinates propagation of Truffle AST {@link ExecutionEvents}. |
39 */ | 39 */ |
40 public abstract class InstrumentationNode extends Node implements ExecutionEvents { | 40 public abstract class InstrumentationNode extends Node implements ExecutionEvents { |
41 | 41 |
42 public interface ProbeCallback { | 42 interface ProbeCallback { |
43 void newTagAdded(ProbeImpl probe, PhylumTag tag); | 43 void newTagAdded(ProbeImpl probe, PhylumTag tag); |
44 } | 44 } |
45 | 45 |
46 /** | 46 /** |
47 * Creates a new {@link Probe}, presumed to be unique to a particular {@linkplain SourceSection} | 47 * Creates a new {@link Probe}, presumed to be unique to a particular {@linkplain SourceSection} |
48 * extent of guest language source code. | 48 * extent of guest language source code. |
49 * | 49 * |
50 * @return a new probe | 50 * @return a new probe |
51 */ | 51 */ |
52 public static ProbeImpl createProbe(SourceSection sourceSection, ProbeCallback probeCallback) { | 52 static ProbeImpl createProbe(SourceSection sourceSection, ProbeCallback probeCallback) { |
53 return new ProbeImpl(sourceSection, probeCallback); | 53 return new ProbeImpl(sourceSection, probeCallback); |
54 } | 54 } |
55 | 55 |
56 /** | 56 /** |
57 * Next in chain. | 57 * Next in chain. |
62 } | 62 } |
63 | 63 |
64 /** | 64 /** |
65 * @return the instance of {@link Probe} to which this instrument is attached. | 65 * @return the instance of {@link Probe} to which this instrument is attached. |
66 */ | 66 */ |
67 public Probe getProbe() { | 67 protected Probe getProbe() { |
68 final InstrumentationNode parent = (InstrumentationNode) getParent(); | 68 final InstrumentationNode parent = (InstrumentationNode) getParent(); |
69 return parent == null ? null : parent.getProbe(); | 69 return parent == null ? null : parent.getProbe(); |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
197 * originally attached, so it holds no parent pointer. | 197 * originally attached, so it holds no parent pointer. |
198 * <p> | 198 * <p> |
199 * May be categorized by one or more {@linkplain PhylumTag tags}, signifying information useful | 199 * May be categorized by one or more {@linkplain PhylumTag tags}, signifying information useful |
200 * for instrumentation about its AST location(s). | 200 * for instrumentation about its AST location(s). |
201 */ | 201 */ |
202 public static final class ProbeImpl extends InstrumentationNode implements Probe { | 202 static final class ProbeImpl extends InstrumentationNode implements Probe { |
203 | 203 |
204 private final ProbeCallback probeCallback; | 204 private final ProbeCallback probeCallback; |
205 | 205 |
206 /** | 206 /** |
207 * Source information about the AST node (and its clones) to which this probe is attached. | 207 * Source information about the AST node (and its clones) to which this probe is attached. |
257 super.internalRemoveInstrument(instrument); | 257 super.internalRemoveInstrument(instrument); |
258 probeUnchanged = Truffle.getRuntime().createAssumption(); | 258 probeUnchanged = Truffle.getRuntime().createAssumption(); |
259 } | 259 } |
260 | 260 |
261 @Override | 261 @Override |
262 public Probe getProbe() { | 262 protected Probe getProbe() { |
263 return this; | 263 return this; |
264 } | 264 } |
265 | 265 |
266 @Override | 266 @Override |
267 @SlowPath | 267 @SlowPath |
269 probeUnchanged.invalidate(); | 269 probeUnchanged.invalidate(); |
270 probeUnchanged = Truffle.getRuntime().createAssumption(); | 270 probeUnchanged = Truffle.getRuntime().createAssumption(); |
271 } | 271 } |
272 | 272 |
273 @SlowPath | 273 @SlowPath |
274 public void setTrap(PhylumTrap trap) { | 274 void setTrap(PhylumTrap trap) { |
275 assert trap == null || isTaggedAs(trap.getTag()); | 275 assert trap == null || isTaggedAs(trap.getTag()); |
276 probeUnchanged.invalidate(); | 276 probeUnchanged.invalidate(); |
277 this.trap = trap; | 277 this.trap = trap; |
278 probeUnchanged = Truffle.getRuntime().createAssumption(); | 278 probeUnchanged = Truffle.getRuntime().createAssumption(); |
279 } | 279 } |
280 | 280 |
281 public void notifyEnter(Node astNode, VirtualFrame frame) { | 281 public void enter(Node astNode, VirtualFrame frame) { |
282 if (trap != null || next != null) { | 282 if (trap != null || next != null) { |
283 if (!probeUnchanged.isValid()) { | 283 if (!probeUnchanged.isValid()) { |
284 CompilerDirectives.transferToInterpreter(); | 284 CompilerDirectives.transferToInterpreter(); |
285 } | 285 } |
286 if (trap != null) { | 286 if (trap != null) { |
290 next.internalEnter(astNode, frame); | 290 next.internalEnter(astNode, frame); |
291 } | 291 } |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 public void notifyLeave(Node astNode, VirtualFrame frame) { | 295 public void leave(Node astNode, VirtualFrame frame) { |
296 if (next != null) { | 296 if (next != null) { |
297 if (!probeUnchanged.isValid()) { | 297 if (!probeUnchanged.isValid()) { |
298 CompilerDirectives.transferToInterpreter(); | 298 CompilerDirectives.transferToInterpreter(); |
299 } | 299 } |
300 next.internalLeave(astNode, frame); | 300 next.internalLeave(astNode, frame); |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 public void notifyLeave(Node astNode, VirtualFrame frame, boolean result) { | 304 public void leave(Node astNode, VirtualFrame frame, boolean result) { |
305 if (next != null) { | 305 if (next != null) { |
306 if (!probeUnchanged.isValid()) { | 306 if (!probeUnchanged.isValid()) { |
307 CompilerDirectives.transferToInterpreter(); | 307 CompilerDirectives.transferToInterpreter(); |
308 } | 308 } |
309 next.internalLeave(astNode, frame, result); | 309 next.internalLeave(astNode, frame, result); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 public void notifyLeave(Node astNode, VirtualFrame frame, byte result) { | 313 public void leave(Node astNode, VirtualFrame frame, byte result) { |
314 if (next != null) { | 314 if (next != null) { |
315 if (!probeUnchanged.isValid()) { | 315 if (!probeUnchanged.isValid()) { |
316 CompilerDirectives.transferToInterpreter(); | 316 CompilerDirectives.transferToInterpreter(); |
317 } | 317 } |
318 next.internalLeave(astNode, frame, result); | 318 next.internalLeave(astNode, frame, result); |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 public void notifyLeave(Node astNode, VirtualFrame frame, short result) { | 322 public void leave(Node astNode, VirtualFrame frame, short result) { |
323 if (next != null) { | 323 if (next != null) { |
324 if (!probeUnchanged.isValid()) { | 324 if (!probeUnchanged.isValid()) { |
325 CompilerDirectives.transferToInterpreter(); | 325 CompilerDirectives.transferToInterpreter(); |
326 } | 326 } |
327 next.internalLeave(astNode, frame, result); | 327 next.internalLeave(astNode, frame, result); |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 public void notifyLeave(Node astNode, VirtualFrame frame, int result) { | 331 public void leave(Node astNode, VirtualFrame frame, int result) { |
332 if (next != null) { | 332 if (next != null) { |
333 if (!probeUnchanged.isValid()) { | 333 if (!probeUnchanged.isValid()) { |
334 CompilerDirectives.transferToInterpreter(); | 334 CompilerDirectives.transferToInterpreter(); |
335 } | 335 } |
336 next.internalLeave(astNode, frame, result); | 336 next.internalLeave(astNode, frame, result); |
337 } | 337 } |
338 } | 338 } |
339 | 339 |
340 public void notifyLeave(Node astNode, VirtualFrame frame, long result) { | 340 public void leave(Node astNode, VirtualFrame frame, long result) { |
341 if (next != null) { | 341 if (next != null) { |
342 if (!probeUnchanged.isValid()) { | 342 if (!probeUnchanged.isValid()) { |
343 CompilerDirectives.transferToInterpreter(); | 343 CompilerDirectives.transferToInterpreter(); |
344 } | 344 } |
345 next.internalLeave(astNode, frame, result); | 345 next.internalLeave(astNode, frame, result); |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 public void notifyLeave(Node astNode, VirtualFrame frame, char result) { | 349 public void leave(Node astNode, VirtualFrame frame, char result) { |
350 if (next != null) { | 350 if (next != null) { |
351 if (!probeUnchanged.isValid()) { | 351 if (!probeUnchanged.isValid()) { |
352 CompilerDirectives.transferToInterpreter(); | 352 CompilerDirectives.transferToInterpreter(); |
353 } | 353 } |
354 next.internalLeave(astNode, frame, result); | 354 next.internalLeave(astNode, frame, result); |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 public void notifyLeave(Node astNode, VirtualFrame frame, float result) { | 358 public void leave(Node astNode, VirtualFrame frame, float result) { |
359 if (next != null) { | 359 if (next != null) { |
360 if (!probeUnchanged.isValid()) { | 360 if (!probeUnchanged.isValid()) { |
361 CompilerDirectives.transferToInterpreter(); | 361 CompilerDirectives.transferToInterpreter(); |
362 } | 362 } |
363 next.internalLeave(astNode, frame, result); | 363 next.internalLeave(astNode, frame, result); |
364 } | 364 } |
365 } | 365 } |
366 | 366 |
367 public void notifyLeave(Node astNode, VirtualFrame frame, double result) { | 367 public void leave(Node astNode, VirtualFrame frame, double result) { |
368 if (next != null) { | 368 if (next != null) { |
369 if (!probeUnchanged.isValid()) { | 369 if (!probeUnchanged.isValid()) { |
370 CompilerDirectives.transferToInterpreter(); | 370 CompilerDirectives.transferToInterpreter(); |
371 } | 371 } |
372 next.internalLeave(astNode, frame, result); | 372 next.internalLeave(astNode, frame, result); |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 public void notifyLeave(Node astNode, VirtualFrame frame, Object result) { | 376 public void leave(Node astNode, VirtualFrame frame, Object result) { |
377 if (next != null) { | 377 if (next != null) { |
378 if (!probeUnchanged.isValid()) { | 378 if (!probeUnchanged.isValid()) { |
379 CompilerDirectives.transferToInterpreter(); | 379 CompilerDirectives.transferToInterpreter(); |
380 } | 380 } |
381 next.internalLeave(astNode, frame, result); | 381 next.internalLeave(astNode, frame, result); |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 public void notifyLeaveExceptional(Node astNode, VirtualFrame frame, Exception e) { | 385 public void leaveExceptional(Node astNode, VirtualFrame frame, Exception e) { |
386 if (next != null) { | 386 if (next != null) { |
387 if (!probeUnchanged.isValid()) { | 387 if (!probeUnchanged.isValid()) { |
388 CompilerDirectives.transferToInterpreter(); | 388 CompilerDirectives.transferToInterpreter(); |
389 } | 389 } |
390 next.internalLeaveExceptional(astNode, frame, e); | 390 next.internalLeaveExceptional(astNode, frame, e); |
391 } | 391 } |
392 } | 392 } |
393 | 393 |
394 public void enter(Node astNode, VirtualFrame frame) { | |
395 } | |
396 | |
397 public void leave(Node astNode, VirtualFrame frame) { | |
398 } | |
399 | |
400 public void leave(Node astNode, VirtualFrame frame, boolean result) { | |
401 leave(astNode, frame, (Object) result); | |
402 } | |
403 | |
404 public void leave(Node astNode, VirtualFrame frame, byte result) { | |
405 leave(astNode, frame, (Object) result); | |
406 } | |
407 | |
408 public void leave(Node astNode, VirtualFrame frame, short result) { | |
409 leave(astNode, frame, (Object) result); | |
410 } | |
411 | |
412 public void leave(Node astNode, VirtualFrame frame, int result) { | |
413 leave(astNode, frame, (Object) result); | |
414 } | |
415 | |
416 public void leave(Node astNode, VirtualFrame frame, long result) { | |
417 leave(astNode, frame, (Object) result); | |
418 } | |
419 | |
420 public void leave(Node astNode, VirtualFrame frame, char result) { | |
421 leave(astNode, frame, (Object) result); | |
422 } | |
423 | |
424 public void leave(Node astNode, VirtualFrame frame, float result) { | |
425 leave(astNode, frame, (Object) result); | |
426 } | |
427 | |
428 public void leave(Node astNode, VirtualFrame frame, double result) { | |
429 leave(astNode, frame, (Object) result); | |
430 } | |
431 | |
432 public void leave(Node astNode, VirtualFrame frame, Object result) { | |
433 } | |
434 | |
435 public void leaveExceptional(Node astNode, VirtualFrame frame, Exception e) { | |
436 } | |
437 | |
438 } | 394 } |
439 | 395 |
440 } | 396 } |