author | shade |
Sun, 07 Apr 2019 13:28:18 +0200 | |
changeset 54449 | ac4b327623f6 |
parent 50577 | bf7e2684cd0a |
permissions | -rw-r--r-- |
10547 | 1 |
/* |
54449
ac4b327623f6
8221917: serviceability/sa/TestPrintMdo.java fails on 32-bit platforms
shade
parents:
50577
diff
changeset
|
2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
12265
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
10547 | 4 |
* |
12265
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
7 |
* published by the Free Software Foundation. |
10547 | 8 |
* |
12265
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
13 |
* accompanied this code). |
10547 | 14 |
* |
12265
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
10547 | 18 |
* |
12265
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
bc2565f91b58
7156960: Incorrect copyright headers in parts of the Serviceability agent
minqi
parents:
10547
diff
changeset
|
21 |
* questions. |
10547 | 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 class DataLayout { |
|
35 |
public static final int noTag = 0; |
|
36 |
public static final int bitDataTag = 1; |
|
37 |
public static final int counterDataTag = 2; |
|
38 |
public static final int jumpDataTag= 3; |
|
39 |
public static final int receiverTypeDataTag = 4; |
|
40 |
public static final int virtualCallDataTag = 5; |
|
41 |
public static final int retDataTag = 6; |
|
42 |
public static final int branchDataTag = 7; |
|
43 |
public static final int multiBranchDataTag = 8; |
|
24476
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
44 |
public static final int argInfoDataTag = 9; |
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
45 |
public static final int callTypeDataTag = 10; |
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
46 |
public static final int virtualCallTypeDataTag = 11; |
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
47 |
public static final int parametersTypeDataTag = 12; |
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
48 |
public static final int speculativeTrapDataTag = 13; |
10547 | 49 |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
50 |
// The trap state breaks down as [recompile:1 | reason:31]. |
10547 | 51 |
// This further breakdown is defined in deoptimization.cpp. |
52 |
// See Deoptimization.trapStateReason for an assert that |
|
53 |
// trapBits is big enough to hold reasons < reasonRecordedLimit. |
|
54 |
// |
|
55 |
// The trapState is collected only if ProfileTraps is true. |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
56 |
public static final int trapBits = 1+31; // 31: enough to distinguish [0..reasonRecordedLimit]. |
10547 | 57 |
public static final int trapMask = Bits.rightNBits(trapBits); |
58 |
public static final int firstFlag = 0; |
|
59 |
||
60 |
private Address data; |
|
61 |
||
62 |
private int offset; |
|
63 |
||
64 |
public DataLayout(MethodData d, int o) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
12265
diff
changeset
|
65 |
data = d.getAddress(); |
10547 | 66 |
offset = o; |
67 |
} |
|
68 |
||
69 |
public DataLayout(Address d, int o) { |
|
70 |
data = d; |
|
71 |
offset = o; |
|
72 |
} |
|
73 |
||
74 |
public int dp() { return offset; } |
|
75 |
||
76 |
private int getU11(int at) { |
|
77 |
return data.getJByteAt(offset + at) & 0xff; |
|
78 |
} |
|
79 |
||
80 |
private int getU22(int at) { |
|
81 |
return data.getJShortAt(offset + at) & 0xffff; |
|
82 |
} |
|
83 |
||
84 |
int cellAt(int index) { |
|
85 |
// Cells are intptr_t sized but only contain ints as raw values |
|
86 |
return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false); |
|
87 |
} |
|
88 |
||
89 |
public Address addressAt(int index) { |
|
24476
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
90 |
return data.getAddressAt(offset + cellOffset(index)); |
10547 | 91 |
} |
92 |
||
93 |
// Every data layout begins with a header. This header |
|
94 |
// contains a tag, which is used to indicate the size/layout |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
95 |
// of the data, 8 bits of flags, which can be used in any way, |
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
96 |
// 32 bits of trap history (none/one reason/many reasons), |
10547 | 97 |
// and a bci, which is used to tie this piece of data to a |
98 |
// specific bci in the bytecodes. |
|
99 |
// union { |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
100 |
// u8 _bits; |
10547 | 101 |
// struct { |
102 |
// u1 _tag; |
|
103 |
// u1 _flags; |
|
104 |
// u2 _bci; |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
105 |
// u4 _traps; |
10547 | 106 |
// } _struct; |
107 |
// } _header; |
|
108 |
||
109 |
// Some types of data layouts need a length field. |
|
110 |
static boolean needsArrayLen(int tag) { |
|
111 |
return (tag == multiBranchDataTag); |
|
112 |
} |
|
113 |
||
114 |
public static final int counterIncrement = 1; |
|
115 |
||
116 |
// Size computation |
|
117 |
static int headerSizeInBytes() { |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
118 |
return MethodData.cellSize * headerSizeInCells(); |
10547 | 119 |
} |
120 |
static int headerSizeInCells() { |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
121 |
return VM.getVM().isLP64() ? 1 : 2; |
10547 | 122 |
} |
123 |
||
24476
912595db2e75
8026694: New type profiling points break compilation replay
roland
parents:
13728
diff
changeset
|
124 |
static public int computeSizeInBytes(int cellCount) { |
10547 | 125 |
return headerSizeInBytes() + cellCount * MethodData.cellSize; |
126 |
} |
|
127 |
||
128 |
// Initialization |
|
129 |
// void initialize(int tag, int bci, int cellCount); |
|
130 |
||
131 |
// Accessors |
|
132 |
public int tag() { |
|
133 |
return getU11(0); |
|
134 |
} |
|
135 |
||
136 |
// Return a few bits of trap state. Range is [0..trapMask]. |
|
137 |
// The state tells if traps with zero, one, or many reasons have occurred. |
|
138 |
// It also tells whether zero or many recompilations have occurred. |
|
139 |
// The associated trap histogram in the MDO itself tells whether |
|
140 |
// traps are common or not. If a BCI shows that a trap X has |
|
141 |
// occurred, and the MDO shows N occurrences of X, we make the |
|
142 |
// simplifying assumption that all N occurrences can be blamed |
|
143 |
// on that BCI. |
|
144 |
int trapState() { |
|
50577
bf7e2684cd0a
8204240: Extend MDO to allow more reasons to be recorded per bci
roland
parents:
47216
diff
changeset
|
145 |
return data.getJIntAt(offset+4); |
10547 | 146 |
} |
147 |
||
148 |
int flags() { |
|
149 |
return getU11(1); |
|
150 |
} |
|
151 |
||
152 |
int bci() { |
|
153 |
return getU22(2); |
|
154 |
} |
|
155 |
||
156 |
boolean flagAt(int flagNumber) { |
|
157 |
// assert(flagNumber < flagLimit, "oob"); |
|
158 |
return (flags() & (0x1 << flagNumber)) != 0; |
|
159 |
} |
|
160 |
||
161 |
// Low-level support for code generation. |
|
162 |
static int headerOffset() { |
|
163 |
return 0; |
|
164 |
} |
|
165 |
static int tagOffset() { |
|
166 |
return 0; |
|
167 |
} |
|
168 |
static int flagsOffset() { |
|
169 |
return 1; |
|
170 |
} |
|
171 |
static int bciOffset() { |
|
172 |
return 2; |
|
173 |
} |
|
174 |
public static int cellOffset(int index) { |
|
54449
ac4b327623f6
8221917: serviceability/sa/TestPrintMdo.java fails on 32-bit platforms
shade
parents:
50577
diff
changeset
|
175 |
return (headerSizeInCells() + index) * MethodData.cellSize; |
10547 | 176 |
} |
177 |
// // Return a value which, when or-ed as a byte into _flags, sets the flag. |
|
178 |
// static int flagNumberToByteConstant(int flagNumber) { |
|
179 |
// assert(0 <= flagNumber && flagNumber < flagLimit, "oob"); |
|
180 |
// DataLayout temp; temp.setHeader(0); |
|
181 |
// temp.setFlagAt(flagNumber); |
|
182 |
// return temp._header._struct._flags; |
|
183 |
// } |
|
184 |
// // Return a value which, when or-ed as a word into _header, sets the flag. |
|
185 |
// static intptrT flagMaskToHeaderMask(int byteConstant) { |
|
186 |
// DataLayout temp; temp.setHeader(0); |
|
187 |
// temp._header._struct._flags = byteConstant; |
|
188 |
// return temp._header._bits; |
|
189 |
// } |
|
190 |
} |