Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java @ 21353:876e710523c5
Truffle/Instrumentation: rename "Tool Eval" Instrument kind to "Advanced" Instrument kind
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 12 May 2015 12:57:47 -0700 |
parents | e93c6e5c6c35 |
children | 575032310b2c |
comparison
equal
deleted
inserted
replaced
21345:a818a6a57ef4 | 21353:876e710523c5 |
---|---|
125 public static Instrument create(StandardInstrumentListener standardListener, String instrumentInfo) { | 125 public static Instrument create(StandardInstrumentListener standardListener, String instrumentInfo) { |
126 return new StandardInstrument(standardListener, instrumentInfo); | 126 return new StandardInstrument(standardListener, instrumentInfo); |
127 } | 127 } |
128 | 128 |
129 /** | 129 /** |
130 * Creates a <em>Tool Eval Instrument</em>: this Instrument executes efficiently, subject to | 130 * Creates an <em>Advanced Instrument</em>: this Instrument executes efficiently, subject to |
131 * full Truffle optimization, a client-provided AST fragment every time the Probed node is | 131 * full Truffle optimization, a client-provided AST fragment every time the Probed node is |
132 * entered. | 132 * entered. |
133 * | 133 * |
134 * @param toolEvalNodeFactory provider of AST fragments on behalf of the client | 134 * @param rootFactory provider of AST fragments on behalf of the client |
135 * @param instrumentInfo optional description of the instrument's role, intended for debugging. | 135 * @param instrumentInfo optional description of the instrument's role, intended for debugging. |
136 * @return a new instrument, ready for attachment at a probe | 136 * @return a new instrument, ready for attachment at a probe |
137 */ | 137 */ |
138 public static Instrument create(ToolEvalNodeFactory toolEvalNodeFactory, String instrumentInfo) { | 138 public static Instrument create(AdvancedInstrumentRootFactory rootFactory, String instrumentInfo) { |
139 return new ToolEvalInstrument(toolEvalNodeFactory, instrumentInfo); | 139 return new AdvancedInstrument(rootFactory, instrumentInfo); |
140 } | 140 } |
141 | 141 |
142 // TODO (mlvdv) experimental | 142 // TODO (mlvdv) experimental |
143 /** | 143 /** |
144 * For implementation testing. | 144 * For implementation testing. |
377 /** | 377 /** |
378 * An instrument that allows clients to provide an AST fragment to be executed directly from | 378 * An instrument that allows clients to provide an AST fragment to be executed directly from |
379 * within a Probe's <em>instrumentation chain</em>, and thus directly in the executing Truffle | 379 * within a Probe's <em>instrumentation chain</em>, and thus directly in the executing Truffle |
380 * AST with potential for full optimization. | 380 * AST with potential for full optimization. |
381 */ | 381 */ |
382 private static final class ToolEvalInstrument extends Instrument { | 382 private static final class AdvancedInstrument extends Instrument { |
383 | 383 |
384 /** | 384 /** |
385 * Client-provided supplier of new node instances to attach. | 385 * Client-provided supplier of new node instances to attach. |
386 */ | 386 */ |
387 private final ToolEvalNodeFactory toolEvalNodeFactory; | 387 private final AdvancedInstrumentRootFactory rootFactory; |
388 | 388 |
389 private ToolEvalInstrument(ToolEvalNodeFactory toolEvalNodeFactory, String instrumentInfo) { | 389 private AdvancedInstrument(AdvancedInstrumentRootFactory rootFactory, String instrumentInfo) { |
390 super(instrumentInfo); | 390 super(instrumentInfo); |
391 this.toolEvalNodeFactory = toolEvalNodeFactory; | 391 this.rootFactory = rootFactory; |
392 | 392 |
393 } | 393 } |
394 | 394 |
395 @Override | 395 @Override |
396 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) { | 396 AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) { |
397 return new ToolEvalNodeInstrumentNode(nextNode); | 397 return new AdvancedInstrumentNode(nextNode); |
398 } | 398 } |
399 | 399 |
400 @Override | 400 @Override |
401 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) { | 401 AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) { |
402 boolean found = false; | 402 boolean found = false; |
404 if (instrumentNode.getInstrument() == this) { | 404 if (instrumentNode.getInstrument() == this) { |
405 // Found the match at the head of the chain | 405 // Found the match at the head of the chain |
406 return instrumentNode.nextInstrumentNode; | 406 return instrumentNode.nextInstrumentNode; |
407 } | 407 } |
408 // Match not at the head of the chain; remove it. | 408 // Match not at the head of the chain; remove it. |
409 found = instrumentNode.removeFromChain(ToolEvalInstrument.this); | 409 found = instrumentNode.removeFromChain(AdvancedInstrument.this); |
410 } | 410 } |
411 if (!found) { | 411 if (!found) { |
412 throw new IllegalStateException("Couldn't find instrument node to remove: " + this); | 412 throw new IllegalStateException("Couldn't find instrument node to remove: " + this); |
413 } | 413 } |
414 return instrumentNode; | 414 return instrumentNode; |
415 } | 415 } |
416 | 416 |
417 /** | 417 /** |
418 * Node that implements a {@link ToolEvalInstrument} in a particular AST. | 418 * Node that implements a {@link AdvancedInstrument} in a particular AST. |
419 */ | 419 */ |
420 @NodeInfo(cost = NodeCost.NONE) | 420 @NodeInfo(cost = NodeCost.NONE) |
421 private final class ToolEvalNodeInstrumentNode extends AbstractInstrumentNode { | 421 private final class AdvancedInstrumentNode extends AbstractInstrumentNode { |
422 | 422 |
423 @Child private ToolEvalNode toolEvalNode; | 423 @Child private AdvancedInstrumentRoot instrumentRoot; |
424 | 424 |
425 private ToolEvalNodeInstrumentNode(AbstractInstrumentNode nextNode) { | 425 private AdvancedInstrumentNode(AbstractInstrumentNode nextNode) { |
426 super(nextNode); | 426 super(nextNode); |
427 } | 427 } |
428 | 428 |
429 public void enter(Node node, VirtualFrame vFrame) { | 429 public void enter(Node node, VirtualFrame vFrame) { |
430 if (toolEvalNode == null) { | 430 if (instrumentRoot == null) { |
431 final ToolEvalNode newToolEvalNodeNode = ToolEvalInstrument.this.toolEvalNodeFactory.createToolEvalNode(ToolEvalInstrument.this.probe, node); | 431 final AdvancedInstrumentRoot newInstrumentRoot = AdvancedInstrument.this.rootFactory.createInstrumentRoot(AdvancedInstrument.this.probe, node); |
432 if (newToolEvalNodeNode != null) { | 432 if (newInstrumentRoot != null) { |
433 toolEvalNode = newToolEvalNodeNode; | 433 instrumentRoot = newInstrumentRoot; |
434 adoptChildren(); | 434 adoptChildren(); |
435 ToolEvalInstrument.this.probe.invalidateProbeUnchanged(); | 435 AdvancedInstrument.this.probe.invalidateProbeUnchanged(); |
436 } | 436 } |
437 } | 437 } |
438 if (toolEvalNode != null) { | 438 if (instrumentRoot != null) { |
439 // TODO (mlvdv) should report exception ; non-trivial architectural change | 439 // TODO (mlvdv) should report exception ; non-trivial architectural change |
440 toolEvalNode.executeToolEvalNode(node, vFrame); | 440 instrumentRoot.executeRoot(node, vFrame); |
441 } | 441 } |
442 if (nextInstrumentNode != null) { | 442 if (nextInstrumentNode != null) { |
443 nextInstrumentNode.enter(node, vFrame); | 443 nextInstrumentNode.enter(node, vFrame); |
444 } | 444 } |
445 } | 445 } |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 public String instrumentationInfo() { | 465 public String instrumentationInfo() { |
466 final String info = getInstrumentInfo(); | 466 final String info = getInstrumentInfo(); |
467 return info != null ? info : toolEvalNodeFactory.getClass().getSimpleName(); | 467 return info != null ? info : rootFactory.getClass().getSimpleName(); |
468 } | 468 } |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 public interface TruffleOptListener { | 472 public interface TruffleOptListener { |