Mercurial > hg > graal-jvmci-8
annotate agent/src/share/classes/sun/jvm/hotspot/oops/ReceiverTypeData.java @ 24234:ea6f94ab283b default tip
Added tag jvmci-0.36 for changeset 8128b98d4736
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 18 Sep 2017 18:49:45 +0200 |
parents | da91efe96a93 |
children |
rev | line source |
---|---|
3939 | 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 | 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 | 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 | 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 | 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 | 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 // ReceiverTypeData | |
35 // | |
36 // A ReceiverTypeData is used to access profiling information about a | |
37 // dynamic type check. It consists of a counter which counts the total times | |
38 // that the check is reached, and a series of (Klass, count) pairs | |
39 // which are used to store a type profile for the receiver of the check. | |
40 public class ReceiverTypeData extends CounterData { | |
41 static final int receiver0Offset = counterCellCount; | |
42 static final int count0Offset = receiver0Offset + 1; | |
43 static final int receiverTypeRowCellCount = (count0Offset + 1) - receiver0Offset; | |
44 | |
45 public ReceiverTypeData(DataLayout layout) { | |
46 super(layout); | |
47 //assert(layout.tag() == DataLayout.receiverTypeDataTag || | |
48 // layout.tag() == DataLayout.virtualCallDataTag, "wrong type"); | |
49 } | |
50 | |
51 boolean isReceivertypedata() { return true; } | |
52 | |
53 static int staticCellCount() { | |
54 return counterCellCount + MethodData.TypeProfileWidth * receiverTypeRowCellCount; | |
55 } | |
56 | |
57 public int cellCount() { | |
58 return staticCellCount(); | |
59 } | |
60 | |
61 // Direct accessors | |
62 public static int rowLimit() { | |
63 return MethodData.TypeProfileWidth; | |
64 } | |
65 public static int receiverCellIndex(int row) { | |
66 return receiver0Offset + row * receiverTypeRowCellCount; | |
67 } | |
68 public static int receiverCountCellIndex(int row) { | |
69 return count0Offset + row * receiverTypeRowCellCount; | |
70 } | |
71 | |
72 // Get the receiver at row. The 'unchecked' version is needed by parallel old | |
73 // gc; it does not assert the receiver is a klass. During compaction of the | |
74 // perm gen, the klass may already have moved, so the isKlass() predicate | |
75 // would fail. The 'normal' version should be used whenever possible. | |
76 Klass receiverUnchecked(int row) { | |
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 | 80 } |
81 | |
82 public Klass receiver(int row) { | |
83 Klass recv = receiverUnchecked(row); | |
84 //assert(recv == NULL || ((oop)recv).isKlass(), "wrong type"); | |
85 return recv; | |
86 } | |
87 | |
88 public int receiverCount(int row) { | |
89 //assert(row < rowLimit(), "oob"); | |
90 return uintAt(receiverCountCellIndex(row)); | |
91 } | |
92 | |
93 // Code generation support | |
94 static int receiverOffset(int row) { | |
95 return cellOffset(receiverCellIndex(row)); | |
96 } | |
97 static int receiverCountOffset(int row) { | |
98 return cellOffset(receiverCountCellIndex(row)); | |
99 } | |
100 static int receiverTypeDataSize() { | |
101 return cellOffset(staticCellCount()); | |
102 } | |
103 | |
104 void printReceiverDataOn(PrintStream st) { | |
105 int row; | |
106 int entries = 0; | |
107 for (row = 0; row < rowLimit(); row++) { | |
108 if (receiver(row) != null) entries++; | |
109 } | |
110 st.println("count(" + count() + ") entries(" + entries + ")"); | |
111 for (row = 0; row < rowLimit(); row++) { | |
112 if (receiver(row) != null) { | |
113 tab(st); | |
114 receiver(row).printValueOn(st); | |
115 st.println("(" + receiverCount(row) + ")"); | |
116 } | |
117 } | |
118 } | |
119 public void printDataOn(PrintStream st) { | |
120 printShared(st, "ReceiverTypeData"); | |
121 printReceiverDataOn(st); | |
122 } | |
123 } |