--- a/hotspot/src/share/vm/runtime/jniHandles.cpp Mon Feb 27 17:36:36 2017 +0100
+++ b/hotspot/src/share/vm/runtime/jniHandles.cpp Thu Mar 02 17:46:59 2017 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -31,9 +31,6 @@
#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;
@@ -95,48 +92,28 @@
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);
+ 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;
}
-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();
+ *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it
}
}
void JNIHandles::destroy_weak_global(jobject handle) {
if (handle != NULL) {
- jweak_ref(handle) = deleted_handle();
+ 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
}
}