annotate agent/src/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.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 4bec1b1f7b33
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5981
diff changeset
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
5981
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
4 *
5981
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
7 * published by the Free Software Foundation.
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
8 *
5981
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
13 * accompanied this code).
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
14 *
5981
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
15 * You should have received a copy of the GNU General Public License version
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
18 *
5981
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4bec1b1f7b33 7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents: 3939
diff changeset
21 * questions.
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
22 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
23 */
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
24
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
25 package sun.jvm.hotspot.oops;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
26
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
27 import java.io.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
28 import java.util.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
31 import sun.jvm.hotspot.types.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
32 import sun.jvm.hotspot.utilities.*;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
33
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
34 // ReceiverTypeData
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
35 //
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
36 // A ReceiverTypeData is used to access profiling information about a
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
37 // dynamic type check. It consists of a counter which counts the total times
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
38 // that the check is reached, and a series of (Klass, count) pairs
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
39 // which are used to store a type profile for the receiver of the check.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
40 public class ReceiverTypeData extends CounterData {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
41 static final int receiver0Offset = counterCellCount;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
42 static final int count0Offset = receiver0Offset + 1;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
43 static final int receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
44
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
45 public ReceiverTypeData(DataLayout layout) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
46 super(layout);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
47 //assert(layout.tag() == DataLayout.receiverTypeDataTag ||
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
48 // layout.tag() == DataLayout.virtualCallDataTag, "wrong type");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
49 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
50
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
51 boolean isReceivertypedata() { return true; }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
52
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
53 static int staticCellCount() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
54 return counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
55 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
56
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
57 public int cellCount() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
58 return staticCellCount();
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
59 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
60
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
61 // Direct accessors
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
62 public static int rowLimit() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
63 return MethodData.TypeProfileWidth;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
64 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
65 public static int receiverCellIndex(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
66 return receiver0Offset + row * receiverTypeRowCellCount;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
67 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
68 public static int receiverCountCellIndex(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
69 return count0Offset + row * receiverTypeRowCellCount;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
70 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
71
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
72 // Get the receiver at row. The 'unchecked' version is needed by parallel old
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
73 // gc; it does not assert the receiver is a klass. During compaction of the
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
74 // perm gen, the klass may already have moved, so the isKlass() predicate
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
75 // would fail. The 'normal' version should be used whenever possible.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
76 Klass receiverUnchecked(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
77 //assert(row < rowLimit(), "oob");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5981
diff changeset
78 Address recv = addressAt(receiverCellIndex(row));
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 5981
diff changeset
79 return (Klass)Metadata.instantiateWrapperFor(recv);
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
80 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
81
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
82 public Klass receiver(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
83 Klass recv = receiverUnchecked(row);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
84 //assert(recv == NULL || ((oop)recv).isKlass(), "wrong type");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
85 return recv;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
86 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
87
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
88 public int receiverCount(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
89 //assert(row < rowLimit(), "oob");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
90 return uintAt(receiverCountCellIndex(row));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
91 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
92
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
93 // Code generation support
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
94 static int receiverOffset(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
95 return cellOffset(receiverCellIndex(row));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
96 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
97 static int receiverCountOffset(int row) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
98 return cellOffset(receiverCountCellIndex(row));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
99 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
100 static int receiverTypeDataSize() {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
101 return cellOffset(staticCellCount());
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
102 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
103
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
104 void printReceiverDataOn(PrintStream st) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
105 int row;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
106 int entries = 0;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
107 for (row = 0; row < rowLimit(); row++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
108 if (receiver(row) != null) entries++;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
109 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
110 st.println("count(" + count() + ") entries(" + entries + ")");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
111 for (row = 0; row < rowLimit(); row++) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
112 if (receiver(row) != null) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
113 tab(st);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
114 receiver(row).printValueOn(st);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
115 st.println("(" + receiverCount(row) + ")");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
116 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
117 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
118 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
119 public void printDataOn(PrintStream st) {
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
120 printShared(st, "ReceiverTypeData");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
121 printReceiverDataOn(st);
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
122 }
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
123 }