annotate agent/src/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java @ 3972:4f93f0d00802

7059019: G1: add G1 support to the SA Summary: Extend the SA to recognize the G1CollectedHeap and implement any code that's needed by our serviceability tools (jmap, jinfo, jstack, etc.) that depend on the SA. Reviewed-by: never, poonam, johnc
author tonyp
date Tue, 20 Sep 2011 09:59:59 -0400
parents f6f3bb0ee072
children 4bec1b1f7b33
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 /*
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
3 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
4 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
5 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
6 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
7 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
8 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
9 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
10 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
11 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
12 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
13 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
14 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
15 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
16 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
17 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
18 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
19 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
20 *
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
21 *
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");
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
78 Oop recv = oopAt(receiverCellIndex(row));
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents:
diff changeset
79 return (Klass)recv;
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 }