< prev index next >

src/share/vm/memory/universe.hpp

Print this page
rev 12310 : [mq]: gcinterface.patch


   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_UNIVERSE_HPP
  26 #define SHARE_VM_MEMORY_UNIVERSE_HPP
  27 

  28 #include "runtime/handles.hpp"
  29 #include "utilities/array.hpp"
  30 #include "utilities/growableArray.hpp"
  31 
  32 // Universe is a name space holding known system classes and objects in the VM.
  33 //
  34 // Loaded classes are accessible through the SystemDictionary.
  35 //
  36 // The object heap is allocated and accessed through Universe, and various allocation
  37 // support is provided. Allocation by the interpreter and compiled code is done inline
  38 // and bails out to Scavenge::invoke_and_allocate.
  39 
  40 class CollectedHeap;
  41 class DeferredObjAllocEvent;
  42 
  43 
  44 // A helper class for caching a Method* when the user of the cache
  45 // only cares about the latest version of the Method*.  This cache safely
  46 // interacts with the RedefineClasses API.
  47 


 171   static Array<Klass*>*  _the_array_interfaces_array;
 172 
 173   // array of preallocated error objects with backtrace
 174   static objArrayOop   _preallocated_out_of_memory_error_array;
 175 
 176   // number of preallocated error objects available for use
 177   static volatile jint _preallocated_out_of_memory_error_avail_count;
 178 
 179   static oop          _null_ptr_exception_instance;   // preallocated exception object
 180   static oop          _arithmetic_exception_instance; // preallocated exception object
 181   static oop          _virtual_machine_error_instance; // preallocated exception object
 182   // The object used as an exception dummy when exceptions are thrown for
 183   // the vm thread.
 184   static oop          _vm_exception;
 185 
 186   static oop          _allocation_context_notification_obj;
 187 
 188   // References waiting to be transferred to the ReferenceHandler
 189   static oop          _reference_pending_list;
 190 
 191   // The particular choice of collected heap.
 192   static CollectedHeap* _collectedHeap;
 193 
 194   static intptr_t _non_oop_bits;
 195 
 196   // For UseCompressedOops.
 197   static struct NarrowPtrStruct _narrow_oop;
 198   // For UseCompressedClassPointers.
 199   static struct NarrowPtrStruct _narrow_klass;
 200   static address _narrow_ptrs_base;
 201 
 202   // array of dummy objects used with +FullGCAlot
 203   debug_only(static objArrayOop _fullgc_alot_dummy_array;)
 204   // index of next entry to clear
 205   debug_only(static int         _fullgc_alot_dummy_next;)
 206 
 207   // Compiler/dispatch support
 208   static int  _base_vtable_size;                      // Java vtbl size of klass Object (in words)
 209 
 210   // Initialization
 211   static bool _bootstrapping;                         // true during genesis
 212   static bool _module_initialized;                    // true after call_initPhase2 called
 213   static bool _fully_initialized;                     // true after universe_init and initialize_vtables called
 214 
 215   // the array of preallocated errors with backtraces
 216   static objArrayOop  preallocated_out_of_memory_errors()     { return _preallocated_out_of_memory_error_array; }
 217 
 218   // generate an out of memory error; if possible using an error with preallocated backtrace;
 219   // otherwise return the given default error.
 220   static oop        gen_out_of_memory_error(oop default_err);
 221 
 222   // Historic gc information
 223   static size_t _heap_capacity_at_last_gc;
 224   static size_t _heap_used_at_last_gc;
 225 
 226   template <class Heap, class Policy> static CollectedHeap* create_heap_with_policy();
 227   static CollectedHeap* create_heap();
 228   static CollectedHeap* create_heap_ext();
 229   static jint initialize_heap();
 230   static void initialize_basic_type_mirrors(TRAPS);
 231   static void fixup_mirrors(TRAPS);
 232 
 233   static void reinitialize_vtable_of(KlassHandle h_k, TRAPS);
 234   static void reinitialize_itables(TRAPS);
 235   static void compute_base_vtable_size();             // compute vtable size of class Object
 236 
 237   static void genesis(TRAPS);                         // Create the initial world
 238 
 239   // Mirrors for primitive classes (created eagerly)
 240   static oop check_mirror(oop m) {
 241     assert(m != NULL, "mirror not initialized");
 242     return m;
 243   }
 244 
 245   static void     set_narrow_oop_base(address base) {
 246     assert(UseCompressedOops, "no compressed oops?");
 247     _narrow_oop._base    = base;
 248   }


 359   static oop out_of_memory_error_java_heap()          { return gen_out_of_memory_error(_out_of_memory_error_java_heap);  }
 360   static oop out_of_memory_error_metaspace()          { return gen_out_of_memory_error(_out_of_memory_error_metaspace);   }
 361   static oop out_of_memory_error_class_metaspace()    { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace);   }
 362   static oop out_of_memory_error_array_size()         { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
 363   static oop out_of_memory_error_gc_overhead_limit()  { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit);  }
 364   static oop out_of_memory_error_realloc_objects()    { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects);  }
 365   static oop delayed_stack_overflow_error_message()   { return _delayed_stack_overflow_error_message; }
 366 
 367   // Accessors needed for fast allocation
 368   static Klass** boolArrayKlassObj_addr()           { return &_boolArrayKlassObj;   }
 369   static Klass** byteArrayKlassObj_addr()           { return &_byteArrayKlassObj;   }
 370   static Klass** charArrayKlassObj_addr()           { return &_charArrayKlassObj;   }
 371   static Klass** intArrayKlassObj_addr()            { return &_intArrayKlassObj;    }
 372   static Klass** shortArrayKlassObj_addr()          { return &_shortArrayKlassObj;  }
 373   static Klass** longArrayKlassObj_addr()           { return &_longArrayKlassObj;   }
 374   static Klass** singleArrayKlassObj_addr()         { return &_singleArrayKlassObj; }
 375   static Klass** doubleArrayKlassObj_addr()         { return &_doubleArrayKlassObj; }
 376   static Klass** objectArrayKlassObj_addr()         { return &_objectArrayKlassObj; }
 377 
 378   // The particular choice of collected heap.
 379   static CollectedHeap* heap() { return _collectedHeap; }






 380 
 381   // For UseCompressedOops
 382   // Narrow Oop encoding mode:
 383   // 0 - Use 32-bits oops without encoding when
 384   //     NarrowOopHeapBaseMin + heap_size < 4Gb
 385   // 1 - Use zero based compressed oops with encoding when
 386   //     NarrowOopHeapBaseMin + heap_size < 32Gb
 387   // 2 - Use compressed oops with disjoint heap base if
 388   //     base is 32G-aligned and base > 0. This allows certain
 389   //     optimizations in encoding/decoding.
 390   //     Disjoint: Bits used in base are disjoint from bits used
 391   //     for oops ==> oop = (cOop << 3) | base.  One can disjoint
 392   //     the bits of an oop into base and compressed oop.
 393   // 3 - Use compressed oops with heap base + encoding.
 394   enum NARROW_OOP_MODE {
 395     UnscaledNarrowOop  = 0,
 396     ZeroBasedNarrowOop = 1,
 397     DisjointBaseNarrowOop = 2,
 398     HeapBasedNarrowOop = 3,
 399     AnyNarrowOopMode = 4




   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_UNIVERSE_HPP
  26 #define SHARE_VM_MEMORY_UNIVERSE_HPP
  27 
  28 #include "gc/shared/gc.hpp"
  29 #include "runtime/handles.hpp"
  30 #include "utilities/array.hpp"
  31 #include "utilities/growableArray.hpp"
  32 
  33 // Universe is a name space holding known system classes and objects in the VM.
  34 //
  35 // Loaded classes are accessible through the SystemDictionary.
  36 //
  37 // The object heap is allocated and accessed through Universe, and various allocation
  38 // support is provided. Allocation by the interpreter and compiled code is done inline
  39 // and bails out to Scavenge::invoke_and_allocate.
  40 
  41 class CollectedHeap;
  42 class DeferredObjAllocEvent;
  43 
  44 
  45 // A helper class for caching a Method* when the user of the cache
  46 // only cares about the latest version of the Method*.  This cache safely
  47 // interacts with the RedefineClasses API.
  48 


 172   static Array<Klass*>*  _the_array_interfaces_array;
 173 
 174   // array of preallocated error objects with backtrace
 175   static objArrayOop   _preallocated_out_of_memory_error_array;
 176 
 177   // number of preallocated error objects available for use
 178   static volatile jint _preallocated_out_of_memory_error_avail_count;
 179 
 180   static oop          _null_ptr_exception_instance;   // preallocated exception object
 181   static oop          _arithmetic_exception_instance; // preallocated exception object
 182   static oop          _virtual_machine_error_instance; // preallocated exception object
 183   // The object used as an exception dummy when exceptions are thrown for
 184   // the vm thread.
 185   static oop          _vm_exception;
 186 
 187   static oop          _allocation_context_notification_obj;
 188 
 189   // References waiting to be transferred to the ReferenceHandler
 190   static oop          _reference_pending_list;
 191 



 192   static intptr_t _non_oop_bits;
 193 
 194   // For UseCompressedOops.
 195   static struct NarrowPtrStruct _narrow_oop;
 196   // For UseCompressedClassPointers.
 197   static struct NarrowPtrStruct _narrow_klass;
 198   static address _narrow_ptrs_base;
 199 
 200   // array of dummy objects used with +FullGCAlot
 201   debug_only(static objArrayOop _fullgc_alot_dummy_array;)
 202   // index of next entry to clear
 203   debug_only(static int         _fullgc_alot_dummy_next;)
 204 
 205   // Compiler/dispatch support
 206   static int  _base_vtable_size;                      // Java vtbl size of klass Object (in words)
 207 
 208   // Initialization
 209   static bool _bootstrapping;                         // true during genesis
 210   static bool _module_initialized;                    // true after call_initPhase2 called
 211   static bool _fully_initialized;                     // true after universe_init and initialize_vtables called
 212 
 213   // the array of preallocated errors with backtraces
 214   static objArrayOop  preallocated_out_of_memory_errors()     { return _preallocated_out_of_memory_error_array; }
 215 
 216   // generate an out of memory error; if possible using an error with preallocated backtrace;
 217   // otherwise return the given default error.
 218   static oop        gen_out_of_memory_error(oop default_err);
 219 
 220   // Historic gc information
 221   static size_t _heap_capacity_at_last_gc;
 222   static size_t _heap_used_at_last_gc;
 223 



 224   static jint initialize_heap();
 225   static void initialize_basic_type_mirrors(TRAPS);
 226   static void fixup_mirrors(TRAPS);
 227 
 228   static void reinitialize_vtable_of(KlassHandle h_k, TRAPS);
 229   static void reinitialize_itables(TRAPS);
 230   static void compute_base_vtable_size();             // compute vtable size of class Object
 231 
 232   static void genesis(TRAPS);                         // Create the initial world
 233 
 234   // Mirrors for primitive classes (created eagerly)
 235   static oop check_mirror(oop m) {
 236     assert(m != NULL, "mirror not initialized");
 237     return m;
 238   }
 239 
 240   static void     set_narrow_oop_base(address base) {
 241     assert(UseCompressedOops, "no compressed oops?");
 242     _narrow_oop._base    = base;
 243   }


 354   static oop out_of_memory_error_java_heap()          { return gen_out_of_memory_error(_out_of_memory_error_java_heap);  }
 355   static oop out_of_memory_error_metaspace()          { return gen_out_of_memory_error(_out_of_memory_error_metaspace);   }
 356   static oop out_of_memory_error_class_metaspace()    { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace);   }
 357   static oop out_of_memory_error_array_size()         { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
 358   static oop out_of_memory_error_gc_overhead_limit()  { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit);  }
 359   static oop out_of_memory_error_realloc_objects()    { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects);  }
 360   static oop delayed_stack_overflow_error_message()   { return _delayed_stack_overflow_error_message; }
 361 
 362   // Accessors needed for fast allocation
 363   static Klass** boolArrayKlassObj_addr()           { return &_boolArrayKlassObj;   }
 364   static Klass** byteArrayKlassObj_addr()           { return &_byteArrayKlassObj;   }
 365   static Klass** charArrayKlassObj_addr()           { return &_charArrayKlassObj;   }
 366   static Klass** intArrayKlassObj_addr()            { return &_intArrayKlassObj;    }
 367   static Klass** shortArrayKlassObj_addr()          { return &_shortArrayKlassObj;  }
 368   static Klass** longArrayKlassObj_addr()           { return &_longArrayKlassObj;   }
 369   static Klass** singleArrayKlassObj_addr()         { return &_singleArrayKlassObj; }
 370   static Klass** doubleArrayKlassObj_addr()         { return &_doubleArrayKlassObj; }
 371   static Klass** objectArrayKlassObj_addr()         { return &_objectArrayKlassObj; }
 372 
 373   // The particular choice of collected heap.
 374   /*
 375   static CollectedHeap* heap() {
 376     GC* gc = GC::gc();
 377     if (gc != NULL) return gc->heap();
 378     else return NULL;
 379   }
 380   */
 381 
 382   // For UseCompressedOops
 383   // Narrow Oop encoding mode:
 384   // 0 - Use 32-bits oops without encoding when
 385   //     NarrowOopHeapBaseMin + heap_size < 4Gb
 386   // 1 - Use zero based compressed oops with encoding when
 387   //     NarrowOopHeapBaseMin + heap_size < 32Gb
 388   // 2 - Use compressed oops with disjoint heap base if
 389   //     base is 32G-aligned and base > 0. This allows certain
 390   //     optimizations in encoding/decoding.
 391   //     Disjoint: Bits used in base are disjoint from bits used
 392   //     for oops ==> oop = (cOop << 3) | base.  One can disjoint
 393   //     the bits of an oop into base and compressed oop.
 394   // 3 - Use compressed oops with heap base + encoding.
 395   enum NARROW_OOP_MODE {
 396     UnscaledNarrowOop  = 0,
 397     ZeroBasedNarrowOop = 1,
 398     DisjointBaseNarrowOop = 2,
 399     HeapBasedNarrowOop = 3,
 400     AnyNarrowOopMode = 4


< prev index next >