# HG changeset patch # User iveresov # Date 1227133251 28800 # Node ID b5e603f2e02480180ace404141897cf8f6266e93 # Parent 491a904952f2af6aeb750f9d18ed07a9d514c72c# Parent 8fa025608ec6fc5a2bce99ece1d648873741bc6b Merge diff -r 491a904952f2 -r b5e603f2e024 make/solaris/makefiles/dtrace.make --- a/make/solaris/makefiles/dtrace.make Wed Nov 19 09:09:31 2008 -0800 +++ b/make/solaris/makefiles/dtrace.make Wed Nov 19 14:20:51 2008 -0800 @@ -115,27 +115,25 @@ $(QUIETLY) $(LINK.CC) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \ ./lib$(GENOFFS).so -# $@.tmp is created first. It's to avoid empty $(JVMOFFS).h produced in error case. +CONDITIONALLY_UPDATE_JVMOFFS_TARGET = \ + cmp -s $@ $@.tmp; \ + case $$? in \ + 0) rm -f $@.tmp;; \ + *) rm -f $@ && mv $@.tmp $@ && echo Updated $@;; \ + esac + +# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs. $(JVMOFFS).h: $(GENOFFS) - $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp ; \ - if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ - then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \ - else rm -f $@.tmp; \ - fi + $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -header > $@.tmp + $(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET) $(JVMOFFS)Index.h: $(GENOFFS) - $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp ; \ - if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ - then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \ - else rm -f $@.tmp; \ - fi + $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -index > $@.tmp + $(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET) $(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h - $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp ; \ - if [ `diff $@.tmp $@ > /dev/null 2>&1; echo $$?` -ne 0 ] ; \ - then rm -f $@; mv $@.tmp $@; echo Updated $@ ; \ - else rm -f $@.tmp; \ - fi + $(QUIETLY) LD_LIBRARY_PATH=. ./$(GENOFFS) -table > $@.tmp + $(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET) $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp $(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp diff -r 491a904952f2 -r b5e603f2e024 make/windows/projectfiles/common/Makefile --- a/make/windows/projectfiles/common/Makefile Wed Nov 19 09:09:31 2008 -0800 +++ b/make/windows/projectfiles/common/Makefile Wed Nov 19 14:20:51 2008 -0800 @@ -56,7 +56,8 @@ $(HOTSPOTWORKSPACE)/src/share/vm/gc_implementation/includeDB_gc_shared \ $(HOTSPOTWORKSPACE)/src/share/vm/gc_implementation/includeDB_gc_parNew \ $(HOTSPOTWORKSPACE)/src/share/vm/gc_implementation/includeDB_gc_parallelScavenge \ - $(HOTSPOTWORKSPACE)/src/share/vm/gc_implementation/includeDB_gc_concurrentMarkSweep + $(HOTSPOTWORKSPACE)/src/share/vm/gc_implementation/includeDB_gc_concurrentMarkSweep \ + $(HOTSPOTWORKSPACE)/src/share/vm/gc_implementation/includeDB_gc_g1 IncludeDBs_kernel =$(IncludeDBs_base) \ diff -r 491a904952f2 -r b5e603f2e024 src/os/solaris/vm/os_solaris.cpp --- a/src/os/solaris/vm/os_solaris.cpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/os/solaris/vm/os_solaris.cpp Wed Nov 19 14:20:51 2008 -0800 @@ -3756,7 +3756,6 @@ int maxClamped = MIN2(iaLimits.maxPrio, (int)iaInfo->ia_uprilim); iaInfo->ia_upri = scale_to_lwp_priority(iaLimits.minPrio, maxClamped, newPrio); iaInfo->ia_uprilim = IA_NOCHANGE; - iaInfo->ia_nice = IA_NOCHANGE; iaInfo->ia_mode = IA_NOCHANGE; if (ThreadPriorityVerbose) { tty->print_cr ("IA: [%d...%d] %d->%d\n", diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/gc_implementation/concurrentMarkSweep/concurrentGCThread.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentGCThread.cpp Wed Nov 19 09:09:31 2008 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,314 +0,0 @@ -/* - * Copyright 2001-2005 Sun Microsystems, Inc. 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -// CopyrightVersion 1.2 - -# include "incls/_precompiled.incl" -# include "incls/_concurrentGCThread.cpp.incl" - -bool ConcurrentGCThread::_should_terminate = false; -bool ConcurrentGCThread::_has_terminated = false; -int ConcurrentGCThread::_CGC_flag = CGC_nil; - -SuspendibleThreadSet ConcurrentGCThread::_sts; - -ConcurrentGCThread::ConcurrentGCThread() { - _sts.initialize(); -}; - -void ConcurrentGCThread::stopWorldAndDo(VoidClosure* op) { - MutexLockerEx x(Heap_lock, - Mutex::_no_safepoint_check_flag); - // warning("CGC: about to try stopping world"); - SafepointSynchronize::begin(); - // warning("CGC: successfully stopped world"); - op->do_void(); - SafepointSynchronize::end(); - // warning("CGC: successfully restarted world"); -} - -void ConcurrentGCThread::safepoint_synchronize() { - _sts.suspend_all(); -} - -void ConcurrentGCThread::safepoint_desynchronize() { - _sts.resume_all(); -} - -void ConcurrentGCThread::create_and_start() { - if (os::create_thread(this, os::cgc_thread)) { - // XXX: need to set this to low priority - // unless "agressive mode" set; priority - // should be just less than that of VMThread. - os::set_priority(this, NearMaxPriority); - if (!_should_terminate && !DisableStartThread) { - os::start_thread(this); - } - } -} - -void ConcurrentGCThread::initialize_in_thread() { - this->record_stack_base_and_size(); - this->initialize_thread_local_storage(); - this->set_active_handles(JNIHandleBlock::allocate_block()); - // From this time Thread::current() should be working. - assert(this == Thread::current(), "just checking"); -} - -void ConcurrentGCThread::wait_for_universe_init() { - MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); - while (!is_init_completed() && !_should_terminate) { - CGC_lock->wait(Mutex::_no_safepoint_check_flag, 200); - } -} - -void ConcurrentGCThread::terminate() { - // Signal that it is terminated - { - MutexLockerEx mu(Terminator_lock, - Mutex::_no_safepoint_check_flag); - _has_terminated = true; - Terminator_lock->notify(); - } - - // Thread destructor usually does this.. - ThreadLocalStorage::set_thread(NULL); -} - - -void SuspendibleThreadSet::initialize_work() { - MutexLocker x(STS_init_lock); - if (!_initialized) { - _m = new Monitor(Mutex::leaf, - "SuspendibleThreadSetLock", true); - _async = 0; - _async_stop = false; - _async_stopped = 0; - _initialized = true; - } -} - -void SuspendibleThreadSet::join() { - initialize(); - MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); - while (_async_stop) _m->wait(Mutex::_no_safepoint_check_flag); - _async++; - assert(_async > 0, "Huh."); -} - -void SuspendibleThreadSet::leave() { - assert(_initialized, "Must be initialized."); - MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); - _async--; - assert(_async >= 0, "Huh."); - if (_async_stop) _m->notify_all(); -} - -void SuspendibleThreadSet::yield(const char* id) { - assert(_initialized, "Must be initialized."); - if (_async_stop) { - MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); - if (_async_stop) { - _async_stopped++; - assert(_async_stopped > 0, "Huh."); - if (_async_stopped == _async) { - if (ConcGCYieldTimeout > 0) { - double now = os::elapsedTime(); - guarantee((now - _suspend_all_start) * 1000.0 < - (double)ConcGCYieldTimeout, - "Long delay; whodunit?"); - } - } - _m->notify_all(); - while (_async_stop) _m->wait(Mutex::_no_safepoint_check_flag); - _async_stopped--; - assert(_async >= 0, "Huh"); - _m->notify_all(); - } - } -} - -void SuspendibleThreadSet::suspend_all() { - initialize(); // If necessary. - if (ConcGCYieldTimeout > 0) { - _suspend_all_start = os::elapsedTime(); - } - MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); - assert(!_async_stop, "Only one at a time."); - _async_stop = true; - while (_async_stopped < _async) _m->wait(Mutex::_no_safepoint_check_flag); -} - -void SuspendibleThreadSet::resume_all() { - assert(_initialized, "Must be initialized."); - MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); - assert(_async_stopped == _async, "Huh."); - _async_stop = false; - _m->notify_all(); -} - -static void _sltLoop(JavaThread* thread, TRAPS) { - SurrogateLockerThread* slt = (SurrogateLockerThread*)thread; - slt->loop(); -} - -SurrogateLockerThread::SurrogateLockerThread() : - JavaThread(&_sltLoop), - _monitor(Mutex::nonleaf, "SLTMonitor"), - _buffer(empty) -{} - -SurrogateLockerThread* SurrogateLockerThread::make(TRAPS) { - klassOop k = - SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), - true, CHECK_NULL); - instanceKlassHandle klass (THREAD, k); - instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL); - - const char thread_name[] = "Surrogate Locker Thread (CMS)"; - Handle string = java_lang_String::create_from_str(thread_name, CHECK_NULL); - - // Initialize thread_oop to put it into the system threadGroup - Handle thread_group (THREAD, Universe::system_thread_group()); - JavaValue result(T_VOID); - JavaCalls::call_special(&result, thread_oop, - klass, - vmSymbolHandles::object_initializer_name(), - vmSymbolHandles::threadgroup_string_void_signature(), - thread_group, - string, - CHECK_NULL); - - SurrogateLockerThread* res; - { - MutexLocker mu(Threads_lock); - res = new SurrogateLockerThread(); - - // At this point it may be possible that no osthread was created for the - // JavaThread due to lack of memory. We would have to throw an exception - // in that case. However, since this must work and we do not allow - // exceptions anyway, check and abort if this fails. - if (res == NULL || res->osthread() == NULL) { - vm_exit_during_initialization("java.lang.OutOfMemoryError", - "unable to create new native thread"); - } - java_lang_Thread::set_thread(thread_oop(), res); - java_lang_Thread::set_priority(thread_oop(), NearMaxPriority); - java_lang_Thread::set_daemon(thread_oop()); - - res->set_threadObj(thread_oop()); - Threads::add(res); - Thread::start(res); - } - os::yield(); // This seems to help with initial start-up of SLT - return res; -} - -void SurrogateLockerThread::manipulatePLL(SLT_msg_type msg) { - MutexLockerEx x(&_monitor, Mutex::_no_safepoint_check_flag); - assert(_buffer == empty, "Should be empty"); - assert(msg != empty, "empty message"); - _buffer = msg; - while (_buffer != empty) { - _monitor.notify(); - _monitor.wait(Mutex::_no_safepoint_check_flag); - } -} - -// ======= Surrogate Locker Thread ============= - -void SurrogateLockerThread::loop() { - BasicLock pll_basic_lock; - SLT_msg_type msg; - debug_only(unsigned int owned = 0;) - - while (/* !isTerminated() */ 1) { - { - MutexLocker x(&_monitor); - // Since we are a JavaThread, we can't be here at a safepoint. - assert(!SafepointSynchronize::is_at_safepoint(), - "SLT is a JavaThread"); - // wait for msg buffer to become non-empty - while (_buffer == empty) { - _monitor.notify(); - _monitor.wait(); - } - msg = _buffer; - } - switch(msg) { - case acquirePLL: { - instanceRefKlass::acquire_pending_list_lock(&pll_basic_lock); - debug_only(owned++;) - break; - } - case releaseAndNotifyPLL: { - assert(owned > 0, "Don't have PLL"); - instanceRefKlass::release_and_notify_pending_list_lock(&pll_basic_lock); - debug_only(owned--;) - break; - } - case empty: - default: { - guarantee(false,"Unexpected message in _buffer"); - break; - } - } - { - MutexLocker x(&_monitor); - // Since we are a JavaThread, we can't be here at a safepoint. - assert(!SafepointSynchronize::is_at_safepoint(), - "SLT is a JavaThread"); - _buffer = empty; - _monitor.notify(); - } - } - assert(!_monitor.owned_by_self(), "Should unlock before exit."); -} - - -// ===== STS Access From Outside CGCT ===== - -void ConcurrentGCThread::stsYield(const char* id) { - assert( Thread::current()->is_ConcurrentGC_thread(), - "only a conc GC thread can call this" ); - _sts.yield(id); -} - -bool ConcurrentGCThread::stsShouldYield() { - assert( Thread::current()->is_ConcurrentGC_thread(), - "only a conc GC thread can call this" ); - return _sts.should_yield(); -} - -void ConcurrentGCThread::stsJoin() { - assert( Thread::current()->is_ConcurrentGC_thread(), - "only a conc GC thread can call this" ); - _sts.join(); -} - -void ConcurrentGCThread::stsLeave() { - assert( Thread::current()->is_ConcurrentGC_thread(), - "only a conc GC thread can call this" ); - _sts.leave(); -} diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/gc_implementation/concurrentMarkSweep/concurrentGCThread.hpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentGCThread.hpp Wed Nov 19 09:09:31 2008 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* - * Copyright 2001-2005 Sun Microsystems, Inc. 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - */ - -class VoidClosure; - -// A SuspendibleThreadSet is (obviously) a set of threads that can be -// suspended. A thread can join and later leave the set, and periodically -// yield. If some thread (not in the set) requests, via suspend_all, that -// the threads be suspended, then the requesting thread is blocked until -// all the threads in the set have yielded or left the set. (Threads may -// not enter the set when an attempted suspension is in progress.) The -// suspending thread later calls resume_all, allowing the suspended threads -// to continue. - -class SuspendibleThreadSet { - Monitor* _m; - int _async; - bool _async_stop; - int _async_stopped; - bool _initialized; - double _suspend_all_start; - - void initialize_work(); - - public: - SuspendibleThreadSet() : _initialized(false) {} - - // Add the current thread to the set. May block if a suspension - // is in progress. - void join(); - // Removes the current thread from the set. - void leave(); - // Returns "true" iff an suspension is in progress. - bool should_yield() { return _async_stop; } - // Suspends the current thread if a suspension is in progress (for - // the duration of the suspension.) - void yield(const char* id); - // Return when all threads in the set are suspended. - void suspend_all(); - // Allow suspended threads to resume. - void resume_all(); - // Redundant initializations okay. - void initialize() { - // Double-check dirty read idiom. - if (!_initialized) initialize_work(); - } -}; - - -class ConcurrentGCThread: public NamedThread { - friend class VMStructs; - -protected: - static bool _should_terminate; - static bool _has_terminated; - - enum CGC_flag_type { - CGC_nil = 0x0, - CGC_dont_suspend = 0x1, - CGC_CGC_safepoint = 0x2, - CGC_VM_safepoint = 0x4 - }; - - static int _CGC_flag; - - static bool CGC_flag_is_set(int b) { return (_CGC_flag & b) != 0; } - static int set_CGC_flag(int b) { return _CGC_flag |= b; } - static int reset_CGC_flag(int b) { return _CGC_flag &= ~b; } - - void stopWorldAndDo(VoidClosure* op); - - // All instances share this one set. - static SuspendibleThreadSet _sts; - - // Create and start the thread (setting it's priority high.) - void create_and_start(); - - // Do initialization steps in the thread: record stack base and size, - // init thread local storage, set JNI handle block. - void initialize_in_thread(); - - // Wait until Universe::is_fully_initialized(); - void wait_for_universe_init(); - - // Record that the current thread is terminating, and will do more - // concurrent work. - void terminate(); - -public: - // Constructor - - ConcurrentGCThread(); - ~ConcurrentGCThread() {} // Exists to call NamedThread destructor. - - // Tester - bool is_ConcurrentGC_thread() const { return true; } - - static void safepoint_synchronize(); - static void safepoint_desynchronize(); - - // All overridings should probably do _sts::yield, but we allow - // overriding for distinguished debugging messages. Default is to do - // nothing. - virtual void yield() {} - - bool should_yield() { return _sts.should_yield(); } - - // they are prefixed by sts since there are already yield() and - // should_yield() (non-static) methods in this class and it was an - // easy way to differentiate them. - static void stsYield(const char* id); - static bool stsShouldYield(); - static void stsJoin(); - static void stsLeave(); - -}; - -// The SurrogateLockerThread is used by concurrent GC threads for -// manipulating Java monitors, in particular, currently for -// manipulating the pending_list_lock. XXX -class SurrogateLockerThread: public JavaThread { - friend class VMStructs; - public: - enum SLT_msg_type { - empty = 0, // no message - acquirePLL, // acquire pending list lock - releaseAndNotifyPLL // notify and release pending list lock - }; - private: - // the following are shared with the CMSThread - SLT_msg_type _buffer; // communication buffer - Monitor _monitor; // monitor controlling buffer - BasicLock _basicLock; // used for PLL locking - - public: - static SurrogateLockerThread* make(TRAPS); - - SurrogateLockerThread(); - - bool is_hidden_from_external_view() const { return true; } - - void loop(); // main method - - void manipulatePLL(SLT_msg_type msg); - -}; diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/gc_implementation/g1/ptrQueue.cpp --- a/src/share/vm/gc_implementation/g1/ptrQueue.cpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.cpp Wed Nov 19 14:20:51 2008 -0800 @@ -30,7 +30,7 @@ _perm(perm), _lock(NULL) {} -PtrQueue::~PtrQueue() { +void PtrQueue::flush() { if (!_perm && _buf != NULL) { if (_index == _sz) { // No work to do. @@ -41,8 +41,9 @@ _buf[byte_index_to_index((int)i)] = NULL; } qset()->enqueue_complete_buffer(_buf); - _buf = NULL; } + _buf = NULL; + _index = 0; } } diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/gc_implementation/g1/ptrQueue.hpp --- a/src/share/vm/gc_implementation/g1/ptrQueue.hpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/gc_implementation/g1/ptrQueue.hpp Wed Nov 19 14:20:51 2008 -0800 @@ -62,7 +62,9 @@ // given PtrQueueSet. PtrQueue(PtrQueueSet*, bool perm = false); // Release any contained resources. - ~PtrQueue(); + void flush(); + // Calls flush() when destroyed. + ~PtrQueue() { flush(); } // Associate a lock with a ptr queue. void set_lock(Mutex* lock) { _lock = lock; } diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.cpp Wed Nov 19 14:20:51 2008 -0800 @@ -90,10 +90,10 @@ */ bool skip_dead = ((PSMarkSweep::total_invocations() % MarkSweepAlwaysCompactCount) != 0); - ssize_t allowed_deadspace = 0; + size_t allowed_deadspace = 0; if (skip_dead) { - int ratio = allowed_dead_ratio(); - allowed_deadspace = (space()->capacity_in_bytes() * ratio / 100) / HeapWordSize; + const size_t ratio = allowed_dead_ratio(); + allowed_deadspace = space()->capacity_in_words() * ratio / 100; } // Fetch the current destination decorator @@ -271,10 +271,10 @@ dest->set_compaction_top(compact_top); } -bool PSMarkSweepDecorator::insert_deadspace(ssize_t& allowed_deadspace_words, - HeapWord* q, size_t deadlength) { - allowed_deadspace_words -= deadlength; - if (allowed_deadspace_words >= 0) { +bool PSMarkSweepDecorator::insert_deadspace(size_t& allowed_deadspace_words, + HeapWord* q, size_t deadlength) { + if (allowed_deadspace_words >= deadlength) { + allowed_deadspace_words -= deadlength; oop(q)->set_mark(markOopDesc::prototype()->set_marked()); const size_t aligned_min_int_array_size = align_object_size(typeArrayOopDesc::header_size(T_INT)); diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp Wed Nov 19 14:20:51 2008 -0800 @@ -39,14 +39,16 @@ HeapWord* _first_dead; HeapWord* _end_of_live; HeapWord* _compaction_top; - unsigned int _allowed_dead_ratio; + size_t _allowed_dead_ratio; - bool insert_deadspace(ssize_t& allowed_deadspace_words, HeapWord* q, size_t word_len); + bool insert_deadspace(size_t& allowed_deadspace_words, HeapWord* q, + size_t word_len); public: PSMarkSweepDecorator(MutableSpace* space, ObjectStartArray* start_array, - unsigned int allowed_dead_ratio) : - _space(space), _start_array(start_array), _allowed_dead_ratio(allowed_dead_ratio) { } + size_t allowed_dead_ratio) : + _space(space), _start_array(start_array), + _allowed_dead_ratio(allowed_dead_ratio) { } // During a compacting collection, we need to collapse objects into // spaces in a given order. We want to fill space A, space B, and so @@ -57,14 +59,14 @@ static PSMarkSweepDecorator* destination_decorator(); // Accessors - MutableSpace* space() { return _space; } - ObjectStartArray* start_array() { return _start_array; } + MutableSpace* space() { return _space; } + ObjectStartArray* start_array() { return _start_array; } - HeapWord* compaction_top() { return _compaction_top; } - void set_compaction_top(HeapWord* value) { _compaction_top = value; } + HeapWord* compaction_top() { return _compaction_top; } + void set_compaction_top(HeapWord* value) { _compaction_top = value; } - unsigned int allowed_dead_ratio() { return _allowed_dead_ratio; } - void set_allowed_dead_ratio(unsigned int value) { _allowed_dead_ratio = value; } + size_t allowed_dead_ratio() { return _allowed_dead_ratio; } + void set_allowed_dead_ratio(size_t value) { _allowed_dead_ratio = value; } // Work methods void adjust_pointers(); diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/memory/space.cpp --- a/src/share/vm/memory/space.cpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/memory/space.cpp Wed Nov 19 14:20:51 2008 -0800 @@ -997,11 +997,11 @@ } -int TenuredSpace::allowed_dead_ratio() const { +size_t TenuredSpace::allowed_dead_ratio() const { return MarkSweepDeadRatio; } -int ContigPermSpace::allowed_dead_ratio() const { +size_t ContigPermSpace::allowed_dead_ratio() const { return PermMarkSweepDeadRatio; } diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/memory/space.hpp --- a/src/share/vm/memory/space.hpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/memory/space.hpp Wed Nov 19 14:20:51 2008 -0800 @@ -421,7 +421,7 @@ // The maximum percentage of objects that can be dead in the compacted // live part of a compacted space ("deadwood" support.) - virtual int allowed_dead_ratio() const { return 0; }; + virtual size_t allowed_dead_ratio() const { return 0; }; // Some contiguous spaces may maintain some data structures that should // be updated whenever an allocation crosses a boundary. This function @@ -507,7 +507,7 @@ \ size_t allowed_deadspace = 0; \ if (skip_dead) { \ - int ratio = allowed_dead_ratio(); \ + const size_t ratio = allowed_dead_ratio(); \ allowed_deadspace = (capacity() * ratio / 100) / HeapWordSize; \ } \ \ @@ -1079,7 +1079,7 @@ friend class VMStructs; protected: // Mark sweep support - int allowed_dead_ratio() const; + size_t allowed_dead_ratio() const; public: // Constructor TenuredSpace(BlockOffsetSharedArray* sharedOffsetArray, @@ -1094,7 +1094,7 @@ friend class VMStructs; protected: // Mark sweep support - int allowed_dead_ratio() const; + size_t allowed_dead_ratio() const; public: // Constructor ContigPermSpace(BlockOffsetSharedArray* sharedOffsetArray, MemRegion mr) : diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/memory/tenuredGeneration.hpp --- a/src/share/vm/memory/tenuredGeneration.hpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/memory/tenuredGeneration.hpp Wed Nov 19 14:20:51 2008 -0800 @@ -73,7 +73,6 @@ // Mark sweep support void compute_new_size(); - int allowed_dead_ratio() const; virtual void gc_prologue(bool full); virtual void gc_epilogue(bool full); diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/runtime/globals.hpp --- a/src/share/vm/runtime/globals.hpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/runtime/globals.hpp Wed Nov 19 14:20:51 2008 -0800 @@ -2792,7 +2792,7 @@ product(intx, TargetSurvivorRatio, 50, \ "Desired percentage of survivor space used after scavenge") \ \ - product(intx, MarkSweepDeadRatio, 5, \ + product(uintx, MarkSweepDeadRatio, 5, \ "Percentage (0-100) of the old gen allowed as dead wood." \ "Serial mark sweep treats this as both the min and max value." \ "CMS uses this value only if it falls back to mark sweep." \ @@ -2801,7 +2801,7 @@ "either completely full or completely empty. Par compact also" \ "has a smaller default value; see arguments.cpp.") \ \ - product(intx, PermMarkSweepDeadRatio, 20, \ + product(uintx, PermMarkSweepDeadRatio, 20, \ "Percentage (0-100) of the perm gen allowed as dead wood." \ "See MarkSweepDeadRatio for collector-specific comments.") \ \ diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/runtime/thread.cpp --- a/src/share/vm/runtime/thread.cpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/runtime/thread.cpp Wed Nov 19 14:20:51 2008 -0800 @@ -1422,6 +1422,7 @@ thread->clear_pending_exception(); } + // For any new cleanup additions, please check to see if they need to be applied to // cleanup_failed_attach_current_thread as well. void JavaThread::exit(bool destroy_vm, ExitType exit_type) { @@ -1592,39 +1593,62 @@ JvmtiExport::cleanup_thread(this); } +#ifndef SERIALGC + // We must flush G1-related buffers before removing a thread from + // the list of active threads. + if (UseG1GC) { + flush_barrier_queues(); + } +#endif + // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread Threads::remove(this); } +#ifndef SERIALGC +// Flush G1-related queues. +void JavaThread::flush_barrier_queues() { + satb_mark_queue().flush(); + dirty_card_queue().flush(); +} +#endif + void JavaThread::cleanup_failed_attach_current_thread() { - - if (get_thread_profiler() != NULL) { - get_thread_profiler()->disengage(); - ResourceMark rm; - get_thread_profiler()->print(get_thread_name()); - } - - if (active_handles() != NULL) { - JNIHandleBlock* block = active_handles(); - set_active_handles(NULL); - JNIHandleBlock::release_block(block); - } - - if (free_handle_block() != NULL) { - JNIHandleBlock* block = free_handle_block(); - set_free_handle_block(NULL); - JNIHandleBlock::release_block(block); - } - - if (UseTLAB) { - tlab().make_parsable(true); // retire TLAB, if any - } - - Threads::remove(this); - delete this; + if (get_thread_profiler() != NULL) { + get_thread_profiler()->disengage(); + ResourceMark rm; + get_thread_profiler()->print(get_thread_name()); + } + + if (active_handles() != NULL) { + JNIHandleBlock* block = active_handles(); + set_active_handles(NULL); + JNIHandleBlock::release_block(block); + } + + if (free_handle_block() != NULL) { + JNIHandleBlock* block = free_handle_block(); + set_free_handle_block(NULL); + JNIHandleBlock::release_block(block); + } + + if (UseTLAB) { + tlab().make_parsable(true); // retire TLAB, if any + } + +#ifndef SERIALGC + if (UseG1GC) { + flush_barrier_queues(); + } +#endif + + Threads::remove(this); + delete this; } + + JavaThread* JavaThread::active() { Thread* thread = ThreadLocalStorage::thread(); assert(thread != NULL, "just checking"); diff -r 491a904952f2 -r b5e603f2e024 src/share/vm/runtime/thread.hpp --- a/src/share/vm/runtime/thread.hpp Wed Nov 19 09:09:31 2008 -0800 +++ b/src/share/vm/runtime/thread.hpp Wed Nov 19 14:20:51 2008 -0800 @@ -793,6 +793,8 @@ DirtyCardQueue _dirty_card_queue; // Thread-local log for dirty cards. // Set of all such queues. static DirtyCardQueueSet _dirty_card_queue_set; + + void flush_barrier_queues(); #endif // !SERIALGC friend class VMThread;