Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.ruby.parser/src/com/oracle/truffle/ruby/parser/DefaultRubyNodeInstrumenter.java @ 13735:2c1c805153e6
Ruby: refactor low level instrumentation services
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 22 Jan 2014 21:02:06 -0800 |
parents | |
children | 22bf5a8ba9eb |
rev | line source |
---|---|
13735
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. This |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
3 * code is released under a tri EPL/GPL/LGPL license. You can use it, |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * redistribute it and/or modify it under the terms of the: |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
5 * |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
6 * Eclipse Public License version 1.0 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
7 * GNU General Public License version 2 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
8 * GNU Lesser General Public License version 2.1 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
9 */ |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 package com.oracle.truffle.ruby.parser; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
11 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
12 import com.oracle.truffle.api.nodes.instrument.*; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 import com.oracle.truffle.ruby.nodes.*; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 import com.oracle.truffle.ruby.nodes.debug.*; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
15 import com.oracle.truffle.ruby.runtime.*; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
16 import com.oracle.truffle.ruby.runtime.debug.*; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
17 import com.oracle.truffle.ruby.runtime.methods.*; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
19 /** |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
20 * Utility for instrumenting Ruby AST nodes to support the language's built-in <A |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * href="http://www.ruby-doc.org/core-2.0.0/Kernel.html#method-i-set_trace_func">tracing |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 * facility</A>. It ignores nodes other than {@linkplain NodePhylum#STATEMENT statements}. |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 */ |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 final class DefaultRubyNodeInstrumenter implements RubyNodeInstrumenter { |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
25 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
26 public DefaultRubyNodeInstrumenter() { |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
27 } |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
28 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
29 public RubyNode instrumentAsStatement(RubyNode rubyNode) { |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
30 assert rubyNode != null; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
31 assert !(rubyNode instanceof RubyProxyNode); |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
32 final RubyContext context = rubyNode.getContext(); |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
33 if (context.getConfiguration().getTrace()) { |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
34 final RubyProxyNode proxy = new RubyProxyNode(context, rubyNode); |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
35 proxy.markAs(NodePhylum.STATEMENT); |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
36 proxy.getProbeChain().appendProbe(new RubyTraceProbe(context)); |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
37 return proxy; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
38 } |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
39 return rubyNode; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
40 } |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
41 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
42 public RubyNode instrumentAsCall(RubyNode node, String callName) { |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
43 return node; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
44 } |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
45 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
46 public RubyNode instrumentAsLocalAssignment(RubyNode node, UniqueMethodIdentifier methodIdentifier, String localName) { |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
47 return node; |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 } |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 |
2c1c805153e6
Ruby: refactor low level instrumentation services
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 } |