Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/DataLayout.java
41161 views
1
/*
2
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
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;
44
public static final int argInfoDataTag = 9;
45
public static final int callTypeDataTag = 10;
46
public static final int virtualCallTypeDataTag = 11;
47
public static final int parametersTypeDataTag = 12;
48
public static final int speculativeTrapDataTag = 13;
49
50
// The trap state breaks down as [recompile:1 | reason:31].
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.
56
public static final int trapBits = 1+31; // 31: enough to distinguish [0..reasonRecordedLimit].
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) {
65
data = d.getAddress();
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
long cellAt(int index) {
85
return data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false);
86
}
87
88
public Address addressAt(int index) {
89
return data.getAddressAt(offset + cellOffset(index));
90
}
91
92
// Every data layout begins with a header. This header
93
// contains a tag, which is used to indicate the size/layout
94
// of the data, 8 bits of flags, which can be used in any way,
95
// 32 bits of trap history (none/one reason/many reasons),
96
// and a bci, which is used to tie this piece of data to a
97
// specific bci in the bytecodes.
98
// union {
99
// u8 _bits;
100
// struct {
101
// u1 _tag;
102
// u1 _flags;
103
// u2 _bci;
104
// u4 _traps;
105
// } _struct;
106
// } _header;
107
108
// Some types of data layouts need a length field.
109
static boolean needsArrayLen(int tag) {
110
return (tag == multiBranchDataTag);
111
}
112
113
public static final int counterIncrement = 1;
114
115
// Size computation
116
static int headerSizeInBytes() {
117
return MethodData.cellSize * headerSizeInCells();
118
}
119
static int headerSizeInCells() {
120
return VM.getVM().isLP64() ? 1 : 2;
121
}
122
123
static public int computeSizeInBytes(int cellCount) {
124
return headerSizeInBytes() + cellCount * MethodData.cellSize;
125
}
126
127
// Initialization
128
// void initialize(int tag, int bci, int cellCount);
129
130
// Accessors
131
public int tag() {
132
return getU11(0);
133
}
134
135
// Return a few bits of trap state. Range is [0..trapMask].
136
// The state tells if traps with zero, one, or many reasons have occurred.
137
// It also tells whether zero or many recompilations have occurred.
138
// The associated trap histogram in the MDO itself tells whether
139
// traps are common or not. If a BCI shows that a trap X has
140
// occurred, and the MDO shows N occurrences of X, we make the
141
// simplifying assumption that all N occurrences can be blamed
142
// on that BCI.
143
int trapState() {
144
return data.getJIntAt(offset+4);
145
}
146
147
int flags() {
148
return getU11(1);
149
}
150
151
int bci() {
152
return getU22(2);
153
}
154
155
boolean flagAt(int flagNumber) {
156
// assert(flagNumber < flagLimit, "oob");
157
return (flags() & (0x1 << flagNumber)) != 0;
158
}
159
160
// Low-level support for code generation.
161
static int headerOffset() {
162
return 0;
163
}
164
static int tagOffset() {
165
return 0;
166
}
167
static int flagsOffset() {
168
return 1;
169
}
170
static int bciOffset() {
171
return 2;
172
}
173
public static int cellOffset(int index) {
174
return (headerSizeInCells() + index) * MethodData.cellSize;
175
}
176
// // Return a value which, when or-ed as a byte into _flags, sets the flag.
177
// static int flagNumberToByteConstant(int flagNumber) {
178
// assert(0 <= flagNumber && flagNumber < flagLimit, "oob");
179
// DataLayout temp; temp.setHeader(0);
180
// temp.setFlagAt(flagNumber);
181
// return temp._header._struct._flags;
182
// }
183
// // Return a value which, when or-ed as a word into _header, sets the flag.
184
// static intptrT flagMaskToHeaderMask(int byteConstant) {
185
// DataLayout temp; temp.setHeader(0);
186
// temp._header._struct._flags = byteConstant;
187
// return temp._header._bits;
188
// }
189
}
190
191