提交 3fe26ea8 编写于 作者: C ccheung

8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"

Reviewed-by: coleenp, zgu, hseigel
上级 8889d4db
...@@ -824,7 +824,7 @@ void os::init_system_properties_values() { ...@@ -824,7 +824,7 @@ void os::init_system_properties_values() {
// allocate new buffer and initialize // allocate new buffer and initialize
info = (Dl_serinfo*)malloc(_info.dls_size); info = (Dl_serinfo*)malloc(_info.dls_size);
if (info == NULL) { if (info == NULL) {
vm_exit_out_of_memory(_info.dls_size, vm_exit_out_of_memory(_info.dls_size, OOM_MALLOC_ERROR,
"init_system_properties_values info"); "init_system_properties_values info");
} }
info->dls_size = _info.dls_size; info->dls_size = _info.dls_size;
...@@ -866,7 +866,7 @@ void os::init_system_properties_values() { ...@@ -866,7 +866,7 @@ void os::init_system_properties_values() {
common_path = malloc(bufsize); common_path = malloc(bufsize);
if (common_path == NULL) { if (common_path == NULL) {
free(info); free(info);
vm_exit_out_of_memory(bufsize, vm_exit_out_of_memory(bufsize, OOM_MALLOC_ERROR,
"init_system_properties_values common_path"); "init_system_properties_values common_path");
} }
sprintf(common_path, COMMON_DIR "/lib/%s", cpu_arch); sprintf(common_path, COMMON_DIR "/lib/%s", cpu_arch);
...@@ -879,7 +879,7 @@ void os::init_system_properties_values() { ...@@ -879,7 +879,7 @@ void os::init_system_properties_values() {
if (library_path == NULL) { if (library_path == NULL) {
free(info); free(info);
free(common_path); free(common_path);
vm_exit_out_of_memory(bufsize, vm_exit_out_of_memory(bufsize, OOM_MALLOC_ERROR,
"init_system_properties_values library_path"); "init_system_properties_values library_path");
} }
library_path[0] = '\0'; library_path[0] = '\0';
...@@ -1623,7 +1623,8 @@ void os::thread_local_storage_at_put(int index, void* value) { ...@@ -1623,7 +1623,8 @@ void os::thread_local_storage_at_put(int index, void* value) {
// %%% this is used only in threadLocalStorage.cpp // %%% this is used only in threadLocalStorage.cpp
if (thr_setspecific((thread_key_t)index, value)) { if (thr_setspecific((thread_key_t)index, value)) {
if (errno == ENOMEM) { if (errno == ENOMEM) {
vm_exit_out_of_memory(SMALLINT, "thr_setspecific: out of swap space"); vm_exit_out_of_memory(SMALLINT, OOM_MALLOC_ERROR,
"thr_setspecific: out of swap space");
} else { } else {
fatal(err_msg("os::thread_local_storage_at_put: thr_setspecific failed " fatal(err_msg("os::thread_local_storage_at_put: thr_setspecific failed "
"(%s)", strerror(errno))); "(%s)", strerror(errno)));
......
...@@ -178,7 +178,7 @@ static void current_stack_region(address* bottom, size_t* size) { ...@@ -178,7 +178,7 @@ static void current_stack_region(address* bottom, size_t* size) {
// JVM needs to know exact stack location, abort if it fails // JVM needs to know exact stack location, abort if it fails
if (rslt != 0) { if (rslt != 0) {
if (rslt == ENOMEM) { if (rslt == ENOMEM) {
vm_exit_out_of_memory(0, "pthread_getattr_np"); vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
} else { } else {
fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt)); fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
} }
......
...@@ -710,7 +710,7 @@ static void current_stack_region(address * bottom, size_t * size) { ...@@ -710,7 +710,7 @@ static void current_stack_region(address * bottom, size_t * size) {
// JVM needs to know exact stack location, abort if it fails // JVM needs to know exact stack location, abort if it fails
if (rslt != 0) { if (rslt != 0) {
if (rslt == ENOMEM) { if (rslt == ENOMEM) {
vm_exit_out_of_memory(0, "pthread_getattr_np"); vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
} else { } else {
fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt)); fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
} }
......
...@@ -313,7 +313,7 @@ static void current_stack_region(address *bottom, size_t *size) { ...@@ -313,7 +313,7 @@ static void current_stack_region(address *bottom, size_t *size) {
int res = pthread_getattr_np(pthread_self(), &attr); int res = pthread_getattr_np(pthread_self(), &attr);
if (res != 0) { if (res != 0) {
if (res == ENOMEM) { if (res == ENOMEM) {
vm_exit_out_of_memory(0, "pthread_getattr_np"); vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
} }
else { else {
fatal(err_msg("pthread_getattr_np failed with errno = %d", res)); fatal(err_msg("pthread_getattr_np failed with errno = %d", res));
......
...@@ -591,7 +591,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, ...@@ -591,7 +591,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid,
// on the thread stack, which could get a mapping error when touched. // on the thread stack, which could get a mapping error when touched.
address addr = (address) info->si_addr; address addr = (address) info->si_addr;
if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
vm_exit_out_of_memory(0, "Out of swap space to map in thread stack."); vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack.");
} }
VMError err(t, sig, pc, info, ucVoid); VMError err(t, sig, pc, info, ucVoid);
......
...@@ -745,7 +745,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, ...@@ -745,7 +745,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid,
// on the thread stack, which could get a mapping error when touched. // on the thread stack, which could get a mapping error when touched.
address addr = (address) info->si_addr; address addr = (address) info->si_addr;
if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
vm_exit_out_of_memory(0, "Out of swap space to map in thread stack."); vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "Out of swap space to map in thread stack.");
} }
VMError err(t, sig, pc, info, ucVoid); VMError err(t, sig, pc, info, ucVoid);
......
...@@ -44,7 +44,7 @@ AbstractAssembler::AbstractAssembler(CodeBuffer* code) { ...@@ -44,7 +44,7 @@ AbstractAssembler::AbstractAssembler(CodeBuffer* code) {
CodeSection* cs = code->insts(); CodeSection* cs = code->insts();
cs->clear_mark(); // new assembler kills old mark cs->clear_mark(); // new assembler kills old mark
if (cs->start() == NULL) { if (cs->start() == NULL) {
vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s", vm_exit_out_of_memory(0, OOM_MMAP_ERROR, err_msg("CodeCache: no room for %s",
code->name())); code->name()));
} }
_code_section = cs; _code_section = cs;
......
...@@ -67,7 +67,7 @@ StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size, ...@@ -67,7 +67,7 @@ StubQueue::StubQueue(StubInterface* stub_interface, int buffer_size,
intptr_t size = round_to(buffer_size, 2*BytesPerWord); intptr_t size = round_to(buffer_size, 2*BytesPerWord);
BufferBlob* blob = BufferBlob::create(name, size); BufferBlob* blob = BufferBlob::create(name, size);
if( blob == NULL) { if( blob == NULL) {
vm_exit_out_of_memory(size, err_msg("CodeCache: no room for %s", name)); vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, err_msg("CodeCache: no room for %s", name));
} }
_stub_interface = stub_interface; _stub_interface = stub_interface;
_buffer_size = blob->content_size(); _buffer_size = blob->content_size();
......
...@@ -60,7 +60,7 @@ void* VtableStub::operator new(size_t size, int code_size) { ...@@ -60,7 +60,7 @@ void* VtableStub::operator new(size_t size, int code_size) {
const int bytes = chunk_factor * real_size + pd_code_alignment(); const int bytes = chunk_factor * real_size + pd_code_alignment();
BufferBlob* blob = BufferBlob::create("vtable chunks", bytes); BufferBlob* blob = BufferBlob::create("vtable chunks", bytes);
if (blob == NULL) { if (blob == NULL) {
vm_exit_out_of_memory(bytes, "CodeCache: no room for vtable chunks"); vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "CodeCache: no room for vtable chunks");
} }
_chunk = blob->content_begin(); _chunk = blob->content_begin();
_chunk_end = _chunk + bytes; _chunk_end = _chunk + bytes;
......
...@@ -77,7 +77,7 @@ void G1BlockOffsetSharedArray::resize(size_t new_word_size) { ...@@ -77,7 +77,7 @@ void G1BlockOffsetSharedArray::resize(size_t new_word_size) {
assert(delta > 0, "just checking"); assert(delta > 0, "just checking");
if (!_vs.expand_by(delta)) { if (!_vs.expand_by(delta)) {
// Do better than this for Merlin // Do better than this for Merlin
vm_exit_out_of_memory(delta, "offset table expansion"); vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
} }
assert(_vs.high() == high + delta, "invalid expansion"); assert(_vs.high() == high + delta, "invalid expansion");
// Initialization of the contents is left to the // Initialization of the contents is left to the
......
...@@ -1831,7 +1831,7 @@ bool G1CollectedHeap::expand(size_t expand_bytes) { ...@@ -1831,7 +1831,7 @@ bool G1CollectedHeap::expand(size_t expand_bytes) {
if (G1ExitOnExpansionFailure && if (G1ExitOnExpansionFailure &&
_g1_storage.uncommitted_size() >= aligned_expand_bytes) { _g1_storage.uncommitted_size() >= aligned_expand_bytes) {
// We had head room... // We had head room...
vm_exit_out_of_memory(aligned_expand_bytes, "G1 heap expansion"); vm_exit_out_of_memory(aligned_expand_bytes, OOM_MMAP_ERROR, "G1 heap expansion");
} }
} }
return successful; return successful;
...@@ -3614,7 +3614,7 @@ G1CollectedHeap::setup_surviving_young_words() { ...@@ -3614,7 +3614,7 @@ G1CollectedHeap::setup_surviving_young_words() {
uint array_length = g1_policy()->young_cset_region_length(); uint array_length = g1_policy()->young_cset_region_length();
_surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC); _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
if (_surviving_young_words == NULL) { if (_surviving_young_words == NULL) {
vm_exit_out_of_memory(sizeof(size_t) * array_length, vm_exit_out_of_memory(sizeof(size_t) * array_length, OOM_MALLOC_ERROR,
"Not enough space for young surv words summary."); "Not enough space for young surv words summary.");
} }
memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t)); memset(_surviving_young_words, 0, (size_t) array_length * sizeof(size_t));
...@@ -4397,7 +4397,7 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num) ...@@ -4397,7 +4397,7 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h, uint queue_num)
PADDING_ELEM_NUM; PADDING_ELEM_NUM;
_surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC); _surviving_young_words_base = NEW_C_HEAP_ARRAY(size_t, array_length, mtGC);
if (_surviving_young_words_base == NULL) if (_surviving_young_words_base == NULL)
vm_exit_out_of_memory(array_length * sizeof(size_t), vm_exit_out_of_memory(array_length * sizeof(size_t), OOM_MALLOC_ERROR,
"Not enough space for young surv histo."); "Not enough space for young surv histo.");
_surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM; _surviving_young_words = _surviving_young_words_base + PADDING_ELEM_NUM;
memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t)); memset(_surviving_young_words, 0, (size_t) real_length * sizeof(size_t));
......
...@@ -285,7 +285,7 @@ OtherRegionsTable::OtherRegionsTable(HeapRegion* hr) : ...@@ -285,7 +285,7 @@ OtherRegionsTable::OtherRegionsTable(HeapRegion* hr) :
_fine_grain_regions = new PerRegionTablePtr[_max_fine_entries]; _fine_grain_regions = new PerRegionTablePtr[_max_fine_entries];
if (_fine_grain_regions == NULL) { if (_fine_grain_regions == NULL) {
vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, vm_exit_out_of_memory(sizeof(void*)*_max_fine_entries, OOM_MALLOC_ERROR,
"Failed to allocate _fine_grain_entries."); "Failed to allocate _fine_grain_entries.");
} }
......
...@@ -567,7 +567,7 @@ bool CardTableExtension::resize_commit_uncommit(int changed_region, ...@@ -567,7 +567,7 @@ bool CardTableExtension::resize_commit_uncommit(int changed_region,
MemRegion(new_start_aligned, new_end_for_commit); MemRegion(new_start_aligned, new_end_for_commit);
if (!os::commit_memory((char*)new_committed.start(), if (!os::commit_memory((char*)new_committed.start(),
new_committed.byte_size())) { new_committed.byte_size())) {
vm_exit_out_of_memory(new_committed.byte_size(), vm_exit_out_of_memory(new_committed.byte_size(), OOM_MMAP_ERROR,
"card table expansion"); "card table expansion");
} }
} }
......
...@@ -43,7 +43,7 @@ GCTaskThread::GCTaskThread(GCTaskManager* manager, ...@@ -43,7 +43,7 @@ GCTaskThread::GCTaskThread(GCTaskManager* manager,
_time_stamp_index(0) _time_stamp_index(0)
{ {
if (!os::create_thread(this, os::pgc_thread)) if (!os::create_thread(this, os::pgc_thread))
vm_exit_out_of_memory(0, "Cannot create GC thread. Out of system resources."); vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GC thread. Out of system resources.");
if (PrintGCTaskTimeStamps) { if (PrintGCTaskTimeStamps) {
_time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC); _time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
......
...@@ -99,7 +99,7 @@ void ObjectStartArray::set_covered_region(MemRegion mr) { ...@@ -99,7 +99,7 @@ void ObjectStartArray::set_covered_region(MemRegion mr) {
// Expand // Expand
size_t expand_by = requested_blocks_size_in_bytes - current_blocks_size_in_bytes; size_t expand_by = requested_blocks_size_in_bytes - current_blocks_size_in_bytes;
if (!_virtual_space.expand_by(expand_by)) { if (!_virtual_space.expand_by(expand_by)) {
vm_exit_out_of_memory(expand_by, "object start array expansion"); vm_exit_out_of_memory(expand_by, OOM_MMAP_ERROR, "object start array expansion");
} }
// Clear *only* the newly allocated region // Clear *only* the newly allocated region
memset(_blocks_region.end(), clean_block, expand_by); memset(_blocks_region.end(), clean_block, expand_by);
......
...@@ -1052,7 +1052,7 @@ void SignatureHandlerLibrary::initialize() { ...@@ -1052,7 +1052,7 @@ void SignatureHandlerLibrary::initialize() {
return; return;
} }
if (set_handler_blob() == NULL) { if (set_handler_blob() == NULL) {
vm_exit_out_of_memory(blob_size, "native signature handlers"); vm_exit_out_of_memory(blob_size, OOM_MALLOC_ERROR, "native signature handlers");
} }
BufferBlob* bb = BufferBlob::create("Signature Handler Temp Buffer", BufferBlob* bb = BufferBlob::create("Signature Handler Temp Buffer",
......
...@@ -259,7 +259,7 @@ class ChunkPool: public CHeapObj<mtInternal> { ...@@ -259,7 +259,7 @@ class ChunkPool: public CHeapObj<mtInternal> {
} }
if (p == NULL) p = os::malloc(bytes, mtChunk, CURRENT_PC); if (p == NULL) p = os::malloc(bytes, mtChunk, CURRENT_PC);
if (p == NULL) if (p == NULL)
vm_exit_out_of_memory(bytes, "ChunkPool::allocate"); vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "ChunkPool::allocate");
return p; return p;
} }
...@@ -371,7 +371,7 @@ void* Chunk::operator new(size_t requested_size, size_t length) { ...@@ -371,7 +371,7 @@ void* Chunk::operator new(size_t requested_size, size_t length) {
default: { default: {
void *p = os::malloc(bytes, mtChunk, CALLER_PC); void *p = os::malloc(bytes, mtChunk, CALLER_PC);
if (p == NULL) if (p == NULL)
vm_exit_out_of_memory(bytes, "Chunk::new"); vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "Chunk::new");
return p; return p;
} }
} }
...@@ -531,7 +531,7 @@ size_t Arena::used() const { ...@@ -531,7 +531,7 @@ size_t Arena::used() const {
} }
void Arena::signal_out_of_memory(size_t sz, const char* whence) const { void Arena::signal_out_of_memory(size_t sz, const char* whence) const {
vm_exit_out_of_memory(sz, whence); vm_exit_out_of_memory(sz, OOM_MALLOC_ERROR, whence);
} }
// Grow a new Chunk // Grow a new Chunk
......
...@@ -58,7 +58,9 @@ inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0, ...@@ -58,7 +58,9 @@ inline char* AllocateHeap(size_t size, MEMFLAGS flags, address pc = 0,
#ifdef ASSERT #ifdef ASSERT
if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p); if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
#endif #endif
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "AllocateHeap"); if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
}
return p; return p;
} }
...@@ -68,7 +70,9 @@ inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags, ...@@ -68,7 +70,9 @@ inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flags,
#ifdef ASSERT #ifdef ASSERT
if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p); if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
#endif #endif
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) vm_exit_out_of_memory(size, "ReallocateHeap"); if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
}
return p; return p;
} }
...@@ -130,12 +134,12 @@ E* ArrayAllocator<E, F>::allocate(size_t length) { ...@@ -130,12 +134,12 @@ E* ArrayAllocator<E, F>::allocate(size_t length) {
_addr = os::reserve_memory(_size, NULL, alignment); _addr = os::reserve_memory(_size, NULL, alignment);
if (_addr == NULL) { if (_addr == NULL) {
vm_exit_out_of_memory(_size, "Allocator (reserve)"); vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (reserve)");
} }
bool success = os::commit_memory(_addr, _size, false /* executable */); bool success = os::commit_memory(_addr, _size, false /* executable */);
if (!success) { if (!success) {
vm_exit_out_of_memory(_size, "Allocator (commit)"); vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (commit)");
} }
return (E*)_addr; return (E*)_addr;
......
...@@ -80,7 +80,7 @@ void BlockOffsetSharedArray::resize(size_t new_word_size) { ...@@ -80,7 +80,7 @@ void BlockOffsetSharedArray::resize(size_t new_word_size) {
assert(delta > 0, "just checking"); assert(delta > 0, "just checking");
if (!_vs.expand_by(delta)) { if (!_vs.expand_by(delta)) {
// Do better than this for Merlin // Do better than this for Merlin
vm_exit_out_of_memory(delta, "offset table expansion"); vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
} }
assert(_vs.high() == high + delta, "invalid expansion"); assert(_vs.high() == high + delta, "invalid expansion");
} else { } else {
......
...@@ -116,7 +116,7 @@ CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap, ...@@ -116,7 +116,7 @@ CardTableModRefBS::CardTableModRefBS(MemRegion whole_heap,
_guard_region = MemRegion((HeapWord*)guard_page, _page_size); _guard_region = MemRegion((HeapWord*)guard_page, _page_size);
if (!os::commit_memory((char*)guard_page, _page_size, _page_size)) { if (!os::commit_memory((char*)guard_page, _page_size, _page_size)) {
// Do better than this for Merlin // Do better than this for Merlin
vm_exit_out_of_memory(_page_size, "card table last card"); vm_exit_out_of_memory(_page_size, OOM_MMAP_ERROR, "card table last card");
} }
*guard_card = last_card; *guard_card = last_card;
...@@ -292,7 +292,7 @@ void CardTableModRefBS::resize_covered_region(MemRegion new_region) { ...@@ -292,7 +292,7 @@ void CardTableModRefBS::resize_covered_region(MemRegion new_region) {
if (!os::commit_memory((char*)new_committed.start(), if (!os::commit_memory((char*)new_committed.start(),
new_committed.byte_size(), _page_size)) { new_committed.byte_size(), _page_size)) {
// Do better than this for Merlin // Do better than this for Merlin
vm_exit_out_of_memory(new_committed.byte_size(), vm_exit_out_of_memory(new_committed.byte_size(), OOM_MMAP_ERROR,
"card table expansion"); "card table expansion");
} }
// Use new_end_aligned (as opposed to new_end_for_commit) because // Use new_end_aligned (as opposed to new_end_for_commit) because
......
...@@ -111,7 +111,7 @@ unsigned int oopDesc::new_hash(jint seed) { ...@@ -111,7 +111,7 @@ unsigned int oopDesc::new_hash(jint seed) {
// Use alternate hashing algorithm on the string // Use alternate hashing algorithm on the string
return AltHashing::murmur3_32(seed, chars, length); return AltHashing::murmur3_32(seed, chars, length);
} else { } else {
vm_exit_out_of_memory(length, "unable to create Unicode strings for String table rehash"); vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash");
return 0; return 0;
} }
} }
......
...@@ -153,7 +153,8 @@ class JvmtiTagHashmap : public CHeapObj<mtInternal> { ...@@ -153,7 +153,8 @@ class JvmtiTagHashmap : public CHeapObj<mtInternal> {
size_t s = initial_size * sizeof(JvmtiTagHashmapEntry*); size_t s = initial_size * sizeof(JvmtiTagHashmapEntry*);
_table = (JvmtiTagHashmapEntry**)os::malloc(s, mtInternal); _table = (JvmtiTagHashmapEntry**)os::malloc(s, mtInternal);
if (_table == NULL) { if (_table == NULL) {
vm_exit_out_of_memory(s, "unable to allocate initial hashtable for jvmti object tags"); vm_exit_out_of_memory(s, OOM_MALLOC_ERROR,
"unable to allocate initial hashtable for jvmti object tags");
} }
for (int i=0; i<initial_size; i++) { for (int i=0; i<initial_size; i++) {
_table[i] = NULL; _table[i] = NULL;
......
...@@ -67,7 +67,8 @@ void MethodHandles::generate_adapters() { ...@@ -67,7 +67,8 @@ void MethodHandles::generate_adapters() {
TraceTime timer("MethodHandles adapters generation", TraceStartupTime); TraceTime timer("MethodHandles adapters generation", TraceStartupTime);
_adapter_code = MethodHandlesAdapterBlob::create(adapter_code_size); _adapter_code = MethodHandlesAdapterBlob::create(adapter_code_size);
if (_adapter_code == NULL) if (_adapter_code == NULL)
vm_exit_out_of_memory(adapter_code_size, "CodeCache: no room for MethodHandles adapters"); vm_exit_out_of_memory(adapter_code_size, OOM_MALLOC_ERROR,
"CodeCache: no room for MethodHandles adapters");
{ {
CodeBuffer code(_adapter_code); CodeBuffer code(_adapter_code);
MethodHandlesAdapterGenerator g(&code); MethodHandlesAdapterGenerator g(&code);
......
...@@ -2404,7 +2404,7 @@ void ObjectMonitor::DeferredInitialize () { ...@@ -2404,7 +2404,7 @@ void ObjectMonitor::DeferredInitialize () {
size_t sz = strlen (SyncKnobs) ; size_t sz = strlen (SyncKnobs) ;
char * knobs = (char *) malloc (sz + 2) ; char * knobs = (char *) malloc (sz + 2) ;
if (knobs == NULL) { if (knobs == NULL) {
vm_exit_out_of_memory (sz + 2, "Parse SyncKnobs") ; vm_exit_out_of_memory (sz + 2, OOM_MALLOC_ERROR, "Parse SyncKnobs") ;
guarantee (0, "invariant") ; guarantee (0, "invariant") ;
} }
strcpy (knobs, SyncKnobs) ; strcpy (knobs, SyncKnobs) ;
......
...@@ -147,7 +147,7 @@ void StubRoutines::initialize1() { ...@@ -147,7 +147,7 @@ void StubRoutines::initialize1() {
TraceTime timer("StubRoutines generation 1", TraceStartupTime); TraceTime timer("StubRoutines generation 1", TraceStartupTime);
_code1 = BufferBlob::create("StubRoutines (1)", code_size1); _code1 = BufferBlob::create("StubRoutines (1)", code_size1);
if (_code1 == NULL) { if (_code1 == NULL) {
vm_exit_out_of_memory(code_size1, "CodeCache: no room for StubRoutines (1)"); vm_exit_out_of_memory(code_size1, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (1)");
} }
CodeBuffer buffer(_code1); CodeBuffer buffer(_code1);
StubGenerator_generate(&buffer, false); StubGenerator_generate(&buffer, false);
...@@ -199,7 +199,7 @@ void StubRoutines::initialize2() { ...@@ -199,7 +199,7 @@ void StubRoutines::initialize2() {
TraceTime timer("StubRoutines generation 2", TraceStartupTime); TraceTime timer("StubRoutines generation 2", TraceStartupTime);
_code2 = BufferBlob::create("StubRoutines (2)", code_size2); _code2 = BufferBlob::create("StubRoutines (2)", code_size2);
if (_code2 == NULL) { if (_code2 == NULL) {
vm_exit_out_of_memory(code_size2, "CodeCache: no room for StubRoutines (2)"); vm_exit_out_of_memory(code_size2, OOM_MALLOC_ERROR, "CodeCache: no room for StubRoutines (2)");
} }
CodeBuffer buffer(_code2); CodeBuffer buffer(_code2);
StubGenerator_generate(&buffer, true); StubGenerator_generate(&buffer, true);
......
...@@ -1018,7 +1018,8 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { ...@@ -1018,7 +1018,8 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) {
// We might be able to induce a STW safepoint and scavenge enough // We might be able to induce a STW safepoint and scavenge enough
// objectMonitors to permit progress. // objectMonitors to permit progress.
if (temp == NULL) { if (temp == NULL) {
vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), "Allocate ObjectMonitors") ; vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), OOM_MALLOC_ERROR,
"Allocate ObjectMonitors");
} }
// Format the block. // Format the block.
......
...@@ -229,11 +229,11 @@ void report_fatal(const char* file, int line, const char* message) ...@@ -229,11 +229,11 @@ void report_fatal(const char* file, int line, const char* message)
} }
void report_vm_out_of_memory(const char* file, int line, size_t size, void report_vm_out_of_memory(const char* file, int line, size_t size,
const char* message) { VMErrorType vm_err_type, const char* message) {
if (Debugging) return; if (Debugging) return;
Thread* thread = ThreadLocalStorage::get_thread_slow(); Thread* thread = ThreadLocalStorage::get_thread_slow();
VMError(thread, file, line, size, message).report_and_die(); VMError(thread, file, line, size, vm_err_type, message).report_and_die();
// The UseOSErrorReporting option in report_and_die() may allow a return // The UseOSErrorReporting option in report_and_die() may allow a return
// to here. If so then we'll have to figure out how to handle it. // to here. If so then we'll have to figure out how to handle it.
...@@ -344,7 +344,7 @@ void test_error_handler(size_t test_num) ...@@ -344,7 +344,7 @@ void test_error_handler(size_t test_num)
msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
msg, eol, msg, eol, msg, eol, msg, eol, msg)); msg, eol, msg, eol, msg, eol, msg, eol, msg));
case 8: vm_exit_out_of_memory(num, "ChunkPool::allocate"); case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
case 9: ShouldNotCallThis(); case 9: ShouldNotCallThis();
case 10: ShouldNotReachHere(); case 10: ShouldNotReachHere();
case 11: Unimplemented(); case 11: Unimplemented();
......
...@@ -174,9 +174,9 @@ do { \ ...@@ -174,9 +174,9 @@ do { \
} while (0) } while (0)
// out of memory // out of memory
#define vm_exit_out_of_memory(size, msg) \ #define vm_exit_out_of_memory(size, vm_err_type, msg) \
do { \ do { \
report_vm_out_of_memory(__FILE__, __LINE__, size, msg); \ report_vm_out_of_memory(__FILE__, __LINE__, size, vm_err_type, msg); \
BREAKPOINT; \ BREAKPOINT; \
} while (0) } while (0)
...@@ -204,12 +204,20 @@ do { \ ...@@ -204,12 +204,20 @@ do { \
BREAKPOINT; \ BREAKPOINT; \
} while (0); } while (0);
// types of VM error - originally in vmError.hpp
enum VMErrorType {
INTERNAL_ERROR = 0xe0000000,
OOM_MALLOC_ERROR = 0xe0000001,
OOM_MMAP_ERROR = 0xe0000002
};
// error reporting helper functions // error reporting helper functions
void report_vm_error(const char* file, int line, const char* error_msg, void report_vm_error(const char* file, int line, const char* error_msg,
const char* detail_msg = NULL); const char* detail_msg = NULL);
void report_fatal(const char* file, int line, const char* message); void report_fatal(const char* file, int line, const char* message);
void report_vm_out_of_memory(const char* file, int line, size_t size, void report_vm_out_of_memory(const char* file, int line, size_t size,
const char* message); VMErrorType vm_err_type, const char* message);
void report_should_not_call(const char* file, int line); void report_should_not_call(const char* file, int line);
void report_should_not_reach_here(const char* file, int line); void report_should_not_reach_here(const char* file, int line);
void report_unimplemented(const char* file, int line); void report_unimplemented(const char* file, int line);
......
...@@ -100,7 +100,7 @@ VMError::VMError(Thread* thread, const char* filename, int lineno, ...@@ -100,7 +100,7 @@ VMError::VMError(Thread* thread, const char* filename, int lineno,
const char* message, const char * detail_msg) const char* message, const char * detail_msg)
{ {
_thread = thread; _thread = thread;
_id = internal_error; // Value that's not an OS exception/signal _id = INTERNAL_ERROR; // Value that's not an OS exception/signal
_filename = filename; _filename = filename;
_lineno = lineno; _lineno = lineno;
_message = message; _message = message;
...@@ -119,9 +119,9 @@ VMError::VMError(Thread* thread, const char* filename, int lineno, ...@@ -119,9 +119,9 @@ VMError::VMError(Thread* thread, const char* filename, int lineno,
// Constructor for OOM errors // Constructor for OOM errors
VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size, VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size,
const char* message) { VMErrorType vm_err_type, const char* message) {
_thread = thread; _thread = thread;
_id = oom_error; // Value that's not an OS exception/signal _id = vm_err_type; // Value that's not an OS exception/signal
_filename = filename; _filename = filename;
_lineno = lineno; _lineno = lineno;
_message = message; _message = message;
...@@ -142,7 +142,7 @@ VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size, ...@@ -142,7 +142,7 @@ VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size,
// Constructor for non-fatal errors // Constructor for non-fatal errors
VMError::VMError(const char* message) { VMError::VMError(const char* message) {
_thread = NULL; _thread = NULL;
_id = internal_error; // Value that's not an OS exception/signal _id = INTERNAL_ERROR; // Value that's not an OS exception/signal
_filename = NULL; _filename = NULL;
_lineno = 0; _lineno = 0;
_message = message; _message = message;
...@@ -351,9 +351,12 @@ void VMError::report(outputStream* st) { ...@@ -351,9 +351,12 @@ void VMError::report(outputStream* st) {
STEP(15, "(printing type of error)") STEP(15, "(printing type of error)")
switch(_id) { switch(_id) {
case oom_error: case OOM_MALLOC_ERROR:
case OOM_MMAP_ERROR:
if (_size) { if (_size) {
st->print("# Native memory allocation (malloc) failed to allocate "); st->print("# Native memory allocation ");
st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
"(mmap) failed to map ");
jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size); jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
st->print(buf); st->print(buf);
st->print(" bytes"); st->print(" bytes");
...@@ -386,7 +389,7 @@ void VMError::report(outputStream* st) { ...@@ -386,7 +389,7 @@ void VMError::report(outputStream* st) {
return; // that's enough for the screen return; // that's enough for the screen
} }
break; break;
case internal_error: case INTERNAL_ERROR:
default: default:
break; break;
} }
......
...@@ -34,10 +34,6 @@ class VMError : public StackObj { ...@@ -34,10 +34,6 @@ class VMError : public StackObj {
friend class VM_ReportJavaOutOfMemory; friend class VM_ReportJavaOutOfMemory;
friend class Decoder; friend class Decoder;
enum ErrorType {
internal_error = 0xe0000000,
oom_error = 0xe0000001
};
int _id; // Solaris/Linux signals: 0 - SIGRTMAX int _id; // Solaris/Linux signals: 0 - SIGRTMAX
// Windows exceptions: 0xCxxxxxxx system errors // Windows exceptions: 0xCxxxxxxx system errors
// 0x8xxxxxxx system warnings // 0x8xxxxxxx system warnings
...@@ -96,9 +92,12 @@ class VMError : public StackObj { ...@@ -96,9 +92,12 @@ class VMError : public StackObj {
// accessor // accessor
const char* message() const { return _message; } const char* message() const { return _message; }
const char* detail_msg() const { return _detail_msg; } const char* detail_msg() const { return _detail_msg; }
bool should_report_bug(unsigned int id) { return id != oom_error; } bool should_report_bug(unsigned int id) {
return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
}
public: public:
// Constructor for crashes // Constructor for crashes
VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
void* context); void* context);
...@@ -108,7 +107,7 @@ public: ...@@ -108,7 +107,7 @@ public:
// Constructor for VM OOM errors // Constructor for VM OOM errors
VMError(Thread* thread, const char* filename, int lineno, size_t size, VMError(Thread* thread, const char* filename, int lineno, size_t size,
const char* message); VMErrorType vm_err_type, const char* message);
// Constructor for non-fatal errors // Constructor for non-fatal errors
VMError(const char* message); VMError(const char* message);
......
...@@ -79,7 +79,7 @@ bool WorkGang::initialize_workers() { ...@@ -79,7 +79,7 @@ bool WorkGang::initialize_workers() {
} }
_gang_workers = NEW_C_HEAP_ARRAY(GangWorker*, total_workers(), mtInternal); _gang_workers = NEW_C_HEAP_ARRAY(GangWorker*, total_workers(), mtInternal);
if (gang_workers() == NULL) { if (gang_workers() == NULL) {
vm_exit_out_of_memory(0, "Cannot create GangWorker array."); vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array.");
return false; return false;
} }
os::ThreadType worker_type; os::ThreadType worker_type;
...@@ -93,7 +93,8 @@ bool WorkGang::initialize_workers() { ...@@ -93,7 +93,8 @@ bool WorkGang::initialize_workers() {
assert(new_worker != NULL, "Failed to allocate GangWorker"); assert(new_worker != NULL, "Failed to allocate GangWorker");
_gang_workers[worker] = new_worker; _gang_workers[worker] = new_worker;
if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) { if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) {
vm_exit_out_of_memory(0, "Cannot create worker GC thread. Out of system resources."); vm_exit_out_of_memory(0, OOM_MALLOC_ERROR,
"Cannot create worker GC thread. Out of system resources.");
return false; return false;
} }
if (!DisableStartThread) { if (!DisableStartThread) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册