< prev index next >

src/share/vm/memory/universe.hpp

Print this page
rev 11777 : [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 


 168   static Array<Klass*>*  _the_empty_klass_array;  // Canonicalized klass obj array
 169   static Array<Method*>* _the_empty_method_array; // Canonicalized method obj array
 170 
 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   // The particular choice of collected heap.
 189   static CollectedHeap* _collectedHeap;
 190 
 191   static intptr_t _non_oop_bits;
 192 
 193   // For UseCompressedOops.
 194   static struct NarrowPtrStruct _narrow_oop;
 195   // For UseCompressedClassPointers.
 196   static struct NarrowPtrStruct _narrow_klass;
 197   static address _narrow_ptrs_base;
 198 
 199   // array of dummy objects used with +FullGCAlot
 200   debug_only(static objArrayOop _fullgc_alot_dummy_array;)
 201   // index of next entry to clear
 202   debug_only(static int         _fullgc_alot_dummy_next;)
 203 
 204   // Compiler/dispatch support
 205   static int  _base_vtable_size;                      // Java vtbl size of klass Object (in words)
 206 
 207   // Initialization
 208   static bool _bootstrapping;                         // true during genesis
 209   static bool _module_initialized;                    // true after call_initPhase2 called
 210   static bool _fully_initialized;                     // true after universe_init and initialize_vtables called
 211 
 212   // the array of preallocated errors with backtraces
 213   static objArrayOop  preallocated_out_of_memory_errors()     { return _preallocated_out_of_memory_error_array; }
 214 
 215   // generate an out of memory error; if possible using an error with preallocated backtrace;
 216   // otherwise return the given default error.
 217   static oop        gen_out_of_memory_error(oop default_err);
 218 
 219   // Historic gc information
 220   static size_t _heap_capacity_at_last_gc;
 221   static size_t _heap_used_at_last_gc;
 222 
 223   template <class Heap, class Policy> static CollectedHeap* create_heap_with_policy();
 224   static CollectedHeap* create_heap();
 225   static CollectedHeap* create_heap_ext();
 226   static jint initialize_heap();
 227   static void initialize_basic_type_mirrors(TRAPS);
 228   static void fixup_mirrors(TRAPS);
 229 
 230   static void reinitialize_vtable_of(KlassHandle h_k, TRAPS);
 231   static void reinitialize_itables(TRAPS);
 232   static void compute_base_vtable_size();             // compute vtable size of class Object
 233 
 234   static void genesis(TRAPS);                         // Create the initial world
 235 
 236   // Mirrors for primitive classes (created eagerly)
 237   static oop check_mirror(oop m) {
 238     assert(m != NULL, "mirror not initialized");
 239     return m;
 240   }
 241 
 242   static void     set_narrow_oop_base(address base) {
 243     assert(UseCompressedOops, "no compressed oops?");
 244     _narrow_oop._base    = base;
 245   }


 345   static oop out_of_memory_error_java_heap()          { return gen_out_of_memory_error(_out_of_memory_error_java_heap);  }
 346   static oop out_of_memory_error_metaspace()          { return gen_out_of_memory_error(_out_of_memory_error_metaspace);   }
 347   static oop out_of_memory_error_class_metaspace()    { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace);   }
 348   static oop out_of_memory_error_array_size()         { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
 349   static oop out_of_memory_error_gc_overhead_limit()  { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit);  }
 350   static oop out_of_memory_error_realloc_objects()    { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects);  }
 351   static oop delayed_stack_overflow_error_message()   { return _delayed_stack_overflow_error_message; }
 352 
 353   // Accessors needed for fast allocation
 354   static Klass** boolArrayKlassObj_addr()           { return &_boolArrayKlassObj;   }
 355   static Klass** byteArrayKlassObj_addr()           { return &_byteArrayKlassObj;   }
 356   static Klass** charArrayKlassObj_addr()           { return &_charArrayKlassObj;   }
 357   static Klass** intArrayKlassObj_addr()            { return &_intArrayKlassObj;    }
 358   static Klass** shortArrayKlassObj_addr()          { return &_shortArrayKlassObj;  }
 359   static Klass** longArrayKlassObj_addr()           { return &_longArrayKlassObj;   }
 360   static Klass** singleArrayKlassObj_addr()         { return &_singleArrayKlassObj; }
 361   static Klass** doubleArrayKlassObj_addr()         { return &_doubleArrayKlassObj; }
 362   static Klass** objectArrayKlassObj_addr()         { return &_objectArrayKlassObj; }
 363 
 364   // The particular choice of collected heap.
 365   static CollectedHeap* heap() { return _collectedHeap; }






 366 
 367   // For UseCompressedOops
 368   // Narrow Oop encoding mode:
 369   // 0 - Use 32-bits oops without encoding when
 370   //     NarrowOopHeapBaseMin + heap_size < 4Gb
 371   // 1 - Use zero based compressed oops with encoding when
 372   //     NarrowOopHeapBaseMin + heap_size < 32Gb
 373   // 2 - Use compressed oops with disjoint heap base if
 374   //     base is 32G-aligned and base > 0. This allows certain
 375   //     optimizations in encoding/decoding.
 376   //     Disjoint: Bits used in base are disjoint from bits used
 377   //     for oops ==> oop = (cOop << 3) | base.  One can disjoint
 378   //     the bits of an oop into base and compressed oop.
 379   // 3 - Use compressed oops with heap base + encoding.
 380   enum NARROW_OOP_MODE {
 381     UnscaledNarrowOop  = 0,
 382     ZeroBasedNarrowOop = 1,
 383     DisjointBaseNarrowOop = 2,
 384     HeapBasedNarrowOop = 3,
 385     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 


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



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


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


< prev index next >