universe.hpp revision 113
/*
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
// Universe is a name space holding known system classes and objects in the VM.
//
// Loaded classes are accessible through the SystemDictionary.
//
// The object heap is allocated and accessed through Universe, and various allocation
// support is provided. Allocation by the interpreter and compiled code is done inline
// and bails out to Scavenge::invoke_and_allocate.
class CollectedHeap;
class DeferredObjAllocEvent;
// Common parts of a methodOop cache. This cache safely interacts with
// the RedefineClasses API.
//
class CommonMethodOopCache : public CHeapObj {
// We save the klassOop and the idnum of methodOop in order to get
// the current cached methodOop.
private:
int _method_idnum;
public:
int method_idnum() const { return _method_idnum; }
// GC support
};
// A helper class for caching a methodOop when the user of the cache
// cares about all versions of the methodOop.
//
class ActiveMethodOopsCache : public CommonMethodOopCache {
// This subclass adds weak references to older versions of the
// methodOop and a query method for a methodOop.
private:
// If the cached methodOop has not been redefined, then
// _prev_methods will be NULL. If all of the previous
// versions of the method have been collected, then
// _prev_methods can have a length of zero.
public:
};
// A helper class for caching a methodOop when the user of the cache
// only cares about the latest version of the methodOop.
//
class LatestMethodOopCache : public CommonMethodOopCache {
// This subclass adds a getter method for the latest methodOop.
public:
};
friend class MarkSweep;
friend class oopDesc;
friend class ClassLoader;
friend class Arguments;
friend class SystemDictionary;
friend class VMStructs;
friend class CompactingPermGenGen;
friend class VM_PopulateDumpSharedSpace;
friend jint universe_init();
friend void universe2_init();
friend bool universe_post_init();
private:
// Known classes in the VM
static klassOop _boolArrayKlassObj;
static klassOop _byteArrayKlassObj;
static klassOop _charArrayKlassObj;
static klassOop _intArrayKlassObj;
static klassOop _shortArrayKlassObj;
static klassOop _longArrayKlassObj;
static klassOop _singleArrayKlassObj;
static klassOop _doubleArrayKlassObj;
static klassOop _objectArrayKlassObj;
static klassOop _symbolKlassObj;
static klassOop _methodKlassObj;
static klassOop _constMethodKlassObj;
static klassOop _methodDataKlassObj;
static klassOop _klassKlassObj;
static klassOop _arrayKlassKlassObj;
static klassOop _objArrayKlassKlassObj;
static klassOop _typeArrayKlassKlassObj;
static klassOop _instanceKlassKlassObj;
static klassOop _constantPoolKlassObj;
static klassOop _constantPoolCacheKlassObj;
static klassOop _compiledICHolderKlassObj;
static klassOop _systemObjArrayKlassObj;
// Known objects in the VM
// Primitive objects
static oop _int_mirror;
static oop _float_mirror;
static oop _double_mirror;
static oop _byte_mirror;
static oop _bool_mirror;
static oop _char_mirror;
static oop _long_mirror;
static oop _short_mirror;
static oop _void_mirror;
static objArrayOop _the_array_interfaces_array; // Canonicalized 2-array of cloneable & serializable klasses
static LatestMethodOopCache* _finalizer_register_cache; // static method for registering finalizable objects
static LatestMethodOopCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector
// array of preallocated error objects with backtrace
// number of preallocated error objects available for use
static volatile jint _preallocated_out_of_memory_error_avail_count;
// The object used as an exception dummy when exceptions are thrown for
// the vm thread.
static oop _vm_exception;
// The particular choice of collected heap.
static CollectedHeap* _collectedHeap;
// Base address for oop-within-java-object materialization.
// NULL if using wide oops. Doubles as heap oop null value.
static address _heap_base;
// array of dummy objects used with +FullGCAlot
// index of next entry to clear
debug_only(static int _fullgc_alot_dummy_next;)
static int _base_vtable_size; // Java vtbl size of klass Object (in words)
// Initialization
static bool _bootstrapping; // true during genesis
static bool _fully_initialized; // true after universe_init and initialize_vtables called
// the array of preallocated errors with backtraces
static objArrayOop preallocated_out_of_memory_errors() { return _preallocated_out_of_memory_error_array; }
// generate an out of memory error; if possible using an error with preallocated backtrace;
// otherwise return the given default error.
// Historic gc information
static size_t _heap_capacity_at_last_gc;
static size_t _heap_used_at_last_gc;
static jint initialize_heap();
static void initialize_basic_type_mirrors(TRAPS);
static void fixup_mirrors(TRAPS);
static void reinitialize_itables(TRAPS);
static void compute_base_vtable_size(); // compute vtable size of class Object
// Mirrors for primitive classes (created eagerly)
return m;
}
// Debugging
static int _verify_count; // number of verifies done
static bool _verify_in_progress;
static void compute_verify_oop_data();
public:
// Known classes in the VM
static klassOop objectArrayKlassObj() {
return _objectArrayKlassObj;
}
return _typeArrayKlassObjs[t];
}
// Known objects in tbe VM
}
// table of same
return check_mirror(_mirrors[t]);
}
// OutOfMemoryError support. Returns an error with the required message. The returned error
// may or may not have a backtrace. If error has a backtrace then the stack trace is already
// filled in.
static oop out_of_memory_error_java_heap() { return gen_out_of_memory_error(_out_of_memory_error_java_heap); }
static oop out_of_memory_error_perm_gen() { return gen_out_of_memory_error(_out_of_memory_error_perm_gen); }
static oop out_of_memory_error_array_size() { return gen_out_of_memory_error(_out_of_memory_error_array_size); }
static oop out_of_memory_error_gc_overhead_limit() { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit); }
// Accessors needed for fast allocation
// The particular choice of collected heap.
// For UseCompressedOops
// Historic gc information
static size_t get_heap_free_at_last_gc() { return _heap_capacity_at_last_gc - _heap_used_at_last_gc; }
static void update_heap_info_at_gc();
// Testers
static bool is_bootstrapping() { return _bootstrapping; }
static bool is_fully_initialized() { return _fully_initialized; }
static bool on_page_boundary(void* addr);
// Finalizer support.
static void run_finalizers_on_exit();
// Iteration
// Apply "f" to the addresses of all the direct heap pointers maintained
// as static fields of "Universe".
// Apply "f" to all klasses for basic types (classes not present in
// SystemDictionary).
static void basic_type_classes_do(void f(klassOop));
// Apply "f" to all system klasses (classes not present in SystemDictionary).
static void system_classes_do(void f(klassOop));
// For sharing -- fill in a list of known vtable pointers.
// Debugging
static bool verify_in_progress() { return _verify_in_progress; }
static int verify_count() { return _verify_count; }
static void print();
static void print_heap_at_SIGBREAK();
// Change the number of dummy objects kept reachable by the full gc dummy
// array; this should trigger relocation in a sliding compaction collector.
debug_only(static bool release_fullgc_alot_dummy();)
// The non-oop pattern (see compiledIC.hpp, etc)
static void* non_oop_word();
// Oop verification (see MacroAssembler::verify_oop)
// Flushing and deoptimization
#ifdef HOTSWAP
// Flushing and deoptimization in case of evolution
#endif // HOTSWAP
// Support for fullspeed debugging
// Compiler support
static int base_vtable_size() { return _base_vtable_size; }
};
class DeferredObjAllocEvent : public CHeapObj {
private:
public:
_oop = o;
_bytesize = s;
}
}
};