Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/oops/ProfileData.java @ 3939:f6f3bb0ee072
7088955: add C2 IR support to the SA
Reviewed-by: kvn
author | never |
---|---|
date | Sun, 11 Sep 2011 14:48:24 -0700 |
parents | |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
3938:e6b1331a51d2 | 3939:f6f3bb0ee072 |
---|---|
1 /* | |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.oops; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.runtime.*; | |
31 import sun.jvm.hotspot.types.*; | |
32 import sun.jvm.hotspot.utilities.*; | |
33 | |
34 public abstract class ProfileData { | |
35 // This is a pointer to a section of profiling data. | |
36 private DataLayout _data; | |
37 | |
38 public DataLayout data() { return _data; } | |
39 | |
40 // How many cells are in this? | |
41 public abstract int cellCount(); | |
42 | |
43 | |
44 // Return the size of this data. | |
45 public int sizeInBytes() { | |
46 return DataLayout.computeSizeInBytes(cellCount()); | |
47 } | |
48 | |
49 public int dp() { | |
50 return data().dp(); | |
51 } | |
52 | |
53 // Low-level accessors for underlying data | |
54 int intptrAt(int index) { | |
55 //assert(0 <= index && index < cellCount(), "oob"); | |
56 return data().cellAt(index); | |
57 } | |
58 int intAt(int index) { | |
59 return (int)intptrAt(index); | |
60 } | |
61 int uintAt(int index) { | |
62 return (int)intptrAt(index); | |
63 } | |
64 Oop oopAt(int index) { | |
65 return data().oopAt(index); | |
66 } | |
67 | |
68 public Address addressAt(int index) { | |
69 return data().addressAt(index); | |
70 } | |
71 | |
72 boolean flagAt(int flagNumber) { | |
73 return data().flagAt(flagNumber); | |
74 } | |
75 | |
76 // two convenient imports for use by subclasses: | |
77 public static int cellOffset(int index) { | |
78 return DataLayout.cellOffset(index); | |
79 } | |
80 | |
81 public ProfileData(DataLayout data) { | |
82 _data = data; | |
83 } | |
84 | |
85 // Constructor for invalid ProfileData. | |
86 ProfileData() { | |
87 _data = null; | |
88 } | |
89 | |
90 int bci() { | |
91 return data().bci(); | |
92 } | |
93 | |
94 int trapState() { | |
95 return data().trapState(); | |
96 } | |
97 public abstract void printDataOn(PrintStream st); | |
98 | |
99 void tab(PrintStream st) { | |
100 st.print("\t"); | |
101 } | |
102 | |
103 void printShared(PrintStream st, String name) { | |
104 st.print("bci: " + bci()); | |
105 // st.fillTo(tabWidthOne); | |
106 st.print(" " + name + " "); | |
107 tab(st); | |
108 int trap = trapState(); | |
109 if (trap != 0) { | |
110 st.print("trap(" + MethodData.formatTrapState(trap) + ") "); | |
111 } | |
112 int flags = data().flags(); | |
113 if (flags != 0) | |
114 st.print("flags(" + flags + ") "); | |
115 } | |
116 | |
117 public String toString() { | |
118 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
119 PrintStream ps = new PrintStream(baos); | |
120 try { | |
121 printDataOn(ps); | |
122 } finally { | |
123 ps.close(); | |
124 } | |
125 return baos.toString(); | |
126 } | |
127 } |