src/share/vm/memory/memRegion.hpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2004, 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 // A very simple data structure representing a contigous region
  26 // region of address space.
  27 
  28 // Note that MemRegions are passed by value, not by reference.
  29 // The intent is that they remain very small and contain no
  30 // objects.
  31 
  32 class MemRegion VALUE_OBJ_CLASS_SPEC {
  33   friend class VMStructs;
  34 private:
  35   HeapWord* _start;
  36   size_t    _word_size;
  37 
  38 public:
  39   MemRegion() : _start(NULL), _word_size(0) {};
  40   MemRegion(HeapWord* start, size_t word_size) :
  41     _start(start), _word_size(word_size) {};
  42   MemRegion(HeapWord* start, HeapWord* end) :
  43     _start(start), _word_size(pointer_delta(end, start)) {
  44     assert(end >= start, "incorrect constructor arguments");


  87 public:
  88   virtual void do_MemRegion(MemRegion mr) = 0;
  89 };
  90 
  91 // A ResourceObj version of MemRegionClosure
  92 
  93 class MemRegionClosureRO: public MemRegionClosure {
  94 public:
  95   void* operator new(size_t size, ResourceObj::allocation_type type) {
  96         return ResourceObj::operator new(size, type);
  97   }
  98   void* operator new(size_t size, Arena *arena) {
  99         return ResourceObj::operator new(size, arena);
 100   }
 101   void* operator new(size_t size) {
 102         return ResourceObj::operator new(size);
 103   }
 104 
 105   void  operator delete(void* p) {} // nothing to do
 106 };


   1 /*
   2  * Copyright (c) 2000, 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_MEMREGION_HPP
  26 #define SHARE_VM_MEMORY_MEMREGION_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "utilities/debug.hpp"
  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 // A very simple data structure representing a contigous region
  33 // region of address space.
  34 
  35 // Note that MemRegions are passed by value, not by reference.
  36 // The intent is that they remain very small and contain no
  37 // objects.
  38 
  39 class MemRegion VALUE_OBJ_CLASS_SPEC {
  40   friend class VMStructs;
  41 private:
  42   HeapWord* _start;
  43   size_t    _word_size;
  44 
  45 public:
  46   MemRegion() : _start(NULL), _word_size(0) {};
  47   MemRegion(HeapWord* start, size_t word_size) :
  48     _start(start), _word_size(word_size) {};
  49   MemRegion(HeapWord* start, HeapWord* end) :
  50     _start(start), _word_size(pointer_delta(end, start)) {
  51     assert(end >= start, "incorrect constructor arguments");


  94 public:
  95   virtual void do_MemRegion(MemRegion mr) = 0;
  96 };
  97 
  98 // A ResourceObj version of MemRegionClosure
  99 
 100 class MemRegionClosureRO: public MemRegionClosure {
 101 public:
 102   void* operator new(size_t size, ResourceObj::allocation_type type) {
 103         return ResourceObj::operator new(size, type);
 104   }
 105   void* operator new(size_t size, Arena *arena) {
 106         return ResourceObj::operator new(size, arena);
 107   }
 108   void* operator new(size_t size) {
 109         return ResourceObj::operator new(size);
 110   }
 111 
 112   void  operator delete(void* p) {} // nothing to do
 113 };
 114 
 115 #endif // SHARE_VM_MEMORY_MEMREGION_HPP