Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/SLStatementNode.java @ 18990:d1c1cd2530d7
Truffle/Instrumentation: clean up and repair some old unit tests
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 27 Jan 2015 20:28:43 -0800 |
parents | e3c95cbbb50c |
children | 3844fb65016c |
comparison
equal
deleted
inserted
replaced
18989:acd822f17ef5 | 18990:d1c1cd2530d7 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
23 package com.oracle.truffle.sl.nodes; | 23 package com.oracle.truffle.sl.nodes; |
24 | 24 |
25 import java.io.*; | 25 import java.io.*; |
26 | 26 |
27 import com.oracle.truffle.api.frame.*; | 27 import com.oracle.truffle.api.frame.*; |
28 import com.oracle.truffle.api.instrument.*; | 28 import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode; |
29 import com.oracle.truffle.api.instrument.ProbeNode.*; | |
30 import com.oracle.truffle.api.nodes.*; | 29 import com.oracle.truffle.api.nodes.*; |
31 import com.oracle.truffle.api.source.*; | 30 import com.oracle.truffle.api.source.*; |
32 import com.oracle.truffle.sl.nodes.instrument.*; | 31 import com.oracle.truffle.sl.nodes.instrument.*; |
33 | 32 |
34 /** | 33 /** |
35 * The base class of all Truffle nodes for SL. All nodes (even expressions) can be used as | 34 * The base class of all Truffle nodes for SL. All nodes (even expressions) can be used as |
36 * statements, i.e., without returning a value. The {@link VirtualFrame} provides access to the | 35 * statements, i.e., without returning a value. The {@link VirtualFrame} provides access to the |
37 * local variables. | 36 * local variables. |
38 */ | 37 */ |
39 @NodeInfo(language = "Simple Language", description = "The abstract base node for all statements") | 38 @NodeInfo(language = "Simple Language", description = "The abstract base node for all statements") |
40 public abstract class SLStatementNode extends Node implements Instrumentable { | 39 public abstract class SLStatementNode extends Node { |
41 | 40 |
42 public SLStatementNode(SourceSection src) { | 41 public SLStatementNode(SourceSection src) { |
43 super(src); | 42 super(src); |
44 } | 43 } |
45 | 44 |
84 return String.format("%s:%d%s", sourceName, startLine, estimated ? "~" : ""); | 83 return String.format("%s:%d%s", sourceName, startLine, estimated ? "~" : ""); |
85 } | 84 } |
86 } | 85 } |
87 | 86 |
88 @Override | 87 @Override |
89 public Probe probe() { | 88 public boolean isInstrumentable() { |
90 Node parent = getParent(); | 89 return true; |
91 | |
92 if (parent == null) { | |
93 throw new IllegalStateException("Cannot call probe() on a node without a parent."); | |
94 } | |
95 | |
96 if (parent instanceof SLStatementWrapperNode) { | |
97 return ((SLStatementWrapperNode) parent).getProbe(); | |
98 } | |
99 | |
100 // Create a new wrapper/probe with this node as its child. | |
101 final SLStatementWrapperNode wrapper = new SLStatementWrapperNode(this); | |
102 | |
103 // Connect it to a Probe | |
104 final Probe probe = ProbeNode.insertProbe(wrapper); | |
105 | |
106 // Replace this node in the AST with the wrapper | |
107 this.replace(wrapper); | |
108 | |
109 return probe; | |
110 } | 90 } |
111 | 91 |
112 @Override | 92 @Override |
113 public void probeLite(TruffleEventReceiver eventReceiver) { | 93 public WrapperNode createWrapperNode() { |
114 Node parent = getParent(); | 94 return new SLStatementWrapperNode(this); |
95 } | |
115 | 96 |
116 if (parent == null) { | |
117 throw new IllegalStateException("Cannot call probeLite() on a node without a parent"); | |
118 } | |
119 | |
120 if (parent instanceof SLStatementWrapperNode) { | |
121 throw new IllegalStateException("Cannot call probeLite() on a node that already has a wrapper."); | |
122 } | |
123 | |
124 final SLStatementWrapperNode wrapper = new SLStatementWrapperNode(this); | |
125 ProbeNode.insertProbeLite(wrapper, eventReceiver); | |
126 | |
127 this.replace(wrapper); | |
128 } | |
129 } | 97 } |