Mercurial > hg > graal-jvmci-8
diff src/share/vm/code/nmethod.cpp @ 8883:b9a918201d47
Merge with hsx25
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Sat, 06 Apr 2013 20:04:06 +0200 |
parents | c3657d00e343 3c786355ffb4 |
children | f94bb5d20e5d |
line wrap: on
line diff
--- a/src/share/vm/code/nmethod.cpp Fri Apr 05 18:53:57 2013 +0200 +++ b/src/share/vm/code/nmethod.cpp Sat Apr 06 20:04:06 2013 +0200 @@ -497,7 +497,6 @@ #endif // def HAVE_DTRACE_H } - nmethod* nmethod::new_native_nmethod(methodHandle method, int compile_id, CodeBuffer *code_buffer, @@ -513,17 +512,19 @@ { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); - CodeOffsets offsets; - offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); - offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); - nm = new (native_nmethod_size) - nmethod(method(), native_nmethod_size, compile_id, &offsets, - code_buffer, frame_size, - basic_lock_owner_sp_offset, basic_lock_sp_offset, - oop_maps); - NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); - if (PrintAssembly && nm != NULL) - Disassembler::decode(nm); + if (CodeCache::has_space(native_nmethod_size)) { + CodeOffsets offsets; + offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); + offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); + nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, + compile_id, &offsets, + code_buffer, frame_size, + basic_lock_owner_sp_offset, + basic_lock_sp_offset, oop_maps); + NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); + if (PrintAssembly && nm != NULL) + Disassembler::decode(nm); + } } // verify nmethod debug_only(if (nm) nm->verify();) // might block @@ -548,16 +549,19 @@ { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); - CodeOffsets offsets; - offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); - offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); - offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); - - nm = new (nmethod_size) nmethod(method(), nmethod_size, &offsets, code_buffer, frame_size); - - NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); - if (PrintAssembly && nm != NULL) - Disassembler::decode(nm); + if (CodeCache::has_space(nmethod_size)) { + CodeOffsets offsets; + offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); + offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); + offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); + + nm = new (nmethod_size) nmethod(method(), nmethod_size, + &offsets, code_buffer, frame_size); + + NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); + if (PrintAssembly && nm != NULL) + Disassembler::decode(nm); + } } // verify nmethod debug_only(if (nm) nm->verify();) // might block @@ -604,8 +608,9 @@ + round_to(handler_table->size_in_bytes(), oopSize) + round_to(nul_chk_table->size_in_bytes(), oopSize) + round_to(debug_info->data_size() , oopSize) - + leaf_graph_ids_size; - nm = new (nmethod_size) + + leaf_graph_ids_size; + if (CodeCache::has_space(nmethod_size)) { + nm = new (nmethod_size) nmethod(method(), nmethod_size, compile_id, entry_bci, offsets, orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, oop_maps, @@ -618,7 +623,8 @@ , installed_code, triggered_deoptimizations #endif - ); + ); + } if (nm != NULL) { // To make dependency checking during class loading fast, record // the nmethod dependencies in the classes it is dependent on. @@ -818,9 +824,9 @@ #endif // def HAVE_DTRACE_H void* nmethod::operator new(size_t size, int nmethod_size) { - // Always leave some room in the CodeCache for I2C/C2I adapters - if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) return NULL; - return CodeCache::allocate(nmethod_size); + void* alloc = CodeCache::allocate(nmethod_size); + guarantee(alloc != NULL, "CodeCache should have enough space"); + return alloc; }