Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/instrument/InstrumentationTest.java @ 19521:b5467bb34b24
Truffle/Instrumentation: some variable renaming for clarity
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Thu, 19 Feb 2015 11:42:03 -0800 |
parents | 128586040207 |
children | 907128d02b31 |
comparison
equal
deleted
inserted
replaced
19520:b08cf18b9f0a | 19521:b5467bb34b24 |
---|---|
437 Probe.unregisterASTProber(astLiteProber); | 437 Probe.unregisterASTProber(astLiteProber); |
438 | 438 |
439 } | 439 } |
440 | 440 |
441 private abstract class TestLanguageNode extends Node { | 441 private abstract class TestLanguageNode extends Node { |
442 public abstract Object execute(VirtualFrame frame); | 442 public abstract Object execute(VirtualFrame vFrame); |
443 | 443 |
444 @Override | 444 @Override |
445 public boolean isInstrumentable() { | 445 public boolean isInstrumentable() { |
446 return true; | 446 return true; |
447 } | 447 } |
490 public Node getChild() { | 490 public Node getChild() { |
491 return child; | 491 return child; |
492 } | 492 } |
493 | 493 |
494 @Override | 494 @Override |
495 public Object execute(VirtualFrame frame) { | 495 public Object execute(VirtualFrame vFrame) { |
496 probeNode.enter(child, frame); | 496 probeNode.enter(child, vFrame); |
497 Object result; | 497 Object result; |
498 | 498 |
499 try { | 499 try { |
500 result = child.execute(frame); | 500 result = child.execute(vFrame); |
501 probeNode.returnValue(child, frame, result); | 501 probeNode.returnValue(child, vFrame, result); |
502 } catch (KillException e) { | 502 } catch (KillException e) { |
503 throw (e); | 503 throw (e); |
504 } catch (Exception e) { | 504 } catch (Exception e) { |
505 probeNode.returnExceptional(child, frame, e); | 505 probeNode.returnExceptional(child, vFrame, e); |
506 throw (e); | 506 throw (e); |
507 } | 507 } |
508 | 508 |
509 return result; | 509 return result; |
510 } | 510 } |
519 public TestValueNode(int value) { | 519 public TestValueNode(int value) { |
520 this.value = value; | 520 this.value = value; |
521 } | 521 } |
522 | 522 |
523 @Override | 523 @Override |
524 public Object execute(VirtualFrame frame) { | 524 public Object execute(VirtualFrame vFrame) { |
525 return new Integer(this.value); | 525 return new Integer(this.value); |
526 } | 526 } |
527 } | 527 } |
528 | 528 |
529 /** | 529 /** |
537 this.leftChild = insert(leftChild); | 537 this.leftChild = insert(leftChild); |
538 this.rightChild = insert(rightChild); | 538 this.rightChild = insert(rightChild); |
539 } | 539 } |
540 | 540 |
541 @Override | 541 @Override |
542 public Object execute(VirtualFrame frame) { | 542 public Object execute(VirtualFrame vFrame) { |
543 return new Integer(((Integer) leftChild.execute(frame)).intValue() + ((Integer) rightChild.execute(frame)).intValue()); | 543 return new Integer(((Integer) leftChild.execute(vFrame)).intValue() + ((Integer) rightChild.execute(vFrame)).intValue()); |
544 } | 544 } |
545 } | 545 } |
546 | 546 |
547 /** | 547 /** |
548 * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST | 548 * Truffle requires that all guest languages to have a {@link RootNode} which sits atop any AST |
561 super(null); | 561 super(null); |
562 this.body = body; | 562 this.body = body; |
563 } | 563 } |
564 | 564 |
565 @Override | 565 @Override |
566 public Object execute(VirtualFrame frame) { | 566 public Object execute(VirtualFrame vFrame) { |
567 return body.execute(frame); | 567 return body.execute(vFrame); |
568 } | 568 } |
569 | 569 |
570 @Override | 570 @Override |
571 public boolean isCloningAllowed() { | 571 public boolean isCloningAllowed() { |
572 return true; | 572 return true; |
589 | 589 |
590 public TestCounter() { | 590 public TestCounter() { |
591 instrument = Instrument.create(new SimpleEventListener() { | 591 instrument = Instrument.create(new SimpleEventListener() { |
592 | 592 |
593 @Override | 593 @Override |
594 public void enter(Node node, VirtualFrame frame) { | 594 public void enter(Node node, VirtualFrame vFrame) { |
595 enterCount++; | 595 enterCount++; |
596 } | 596 } |
597 | 597 |
598 @Override | 598 @Override |
599 public void returnAny(Node node, VirtualFrame frame) { | 599 public void returnAny(Node node, VirtualFrame vFrame) { |
600 leaveCount++; | 600 leaveCount++; |
601 } | 601 } |
602 }, "Instrumentation Test Counter"); | 602 }, "Instrumentation Test Counter"); |
603 } | 603 } |
604 | 604 |
693 // it will get copied when ASTs cloned, so | 693 // it will get copied when ASTs cloned, so |
694 // keep the count in this outer class. | 694 // keep the count in this outer class. |
695 probe.attach(Instrument.create(new SimpleEventListener() { | 695 probe.attach(Instrument.create(new SimpleEventListener() { |
696 | 696 |
697 @Override | 697 @Override |
698 public void enter(Node node, VirtualFrame frame) { | 698 public void enter(Node node, VirtualFrame vFrame) { |
699 count++; | 699 count++; |
700 } | 700 } |
701 }, "Instrumentation Test MultiCounter")); | 701 }, "Instrumentation Test MultiCounter")); |
702 } | 702 } |
703 } | 703 } |