comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java @ 20889:73b1844b5b14

Truffle/Instrumentation: rename InstrumentListener to SimpleInstrumentListener
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Fri, 10 Apr 2015 21:00:26 -0700
parents e7ece52e1ff3
children 263ab98b3bf0
comparison
equal deleted inserted replaced
20888:0f3d81231ecb 20889:73b1844b5b14
175 // Probe the addition node 175 // Probe the addition node
176 final Probe probe = addNode.probe(); 176 final Probe probe = addNode.probe();
177 177
178 // Check instrumentation with the simplest kind of counters. 178 // Check instrumentation with the simplest kind of counters.
179 // They should all be removed when the check is finished. 179 // They should all be removed when the check is finished.
180 checkCounters(probe, callTarget, rootNode, new TestInstrumentCounter(), new TestInstrumentCounter(), new TestInstrumentCounter()); 180 checkCounters(probe, callTarget, rootNode, new TestSimpleInstrumentCounter(), new TestSimpleInstrumentCounter(), new TestSimpleInstrumentCounter());
181 181
182 // Now try with the more complex flavor of listener 182 // Now try with the more complex flavor of listener
183 checkCounters(probe, callTarget, rootNode, new TestASTInstrumentCounter(), new TestASTInstrumentCounter(), new TestASTInstrumentCounter()); 183 checkCounters(probe, callTarget, rootNode, new TestASTInstrumentCounter(), new TestASTInstrumentCounter(), new TestASTInstrumentCounter());
184 } 184 }
185 185
351 } 351 }
352 352
353 /** 353 /**
354 * A counter for the number of times execution enters and leaves a probed AST node. 354 * A counter for the number of times execution enters and leaves a probed AST node.
355 */ 355 */
356 private class TestInstrumentCounter implements TestCounter { 356 private class TestSimpleInstrumentCounter implements TestCounter {
357 357
358 public int enterCount = 0; 358 public int enterCount = 0;
359 public int leaveCount = 0; 359 public int leaveCount = 0;
360 public final Instrument instrument; 360 public final Instrument instrument;
361 361
362 public TestInstrumentCounter() { 362 public TestSimpleInstrumentCounter() {
363 this.instrument = Instrument.create(new InstrumentListener() { 363 this.instrument = Instrument.create(new SimpleInstrumentListener() {
364 364
365 public void enter(Probe probe) { 365 public void enter(Probe probe) {
366 enterCount++; 366 enterCount++;
367 } 367 }
368 368
483 } 483 }
484 484
485 /** 485 /**
486 * Counts the number of "enter" events at probed nodes using the simplest AST listener. 486 * Counts the number of "enter" events at probed nodes using the simplest AST listener.
487 */ 487 */
488 static final class TestInstrumentListener extends DefaultInstrumentListener { 488 static final class TestSimpleInstrumentListener extends DefaultSimpleInstrumentListener {
489 489
490 public int counter = 0; 490 public int counter = 0;
491 491
492 @Override 492 @Override
493 public void enter(Probe probe) { 493 public void enter(Probe probe) {
520 520
521 // Attach a new instrument for every Probe 521 // Attach a new instrument for every Probe
522 // where we want to count executions. 522 // where we want to count executions.
523 // it will get copied when ASTs cloned, so 523 // it will get copied when ASTs cloned, so
524 // keep the count in this outer class. 524 // keep the count in this outer class.
525 probe.attach(Instrument.create(new DefaultInstrumentListener() { 525 probe.attach(Instrument.create(new DefaultSimpleInstrumentListener() {
526 526
527 @Override 527 @Override
528 public void enter(Probe p) { 528 public void enter(Probe p) {
529 count++; 529 count++;
530 } 530 }