< prev index next >

src/share/vm/memory/universe.hpp

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


 166   static Array<Klass*>*  _the_array_interfaces_array;
 167 
 168   // array of preallocated error objects with backtrace
 169   static objArrayOop   _preallocated_out_of_memory_error_array;
 170 
 171   // number of preallocated error objects available for use
 172   static volatile jint _preallocated_out_of_memory_error_avail_count;
 173 
 174   static oop          _null_ptr_exception_instance;   // preallocated exception object
 175   static oop          _arithmetic_exception_instance; // preallocated exception object
 176   static oop          _virtual_machine_error_instance; // preallocated exception object
 177   // The object used as an exception dummy when exceptions are thrown for
 178   // the vm thread.
 179   static oop          _vm_exception;
 180 
 181   static oop          _allocation_context_notification_obj;
 182 
 183   // References waiting to be transferred to the ReferenceHandler
 184   static oop          _reference_pending_list;
 185 
 186   // The particular choice of collected heap.
 187   static CollectedHeap* _collectedHeap;
 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   template <class Heap, class Policy> static CollectedHeap* create_heap_with_policy();
 222   static CollectedHeap* create_heap();
 223   static CollectedHeap* create_heap_ext();
 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(Klass* 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   static CollectedHeap* heap() { return _collectedHeap; }






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


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



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



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


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


< prev index next >