< prev index next > src/hotspot/share/cds/heapShared.hpp
Print this page
*/
#ifndef SHARE_CDS_HEAPSHARED_HPP
#define SHARE_CDS_HEAPSHARED_HPP
+ #include "cds/cds_globals.hpp"
#include "cds/dumpTimeClassInfo.hpp"
#include "cds/metaspaceShared.hpp"
#include "classfile/compactHashtable.hpp"
#include "classfile/javaClasses.hpp"
#include "gc/shared/gc_globals.hpp"
static void count_allocation(size_t size);
static void print_stats();
public:
static void debug_trace();
static unsigned oop_hash(oop const& p);
+ static unsigned oop_handle_hash(OopHandle const& oh);
+ static unsigned oop_handle_hash_raw(OopHandle const& oh);
+ static bool oop_handle_equals(const OopHandle& a, const OopHandle& b);
static unsigned string_oop_hash(oop const& string) {
return java_lang_String::hash_code(string);
}
class CopyKlassSubGraphInfoToArchive;
class CachedOopInfo {
// Used by CDSHeapVerifier.
- oop _orig_referrer;
+ OopHandle _orig_referrer;
// The location of this object inside ArchiveHeapWriter::_buffer
size_t _buffer_offset;
// One or more fields in this object are pointing to non-null oops.
bool _has_oop_pointers;
// One or more fields in this object are pointing to MetaspaceObj
bool _has_native_pointers;
public:
- CachedOopInfo(oop orig_referrer, bool has_oop_pointers)
+ CachedOopInfo(OopHandle orig_referrer, bool has_oop_pointers)
: _orig_referrer(orig_referrer),
_buffer_offset(0),
_has_oop_pointers(has_oop_pointers),
_has_native_pointers(false) {}
- oop orig_referrer() const { return _orig_referrer; }
+ oop orig_referrer() const;
void set_buffer_offset(size_t offset) { _buffer_offset = offset; }
size_t buffer_offset() const { return _buffer_offset; }
bool has_oop_pointers() const { return _has_oop_pointers; }
bool has_native_pointers() const { return _has_native_pointers; }
void set_has_native_pointers() { _has_native_pointers = true; }
};
private:
static const int INITIAL_TABLE_SIZE = 15889; // prime number
static const int MAX_TABLE_SIZE = 1000000;
- typedef ResizeableResourceHashtable<oop, CachedOopInfo,
+ typedef ResizeableResourceHashtable<OopHandle, CachedOopInfo,
AnyObj::C_HEAP,
mtClassShared,
- HeapShared::oop_hash> ArchivedObjectCache;
+ HeapShared::oop_handle_hash_raw,
+ HeapShared::oop_handle_equals> ArchivedObjectCache;
static ArchivedObjectCache* _archived_object_cache;
class DumpTimeKlassSubGraphInfoTable
: public ResourceHashtable<Klass*, KlassSubGraphInfo,
137, // prime number
AnyObj::C_HEAP,
mtClassShared,
HeapShared::oop_hash> SeenObjectsTable;
static SeenObjectsTable *_seen_objects_table;
-
// The "special subgraph" contains all the archived objects that are reachable
// from the following roots:
// - interned strings
// - Klass::java_mirror() -- including aot-initialized mirrors such as those of Enum klasses.
// - ConstantPool::resolved_references()
// - Universe::<xxx>_exception_instance()
static KlassSubGraphInfo* _dump_time_special_subgraph; // for collecting info during dump time
static ArchivedKlassSubGraphInfoRecord* _run_time_special_subgraph; // for initializing classes during run time.
- static GrowableArrayCHeap<oop, mtClassShared>* _pending_roots;
+ static GrowableArrayCHeap<OopHandle, mtClassShared>* _pending_roots;
static GrowableArrayCHeap<OopHandle, mtClassShared>* _root_segments;
+ static GrowableArrayCHeap<const char*, mtClassShared>* _context; // for debugging unarchivable objects
static int _root_segment_max_size_elems;
static OopHandle _scratch_basic_type_mirrors[T_VOID+1];
static MetaspaceObjToOopHandleTable* _scratch_objects_table;
static void init_seen_objects_table() {
assert(_seen_objects_table != nullptr, "must be");
delete _seen_objects_table;
_seen_objects_table = nullptr;
}
+ class ContextMark;
+
// Statistics (for one round of start_recording_subgraph ... done_recording_subgraph)
static int _num_new_walked_objs;
static int _num_new_archived_objs;
static int _num_old_recorded_klasses;
int num_loaded_regions, uintptr_t buffer);
static void init_loaded_heap_relocation(LoadedArchiveHeapRegion* reloc_info,
int num_loaded_regions);
static void fill_failed_loaded_region();
static void mark_native_pointers(oop orig_obj);
- static bool has_been_archived(oop orig_obj);
static void prepare_resolved_references();
static void archive_strings();
static void archive_subgraphs();
// PendingOop and PendingOopStack are used for recursively discovering all cacheable
static PendingOop _object_being_archived;
static bool walk_one_object(PendingOopStack* stack, int level, KlassSubGraphInfo* subgraph_info,
oop orig_obj, oop referrer);
public:
+ static void exit_on_error();
static void reset_archived_object_states(TRAPS);
static void create_archived_object_cache() {
_archived_object_cache =
new (mtClass)ArchivedObjectCache(INITIAL_TABLE_SIZE, MAX_TABLE_SIZE);
}
}
static ArchivedObjectCache* archived_object_cache() {
return _archived_object_cache;
}
+ static CachedOopInfo* get_cached_oop_info(oop orig_obj) {
+ OopHandle oh(&orig_obj);
+ return _archived_object_cache->get(oh);
+ }
+
static int archive_exception_instance(oop exception);
static bool archive_reachable_objects_from(int level,
KlassSubGraphInfo* subgraph_info,
oop orig_obj);
static void add_to_dumped_interned_strings(oop string);
static bool is_dumped_interned_string(oop o);
+ static void track_scratch_object(oop orig_obj, oop scratch_obj);
+
// Scratch objects for archiving Klass::java_mirror()
static void set_scratch_java_mirror(Klass* k, oop mirror);
static void remove_scratch_objects(Klass* k);
static void get_pointer_info(oop src_obj, bool& has_oop_pointers, bool& has_native_pointers);
static void set_has_native_pointers(oop src_obj);
// Other types of roots are also cleared similarly when they become referenced.
// Dump-time only. Returns the index of the root, which can be used at run time to read
// the root using get_root(index, ...).
static int append_root(oop obj);
- static GrowableArrayCHeap<oop, mtClassShared>* pending_roots() { return _pending_roots; }
+ static GrowableArrayCHeap<OopHandle, mtClassShared>* pending_roots() { return _pending_roots; }
// Dump-time and runtime
static objArrayOop root_segment(int segment_idx);
static oop get_root(int index, bool clear=false);
// Run-time only
static void clear_root(int index);
-
static void get_segment_indexes(int index, int& segment_index, int& internal_index);
-
static void setup_test_class(const char* test_class_name) PRODUCT_RETURN;
#endif // INCLUDE_CDS_JAVA_HEAP
public:
+ static bool has_been_archived(oop orig_obj);
+ static oop orig_to_scratch_object(oop orig_obj);
static void write_heap(ArchiveHeapInfo* heap_info) NOT_CDS_JAVA_HEAP_RETURN;
static objArrayOop scratch_resolved_references(ConstantPool* src);
static void add_scratch_resolved_references(ConstantPool* src, objArrayOop dest) NOT_CDS_JAVA_HEAP_RETURN;
static void init_dumping() NOT_CDS_JAVA_HEAP_RETURN;
static void init_scratch_objects_for_basic_type_mirrors(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
static void init_box_classes(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
static bool is_heap_region(int idx) {
CDS_JAVA_HEAP_ONLY(return (idx == MetaspaceShared::hp);)
NOT_CDS_JAVA_HEAP_RETURN_(false);
}
+ static void rehash_archived_object_cache() NOT_CDS_JAVA_HEAP_RETURN;
+ static void delete_tables_with_raw_oops() NOT_CDS_JAVA_HEAP_RETURN;
static void resolve_classes(JavaThread* current) NOT_CDS_JAVA_HEAP_RETURN;
static void initialize_from_archived_subgraph(JavaThread* current, Klass* k) NOT_CDS_JAVA_HEAP_RETURN;
static void init_for_dumping(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
#ifndef PRODUCT
static bool is_a_test_class_in_unnamed_module(Klass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
static void initialize_test_class_from_archive(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
#endif
+ static void add_to_permanent_oop_table(oop obj, int offset);
+
+ // AOT-compile time only: get a stable index for an archived object.
+ // Returns 0 if obj is not archived.
+ static int get_archived_object_permanent_index(oop obj) NOT_CDS_JAVA_HEAP_RETURN_(-1);
+ // Runtime only: get back the same object for an index returned by
+ // get_archived_object_permanent_index().
+ static oop get_archived_object(int permanent_index) NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
+
static void initialize_java_lang_invoke(TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
static void init_classes_for_special_subgraph(Handle loader, TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
static bool is_lambda_form_klass(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
static bool is_lambda_proxy_klass(InstanceKlass* ik) NOT_CDS_JAVA_HEAP_RETURN_(false);
static void scan_java_class(Klass* k);
static void scan_java_mirror(oop orig_mirror);
static void copy_and_rescan_aot_inited_mirror(InstanceKlass* ik);
};
+ class CachedCodeDirectoryInternal {
+ int _permanent_oop_count;
+ int* _permanent_oop_offsets; // offset of each permanent object from the bottom of the archived heap
+ public:
+ void dumptime_init_internal() NOT_CDS_JAVA_HEAP_RETURN;
+ void runtime_init_internal() NOT_CDS_JAVA_HEAP_RETURN;
+ };
+
#if INCLUDE_CDS_JAVA_HEAP
class DumpedInternedStrings :
public ResizeableResourceHashtable<oop, bool,
AnyObj::C_HEAP,
mtClassShared,
< prev index next >