mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8183573: Refactor CodeHeap and AOTCodeHeap to devirtualize hot methods
Reviewed-by: kvn, dlong
This commit is contained in:
parent
4de007ff3b
commit
28bb3a05d9
5 changed files with 26 additions and 36 deletions
|
@ -258,7 +258,6 @@ AOTCodeHeap::AOTCodeHeap(AOTLib* lib) :
|
||||||
_code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode);
|
_code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode);
|
||||||
memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod));
|
memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod));
|
||||||
|
|
||||||
_low_boundary = _code_space;
|
|
||||||
_memory.set_low_boundary((char *)_code_space);
|
_memory.set_low_boundary((char *)_code_space);
|
||||||
_memory.set_high_boundary((char *)_code_space);
|
_memory.set_high_boundary((char *)_code_space);
|
||||||
_memory.set_low((char *)_code_space);
|
_memory.set_low((char *)_code_space);
|
||||||
|
|
|
@ -191,24 +191,20 @@ class AOTCodeHeap : public CodeHeap {
|
||||||
// Collect stubs info
|
// Collect stubs info
|
||||||
int* _stubs_offsets;
|
int* _stubs_offsets;
|
||||||
|
|
||||||
address _low_boundary;
|
|
||||||
|
|
||||||
bool _lib_symbols_initialized;
|
bool _lib_symbols_initialized;
|
||||||
|
|
||||||
void adjust_boundaries(AOTCompiledMethod* method) {
|
void adjust_boundaries(AOTCompiledMethod* method) {
|
||||||
address low = _low_boundary;
|
char* low = (char*)method->code_begin();
|
||||||
if (method->code_begin() < low) {
|
if (low < low_boundary()) {
|
||||||
low = method->code_begin();
|
_memory.set_low_boundary(low);
|
||||||
|
_memory.set_low(low);
|
||||||
}
|
}
|
||||||
address high = high_boundary();
|
char* high = (char *)method->code_end();
|
||||||
if (method->code_end() > high) {
|
if (high > high_boundary()) {
|
||||||
high = method->code_end();
|
_memory.set_high_boundary(high);
|
||||||
|
_memory.set_high(high);
|
||||||
}
|
}
|
||||||
assert(_method_count > 0, "methods count should be set already");
|
assert(_method_count > 0, "methods count should be set already");
|
||||||
|
|
||||||
_low_boundary = low;
|
|
||||||
_memory.set_high_boundary((char *)high);
|
|
||||||
_memory.set_high((char *)high);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_stubs();
|
void register_stubs();
|
||||||
|
@ -231,20 +227,6 @@ public:
|
||||||
AOTCodeHeap(AOTLib* lib);
|
AOTCodeHeap(AOTLib* lib);
|
||||||
virtual ~AOTCodeHeap();
|
virtual ~AOTCodeHeap();
|
||||||
|
|
||||||
address low_boundary() const { return _low_boundary; }
|
|
||||||
address high_boundary() const { return (address)CodeHeap::high(); }
|
|
||||||
|
|
||||||
bool contains(const void* p) const {
|
|
||||||
bool result = (low_boundary() <= p) && (p < high_boundary());
|
|
||||||
assert(!result || (_method_count > 0), "");
|
|
||||||
assert(result == CodeHeap::contains(p), "");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool contains_blob(const CodeBlob* blob) const {
|
|
||||||
return CodeHeap::contains(blob->code_begin());
|
|
||||||
}
|
|
||||||
|
|
||||||
AOTCompiledMethod* find_aot(address p) const;
|
AOTCompiledMethod* find_aot(address p) const;
|
||||||
|
|
||||||
virtual void* find_start(void* p) const;
|
virtual void* find_start(void* p) const;
|
||||||
|
|
|
@ -422,6 +422,16 @@ void CodeCache::add_heap(ReservedSpace rs, const char* name, int code_blob_type)
|
||||||
MemoryService::add_code_heap_memory_pool(heap, name);
|
MemoryService::add_code_heap_memory_pool(heap, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodeHeap* CodeCache::get_code_heap_containing(void* start) {
|
||||||
|
assert(start != NULL, "start is null");
|
||||||
|
FOR_ALL_HEAPS(heap) {
|
||||||
|
if ((*heap)->contains(start)) {
|
||||||
|
return *heap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) {
|
CodeHeap* CodeCache::get_code_heap(const CodeBlob* cb) {
|
||||||
assert(cb != NULL, "CodeBlob is null");
|
assert(cb != NULL, "CodeBlob is null");
|
||||||
FOR_ALL_HEAPS(heap) {
|
FOR_ALL_HEAPS(heap) {
|
||||||
|
@ -609,12 +619,10 @@ CodeBlob* CodeCache::find_blob(void* start) {
|
||||||
// what you are doing)
|
// what you are doing)
|
||||||
CodeBlob* CodeCache::find_blob_unsafe(void* start) {
|
CodeBlob* CodeCache::find_blob_unsafe(void* start) {
|
||||||
// NMT can walk the stack before code cache is created
|
// NMT can walk the stack before code cache is created
|
||||||
if (_heaps != NULL && !_heaps->is_empty()) {
|
if (_heaps != NULL) {
|
||||||
FOR_ALL_HEAPS(heap) {
|
CodeHeap* heap = get_code_heap_containing(start);
|
||||||
CodeBlob* result = (*heap)->find_blob_unsafe(start);
|
if (heap != NULL) {
|
||||||
if (result != NULL) {
|
return heap->find_blob_unsafe(start);
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -102,6 +102,7 @@ class CodeCache : AllStatic {
|
||||||
static void check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set);
|
static void check_heap_sizes(size_t non_nmethod_size, size_t profiled_size, size_t non_profiled_size, size_t cache_size, bool all_set);
|
||||||
// Creates a new heap with the given name and size, containing CodeBlobs of the given type
|
// Creates a new heap with the given name and size, containing CodeBlobs of the given type
|
||||||
static void add_heap(ReservedSpace rs, const char* name, int code_blob_type);
|
static void add_heap(ReservedSpace rs, const char* name, int code_blob_type);
|
||||||
|
static CodeHeap* get_code_heap_containing(void* p); // Returns the CodeHeap containing the given pointer, or NULL
|
||||||
static CodeHeap* get_code_heap(const CodeBlob* cb); // Returns the CodeHeap for the given CodeBlob
|
static CodeHeap* get_code_heap(const CodeBlob* cb); // Returns the CodeHeap for the given CodeBlob
|
||||||
static CodeHeap* get_code_heap(int code_blob_type); // Returns the CodeHeap for the given CodeBlobType
|
static CodeHeap* get_code_heap(int code_blob_type); // Returns the CodeHeap for the given CodeBlobType
|
||||||
// Returns the name of the VM option to set the size of the corresponding CodeHeap
|
// Returns the name of the VM option to set the size of the corresponding CodeHeap
|
||||||
|
|
|
@ -153,8 +153,8 @@ class CodeHeap : public CHeapObj<mtCode> {
|
||||||
char* high() const { return _memory.high(); }
|
char* high() const { return _memory.high(); }
|
||||||
char* high_boundary() const { return _memory.high_boundary(); }
|
char* high_boundary() const { return _memory.high_boundary(); }
|
||||||
|
|
||||||
virtual bool contains(const void* p) const { return low_boundary() <= p && p < high(); }
|
bool contains(const void* p) const { return low_boundary() <= p && p < high(); }
|
||||||
virtual bool contains_blob(const CodeBlob* blob) const { return low_boundary() <= (char*) blob && (char*) blob < high(); }
|
bool contains_blob(const CodeBlob* blob) const { return contains(blob->code_begin()); }
|
||||||
|
|
||||||
virtual void* find_start(void* p) const; // returns the block containing p or NULL
|
virtual void* find_start(void* p) const; // returns the block containing p or NULL
|
||||||
virtual CodeBlob* find_blob_unsafe(void* start) const;
|
virtual CodeBlob* find_blob_unsafe(void* start) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue