src/share/vm/memory/iterator.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2009, 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  *
  23  */
  24 








  25 // The following classes are C++ `closures` for iterating over objects, roots and spaces
  26 
  27 class CodeBlob;
  28 class nmethod;
  29 class ReferenceProcessor;
  30 class DataLayout;
  31 
  32 // Closure provides abortability.
  33 
  34 class Closure : public StackObj {
  35  protected:
  36   bool _abort;
  37   void set_abort() { _abort = true; }
  38  public:
  39   Closure() : _abort(false) {}
  40   // A subtype can use this mechanism to indicate to some iterator mapping
  41   // functions that the iteration should cease.
  42   bool abort() { return _abort; }
  43   void clear_abort() { _abort = false; }
  44 };


 308     // the current collection is an explicit collection.  Turning
 309     // on the checking in general for
 310     // ExplicitGCInvokesConcurrentAndUnloadsClasses and
 311     // UseConcMarkSweepGC should not lead to false positives.
 312     _do_check =
 313       ClassUnloading && !UseConcMarkSweepGC ||
 314       CMSClassUnloadingEnabled && UseConcMarkSweepGC ||
 315       ExplicitGCInvokesConcurrentAndUnloadsClasses && UseConcMarkSweepGC;
 316     if (_do_check) {
 317       _saved_state = OopClosure::must_remember_klasses();
 318       OopClosure::set_must_remember_klasses(checking_on);
 319     }
 320   }
 321   ~RememberKlassesChecker() {
 322     if (_do_check) {
 323       OopClosure::set_must_remember_klasses(_saved_state);
 324     }
 325   }
 326 };
 327 #endif  // ASSERT


   1 /*
   2  * Copyright (c) 1997, 2010, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_MEMORY_ITERATOR_HPP
  26 #define SHARE_VM_MEMORY_ITERATOR_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "memory/memRegion.hpp"
  30 #include "runtime/prefetch.hpp"
  31 #include "utilities/top.hpp"
  32 
  33 // The following classes are C++ `closures` for iterating over objects, roots and spaces
  34 
  35 class CodeBlob;
  36 class nmethod;
  37 class ReferenceProcessor;
  38 class DataLayout;
  39 
  40 // Closure provides abortability.
  41 
  42 class Closure : public StackObj {
  43  protected:
  44   bool _abort;
  45   void set_abort() { _abort = true; }
  46  public:
  47   Closure() : _abort(false) {}
  48   // A subtype can use this mechanism to indicate to some iterator mapping
  49   // functions that the iteration should cease.
  50   bool abort() { return _abort; }
  51   void clear_abort() { _abort = false; }
  52 };


 316     // the current collection is an explicit collection.  Turning
 317     // on the checking in general for
 318     // ExplicitGCInvokesConcurrentAndUnloadsClasses and
 319     // UseConcMarkSweepGC should not lead to false positives.
 320     _do_check =
 321       ClassUnloading && !UseConcMarkSweepGC ||
 322       CMSClassUnloadingEnabled && UseConcMarkSweepGC ||
 323       ExplicitGCInvokesConcurrentAndUnloadsClasses && UseConcMarkSweepGC;
 324     if (_do_check) {
 325       _saved_state = OopClosure::must_remember_klasses();
 326       OopClosure::set_must_remember_klasses(checking_on);
 327     }
 328   }
 329   ~RememberKlassesChecker() {
 330     if (_do_check) {
 331       OopClosure::set_must_remember_klasses(_saved_state);
 332     }
 333   }
 334 };
 335 #endif  // ASSERT
 336 
 337 #endif // SHARE_VM_MEMORY_ITERATOR_HPP