annotate agent/src/share/classes/sun/jvm/hotspot/oops/MethodData.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents f6f3bb0ee072
children bd7a7ce2e264
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.oops;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // A MethodData provides interpreter profiling information
a61af66fc99e Initial load
duke
parents:
diff changeset
35
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
36 public class MethodData extends Metadata {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
37 static int TypeProfileWidth = 2;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
38 static int BciProfileWidth = 2;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
39 static int CompileThreshold;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
40
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
41 static int Reason_many; // indicates presence of several reasons
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
42 static int Reason_none; // indicates absence of a relevant deopt.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
43 static int Reason_LIMIT;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
44 static int Reason_RECORDED_LIMIT; // some are not recorded per bc
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
45
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
46 private static String[] trapReasonName;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
47
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
48 static String trapReasonName(int reason) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
49 if (reason == Reason_many) return "many";
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
50 if (reason < Reason_LIMIT)
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
51 return trapReasonName[reason];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
52 return "reason" + reason;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
53 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
54
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
55
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
56 static int trapStateReason(int trapState) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
57 // This assert provides the link between the width of DataLayout.trapBits
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
58 // and the encoding of "recorded" reasons. It ensures there are enough
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
59 // bits to store all needed reasons in the per-BCI MDO profile.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
60 // assert(dsReasonMask >= reasonRecordedLimit, "enough bits");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
61 int recompileBit = (trapState & dsRecompileBit);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
62 trapState -= recompileBit;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
63 if (trapState == dsReasonMask) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
64 return Reason_many;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
65 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
66 // assert((int)reasonNone == 0, "state=0 => Reason_none");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
67 return trapState;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
68 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
69 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
70
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
71
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
72 static final int dsReasonMask = DataLayout.trapMask >> 1;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
73 static final int dsRecompileBit = DataLayout.trapMask - dsReasonMask;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
74
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
75 static boolean trapStateIsRecompiled(int trapState) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
76 return (trapState & dsRecompileBit) != 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
77 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
78
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
79 static boolean reasonIsRecordedPerBytecode(int reason) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
80 return reason > Reason_none && reason < Reason_RECORDED_LIMIT;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
81 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
82 static int trapStateAddReason(int trapState, int reason) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
83 // assert(reasonIsRecordedPerBytecode((DeoptReason)reason) || reason == reasonMany, "valid reason");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
84 int recompileBit = (trapState & dsRecompileBit);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
85 trapState -= recompileBit;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
86 if (trapState == dsReasonMask) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
87 return trapState + recompileBit; // already at state lattice bottom
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
88 } else if (trapState == reason) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
89 return trapState + recompileBit; // the condition is already true
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
90 } else if (trapState == 0) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
91 return reason + recompileBit; // no condition has yet been true
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
92 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
93 return dsReasonMask + recompileBit; // fall to state lattice bottom
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
94 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
95 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
96 static int trapStateSetRecompiled(int trapState, boolean z) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
97 if (z) return trapState | dsRecompileBit;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
98 else return trapState & ~dsRecompileBit;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
99 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
100
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
101 static String formatTrapState(int trapState) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
102 int reason = trapStateReason(trapState);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
103 boolean recompFlag = trapStateIsRecompiled(trapState);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
104 // Re-encode the state from its decoded components.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
105 int decodedState = 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
106 if (reasonIsRecordedPerBytecode(reason) || reason == Reason_many)
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
107 decodedState = trapStateAddReason(decodedState, reason);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
108 if (recompFlag)
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
109 decodedState = trapStateSetRecompiled(decodedState, recompFlag);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
110 // If the state re-encodes properly, format it symbolically.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
111 // Because this routine is used for debugging and diagnostics,
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
112 // be robust even if the state is a strange value.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
113 if (decodedState != trapState) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
114 // Random buggy state that doesn't decode??
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
115 return "#" + trapState;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
116 } else {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
117 return trapReasonName(reason) + (recompFlag ? " recompiled" : "");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
118 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
119 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
120
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
121
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
122
0
a61af66fc99e Initial load
duke
parents:
diff changeset
123 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 });
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
132 Type type = db.lookupType("MethodData");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 baseOffset = type.getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 size = new CIntField(type.getCIntegerField("_size"), 0);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
136 method = new MetadataField(type.getAddressField("_method"), 0);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
137
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
138 VM.Flag[] flags = VM.getVM().getCommandLineFlags();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
139 for (int f = 0; f < flags.length; f++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
140 VM.Flag flag = flags[f];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
141 if (flag.getName().equals("TypeProfileWidth")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
142 TypeProfileWidth = (int)flag.getIntx();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
143 } else if (flag.getName().equals("BciProfileWidth")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
144 BciProfileWidth = (int)flag.getIntx();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
145 } else if (flag.getName().equals("CompileThreshold")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
146 CompileThreshold = (int)flag.getIntx();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
147 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
148 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
149
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
150 cellSize = (int)VM.getVM().getAddressSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
151
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
152 dataSize = new CIntField(type.getCIntegerField("_data_size"), 0);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
153 data = type.getAddressField("_data[0]");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
154
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
155 sizeofMethodDataOopDesc = (int)type.getSize();;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
156
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
157 Reason_many = db.lookupIntConstant("Deoptimization::Reason_many").intValue();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
158 Reason_none = db.lookupIntConstant("Deoptimization::Reason_none").intValue();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
159 Reason_LIMIT = db.lookupIntConstant("Deoptimization::Reason_LIMIT").intValue();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
160 Reason_RECORDED_LIMIT = db.lookupIntConstant("Deoptimization::Reason_RECORDED_LIMIT").intValue();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
161
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
162 trapReasonName = new String[Reason_LIMIT];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
163
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
164 // Find Deopt reasons
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
165 Iterator i = db.getIntConstants();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
166 String prefix = "Deoptimization::Reason_";
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
167 while (i.hasNext()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
168 String name = (String)i.next();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
169 if (name.startsWith(prefix)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
170 // Strip prefix
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
171 if (!name.endsWith("Reason_many") &&
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
172 !name.endsWith("Reason_LIMIT") &&
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
173 !name.endsWith("Reason_RECORDED_LIMIT")) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
174 String trimmed = name.substring(prefix.length());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
175 int value = db.lookupIntConstant(name).intValue();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
176 if (trapReasonName[value] != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
177 throw new InternalError("duplicate reasons: " + trapReasonName[value] + " " + trimmed);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
178 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
179 trapReasonName[value] = trimmed;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
180 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
181 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
182 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
183 for (int index = 0; index < trapReasonName.length; index++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
184 if (trapReasonName[index] == null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
185 throw new InternalError("missing reason for " + index);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
186 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
187 System.out.println(trapReasonName[index]);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
188 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
191 public MethodData(Address addr) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
192 super(addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 public boolean isMethodData() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 private static long baseOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 private static CIntField size;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
199 private static MetadataField method;
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
200 private static CIntField dataSize;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
201 private static AddressField data;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
202
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
203 public static int sizeofMethodDataOopDesc;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
204 public static int cellSize;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public Method getMethod() {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 return (Method) method.getValue(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public void printValueOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 Method m = getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 tty.print("MethodData for " + m.getName().asString() + m.getSignature().asString());
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
215 public void iterateFields(MetadataVisitor visitor) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
216 super.iterateFields(visitor);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
217 visitor.doMetadata(method, true);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
218 visitor.doCInt(size, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
220
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
221 int dataSize() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
222 if (dataSize == null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
223 return 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
224 } else {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
225 return (int)dataSize.getValue(getAddress());
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
226 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
227 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
228
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
229 boolean outOfBounds(int dataIndex) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
230 return dataIndex >= dataSize();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
231 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
232
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
233 ProfileData dataAt(int dataIndex) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
234 if (outOfBounds(dataIndex)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
235 return null;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
236 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
237 DataLayout dataLayout = new DataLayout(this, dataIndex + (int)data.getOffset());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
238
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
239 switch (dataLayout.tag()) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
240 case DataLayout.noTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
241 default:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
242 throw new InternalError(dataIndex + " " + dataSize() + " " + dataLayout.tag());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
243 case DataLayout.bitDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
244 return new BitData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
245 case DataLayout.counterDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
246 return new CounterData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
247 case DataLayout.jumpDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
248 return new JumpData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
249 case DataLayout.receiverTypeDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
250 return new ReceiverTypeData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
251 case DataLayout.virtualCallDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
252 return new VirtualCallData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
253 case DataLayout.retDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
254 return new RetData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
255 case DataLayout.branchDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
256 return new BranchData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
257 case DataLayout.multiBranchDataTag:
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
258 return new MultiBranchData(dataLayout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
259 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
260 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
261
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
262 int dpToDi(int dp) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
263 // this in an offset from the base of the MDO, so convert to offset into _data
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
264 return dp - (int)data.getOffset();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
265 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
266
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
267 int firstDi() { return 0; }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
268 public ProfileData firstData() { return dataAt(firstDi()); }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
269 public ProfileData nextData(ProfileData current) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
270 int currentIndex = dpToDi(current.dp());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
271 int nextIndex = currentIndex + current.sizeInBytes();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
272 return dataAt(nextIndex);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
273 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
274 boolean isValid(ProfileData current) { return current != null; }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
275
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
276 public void printDataOn(PrintStream st) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
277 ProfileData data = firstData();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
278 for ( ; isValid(data); data = nextData(data)) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
279 st.print(dpToDi(data.dp()));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
280 st.print(" ");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
281 // st->fillTo(6);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
282 data.printDataOn(st);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
283 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
284 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
285
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
286 private byte[] fetchDataAt(Address base, long offset, long size) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
287 byte[] result = new byte[(int)size];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
288 for (int i = 0; i < size; i++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
289 result[i] = base.getJByteAt(offset + i);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
290 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
291 return result;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
292 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
293
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
294 public byte[] orig() {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
295 // fetch the orig MethodData data between header and dataSize
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
296 return fetchDataAt(getAddress(), 0, sizeofMethodDataOopDesc);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
297 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
298
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
299 public long[] data() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
300 // Read the data as an array of intptr_t elements
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 3939
diff changeset
301 Address base = getAddress();
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
302 long offset = data.getOffset();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
303 int elements = dataSize() / cellSize;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
304 long[] result = new long[elements];
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
305 for (int i = 0; i < elements; i++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
306 Address value = base.getAddressAt(offset + i * MethodData.cellSize);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
307 if (value != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
308 result[i] = value.minus(null);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
309 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
310 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
311 return result;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
312 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
313
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
314 // Get a measure of how much mileage the method has on it.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
315 int mileageOf(Method method) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
316 long mileage = 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
317 int iic = method.interpreterInvocationCount();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
318 if (mileage < iic) mileage = iic;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
319
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
320 long ic = method.getInvocationCounter();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
321 long bc = method.getBackedgeCounter();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
322
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
323 long icval = ic >> 3;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
324 if ((ic & 4) != 0) icval += CompileThreshold;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
325 if (mileage < icval) mileage = icval;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
326 long bcval = bc >> 3;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
327 if ((bc & 4) != 0) bcval += CompileThreshold;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
328 if (mileage < bcval) mileage = bcval;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
329 return (int)mileage;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
330 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
331
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
332 public int currentMileage() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
333 return 20000;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 1552
diff changeset
334 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }