< prev index next >

src/share/vm/memory/sharedHeap.cpp

Print this page
rev 7854 : imported patch 8027962-per-phase-timing-measurements-for-strong-roots-processing
rev 7855 : [mq]: 8027962-bengt-suggestions
   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 173 void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) {
 174   assert(UseG1GC,                          "Currently only used by G1");
 175   assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
 176 
 177   // No need to use the barrier if this is single-threaded code.
 178   if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) {
 179     MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
 180     while ((uint)_n_workers_done_with_threads != n_workers) {
 181       _lock->wait(Mutex::_no_safepoint_check_flag, 0, false);
 182     }
 183   }
 184 }
 185 
 186 void SharedHeap::process_roots(bool activate_scope,
 187                                ScanningOption so,
 188                                OopClosure* strong_roots,
 189                                OopClosure* weak_roots,
 190                                CLDClosure* strong_cld_closure,
 191                                CLDClosure* weak_cld_closure,
 192                                CodeBlobClosure* code_roots,
 193                                GCPhaseTimeTracker* phase_durations) {
 194   StrongRootsScope srs(this, activate_scope);
 195 
 196   // General roots.
 197   assert(_strong_roots_parity != 0, "must have called prologue code");
 198   assert(code_roots != NULL, "code root closure should always be set");
 199   // _n_termination for _process_strong_tasks should be set up stream
 200   // in a method not running in a GC worker.  Otherwise the GC worker
 201   // could be trying to change the termination condition while the task
 202   // is executing in another GC worker.
 203 
 204   // Iterating over the CLDG and the Threads are done early to allow G1 to
 205   // first process the strong CLDs and nmethods and then, after a barrier,
 206   // let the thread process the weak CLDs and nmethods.
 207 
 208   {
 209     TrackPhaseTime x(phase_durations, SH_PS_ClassLoaderDataGraph_oops_do);
 210     if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) {
 211       ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
 212     }
 213   }


 294 
 295         // CMSCollector uses this to do intermediate-strength collections.
 296         // We scan the entire code cache, since CodeCache::do_unloading is not called.
 297         CodeCache::blobs_do(code_roots);
 298       }
 299       // Verify that the code cache contents are not subject to
 300       // movement by a scavenging collection.
 301       DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 302       DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 303     }
 304   }
 305 
 306   _process_strong_tasks->all_tasks_completed();
 307 }
 308 
 309 void SharedHeap::process_all_roots(bool activate_scope,
 310                                    ScanningOption so,
 311                                    OopClosure* roots,
 312                                    CLDClosure* cld_closure,
 313                                    CodeBlobClosure* code_closure,
 314                                    GCPhaseTimeTracker* phase_durations) {
 315   process_roots(activate_scope, so,
 316                 roots, roots,
 317                 cld_closure, cld_closure,
 318                 code_closure,
 319                 phase_durations);
 320 }
 321 
 322 void SharedHeap::process_strong_roots(bool activate_scope,
 323                                       ScanningOption so,
 324                                       OopClosure* roots,
 325                                       CLDClosure* cld_closure,
 326                                       CodeBlobClosure* code_closure,
 327                                       GCPhaseTimeTracker* phase_durations) {
 328   process_roots(activate_scope, so,
 329                 roots, NULL,
 330                 cld_closure, NULL,
 331                 code_closure,
 332                 phase_durations);
 333 }
 334 
 335 
 336 class AlwaysTrueClosure: public BoolObjectClosure {
 337 public:
 338   bool do_object_b(oop p) { return true; }
 339 };
 340 static AlwaysTrueClosure always_true;
 341 
 342 void SharedHeap::process_weak_roots(OopClosure* root_closure) {
 343   // Global (weak) JNI handles
 344   JNIHandles::weak_oops_do(&always_true, root_closure);
 345 }
 346 
 347 void SharedHeap::set_barrier_set(BarrierSet* bs) {


   1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 173 void SharedHeap::StrongRootsScope::wait_until_all_workers_done_with_threads(uint n_workers) {
 174   assert(UseG1GC,                          "Currently only used by G1");
 175   assert(ClassUnloadingWithConcurrentMark, "Currently only needed when doing G1 Class Unloading");
 176 
 177   // No need to use the barrier if this is single-threaded code.
 178   if (n_workers > 0 && (uint)_n_workers_done_with_threads != n_workers) {
 179     MonitorLockerEx ml(_lock, Mutex::_no_safepoint_check_flag);
 180     while ((uint)_n_workers_done_with_threads != n_workers) {
 181       _lock->wait(Mutex::_no_safepoint_check_flag, 0, false);
 182     }
 183   }
 184 }
 185 
 186 void SharedHeap::process_roots(bool activate_scope,
 187                                ScanningOption so,
 188                                OopClosure* strong_roots,
 189                                OopClosure* weak_roots,
 190                                CLDClosure* strong_cld_closure,
 191                                CLDClosure* weak_cld_closure,
 192                                CodeBlobClosure* code_roots,
 193                                PhaseTimeData* phase_durations) {
 194   StrongRootsScope srs(this, activate_scope);
 195 
 196   // General roots.
 197   assert(_strong_roots_parity != 0, "must have called prologue code");
 198   assert(code_roots != NULL, "code root closure should always be set");
 199   // _n_termination for _process_strong_tasks should be set up stream
 200   // in a method not running in a GC worker.  Otherwise the GC worker
 201   // could be trying to change the termination condition while the task
 202   // is executing in another GC worker.
 203 
 204   // Iterating over the CLDG and the Threads are done early to allow G1 to
 205   // first process the strong CLDs and nmethods and then, after a barrier,
 206   // let the thread process the weak CLDs and nmethods.
 207 
 208   {
 209     TrackPhaseTime x(phase_durations, SH_PS_ClassLoaderDataGraph_oops_do);
 210     if (!_process_strong_tasks->is_task_claimed(SH_PS_ClassLoaderDataGraph_oops_do)) {
 211       ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure);
 212     }
 213   }


 294 
 295         // CMSCollector uses this to do intermediate-strength collections.
 296         // We scan the entire code cache, since CodeCache::do_unloading is not called.
 297         CodeCache::blobs_do(code_roots);
 298       }
 299       // Verify that the code cache contents are not subject to
 300       // movement by a scavenging collection.
 301       DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 302       DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 303     }
 304   }
 305 
 306   _process_strong_tasks->all_tasks_completed();
 307 }
 308 
 309 void SharedHeap::process_all_roots(bool activate_scope,
 310                                    ScanningOption so,
 311                                    OopClosure* roots,
 312                                    CLDClosure* cld_closure,
 313                                    CodeBlobClosure* code_closure,
 314                                    PhaseTimeData* phase_durations) {
 315   process_roots(activate_scope, so,
 316                 roots, roots,
 317                 cld_closure, cld_closure,
 318                 code_closure,
 319                 phase_durations);
 320 }
 321 
 322 void SharedHeap::process_strong_roots(bool activate_scope,
 323                                       ScanningOption so,
 324                                       OopClosure* roots,
 325                                       CLDClosure* cld_closure,
 326                                       CodeBlobClosure* code_closure,
 327                                       PhaseTimeData* phase_durations) {
 328   process_roots(activate_scope, so,
 329                 roots, NULL,
 330                 cld_closure, NULL,
 331                 code_closure,
 332                 phase_durations);
 333 }
 334 
 335 
 336 class AlwaysTrueClosure: public BoolObjectClosure {
 337 public:
 338   bool do_object_b(oop p) { return true; }
 339 };
 340 static AlwaysTrueClosure always_true;
 341 
 342 void SharedHeap::process_weak_roots(OopClosure* root_closure) {
 343   // Global (weak) JNI handles
 344   JNIHandles::weak_oops_do(&always_true, root_closure);
 345 }
 346 
 347 void SharedHeap::set_barrier_set(BarrierSet* bs) {


< prev index next >