universe.hpp revision 11869:03762a0cf7e1
1168404Spjd/* 2168404Spjd * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. 3168404Spjd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4168404Spjd * 5168404Spjd * This code is free software; you can redistribute it and/or modify it 6168404Spjd * under the terms of the GNU General Public License version 2 only, as 7168404Spjd * published by the Free Software Foundation. 8168404Spjd * 9168404Spjd * This code is distributed in the hope that it will be useful, but WITHOUT 10168404Spjd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11168404Spjd * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12168404Spjd * version 2 for more details (a copy is included in the LICENSE file that 13168404Spjd * accompanied this code). 14168404Spjd * 15168404Spjd * You should have received a copy of the GNU General Public License version 16168404Spjd * 2 along with this work; if not, write to the Free Software Foundation, 17168404Spjd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18168404Spjd * 19168404Spjd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20168404Spjd * or visit www.oracle.com if you need additional information or have any 21168404Spjd * questions. 22219089Spjd * 23168404Spjd */ 24168404Spjd 25168404Spjd#ifndef SHARE_VM_MEMORY_UNIVERSE_HPP 26168404Spjd#define SHARE_VM_MEMORY_UNIVERSE_HPP 27269845Sdelphij 28288595Smav#include "runtime/handles.hpp" 29269845Sdelphij#include "utilities/array.hpp" 30269845Sdelphij#include "utilities/growableArray.hpp" 31269845Sdelphij 32168404Spjd// Universe is a name space holding known system classes and objects in the VM. 33168404Spjd// 34168404Spjd// Loaded classes are accessible through the SystemDictionary. 35168404Spjd// 36168404Spjd// The object heap is allocated and accessed through Universe, and various allocation 37168404Spjd// support is provided. Allocation by the interpreter and compiled code is done inline 38168404Spjd// and bails out to Scavenge::invoke_and_allocate. 39168404Spjd 40168404Spjdclass CollectedHeap; 41168404Spjdclass DeferredObjAllocEvent; 42168404Spjd 43168404Spjd 44168404Spjd// A helper class for caching a Method* when the user of the cache 45265745Sdelphij// only cares about the latest version of the Method*. This cache safely 46168404Spjd// interacts with the RedefineClasses API. 47168404Spjd 48168404Spjdclass LatestMethodCache : public CHeapObj<mtClass> { 49168404Spjd // We save the Klass* and the idnum of Method* in order to get 50168404Spjd // the current cached Method*. 51168404Spjd private: 52168404Spjd Klass* _klass; 53265745Sdelphij int _method_idnum; 54168404Spjd 55168404Spjd public: 56168404Spjd LatestMethodCache() { _klass = NULL; _method_idnum = -1; } 57168404Spjd ~LatestMethodCache() { _klass = NULL; _method_idnum = -1; } 58168404Spjd 59168404Spjd void init(Klass* k, Method* m); 60168404Spjd Klass* klass() const { return _klass; } 61168404Spjd int method_idnum() const { return _method_idnum; } 62168404Spjd 63168404Spjd Method* get_method(); 64168404Spjd 65168404Spjd // Enhanced Class Redefinition support 66168404Spjd void classes_do(void f(Klass*)) { 67168404Spjd f(_klass); 68168404Spjd } 69168404Spjd 70168404Spjd // CDS support. Replace the klass in this with the archive version 71168404Spjd // could use this for Enhanced Class Redefinition also. 72168404Spjd void serialize(SerializeClosure* f) { 73168404Spjd f->do_ptr((void**)&_klass); 74168404Spjd } 75168404Spjd}; 76168404Spjd 77168404Spjd 78168404Spjd// For UseCompressedOops. 79168404Spjdstruct NarrowPtrStruct { 80168404Spjd // Base address for oop-within-java-object materialization. 81168404Spjd // NULL if using wide oops or zero based narrow oops. 82168404Spjd address _base; 83168404Spjd // Number of shift bits for encoding/decoding narrow ptrs. 84168404Spjd // 0 if using wide ptrs or zero based unscaled narrow ptrs, 85168404Spjd // LogMinObjAlignmentInBytes/LogKlassAlignmentInBytes otherwise. 86168404Spjd int _shift; 87168404Spjd // Generate code with implicit null checks for narrow ptrs. 88168404Spjd bool _use_implicit_null_checks; 89168404Spjd}; 90168404Spjd 91168404Spjdenum VerifyOption { 92168404Spjd VerifyOption_Default = 0, 93269845Sdelphij 94269845Sdelphij // G1 95269845Sdelphij VerifyOption_G1UsePrevMarking = VerifyOption_Default, 96269845Sdelphij VerifyOption_G1UseNextMarking = VerifyOption_G1UsePrevMarking + 1, 97269845Sdelphij VerifyOption_G1UseMarkWord = VerifyOption_G1UseNextMarking + 1 98269845Sdelphij}; 99168404Spjd 100168404Spjdclass Universe: AllStatic { 101168404Spjd // Ugh. Universe is much too friendly. 102168404Spjd friend class MarkSweep; 103174046Sjb friend class oopDesc; 104168404Spjd friend class ClassLoader; 105168404Spjd friend class SystemDictionary; 106168404Spjd friend class ReservedHeapSpace; 107168404Spjd friend class VMStructs; 108265745Sdelphij friend class VM_PopulateDumpSharedSpace; 109168404Spjd friend class Metaspace; 110168404Spjd 111168404Spjd friend jint universe_init(); 112168404Spjd friend void universe2_init(); 113168404Spjd friend bool universe_post_init(); 114168404Spjd friend void universe_post_module_init(); 115168404Spjd 116168404Spjd private: 117168404Spjd // Known classes in the VM 118168404Spjd static Klass* _boolArrayKlassObj; 119168404Spjd static Klass* _byteArrayKlassObj; 120168404Spjd static Klass* _charArrayKlassObj; 121168404Spjd static Klass* _intArrayKlassObj; 122168404Spjd static Klass* _shortArrayKlassObj; 123168404Spjd static Klass* _longArrayKlassObj; 124168404Spjd static Klass* _singleArrayKlassObj; 125168404Spjd static Klass* _doubleArrayKlassObj; 126168404Spjd static Klass* _typeArrayKlassObjs[T_VOID+1]; 127168404Spjd 128265745Sdelphij static Klass* _objectArrayKlassObj; 129265745Sdelphij 130168404Spjd // Known objects in the VM 131168404Spjd 132168404Spjd // Primitive objects 133168404Spjd static oop _int_mirror; 134168404Spjd static oop _float_mirror; 135168404Spjd static oop _double_mirror; 136168404Spjd static oop _byte_mirror; 137168404Spjd static oop _bool_mirror; 138168404Spjd static oop _char_mirror; 139168404Spjd static oop _long_mirror; 140168404Spjd static oop _short_mirror; 141168404Spjd static oop _void_mirror; 142168404Spjd 143168404Spjd static oop _main_thread_group; // Reference to the main thread group object 144168404Spjd static oop _system_thread_group; // Reference to the system thread group object 145168404Spjd 146168404Spjd static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class 147168404Spjd static oop _the_null_string; // A cache of "null" as a Java string 148168404Spjd static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string 149168404Spjd static LatestMethodCache* _finalizer_register_cache; // static method for registering finalizable objects 150168404Spjd static LatestMethodCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector 151168404Spjd static LatestMethodCache* _pd_implies_cache; // method for checking protection domain attributes 152168404Spjd static LatestMethodCache* _throw_illegal_access_error_cache; // Unsafe.throwIllegalAccessError() method 153168404Spjd static LatestMethodCache* _do_stack_walk_cache; // method for stack walker callback 154168404Spjd 155168404Spjd // preallocated error objects (no backtrace) 156168404Spjd static oop _out_of_memory_error_java_heap; 157168404Spjd static oop _out_of_memory_error_metaspace; 158168404Spjd static oop _out_of_memory_error_class_metaspace; 159168404Spjd static oop _out_of_memory_error_array_size; 160168404Spjd static oop _out_of_memory_error_gc_overhead_limit; 161168404Spjd static oop _out_of_memory_error_realloc_objects; 162168404Spjd 163168404Spjd // preallocated cause message for delayed StackOverflowError 164168404Spjd static oop _delayed_stack_overflow_error_message; 165168404Spjd 166168404Spjd static Array<int>* _the_empty_int_array; // Canonicalized int array 167168404Spjd static Array<u2>* _the_empty_short_array; // Canonicalized short array 168168404Spjd static Array<Klass*>* _the_empty_klass_array; // Canonicalized klass obj array 169168404Spjd static Array<Method*>* _the_empty_method_array; // Canonicalized method obj array 170168404Spjd 171168404Spjd static Array<Klass*>* _the_array_interfaces_array; 172168404Spjd 173168404Spjd // array of preallocated error objects with backtrace 174168404Spjd static objArrayOop _preallocated_out_of_memory_error_array; 175168404Spjd 176168404Spjd // number of preallocated error objects available for use 177168404Spjd static volatile jint _preallocated_out_of_memory_error_avail_count; 178168404Spjd 179168404Spjd static oop _null_ptr_exception_instance; // preallocated exception object 180168404Spjd static oop _arithmetic_exception_instance; // preallocated exception object 181168404Spjd static oop _virtual_machine_error_instance; // preallocated exception object 182168404Spjd // The object used as an exception dummy when exceptions are thrown for 183168404Spjd // the vm thread. 184168404Spjd static oop _vm_exception; 185168404Spjd 186168404Spjd static oop _allocation_context_notification_obj; 187168404Spjd 188168404Spjd // The particular choice of collected heap. 189168404Spjd static CollectedHeap* _collectedHeap; 190168404Spjd 191168404Spjd static intptr_t _non_oop_bits; 192168404Spjd 193168404Spjd // For UseCompressedOops. 194168404Spjd static struct NarrowPtrStruct _narrow_oop; 195168404Spjd // For UseCompressedClassPointers. 196168404Spjd static struct NarrowPtrStruct _narrow_klass; 197168404Spjd static address _narrow_ptrs_base; 198168404Spjd 199168404Spjd // array of dummy objects used with +FullGCAlot 200168404Spjd debug_only(static objArrayOop _fullgc_alot_dummy_array;) 201168404Spjd // index of next entry to clear 202168404Spjd debug_only(static int _fullgc_alot_dummy_next;) 203168404Spjd 204168404Spjd // Compiler/dispatch support 205168404Spjd static int _base_vtable_size; // Java vtbl size of klass Object (in words) 206168404Spjd 207168404Spjd // Initialization 208168404Spjd static bool _bootstrapping; // true during genesis 209168404Spjd static bool _module_initialized; // true after call_initPhase2 called 210168404Spjd static bool _fully_initialized; // true after universe_init and initialize_vtables called 211168404Spjd 212168404Spjd // the array of preallocated errors with backtraces 213168404Spjd static objArrayOop preallocated_out_of_memory_errors() { return _preallocated_out_of_memory_error_array; } 214168404Spjd 215168404Spjd // generate an out of memory error; if possible using an error with preallocated backtrace; 216168404Spjd // otherwise return the given default error. 217168404Spjd static oop gen_out_of_memory_error(oop default_err); 218168404Spjd 219168404Spjd // Historic gc information 220168404Spjd static size_t _heap_capacity_at_last_gc; 221168404Spjd static size_t _heap_used_at_last_gc; 222168404Spjd 223168404Spjd template <class Heap, class Policy> static CollectedHeap* create_heap_with_policy(); 224168404Spjd static CollectedHeap* create_heap(); 225168404Spjd static CollectedHeap* create_heap_ext(); 226168404Spjd static jint initialize_heap(); 227168404Spjd static void initialize_basic_type_mirrors(TRAPS); 228168404Spjd static void fixup_mirrors(TRAPS); 229168404Spjd 230168404Spjd static void reinitialize_vtable_of(KlassHandle h_k, TRAPS); 231168404Spjd static void reinitialize_itables(TRAPS); 232168404Spjd static void compute_base_vtable_size(); // compute vtable size of class Object 233168404Spjd 234168404Spjd static void genesis(TRAPS); // Create the initial world 235168404Spjd 236168404Spjd // Mirrors for primitive classes (created eagerly) 237168404Spjd static oop check_mirror(oop m) { 238168404Spjd assert(m != NULL, "mirror not initialized"); 239168404Spjd return m; 240168404Spjd } 241168404Spjd 242168404Spjd static void set_narrow_oop_base(address base) { 243168404Spjd assert(UseCompressedOops, "no compressed oops?"); 244168404Spjd _narrow_oop._base = base; 245168404Spjd } 246168404Spjd static void set_narrow_klass_base(address base) { 247168404Spjd assert(UseCompressedClassPointers, "no compressed klass ptrs?"); 248168404Spjd _narrow_klass._base = base; 249168404Spjd } 250168404Spjd static void set_narrow_oop_use_implicit_null_checks(bool use) { 251168404Spjd assert(UseCompressedOops, "no compressed ptrs?"); 252168404Spjd _narrow_oop._use_implicit_null_checks = use; 253168404Spjd } 254168404Spjd 255219089Spjd // Debugging 256168404Spjd static int _verify_count; // number of verifies done 257168404Spjd 258168404Spjd // True during call to verify(). Should only be set/cleared in verify(). 259168404Spjd static bool _verify_in_progress; 260168404Spjd static long verify_flags; 261168404Spjd 262168404Spjd static uintptr_t _verify_oop_mask; 263168404Spjd static uintptr_t _verify_oop_bits; 264168404Spjd 265168404Spjd static void calculate_verify_data(HeapWord* low_boundary, HeapWord* high_boundary) PRODUCT_RETURN; 266168404Spjd static void compute_verify_oop_data(); 267168404Spjd 268168404Spjd public: 269168404Spjd // Known classes in the VM 270168404Spjd static Klass* boolArrayKlassObj() { return _boolArrayKlassObj; } 271168404Spjd static Klass* byteArrayKlassObj() { return _byteArrayKlassObj; } 272168404Spjd static Klass* charArrayKlassObj() { return _charArrayKlassObj; } 273168404Spjd static Klass* intArrayKlassObj() { return _intArrayKlassObj; } 274168404Spjd static Klass* shortArrayKlassObj() { return _shortArrayKlassObj; } 275168404Spjd static Klass* longArrayKlassObj() { return _longArrayKlassObj; } 276168404Spjd static Klass* singleArrayKlassObj() { return _singleArrayKlassObj; } 277168404Spjd static Klass* doubleArrayKlassObj() { return _doubleArrayKlassObj; } 278168404Spjd 279168404Spjd static Klass* objectArrayKlassObj() { 280168404Spjd return _objectArrayKlassObj; 281168404Spjd } 282168404Spjd 283168404Spjd static Klass* typeArrayKlassObj(BasicType t) { 284168404Spjd assert((uint)t < T_VOID+1, "range check for type: %s", type2name(t)); 285168404Spjd assert(_typeArrayKlassObjs[t] != NULL, "domain check"); 286168404Spjd return _typeArrayKlassObjs[t]; 287168404Spjd } 288168404Spjd 289168404Spjd // Known objects in the VM 290168404Spjd static oop int_mirror() { return check_mirror(_int_mirror); } 291168404Spjd static oop float_mirror() { return check_mirror(_float_mirror); } 292168404Spjd static oop double_mirror() { return check_mirror(_double_mirror); } 293168404Spjd static oop byte_mirror() { return check_mirror(_byte_mirror); } 294168404Spjd static oop bool_mirror() { return check_mirror(_bool_mirror); } 295168404Spjd static oop char_mirror() { return check_mirror(_char_mirror); } 296168404Spjd static oop long_mirror() { return check_mirror(_long_mirror); } 297168404Spjd static oop short_mirror() { return check_mirror(_short_mirror); } 298168404Spjd static oop void_mirror() { return check_mirror(_void_mirror); } 299168404Spjd 300168404Spjd // table of same 301168404Spjd static oop _mirrors[T_VOID+1]; 302168404Spjd 303168404Spjd static oop java_mirror(BasicType t) { 304168404Spjd assert((uint)t < T_VOID+1, "range check"); 305168404Spjd return check_mirror(_mirrors[t]); 306168404Spjd } 307168404Spjd static oop main_thread_group() { return _main_thread_group; } 308168404Spjd static void set_main_thread_group(oop group) { _main_thread_group = group;} 309168404Spjd 310168404Spjd static oop system_thread_group() { return _system_thread_group; } 311168404Spjd static void set_system_thread_group(oop group) { _system_thread_group = group;} 312168404Spjd 313168404Spjd static objArrayOop the_empty_class_klass_array () { return _the_empty_class_klass_array; } 314168404Spjd static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; } 315168404Spjd static oop the_null_string() { return _the_null_string; } 316168404Spjd static oop the_min_jint_string() { return _the_min_jint_string; } 317168404Spjd 318168404Spjd static Method* finalizer_register_method() { return _finalizer_register_cache->get_method(); } 319168404Spjd static Method* loader_addClass_method() { return _loader_addClass_cache->get_method(); } 320168404Spjd 321168404Spjd static Method* protection_domain_implies_method() { return _pd_implies_cache->get_method(); } 322168404Spjd static Method* throw_illegal_access_error() { return _throw_illegal_access_error_cache->get_method(); } 323168404Spjd 324168404Spjd static Method* do_stack_walk_method() { return _do_stack_walk_cache->get_method(); } 325168404Spjd 326168404Spjd // Function to initialize these 327168404Spjd static void initialize_known_methods(TRAPS); 328168404Spjd 329168404Spjd static oop null_ptr_exception_instance() { return _null_ptr_exception_instance; } 330168404Spjd static oop arithmetic_exception_instance() { return _arithmetic_exception_instance; } 331168404Spjd static oop virtual_machine_error_instance() { return _virtual_machine_error_instance; } 332168404Spjd static oop vm_exception() { return _vm_exception; } 333168404Spjd 334168404Spjd static inline oop allocation_context_notification_obj(); 335168404Spjd static inline void set_allocation_context_notification_obj(oop obj); 336168404Spjd 337168404Spjd static Array<int>* the_empty_int_array() { return _the_empty_int_array; } 338168404Spjd static Array<u2>* the_empty_short_array() { return _the_empty_short_array; } 339168404Spjd static Array<Method*>* the_empty_method_array() { return _the_empty_method_array; } 340168404Spjd static Array<Klass*>* the_empty_klass_array() { return _the_empty_klass_array; } 341168404Spjd 342168404Spjd // OutOfMemoryError support. Returns an error with the required message. The returned error 343168404Spjd // may or may not have a backtrace. If error has a backtrace then the stack trace is already 344168404Spjd // filled in. 345168404Spjd static oop out_of_memory_error_java_heap() { return gen_out_of_memory_error(_out_of_memory_error_java_heap); } 346168404Spjd static oop out_of_memory_error_metaspace() { return gen_out_of_memory_error(_out_of_memory_error_metaspace); } 347168404Spjd static oop out_of_memory_error_class_metaspace() { return gen_out_of_memory_error(_out_of_memory_error_class_metaspace); } 348168404Spjd static oop out_of_memory_error_array_size() { return gen_out_of_memory_error(_out_of_memory_error_array_size); } 349168404Spjd static oop out_of_memory_error_gc_overhead_limit() { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit); } 350168404Spjd static oop out_of_memory_error_realloc_objects() { return gen_out_of_memory_error(_out_of_memory_error_realloc_objects); } 351168404Spjd static oop delayed_stack_overflow_error_message() { return _delayed_stack_overflow_error_message; } 352168404Spjd 353168404Spjd // Accessors needed for fast allocation 354168404Spjd static Klass** boolArrayKlassObj_addr() { return &_boolArrayKlassObj; } 355168404Spjd static Klass** byteArrayKlassObj_addr() { return &_byteArrayKlassObj; } 356168404Spjd static Klass** charArrayKlassObj_addr() { return &_charArrayKlassObj; } 357168404Spjd static Klass** intArrayKlassObj_addr() { return &_intArrayKlassObj; } 358168404Spjd static Klass** shortArrayKlassObj_addr() { return &_shortArrayKlassObj; } 359168404Spjd static Klass** longArrayKlassObj_addr() { return &_longArrayKlassObj; } 360168404Spjd static Klass** singleArrayKlassObj_addr() { return &_singleArrayKlassObj; } 361168404Spjd static Klass** doubleArrayKlassObj_addr() { return &_doubleArrayKlassObj; } 362168404Spjd static Klass** objectArrayKlassObj_addr() { return &_objectArrayKlassObj; } 363168404Spjd 364168404Spjd // The particular choice of collected heap. 365168404Spjd static CollectedHeap* heap() { return _collectedHeap; } 366168404Spjd 367168404Spjd // For UseCompressedOops 368168404Spjd // Narrow Oop encoding mode: 369168404Spjd // 0 - Use 32-bits oops without encoding when 370168404Spjd // NarrowOopHeapBaseMin + heap_size < 4Gb 371168404Spjd // 1 - Use zero based compressed oops with encoding when 372168404Spjd // NarrowOopHeapBaseMin + heap_size < 32Gb 373168404Spjd // 2 - Use compressed oops with disjoint heap base if 374168404Spjd // base is 32G-aligned and base > 0. This allows certain 375168404Spjd // optimizations in encoding/decoding. 376168404Spjd // Disjoint: Bits used in base are disjoint from bits used 377168404Spjd // for oops ==> oop = (cOop << 3) | base. One can disjoint 378168404Spjd // the bits of an oop into base and compressed oop. 379168404Spjd // 3 - Use compressed oops with heap base + encoding. 380168404Spjd enum NARROW_OOP_MODE { 381168404Spjd UnscaledNarrowOop = 0, 382168404Spjd ZeroBasedNarrowOop = 1, 383168404Spjd DisjointBaseNarrowOop = 2, 384168404Spjd HeapBasedNarrowOop = 3, 385168404Spjd AnyNarrowOopMode = 4 386168404Spjd }; 387168404Spjd static NARROW_OOP_MODE narrow_oop_mode(); 388168404Spjd static const char* narrow_oop_mode_to_string(NARROW_OOP_MODE mode); 389168404Spjd static char* preferred_heap_base(size_t heap_size, size_t alignment, NARROW_OOP_MODE mode); 390168404Spjd static char* preferred_metaspace_base(size_t heap_size, NARROW_OOP_MODE mode); 391168404Spjd static address narrow_oop_base() { return _narrow_oop._base; } 392168404Spjd // Test whether bits of addr and possible offsets into the heap overlap. 393168404Spjd static bool is_disjoint_heap_base_address(address addr) { 394168404Spjd return (((uint64_t)(intptr_t)addr) & 395168404Spjd (((uint64_t)UCONST64(0xFFFFffffFFFFffff)) >> (32-LogMinObjAlignmentInBytes))) == 0; 396168404Spjd } 397168404Spjd // Check for disjoint base compressed oops. 398168404Spjd static bool narrow_oop_base_disjoint() { 399168404Spjd return _narrow_oop._base != NULL && is_disjoint_heap_base_address(_narrow_oop._base); 400168404Spjd } 401168404Spjd // Check for real heapbased compressed oops. 402168404Spjd // We must subtract the base as the bits overlap. 403168404Spjd // If we negate above function, we also get unscaled and zerobased. 404168404Spjd static bool narrow_oop_base_overlaps() { 405168404Spjd return _narrow_oop._base != NULL && !is_disjoint_heap_base_address(_narrow_oop._base); 406168404Spjd } 407168404Spjd static bool is_narrow_oop_base(void* addr) { return (narrow_oop_base() == (address)addr); } 408168404Spjd static int narrow_oop_shift() { return _narrow_oop._shift; } 409168404Spjd static bool narrow_oop_use_implicit_null_checks() { return _narrow_oop._use_implicit_null_checks; } 410168404Spjd 411168404Spjd // For UseCompressedClassPointers 412168404Spjd static address narrow_klass_base() { return _narrow_klass._base; } 413168404Spjd static bool is_narrow_klass_base(void* addr) { return (narrow_klass_base() == (address)addr); } 414168404Spjd static int narrow_klass_shift() { return _narrow_klass._shift; } 415168404Spjd static bool narrow_klass_use_implicit_null_checks() { return _narrow_klass._use_implicit_null_checks; } 416168404Spjd 417168404Spjd static address* narrow_ptrs_base_addr() { return &_narrow_ptrs_base; } 418168404Spjd static void set_narrow_ptrs_base(address a) { _narrow_ptrs_base = a; } 419168404Spjd static address narrow_ptrs_base() { return _narrow_ptrs_base; } 420168404Spjd 421168404Spjd static void print_compressed_oops_mode(outputStream* st); 422168404Spjd 423168404Spjd // this is set in vm_version on sparc (and then reset in universe afaict) 424168404Spjd static void set_narrow_oop_shift(int shift) { 425168404Spjd _narrow_oop._shift = shift; 426168404Spjd } 427168404Spjd 428168404Spjd static void set_narrow_klass_shift(int shift) { 429168404Spjd assert(shift == 0 || shift == LogKlassAlignmentInBytes, "invalid shift for klass ptrs"); 430168404Spjd _narrow_klass._shift = shift; 431168404Spjd } 432168404Spjd 433168404Spjd // Reserve Java heap and determine CompressedOops mode 434168404Spjd static ReservedSpace reserve_heap(size_t heap_size, size_t alignment); 435168404Spjd 436168404Spjd // Historic gc information 437168404Spjd static size_t get_heap_capacity_at_last_gc() { return _heap_capacity_at_last_gc; } 438168404Spjd static size_t get_heap_free_at_last_gc() { return _heap_capacity_at_last_gc - _heap_used_at_last_gc; } 439168404Spjd static size_t get_heap_used_at_last_gc() { return _heap_used_at_last_gc; } 440168404Spjd static void update_heap_info_at_gc(); 441168404Spjd 442168404Spjd // Testers 443168404Spjd static bool is_bootstrapping() { return _bootstrapping; } 444168404Spjd static bool is_module_initialized() { return _module_initialized; } 445168404Spjd static bool is_fully_initialized() { return _fully_initialized; } 446168404Spjd 447168404Spjd static inline bool element_type_should_be_aligned(BasicType type); 448168404Spjd static inline bool field_type_should_be_aligned(BasicType type); 449168404Spjd static bool on_page_boundary(void* addr); 450168404Spjd static bool should_fill_in_stack_trace(Handle throwable); 451168404Spjd static void check_alignment(uintx size, uintx alignment, const char* name); 452168404Spjd 453168404Spjd // Finalizer support. 454168404Spjd static void run_finalizers_on_exit(); 455168404Spjd 456168404Spjd // Iteration 457168404Spjd 458168404Spjd // Apply "f" to the addresses of all the direct heap pointers maintained 459168404Spjd // as static fields of "Universe". 460168404Spjd static void oops_do(OopClosure* f, bool do_all = false); 461168404Spjd 462168404Spjd // CDS support 463168404Spjd static void serialize(SerializeClosure* f, bool do_all = false); 464168404Spjd 465168404Spjd // Apply "f" to all klasses for basic types (classes not present in 466168404Spjd // SystemDictionary). 467168404Spjd static void basic_type_classes_do(void f(Klass*)); 468168404Spjd 469168404Spjd // For sharing -- fill in a list of known vtable pointers. 470168404Spjd static void init_self_patching_vtbl_list(void** list, int count); 471168404Spjd 472168404Spjd // Debugging 473168404Spjd enum VERIFY_FLAGS { 474168404Spjd Verify_Threads = 1, 475168404Spjd Verify_Heap = 2, 476168404Spjd Verify_SymbolTable = 4, 477168404Spjd Verify_StringTable = 8, 478168404Spjd Verify_CodeCache = 16, 479168404Spjd Verify_SystemDictionary = 32, 480168404Spjd Verify_ClassLoaderDataGraph = 64, 481168404Spjd Verify_MetaspaceAux = 128, 482168404Spjd Verify_JNIHandles = 256, 483168404Spjd Verify_CodeCacheOops = 512, 484168404Spjd Verify_All = -1 485168404Spjd }; 486168404Spjd static void initialize_verify_flags(); 487168404Spjd static bool should_verify_subset(uint subset); 488168404Spjd static bool verify_in_progress() { return _verify_in_progress; } 489168404Spjd static void verify(VerifyOption option, const char* prefix); 490168404Spjd static void verify(const char* prefix) { 491168404Spjd verify(VerifyOption_Default, prefix); 492168404Spjd } 493168404Spjd static void verify() { 494168404Spjd verify(""); 495168404Spjd } 496168404Spjd 497168404Spjd static int verify_count() { return _verify_count; } 498168404Spjd static void print_on(outputStream* st); 499168404Spjd static void print_heap_at_SIGBREAK(); 500168404Spjd static void print_heap_before_gc(); 501168404Spjd static void print_heap_after_gc(); 502168404Spjd 503168404Spjd // Change the number of dummy objects kept reachable by the full gc dummy 504168404Spjd // array; this should trigger relocation in a sliding compaction collector. 505168404Spjd debug_only(static bool release_fullgc_alot_dummy();) 506168404Spjd // The non-oop pattern (see compiledIC.hpp, etc) 507168404Spjd static void* non_oop_word(); 508168404Spjd 509168404Spjd // Oop verification (see MacroAssembler::verify_oop) 510168404Spjd static uintptr_t verify_oop_mask() PRODUCT_RETURN0; 511168404Spjd static uintptr_t verify_oop_bits() PRODUCT_RETURN0; 512168404Spjd static uintptr_t verify_mark_bits() PRODUCT_RETURN0; 513168404Spjd static uintptr_t verify_mark_mask() PRODUCT_RETURN0; 514168404Spjd 515168404Spjd // Compiler support 516168404Spjd static int base_vtable_size() { return _base_vtable_size; } 517168404Spjd}; 518168404Spjd 519168404Spjdclass DeferredObjAllocEvent : public CHeapObj<mtInternal> { 520168404Spjd private: 521168404Spjd oop _oop; 522168404Spjd size_t _bytesize; 523168404Spjd jint _arena_id; 524168404Spjd 525168404Spjd public: 526168404Spjd DeferredObjAllocEvent(const oop o, const size_t s, const jint id) { 527168404Spjd _oop = o; 528168404Spjd _bytesize = s; 529168404Spjd _arena_id = id; 530168404Spjd } 531168404Spjd 532168404Spjd ~DeferredObjAllocEvent() { 533168404Spjd } 534168404Spjd 535168404Spjd jint arena_id() { return _arena_id; } 536168404Spjd size_t bytesize() { return _bytesize; } 537168404Spjd oop get_oop() { return _oop; } 538168404Spjd}; 539168404Spjd 540168404Spjd#endif // SHARE_VM_MEMORY_UNIVERSE_HPP 541168404Spjd