8144024: Octane fails with "memory leak: allocating handle outside HandleMark"
Reviewed-by: kvn
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Nov 25 00:40:04 2015 +0100
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Nov 25 21:31:33 2015 +0300
@@ -3220,12 +3220,7 @@
DependencyContext java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(oop call_site) {
assert(java_lang_invoke_MethodHandleNatives_CallSiteContext::is_instance(call_site), "");
intptr_t* vmdeps_addr = (intptr_t*)call_site->address_field_addr(_vmdependencies_offset);
-#ifndef ASSERT
DependencyContext dep_ctx(vmdeps_addr);
-#else
- // Verify that call_site isn't moved during DependencyContext lifetime.
- DependencyContext dep_ctx(vmdeps_addr, Handle(call_site));
-#endif // ASSERT
return dep_ctx;
}
--- a/hotspot/src/share/vm/code/dependencyContext.hpp Wed Nov 25 00:40:04 2015 +0100
+++ b/hotspot/src/share/vm/code/dependencyContext.hpp Wed Nov 25 21:31:33 2015 +0300
@@ -114,22 +114,19 @@
public:
#ifdef ASSERT
- // Verification for dependency contexts rooted at Java objects.
- Handle _base; // non-NULL if dependency context resides in an oop (e.g. CallSite).
- oop _base_oop;
+ // Safepoints are forbidden during DC lifetime. GC can invalidate
+ // _dependency_context_addr if it relocates the holder
+ // (e.g. CallSiteContext Java object).
+ int _safepoint_counter;
- DependencyContext(intptr_t* addr, Handle base = Handle())
- : _dependency_context_addr(addr), _base(base)
- {
- _base_oop = _base();
- }
+ DependencyContext(intptr_t* addr) : _dependency_context_addr(addr),
+ _safepoint_counter(SafepointSynchronize::_safepoint_counter) {}
~DependencyContext() {
- // Base oop relocation invalidates _dependency_context_addr.
- assert(_base_oop == _base(), "base oop relocation is forbidden");
+ assert(_safepoint_counter == SafepointSynchronize::_safepoint_counter, "safepoint happened");
}
#else
- DependencyContext(intptr_t* addr) : _dependency_context_addr(addr) {}
+ DependencyContext(intptr_t* addr) : _dependency_context_addr(addr) {}
#endif // ASSERT
static const intptr_t EMPTY = 0; // dependencies = NULL, has_stale_entries = false