# HG changeset patch # User redestad # Date 1499253134 -7200 # Wed Jul 05 13:12:14 2017 +0200 # Node ID 2f4f8f060802b48aec88609f57fc1ca3f58b2cbc # Parent 80834446b18b4163c7a5647485fd03cec80596a6 Consolidated and devirtualize CodeHeap::contains and contains_blob diff --git a/src/share/vm/aot/aotCodeHeap.cpp b/src/share/vm/aot/aotCodeHeap.cpp --- a/src/share/vm/aot/aotCodeHeap.cpp +++ b/src/share/vm/aot/aotCodeHeap.cpp @@ -258,7 +258,6 @@ _code_to_aot = NEW_C_HEAP_ARRAY(CodeToAMethod, _method_count, mtCode); memset(_code_to_aot, 0, _method_count * sizeof(CodeToAMethod)); - _low_boundary = _code_space; _memory.set_low_boundary((char *)_code_space); _memory.set_high_boundary((char *)_code_space); _memory.set_low((char *)_code_space); diff --git a/src/share/vm/aot/aotCodeHeap.hpp b/src/share/vm/aot/aotCodeHeap.hpp --- a/src/share/vm/aot/aotCodeHeap.hpp +++ b/src/share/vm/aot/aotCodeHeap.hpp @@ -191,24 +191,19 @@ // Collect stubs info int* _stubs_offsets; - address _low_boundary; - bool _lib_symbols_initialized; void adjust_boundaries(AOTCompiledMethod* method) { - address low = _low_boundary; - if (method->code_begin() < low) { - low = method->code_begin(); + char* low = (char*)method->code_begin(); + if (low < low_boundary()) { + _memory.set_low_boundary(low); } - address high = high_boundary(); - if (method->code_end() > high) { - high = method->code_end(); + char* high = (char *)method->code_end(); + if (high > high_boundary()) { + _memory.set_high_boundary(high); + _memory.set_high(high); } 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(); @@ -231,20 +226,6 @@ AOTCodeHeap(AOTLib* lib); 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; virtual void* find_start(void* p) const; diff --git a/src/share/vm/code/codeCache.cpp b/src/share/vm/code/codeCache.cpp --- a/src/share/vm/code/codeCache.cpp +++ b/src/share/vm/code/codeCache.cpp @@ -415,6 +415,16 @@ MemoryService::add_code_heap_memory_pool(heap, name); } +CodeHeap* CodeCache::get_code_heap(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) { assert(cb != NULL, "CodeBlob is null"); FOR_ALL_HEAPS(heap) { @@ -602,12 +612,10 @@ // what you are doing) CodeBlob* CodeCache::find_blob_unsafe(void* start) { // NMT can walk the stack before code cache is created - if (_heaps != NULL && !_heaps->is_empty()) { - FOR_ALL_HEAPS(heap) { - CodeBlob* result = (*heap)->find_blob_unsafe(start); - if (result != NULL) { - return result; - } + if (_heaps != NULL) { + CodeHeap* heap = get_code_heap(start); + if (heap != NULL) { + return heap->find_blob_unsafe(start); } } return NULL; diff --git a/src/share/vm/code/codeCache.hpp b/src/share/vm/code/codeCache.hpp --- a/src/share/vm/code/codeCache.hpp +++ b/src/share/vm/code/codeCache.hpp @@ -101,6 +101,7 @@ 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 static void add_heap(ReservedSpace rs, const char* name, int code_blob_type); + static CodeHeap* get_code_heap(void* p); // Returns the CodeHeap for the given pointer 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 // Returns the name of the VM option to set the size of the corresponding CodeHeap diff --git a/src/share/vm/memory/heap.hpp b/src/share/vm/memory/heap.hpp --- a/src/share/vm/memory/heap.hpp +++ b/src/share/vm/memory/heap.hpp @@ -149,12 +149,12 @@ void deallocate(void* p); // Deallocate memory // Attributes - char* low_boundary() const { return _memory.low_boundary (); } + char* low_boundary() const { return _memory.low_boundary(); } char* high() const { return _memory.high(); } char* high_boundary() const { return _memory.high_boundary(); } - virtual 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(const void* p) const { return low_boundary() <= p && p < high(); } + bool contains_blob(const CodeBlob* blob) const { return low_boundary() <= (char*) blob && (char*) blob < high(); } virtual void* find_start(void* p) const; // returns the block containing p or NULL virtual CodeBlob* find_blob_unsafe(void* start) const;