Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/oops/DataLayout.java @ 17736:58fc1b1523dc
8034079: G1: Refactor the HeapRegionSet hierarchy
Reviewed-by: tschatzl, pliden
author | brutisso |
---|---|
date | Fri, 14 Mar 2014 10:15:46 +0100 |
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 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 | |
45 // The _struct._flags word is formatted as [trapState:4 | flags:4]. | |
46 // The trap state breaks down further as [recompile:1 | reason:3]. | |
47 // This further breakdown is defined in deoptimization.cpp. | |
48 // See Deoptimization.trapStateReason for an assert that | |
49 // trapBits is big enough to hold reasons < reasonRecordedLimit. | |
50 // | |
51 // The trapState is collected only if ProfileTraps is true. | |
52 public static final int trapBits = 1+3; // 3: enough to distinguish [0..reasonRecordedLimit]. | |
53 public static final int trapShift = 8 - trapBits; | |
54 public static final int trapMask = Bits.rightNBits(trapBits); | |
55 public static final int trapMaskInPlace = (trapMask << trapShift); | |
56 public static final int flagLimit = trapShift; | |
57 public static final int flagMask = Bits.rightNBits(flagLimit); | |
58 public static final int firstFlag = 0; | |
59 | |
60 private Address data; | |
61 | |
62 private int offset; | |
63 | |
64 private boolean handlized; | |
65 | |
66 public DataLayout(MethodData d, int o) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
5981
diff
changeset
|
67 data = d.getAddress(); |
3939 | 68 offset = o; |
69 } | |
70 | |
71 public DataLayout(Address d, int o) { | |
72 data = d; | |
73 offset = o; | |
74 handlized = true; | |
75 } | |
76 | |
77 public int dp() { return offset; } | |
78 | |
79 private int getU11(int at) { | |
80 return data.getJByteAt(offset + at) & 0xff; | |
81 } | |
82 | |
83 private int getU22(int at) { | |
84 return data.getJShortAt(offset + at) & 0xffff; | |
85 } | |
86 | |
87 int cellAt(int index) { | |
88 // Cells are intptr_t sized but only contain ints as raw values | |
89 return (int)data.getCIntegerAt(offset + cellOffset(index), MethodData.cellSize, false); | |
90 } | |
91 | |
92 public Address addressAt(int index) { | |
93 OopHandle handle; | |
94 if (handlized) { | |
95 return data.getAddressAt(offset + cellOffset(index)); | |
96 } else { | |
97 return data.getOopHandleAt(offset + cellOffset(index)); | |
98 } | |
99 } | |
100 | |
101 // Every data layout begins with a header. This header | |
102 // contains a tag, which is used to indicate the size/layout | |
103 // of the data, 4 bits of flags, which can be used in any way, | |
104 // 4 bits of trap history (none/one reason/many reasons), | |
105 // and a bci, which is used to tie this piece of data to a | |
106 // specific bci in the bytecodes. | |
107 // union { | |
108 // intptrT _bits; | |
109 // struct { | |
110 // u1 _tag; | |
111 // u1 _flags; | |
112 // u2 _bci; | |
113 // } _struct; | |
114 // } _header; | |
115 | |
116 // Some types of data layouts need a length field. | |
117 static boolean needsArrayLen(int tag) { | |
118 return (tag == multiBranchDataTag); | |
119 } | |
120 | |
121 public static final int counterIncrement = 1; | |
122 | |
123 // Size computation | |
124 static int headerSizeInBytes() { | |
125 return MethodData.cellSize; | |
126 } | |
127 static int headerSizeInCells() { | |
128 return 1; | |
129 } | |
130 | |
131 static int computeSizeInBytes(int cellCount) { | |
132 return headerSizeInBytes() + cellCount * MethodData.cellSize; | |
133 } | |
134 | |
135 // Initialization | |
136 // void initialize(int tag, int bci, int cellCount); | |
137 | |
138 // Accessors | |
139 public int tag() { | |
140 return getU11(0); | |
141 } | |
142 | |
143 // Return a few bits of trap state. Range is [0..trapMask]. | |
144 // The state tells if traps with zero, one, or many reasons have occurred. | |
145 // It also tells whether zero or many recompilations have occurred. | |
146 // The associated trap histogram in the MDO itself tells whether | |
147 // traps are common or not. If a BCI shows that a trap X has | |
148 // occurred, and the MDO shows N occurrences of X, we make the | |
149 // simplifying assumption that all N occurrences can be blamed | |
150 // on that BCI. | |
151 int trapState() { | |
152 return (flags() >> trapShift) & trapMask; | |
153 } | |
154 | |
155 int flags() { | |
156 return getU11(1); | |
157 } | |
158 | |
159 int bci() { | |
160 return getU22(2); | |
161 } | |
162 | |
163 boolean flagAt(int flagNumber) { | |
164 // assert(flagNumber < flagLimit, "oob"); | |
165 return (flags() & (0x1 << flagNumber)) != 0; | |
166 } | |
167 | |
168 // Low-level support for code generation. | |
169 static int headerOffset() { | |
170 return 0; | |
171 } | |
172 static int tagOffset() { | |
173 return 0; | |
174 } | |
175 static int flagsOffset() { | |
176 return 1; | |
177 } | |
178 static int bciOffset() { | |
179 return 2; | |
180 } | |
181 public static int cellOffset(int index) { | |
182 return MethodData.cellSize + index * MethodData.cellSize; | |
183 } | |
184 // // Return a value which, when or-ed as a byte into _flags, sets the flag. | |
185 // static int flagNumberToByteConstant(int flagNumber) { | |
186 // assert(0 <= flagNumber && flagNumber < flagLimit, "oob"); | |
187 // DataLayout temp; temp.setHeader(0); | |
188 // temp.setFlagAt(flagNumber); | |
189 // return temp._header._struct._flags; | |
190 // } | |
191 // // Return a value which, when or-ed as a word into _header, sets the flag. | |
192 // static intptrT flagMaskToHeaderMask(int byteConstant) { | |
193 // DataLayout temp; temp.setHeader(0); | |
194 // temp._header._struct._flags = byteConstant; | |
195 // return temp._header._bits; | |
196 // } | |
197 } |