src/share/vm/gc_implementation/shared/markSweep.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileBroker.hpp"


  27 #include "gc_implementation/shared/markSweep.inline.hpp"
  28 #include "gc_interface/collectedHeap.inline.hpp"
  29 #include "oops/methodData.hpp"
  30 #include "oops/objArrayKlass.inline.hpp"
  31 #include "oops/oop.inline.hpp"
  32 
  33 uint                    MarkSweep::_total_invocations = 0;
  34 
  35 Stack<oop, mtGC>              MarkSweep::_marking_stack;
  36 Stack<ObjArrayTask, mtGC>     MarkSweep::_objarray_stack;
  37 
  38 Stack<oop, mtGC>              MarkSweep::_preserved_oop_stack;
  39 Stack<markOop, mtGC>          MarkSweep::_preserved_mark_stack;
  40 size_t                  MarkSweep::_preserved_count = 0;
  41 size_t                  MarkSweep::_preserved_count_max = 0;
  42 PreservedMark*          MarkSweep::_preserved_marks = NULL;
  43 ReferenceProcessor*     MarkSweep::_ref_processor   = NULL;


  44 
  45 MarkSweep::FollowRootClosure  MarkSweep::follow_root_closure;
  46 CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true);
  47 
  48 void MarkSweep::FollowRootClosure::do_oop(oop* p)       { follow_root(p); }
  49 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); }
  50 
  51 MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure;
  52 MarkSweep::FollowKlassClosure MarkSweep::follow_klass_closure;
  53 MarkSweep::AdjustKlassClosure MarkSweep::adjust_klass_closure;
  54 
  55 void MarkSweep::MarkAndPushClosure::do_oop(oop* p)       { mark_and_push(p); }
  56 void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); }
  57 
  58 void MarkSweep::FollowKlassClosure::do_klass(Klass* klass) {
  59   klass->oops_do(&MarkSweep::mark_and_push_closure);
  60 }
  61 void MarkSweep::AdjustKlassClosure::do_klass(Klass* klass) {
  62   klass->oops_do(&MarkSweep::adjust_pointer_closure);
  63 }


 156     _preserved_marks[i].restore();
 157   }
 158 
 159   // deal with the overflow
 160   while (!_preserved_oop_stack.is_empty()) {
 161     oop obj       = _preserved_oop_stack.pop();
 162     markOop mark  = _preserved_mark_stack.pop();
 163     obj->set_mark(mark);
 164   }
 165 }
 166 
 167 MarkSweep::IsAliveClosure   MarkSweep::is_alive;
 168 
 169 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
 170 
 171 MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
 172 
 173 void MarkSweep::KeepAliveClosure::do_oop(oop* p)       { MarkSweep::KeepAliveClosure::do_oop_work(p); }
 174 void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); }
 175 
 176 void marksweep_init() { /* empty */ }



 177 
 178 #ifndef PRODUCT
 179 
 180 void MarkSweep::trace(const char* msg) {
 181   if (TraceMarkSweep)
 182     gclog_or_tty->print("%s", msg);
 183 }
 184 
 185 #endif


   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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "compiler/compileBroker.hpp"
  27 #include "gc_implementation/shared/gcTimer.hpp"
  28 #include "gc_implementation/shared/gcTrace.hpp"
  29 #include "gc_implementation/shared/markSweep.inline.hpp"
  30 #include "gc_interface/collectedHeap.inline.hpp"
  31 #include "oops/methodData.hpp"
  32 #include "oops/objArrayKlass.inline.hpp"
  33 #include "oops/oop.inline.hpp"
  34 
  35 uint                    MarkSweep::_total_invocations = 0;
  36 
  37 Stack<oop, mtGC>              MarkSweep::_marking_stack;
  38 Stack<ObjArrayTask, mtGC>     MarkSweep::_objarray_stack;
  39 
  40 Stack<oop, mtGC>              MarkSweep::_preserved_oop_stack;
  41 Stack<markOop, mtGC>          MarkSweep::_preserved_mark_stack;
  42 size_t                  MarkSweep::_preserved_count = 0;
  43 size_t                  MarkSweep::_preserved_count_max = 0;
  44 PreservedMark*          MarkSweep::_preserved_marks = NULL;
  45 ReferenceProcessor*     MarkSweep::_ref_processor   = NULL;
  46 STWGCTimer*             MarkSweep::_gc_timer        = NULL;
  47 SerialOldTracer*        MarkSweep::_gc_tracer       = NULL;
  48 
  49 MarkSweep::FollowRootClosure  MarkSweep::follow_root_closure;
  50 CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true);
  51 
  52 void MarkSweep::FollowRootClosure::do_oop(oop* p)       { follow_root(p); }
  53 void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); }
  54 
  55 MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure;
  56 MarkSweep::FollowKlassClosure MarkSweep::follow_klass_closure;
  57 MarkSweep::AdjustKlassClosure MarkSweep::adjust_klass_closure;
  58 
  59 void MarkSweep::MarkAndPushClosure::do_oop(oop* p)       { mark_and_push(p); }
  60 void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); }
  61 
  62 void MarkSweep::FollowKlassClosure::do_klass(Klass* klass) {
  63   klass->oops_do(&MarkSweep::mark_and_push_closure);
  64 }
  65 void MarkSweep::AdjustKlassClosure::do_klass(Klass* klass) {
  66   klass->oops_do(&MarkSweep::adjust_pointer_closure);
  67 }


 160     _preserved_marks[i].restore();
 161   }
 162 
 163   // deal with the overflow
 164   while (!_preserved_oop_stack.is_empty()) {
 165     oop obj       = _preserved_oop_stack.pop();
 166     markOop mark  = _preserved_mark_stack.pop();
 167     obj->set_mark(mark);
 168   }
 169 }
 170 
 171 MarkSweep::IsAliveClosure   MarkSweep::is_alive;
 172 
 173 bool MarkSweep::IsAliveClosure::do_object_b(oop p) { return p->is_gc_marked(); }
 174 
 175 MarkSweep::KeepAliveClosure MarkSweep::keep_alive;
 176 
 177 void MarkSweep::KeepAliveClosure::do_oop(oop* p)       { MarkSweep::KeepAliveClosure::do_oop_work(p); }
 178 void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClosure::do_oop_work(p); }
 179 
 180 void marksweep_init() {
 181   MarkSweep::_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer();
 182   MarkSweep::_gc_tracer = new (ResourceObj::C_HEAP, mtGC) SerialOldTracer();
 183 }
 184 
 185 #ifndef PRODUCT
 186 
 187 void MarkSweep::trace(const char* msg) {
 188   if (TraceMarkSweep)
 189     gclog_or_tty->print("%s", msg);
 190 }
 191 
 192 #endif