8141421: Various test fail with OOME on win x86

Fix memory overuse in g1CodeCacheRemset

Reviewed-by: tschatzl, mgerdin
This commit is contained in:
Derek White 2016-01-22 06:13:52 -05:00
parent 17b9e0a7aa
commit a42a7f2376
2 changed files with 25 additions and 9 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
@ -785,6 +785,9 @@ void HeapRegionRemSet::scrub(CardTableModRefBS* ctbs,
void HeapRegionRemSet::add_strong_code_root(nmethod* nm) {
assert(nm != NULL, "sanity");
assert((!CodeCache_lock->owned_by_self() || SafepointSynchronize::is_at_safepoint()),
"should call add_strong_code_root_locked instead. CodeCache_lock->owned_by_self(): %s, is_at_safepoint(): %s",
BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()));
// Optimistic unlocked contains-check
if (!_code_roots.contains(nm)) {
MutexLockerEx ml(&_m, Mutex::_no_safepoint_check_flag);
@ -794,6 +797,12 @@ void HeapRegionRemSet::add_strong_code_root(nmethod* nm) {
void HeapRegionRemSet::add_strong_code_root_locked(nmethod* nm) {
assert(nm != NULL, "sanity");
assert((CodeCache_lock->owned_by_self() ||
(SafepointSynchronize::is_at_safepoint() &&
(_m.owned_by_self() || Thread::current()->is_VM_thread()))),
"not safely locked. CodeCache_lock->owned_by_self(): %s, is_at_safepoint(): %s, _m.owned_by_self(): %s, Thread::current()->is_VM_thread(): %s",
BOOL_TO_STR(CodeCache_lock->owned_by_self()), BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()),
BOOL_TO_STR(_m.owned_by_self()), BOOL_TO_STR(Thread::current()->is_VM_thread()));
_code_roots.add(nm);
}