annotate src/share/vm/runtime/jfieldIDWorkaround.hpp @ 10292:acac2b03a07f

8014765: VM exits if MaxTenuringThreshold is set below the default InitialTenuringThreshold, and InitialTenuringThreshold is not set Summary: The VM exits when the condition in the subject line applies. The fix sets InitialTenuringThreshold to MaxTenuringThreshold if it is larger than MaxTenuringThreshold and InitialTenuringThreshold has not been set (is default). Reviewed-by: jwilhelm, jmasa, brutisso, johnc
author tschatzl
date Thu, 16 May 2013 23:51:51 +0200
parents da91efe96a93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_RUNTIME_JFIELDIDWORKAROUND_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_JFIELDIDWORKAROUND_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class jfieldIDWorkaround: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // This workaround is because JVMTI doesn't have distinct entry points
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // for methods that use static jfieldIDs and instance jfieldIDs.
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // The workaround is to steal a low-order bit:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // a 1 means the jfieldID is an instance jfieldID,
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // and the rest of the word is the offset of the field.
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // a 0 means the jfieldID is a static jfieldID,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // and the rest of the word is the JNIid*.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Another low-order bit is used to mark if an instance field
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // is accompanied by an indication of which class it applies to.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Bit-format of a jfieldID (most significant first):
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // address:30 instance=0:1 checked=0:1
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // offset:30 instance=1:1 checked=0:1
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // klass:23 offset:7 instance=1:1 checked=1:1
a61af66fc99e Initial load
duke
parents:
diff changeset
44 //
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // If the offset does not fit in 7 bits, or if the fieldID is
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // not checked, then the checked bit is zero and the rest of
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // the word (30 bits) contains only the offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 //
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
50 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 checked_bits = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
52 instance_bits = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
53 address_bits = BitsPerWord - checked_bits - instance_bits,
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 large_offset_bits = address_bits, // unioned with address
a61af66fc99e Initial load
duke
parents:
diff changeset
56 small_offset_bits = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 klass_bits = address_bits - small_offset_bits,
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 checked_shift = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
60 instance_shift = checked_shift + checked_bits,
a61af66fc99e Initial load
duke
parents:
diff changeset
61 address_shift = instance_shift + instance_bits,
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 offset_shift = address_shift, // unioned with address
a61af66fc99e Initial load
duke
parents:
diff changeset
64 klass_shift = offset_shift + small_offset_bits,
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 checked_mask_in_place = right_n_bits(checked_bits) << checked_shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 instance_mask_in_place = right_n_bits(instance_bits) << instance_shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #ifndef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
69 large_offset_mask = right_n_bits(large_offset_bits),
a61af66fc99e Initial load
duke
parents:
diff changeset
70 small_offset_mask = right_n_bits(small_offset_bits),
a61af66fc99e Initial load
duke
parents:
diff changeset
71 klass_mask = right_n_bits(klass_bits)
a61af66fc99e Initial load
duke
parents:
diff changeset
72 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
73 };
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // These values are too big for Win64
a61af66fc99e Initial load
duke
parents:
diff changeset
77 const static uintptr_t large_offset_mask = right_n_bits(large_offset_bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 const static uintptr_t small_offset_mask = right_n_bits(small_offset_bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 const static uintptr_t klass_mask = right_n_bits(klass_bits);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // helper routines:
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static bool is_checked_jfieldID(jfieldID id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 uintptr_t as_uint = (uintptr_t) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return ((as_uint & checked_mask_in_place) != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 static intptr_t raw_instance_offset(jfieldID id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 uintptr_t result = (uintptr_t) id >> address_shift;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (VerifyJNIFields && is_checked_jfieldID(id)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 result &= small_offset_mask; // cut off the hash bits
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return (intptr_t)result;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
94 static intptr_t encode_klass_hash(Klass* k, intptr_t offset);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
95 static bool klass_hash_ok(Klass* k, jfieldID id);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
96 static void verify_instance_jfieldID(Klass* k, jfieldID id);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
99 static bool is_valid_jfieldID(Klass* k, jfieldID id);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
100
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
101 static bool is_instance_jfieldID(Klass* k, jfieldID id) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102 uintptr_t as_uint = (uintptr_t) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return ((as_uint & instance_mask_in_place) != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 static bool is_static_jfieldID(jfieldID id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 uintptr_t as_uint = (uintptr_t) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return ((as_uint & instance_mask_in_place) == 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
110 static jfieldID to_instance_jfieldID(Klass* k, int offset) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111 intptr_t as_uint = ((offset & large_offset_mask) << offset_shift) | instance_mask_in_place;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (VerifyJNIFields) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 as_uint |= encode_klass_hash(k, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 jfieldID result = (jfieldID) as_uint;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 #ifndef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // always verify in debug mode; switchable in anything else
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (VerifyJNIFields)
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
120 {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 verify_instance_jfieldID(k, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 assert(raw_instance_offset(result) == (offset & large_offset_mask), "extract right offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
127 static intptr_t from_instance_jfieldID(Klass* k, jfieldID id) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 #ifndef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // always verify in debug mode; switchable in anything else
a61af66fc99e Initial load
duke
parents:
diff changeset
130 if (VerifyJNIFields)
a61af66fc99e Initial load
duke
parents:
diff changeset
131 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
132 {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 verify_instance_jfieldID(k, id);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return raw_instance_offset(id);
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 static jfieldID to_static_jfieldID(JNIid* id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 assert(id->is_static_field_id(), "from_JNIid, but not static field id");
a61af66fc99e Initial load
duke
parents:
diff changeset
140 jfieldID result = (jfieldID) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(from_static_jfieldID(result) == id, "must produce the same static id");
a61af66fc99e Initial load
duke
parents:
diff changeset
142 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 static JNIid* from_static_jfieldID(jfieldID id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 assert(jfieldIDWorkaround::is_static_jfieldID(id),
a61af66fc99e Initial load
duke
parents:
diff changeset
147 "to_JNIid, but not static jfieldID");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 JNIid* result = (JNIid*) id;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 assert(result->is_static_field_id(), "to_JNIid, but not static field id");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 static jfieldID to_jfieldID(instanceKlassHandle k, int offset, bool is_static) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (is_static) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 JNIid *id = k->jni_id_for(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 debug_only(id->set_is_static_field_id());
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return jfieldIDWorkaround::to_static_jfieldID(id);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return jfieldIDWorkaround::to_instance_jfieldID(k(), offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
163
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
164 #endif // SHARE_VM_RUNTIME_JFIELDIDWORKAROUND_HPP