Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/unsafe.cpp @ 3252:92add02409c9
Merge
author | jmasa |
---|---|
date | Fri, 08 Apr 2011 14:19:50 -0700 |
parents | 38fea01eb669 e1162778c1c8 |
children | 19241ae0d839 |
comparison
equal
deleted
inserted
replaced
2437:4f978fb6c81a | 3252:92add02409c9 |
---|---|
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "classfile/vmSymbols.hpp" | 26 #include "classfile/vmSymbols.hpp" |
27 #ifndef SERIALGC | |
28 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" | |
29 #endif // SERIALGC | |
27 #include "memory/allocation.inline.hpp" | 30 #include "memory/allocation.inline.hpp" |
28 #include "prims/jni.h" | 31 #include "prims/jni.h" |
29 #include "prims/jvm.h" | 32 #include "prims/jvm.h" |
30 #include "runtime/globals.hpp" | 33 #include "runtime/globals.hpp" |
31 #include "runtime/interfaceSupport.hpp" | 34 #include "runtime/interfaceSupport.hpp" |
191 // The xxx140 variants for backward compatibility do not allow a full-width offset. | 194 // The xxx140 variants for backward compatibility do not allow a full-width offset. |
192 UNSAFE_ENTRY(jobject, Unsafe_GetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset)) | 195 UNSAFE_ENTRY(jobject, Unsafe_GetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset)) |
193 UnsafeWrapper("Unsafe_GetObject"); | 196 UnsafeWrapper("Unsafe_GetObject"); |
194 if (obj == NULL) THROW_0(vmSymbols::java_lang_NullPointerException()); | 197 if (obj == NULL) THROW_0(vmSymbols::java_lang_NullPointerException()); |
195 GET_OOP_FIELD(obj, offset, v) | 198 GET_OOP_FIELD(obj, offset, v) |
196 return JNIHandles::make_local(env, v); | 199 jobject ret = JNIHandles::make_local(env, v); |
200 #ifndef SERIALGC | |
201 // We could be accessing the referent field in a reference | |
202 // object. If G1 is enabled then we need to register a non-null | |
203 // referent with the SATB barrier. | |
204 if (UseG1GC) { | |
205 bool needs_barrier = false; | |
206 | |
207 if (ret != NULL) { | |
208 if (offset == java_lang_ref_Reference::referent_offset) { | |
209 oop o = JNIHandles::resolve_non_null(obj); | |
210 klassOop k = o->klass(); | |
211 if (instanceKlass::cast(k)->reference_type() != REF_NONE) { | |
212 assert(instanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); | |
213 needs_barrier = true; | |
214 } | |
215 } | |
216 } | |
217 | |
218 if (needs_barrier) { | |
219 oop referent = JNIHandles::resolve(ret); | |
220 G1SATBCardTableModRefBS::enqueue(referent); | |
221 } | |
222 } | |
223 #endif // SERIALGC | |
224 return ret; | |
197 UNSAFE_END | 225 UNSAFE_END |
198 | 226 |
199 UNSAFE_ENTRY(void, Unsafe_SetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset, jobject x_h)) | 227 UNSAFE_ENTRY(void, Unsafe_SetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset, jobject x_h)) |
200 UnsafeWrapper("Unsafe_SetObject"); | 228 UnsafeWrapper("Unsafe_SetObject"); |
201 if (obj == NULL) THROW(vmSymbols::java_lang_NullPointerException()); | 229 if (obj == NULL) THROW(vmSymbols::java_lang_NullPointerException()); |
224 // But if the base pointer is non-null, the offset should make some sense. | 252 // But if the base pointer is non-null, the offset should make some sense. |
225 // That is, it should be in the range [0, MAX_OBJECT_SIZE]. | 253 // That is, it should be in the range [0, MAX_OBJECT_SIZE]. |
226 UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) | 254 UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) |
227 UnsafeWrapper("Unsafe_GetObject"); | 255 UnsafeWrapper("Unsafe_GetObject"); |
228 GET_OOP_FIELD(obj, offset, v) | 256 GET_OOP_FIELD(obj, offset, v) |
229 return JNIHandles::make_local(env, v); | 257 jobject ret = JNIHandles::make_local(env, v); |
258 #ifndef SERIALGC | |
259 // We could be accessing the referent field in a reference | |
260 // object. If G1 is enabled then we need to register non-null | |
261 // referent with the SATB barrier. | |
262 if (UseG1GC) { | |
263 bool needs_barrier = false; | |
264 | |
265 if (ret != NULL) { | |
266 if (offset == java_lang_ref_Reference::referent_offset && obj != NULL) { | |
267 oop o = JNIHandles::resolve(obj); | |
268 klassOop k = o->klass(); | |
269 if (instanceKlass::cast(k)->reference_type() != REF_NONE) { | |
270 assert(instanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); | |
271 needs_barrier = true; | |
272 } | |
273 } | |
274 } | |
275 | |
276 if (needs_barrier) { | |
277 oop referent = JNIHandles::resolve(ret); | |
278 G1SATBCardTableModRefBS::enqueue(referent); | |
279 } | |
280 } | |
281 #endif // SERIALGC | |
282 return ret; | |
230 UNSAFE_END | 283 UNSAFE_END |
231 | 284 |
232 UNSAFE_ENTRY(void, Unsafe_SetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) | 285 UNSAFE_ENTRY(void, Unsafe_SetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) |
233 UnsafeWrapper("Unsafe_SetObject"); | 286 UnsafeWrapper("Unsafe_SetObject"); |
234 oop x = JNIHandles::resolve(x_h); | 287 oop x = JNIHandles::resolve(x_h); |