< prev index next >

src/share/vm/runtime/jniHandles.cpp

Print this page
rev 12652 : [mq]: kimpatch

*** 1,7 **** /* ! * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 29,38 **** --- 29,41 ---- #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/jniHandles.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/thread.inline.hpp" + #if INCLUDE_ALL_GCS + #include "gc/g1/g1SATBCardTableModRefBS.hpp" + #endif JNIHandleBlock* JNIHandles::_global_handles = NULL; JNIHandleBlock* JNIHandles::_weak_global_handles = NULL; oop JNIHandles::_deleted_handle = NULL;
*** 90,121 **** jobject JNIHandles::make_weak_global(Handle obj) { assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC"); jobject res = NULL; if (!obj.is_null()) { // ignore null handles MutexLocker ml(JNIGlobalHandle_lock); assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); res = _weak_global_handles->allocate_handle(obj()); } else { CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); } return res; } void JNIHandles::destroy_global(jobject handle) { if (handle != NULL) { assert(is_global_handle(handle), "Invalid delete of global JNI handle"); ! *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it } } void JNIHandles::destroy_weak_global(jobject handle) { if (handle != NULL) { ! assert(!CheckJNICalls || is_weak_global_handle(handle), "Invalid delete of weak global JNI handle"); ! *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it } } void JNIHandles::oops_do(OopClosure* f) { --- 93,144 ---- jobject JNIHandles::make_weak_global(Handle obj) { assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC"); jobject res = NULL; if (!obj.is_null()) { // ignore null handles + { MutexLocker ml(JNIGlobalHandle_lock); assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); res = _weak_global_handles->allocate_handle(obj()); + } + // Add weak tag. + assert(is_ptr_aligned(res, weak_tag_alignment), "invariant"); + char* tptr = reinterpret_cast<char*>(res) + weak_tag_value; + res = reinterpret_cast<jobject>(tptr); } else { CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); } return res; } + template<bool external_guard> + oop JNIHandles::resolve_jweak(jweak handle) { + assert(is_jweak(handle), "precondition"); + oop result = jweak_ref(handle); + result = guard_value<external_guard>(result); + #if INCLUDE_ALL_GCS + if (result != NULL && UseG1GC) { + G1SATBCardTableModRefBS::enqueue(result); + } + #endif // INCLUDE_ALL_GCS + return result; + } + + template oop JNIHandles::resolve_jweak<true>(jweak); + template oop JNIHandles::resolve_jweak<false>(jweak); void JNIHandles::destroy_global(jobject handle) { if (handle != NULL) { assert(is_global_handle(handle), "Invalid delete of global JNI handle"); ! jobject_ref(handle) = deleted_handle(); } } void JNIHandles::destroy_weak_global(jobject handle) { if (handle != NULL) { ! jweak_ref(handle) = deleted_handle(); } } void JNIHandles::oops_do(OopClosure* f) {
< prev index next >