Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.ruby.nodes/src/com/oracle/truffle/ruby/nodes/debug/RubyProxyNode.java @ 13569:1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 08 Jan 2014 14:03:36 -0800 |
parents | 0fbee3eb71f0 |
children | 7bab96d62fa3 |
rev | line source |
---|---|
13514 | 1 /* |
13569
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. This |
13514 | 3 * code is released under a tri EPL/GPL/LGPL license. You can use it, |
4 * redistribute it and/or modify it under the terms of the: | |
5 * | |
6 * Eclipse Public License version 1.0 | |
7 * GNU General Public License version 2 | |
8 * GNU Lesser General Public License version 2.1 | |
9 */ | |
10 package com.oracle.truffle.ruby.nodes.debug; | |
11 | |
12 import java.math.*; | |
13569
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
13 import java.util.*; |
13514 | 14 |
15 import com.oracle.truffle.api.*; | |
16 import com.oracle.truffle.api.frame.*; | |
17 import com.oracle.truffle.api.nodes.*; | |
18 import com.oracle.truffle.api.nodes.instrument.*; | |
19 import com.oracle.truffle.api.nodes.instrument.InstrumentationProbeNode.ProbeChain; | |
20 import com.oracle.truffle.ruby.nodes.*; | |
21 import com.oracle.truffle.ruby.runtime.*; | |
22 import com.oracle.truffle.ruby.runtime.core.*; | |
23 import com.oracle.truffle.ruby.runtime.core.array.*; | |
24 | |
25 /** | |
26 * An <strong>instrumentation proxy node</strong> that forwards all Ruby execution calls through to | |
27 * a child node and returns results back to the parent, but which also sends notifications to an | |
28 * attached {@linkplain ProbeChain chain} of {@linkplain InstrumentationProbeNode probes}. | |
29 */ | |
30 public class RubyProxyNode extends RubyNode implements InstrumentationProxyNode { | |
31 | |
32 @Child private RubyNode child; | |
33 | |
34 private final ProbeChain probeChain; | |
35 | |
36 public RubyProxyNode(RubyContext context, RubyNode child) { | |
37 super(context, SourceSection.NULL); | |
38 assert !(child instanceof RubyProxyNode); | |
13569
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
39 this.child = adoptChild(child); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
40 this.probeChain = context.getDebugManager().getProbeChain(child.getSourceSection()); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
41 } |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
42 |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
43 public RubyProxyNode(RubyContext context, RubyNode child, ProbeChain probeChain) { |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
44 super(context, SourceSection.NULL); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
45 assert !(child instanceof RubyProxyNode); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
46 this.child = adoptChild(child); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
47 this.probeChain = probeChain; |
13514 | 48 } |
49 | |
50 @Override | |
51 public RubyNode getNonProxyNode() { | |
52 return child; | |
53 } | |
54 | |
55 public RubyNode getChild() { | |
56 return child; | |
57 } | |
58 | |
59 public ProbeChain getProbeChain() { | |
60 return probeChain; | |
61 } | |
62 | |
63 @Override | |
64 public Object execute(VirtualFrame frame) { | |
65 probeChain.notifyEnter(child, frame); | |
66 | |
67 Object result; | |
68 | |
69 try { | |
70 result = child.execute(frame); | |
71 probeChain.notifyLeave(child, frame, result); | |
72 } catch (Exception e) { | |
73 probeChain.notifyLeaveExceptional(child, frame, e); | |
74 throw (e); | |
75 } | |
76 | |
77 return result; | |
78 } | |
79 | |
80 @Override | |
81 public RubyArray executeArray(VirtualFrame frame) throws UnexpectedResultException { | |
82 probeChain.notifyEnter(child, frame); | |
83 | |
84 RubyArray result; | |
85 | |
86 try { | |
87 result = child.executeArray(frame); | |
88 probeChain.notifyLeave(child, frame, result); | |
89 } catch (Exception e) { | |
90 probeChain.notifyLeaveExceptional(child, frame, e); | |
91 throw (e); | |
92 } | |
93 | |
94 return result; | |
95 } | |
96 | |
97 @Override | |
98 public BigInteger executeBignum(VirtualFrame frame) throws UnexpectedResultException { | |
99 probeChain.notifyEnter(child, frame); | |
100 | |
101 BigInteger result; | |
102 | |
103 try { | |
104 result = child.executeBignum(frame); | |
105 probeChain.notifyLeave(child, frame, result); | |
106 } catch (Exception e) { | |
107 probeChain.notifyLeaveExceptional(child, frame, e); | |
108 throw (e); | |
109 } | |
110 | |
111 return result; | |
112 } | |
113 | |
114 @Override | |
115 public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { | |
116 probeChain.notifyEnter(child, frame); | |
117 | |
118 boolean result; | |
119 | |
120 try { | |
121 result = child.executeBoolean(frame); | |
122 probeChain.notifyLeave(child, frame, result); | |
123 } catch (Exception e) { | |
124 probeChain.notifyLeaveExceptional(child, frame, e); | |
125 throw (e); | |
126 } | |
127 | |
128 return result; | |
129 } | |
130 | |
131 @Override | |
132 public Object isDefined(VirtualFrame frame) { | |
133 return child.isDefined(frame); | |
134 } | |
135 | |
136 @Override | |
137 public int executeFixnum(VirtualFrame frame) throws UnexpectedResultException { | |
138 probeChain.notifyEnter(child, frame); | |
139 | |
140 int result; | |
141 | |
142 try { | |
143 result = child.executeFixnum(frame); | |
144 probeChain.notifyLeave(child, frame, result); | |
145 } catch (Exception e) { | |
146 probeChain.notifyLeaveExceptional(child, frame, e); | |
147 throw (e); | |
148 } | |
149 | |
150 return result; | |
151 } | |
152 | |
153 @Override | |
154 public double executeFloat(VirtualFrame frame) throws UnexpectedResultException { | |
155 probeChain.notifyEnter(child, frame); | |
156 | |
157 double result; | |
158 | |
159 try { | |
160 result = child.executeFloat(frame); | |
161 probeChain.notifyLeave(child, frame, result); | |
162 } catch (Exception e) { | |
163 probeChain.notifyLeaveExceptional(child, frame, e); | |
164 throw (e); | |
165 } | |
166 | |
167 return result; | |
168 } | |
169 | |
170 @Override | |
171 public RubyString executeString(VirtualFrame frame) throws UnexpectedResultException { | |
172 probeChain.notifyEnter(child, frame); | |
173 | |
174 RubyString result; | |
175 | |
176 try { | |
177 result = child.executeString(frame); | |
178 probeChain.notifyLeave(child, frame, result); | |
179 } catch (Exception e) { | |
180 probeChain.notifyLeaveExceptional(child, frame, e); | |
181 throw (e); | |
182 } | |
183 | |
184 return result; | |
185 } | |
186 | |
187 @Override | |
188 public void executeVoid(VirtualFrame frame) { | |
189 probeChain.notifyEnter(child, frame); | |
190 | |
191 try { | |
192 child.executeVoid(frame); | |
193 probeChain.notifyLeave(child, frame); | |
194 } catch (Exception e) { | |
195 probeChain.notifyLeaveExceptional(child, frame, e); | |
196 throw (e); | |
197 } | |
198 } | |
199 | |
13569
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
200 public boolean isMarkedAs(NodePhylum phylum) { |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
201 return probeChain.isMarkedAs(phylum); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
202 } |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
203 |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
204 public Set<NodePhylum> getPhylumMarks() { |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
205 return probeChain.getPhylumMarks(); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
206 } |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
207 |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
208 public void markAs(NodePhylum phylum) { |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
209 probeChain.markAs(phylum); |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
210 } |
1894412de0ed
Ruby: major upgrade in debugging support, mainly for navigation: step, next (passing over calls), return (from enclosing function), etc. Also a few bug fixes.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
13514
diff
changeset
|
211 |
13514 | 212 } |