Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/instrument/SLDefaultVisualizer.java @ 16913:b879421229db
SL: better toString for SL nodes.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sat, 23 Aug 2014 19:31:33 +0200 |
parents | 618d92152d3c |
children | ef30b2318658 |
rev | line source |
---|---|
16595
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
1 /* |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
4 * |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
8 * |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
14 * |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
18 * |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
21 * questions. |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
22 */ |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.sl.nodes.instrument; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
24 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.truffle.api.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
26 import com.oracle.truffle.api.frame.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.instrument.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.instrument.impl.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.nodes.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.sl.nodes.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.sl.runtime.*; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
32 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
33 /** |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
34 * SLDefaultVisualizer provides methods to get the names of SL's internal Truffle AST nodes. |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
35 * |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
36 */ |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
37 public class SLDefaultVisualizer extends DefaultVisualizer { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
38 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
39 private final SLASTPrinter astPrinter; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
40 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
41 public SLDefaultVisualizer() { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
42 this.astPrinter = new SLASTPrinter(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
43 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
44 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
45 @Override |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
46 public ASTPrinter getASTPrinter() { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
47 return astPrinter; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
48 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
49 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
50 @Override |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
51 public String displayMethodName(Node node) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
52 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
53 if (node == null) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
54 return null; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
55 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
56 RootNode root = node.getRootNode(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
57 if (root instanceof SLRootNode) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
58 SLRootNode slRootNode = (SLRootNode) root; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
59 return slRootNode.toString(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
60 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
61 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
62 return "unknown"; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
63 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
64 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
65 @Override |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
66 public String displayCallTargetName(CallTarget callTarget) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
67 if (callTarget instanceof RootCallTarget) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
68 final RootCallTarget rootCallTarget = (RootCallTarget) callTarget; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
69 SLRootNode slRootNode = (SLRootNode) rootCallTarget.getRootNode(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
70 return slRootNode.toString(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
71 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
72 return callTarget.toString(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
73 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
74 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
75 @Override |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
76 public String displayValue(ExecutionContext context, Object value) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
77 if (value == SLNull.SINGLETON) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
78 return "null"; |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
79 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
80 return value.toString(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
81 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
82 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
83 @Override |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
84 public String displayIdentifier(FrameSlot slot) { |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
85 |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
86 final Object id = slot.getIdentifier(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
87 return id.toString(); |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
88 } |
618d92152d3c
SL: Added support for instrumentation.
David Piorkowski <david.piorkowski@oracle.com>
parents:
diff
changeset
|
89 } |