JDK-7009641 : Don't use CodeCache for allocations if it is already full
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs25,6u27,7,8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2010-12-29
  • Updated: 2021-02-01
  • Resolved: 2013-10-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 Other
7u111Fixed 8 b110Fixed hs25,openjdk8u292Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The failure examples in 7008325 show that even when CodeCache is full and compilation is switched off VM still trying to allocate in CodeCache:

# java.lang.OutOfMemoryError: requested 1824 bytes for CodeCache: no room for vtable chunks. Out of swap space?
#
#  Internal Error (vtableStubs.cpp:63), pid=28881, tid=330
#  Error: CodeCache: no room for vtable chunks


V  [libjvm.so+0x547b70]  void report_vm_out_of_memory(const char*,int,unsigned long,const char*)+0x68;;  void report_vm_out_of_memory(const char*,int,unsigned long,const char*)+0x68
V  [libjvm.so+0xa39578]  void*VtableStub::operator new(unsigned long,int)+0xb8;;  void*VtableStub::operator new(unsigned long,int)+0xb8
V  [libjvm.so+0xa39e8c]  VtableStub*VtableStubs::create_vtable_stub(int)+0x3c;;  VtableStub*VtableStubs::create_vtable_stub(int)+0x3c
V  [libjvm.so+0xa397e4]  unsigned char*VtableStubs::create_stub(bool,int,methodOopDesc*)+0x3c;;  unsigned char*VtableStubs::create_stub(bool,int,methodOopDesc*)+0x3c
V  [libjvm.so+0x2ba2ac]  void CompiledIC::set_to_megamorphic(CallInfo*,Bytecodes::Code,Thread*)+0x11c;;  void CompiledIC::set_to_megamorphic(CallInfo*,Bytecodes::Code,Thread*)+0x11c
V  [libjvm.so+0x2bce98]  methodHandle SharedRuntime::handle_ic_miss_helper(JavaThread*,Thread*)+0x7a8;;  methodHandle SharedRuntime::handle_ic_miss_helper(JavaThread*,Thread*)+0x7a8
V  [libjvm.so+0x952988]  unsigned char*SharedRuntime::handle_wrong_method_ic_miss(JavaThread*)+0x30;;  unsigned char*SharedRuntime::handle_wrong_method_ic_miss(JavaThread*)+0x30
v  ~RuntimeStub::ic_miss_stub
J  java.awt.Component.getHWPeerAboveMe()Ljava/awt/peer/ComponentPeer;

Code Cache  [0xffffffff77800000, 0xffffffff7b800000, 0xffffffff7b800000)
 total_blobs=40649 nmethods=16532 adapters=501 free_code_cache=770368

Comments
WORK AROUND increase -XX:CodeCacheMinimumFreeSpace -XX:ReservedCodeCacheSize e.g.: -XX:CodeCacheMinimumFreeSpace=2M -XX:ReservedCodeCacheSize=64M
20-03-2012

SUGGESTED FIX src/share/vm/runtime/sharedRuntime.cpp *** 1246,1255 **** --- 1246,1269 ---- methodHandle SharedRuntime::handle_ic_miss_helper(JavaThread *thread, TRAPS) { ResourceMark rm(thread); CallInfo call_info; Bytecodes::Code bc; + // If the code cache is full deoptimize this frame. + if (!UseCompiler) { + // bypass VM_DeoptimizeFrame and deoptimize the frame directly + RegisterMap reg_map(thread, false); + frame stub_frame = thread->last_frame(); + assert(stub_frame.is_runtime_frame(), "sanity check"); + frame caller_frame = stub_frame.sender(&reg_map); + assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame(), "unexpected frame"); + Deoptimization::deoptimize_frame(thread, caller_frame.id()); + assert(stub_frame.sender(&reg_map).is_deoptimized_frame(), + "caller should be deoptimized now"); + return find_callee_method(thread, CHECK_(methodHandle())); + } + // receiver is NULL for static calls. An exception is thrown for NULL // receivers for non-static calls Handle receiver = find_callee_info(thread, bc, call_info, CHECK_(methodHandle())); // Compiler1 can produce virtual call sites that can actually be statically bound src/share/vm/oops/methodOop.cpp *** 683,693 **** // normal calls. For vtable calls life gets more complicated. When a // call-site goes mega-morphic we need adapters in all methods which can be // called from the vtable. We need adapters on such methods that get loaded // later. Ditto for mega-morphic itable calls. If this proves to be a // problem we'll make these lazily later. ! (void) make_adapters(h_method, CHECK); // ONLY USE the h_method now as make_adapter may have blocked } --- 683,693 ---- // normal calls. For vtable calls life gets more complicated. When a // call-site goes mega-morphic we need adapters in all methods which can be // called from the vtable. We need adapters on such methods that get loaded // later. Ditto for mega-morphic itable calls. If this proves to be a // problem we'll make these lazily later. ! if (UseCompiler) (void) make_adapters(h_method, CHECK); // ONLY USE the h_method now as make_adapter may have blocked }
29-12-2010