Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/thread.cpp @ 4095:bca17e38de00
6593758: RFE: Enhance GC ergonomics to dynamically choose ParallelGCThreads
Summary: Select number of GC threads dynamically based on heap usage and number of Java threads
Reviewed-by: johnc, ysr, jcoomes
author | jmasa |
---|---|
date | Tue, 09 Aug 2011 10:16:01 -0700 |
parents | b20d64f83668 |
children | 04b9a2566eec 94ec88ca68e2 |
comparison
equal
deleted
inserted
replaced
4094:3a298e04d914 | 4095:bca17e38de00 |
---|---|
776 jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity); | 776 jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity); |
777 if (res == thread_parity) { | 777 if (res == thread_parity) { |
778 return true; | 778 return true; |
779 } else { | 779 } else { |
780 guarantee(res == strong_roots_parity, "Or else what?"); | 780 guarantee(res == strong_roots_parity, "Or else what?"); |
781 assert(SharedHeap::heap()->n_par_threads() > 0, | 781 assert(SharedHeap::heap()->workers()->active_workers() > 0, |
782 "Should only fail when parallel."); | 782 "Should only fail when parallel."); |
783 return false; | 783 return false; |
784 } | 784 } |
785 } | 785 } |
786 assert(SharedHeap::heap()->n_par_threads() > 0, | 786 assert(SharedHeap::heap()->workers()->active_workers() > 0, |
787 "Should only fail when parallel."); | 787 "Should only fail when parallel."); |
788 return false; | 788 return false; |
789 } | 789 } |
790 | 790 |
791 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { | 791 void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { |
3937 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) { | 3937 void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) { |
3938 // Introduce a mechanism allowing parallel threads to claim threads as | 3938 // Introduce a mechanism allowing parallel threads to claim threads as |
3939 // root groups. Overhead should be small enough to use all the time, | 3939 // root groups. Overhead should be small enough to use all the time, |
3940 // even in sequential code. | 3940 // even in sequential code. |
3941 SharedHeap* sh = SharedHeap::heap(); | 3941 SharedHeap* sh = SharedHeap::heap(); |
3942 bool is_par = (sh->n_par_threads() > 0); | 3942 // Cannot yet substitute active_workers for n_par_threads |
3943 // because of G1CollectedHeap::verify() use of | |
3944 // SharedHeap::process_strong_roots(). n_par_threads == 0 will | |
3945 // turn off parallelism in process_strong_roots while active_workers | |
3946 // is being used for parallelism elsewhere. | |
3947 bool is_par = sh->n_par_threads() > 0; | |
3948 assert(!is_par || | |
3949 (SharedHeap::heap()->n_par_threads() == | |
3950 SharedHeap::heap()->workers()->active_workers()), "Mismatch"); | |
3943 int cp = SharedHeap::heap()->strong_roots_parity(); | 3951 int cp = SharedHeap::heap()->strong_roots_parity(); |
3944 ALL_JAVA_THREADS(p) { | 3952 ALL_JAVA_THREADS(p) { |
3945 if (p->claim_oops_do(is_par, cp)) { | 3953 if (p->claim_oops_do(is_par, cp)) { |
3946 p->oops_do(f, cf); | 3954 p->oops_do(f, cf); |
3947 } | 3955 } |