Mercurial > hg > graal-jvmci-8
comparison src/share/vm/code/vtableStubs.cpp @ 12294:891687731b59
7009641: Don't fail VM when CodeCache is full
Summary: Allocation in the code cache returns NULL instead of failing the entire VM
Reviewed-by: kvn, iveresov
author | anoll |
---|---|
date | Tue, 24 Sep 2013 15:56:25 +0200 |
parents | b2e698d2276c |
children | 9341a9963d36 |
comparison
equal
deleted
inserted
replaced
12274:8a6a85321d3a | 12294:891687731b59 |
---|---|
44 | 44 |
45 address VtableStub::_chunk = NULL; | 45 address VtableStub::_chunk = NULL; |
46 address VtableStub::_chunk_end = NULL; | 46 address VtableStub::_chunk_end = NULL; |
47 VMReg VtableStub::_receiver_location = VMRegImpl::Bad(); | 47 VMReg VtableStub::_receiver_location = VMRegImpl::Bad(); |
48 | 48 |
49 static int num_vtable_chunks = 0; | |
50 | |
51 | 49 |
52 void* VtableStub::operator new(size_t size, int code_size) throw() { | 50 void* VtableStub::operator new(size_t size, int code_size) throw() { |
53 assert(size == sizeof(VtableStub), "mismatched size"); | 51 assert(size == sizeof(VtableStub), "mismatched size"); |
54 num_vtable_chunks++; | |
55 // compute real VtableStub size (rounded to nearest word) | 52 // compute real VtableStub size (rounded to nearest word) |
56 const int real_size = round_to(code_size + sizeof(VtableStub), wordSize); | 53 const int real_size = round_to(code_size + sizeof(VtableStub), wordSize); |
57 // malloc them in chunks to minimize header overhead | 54 // malloc them in chunks to minimize header overhead |
58 const int chunk_factor = 32; | 55 const int chunk_factor = 32; |
59 if (_chunk == NULL || _chunk + real_size > _chunk_end) { | 56 if (_chunk == NULL || _chunk + real_size > _chunk_end) { |
60 const int bytes = chunk_factor * real_size + pd_code_alignment(); | 57 const int bytes = chunk_factor * real_size + pd_code_alignment(); |
61 BufferBlob* blob = BufferBlob::create("vtable chunks", bytes); | 58 BufferBlob* blob = BufferBlob::create("vtable chunks", bytes); |
62 if (blob == NULL) { | 59 if (blob == NULL) { |
63 vm_exit_out_of_memory(bytes, OOM_MALLOC_ERROR, "CodeCache: no room for vtable chunks"); | 60 return NULL; |
64 } | 61 } |
65 _chunk = blob->content_begin(); | 62 _chunk = blob->content_begin(); |
66 _chunk_end = _chunk + bytes; | 63 _chunk_end = _chunk + bytes; |
67 Forte::register_stub("vtable stub", _chunk, _chunk_end); | 64 Forte::register_stub("vtable stub", _chunk, _chunk_end); |
68 // Notify JVMTI about this stub. The event will be recorded by the enclosing | 65 // Notify JVMTI about this stub. The event will be recorded by the enclosing |
119 if (is_vtable_stub) { | 116 if (is_vtable_stub) { |
120 s = create_vtable_stub(vtable_index); | 117 s = create_vtable_stub(vtable_index); |
121 } else { | 118 } else { |
122 s = create_itable_stub(vtable_index); | 119 s = create_itable_stub(vtable_index); |
123 } | 120 } |
121 | |
122 // Creation of vtable or itable can fail if there is not enough free space in the code cache. | |
123 if (s == NULL) { | |
124 return NULL; | |
125 } | |
126 | |
124 enter(is_vtable_stub, vtable_index, s); | 127 enter(is_vtable_stub, vtable_index, s); |
125 if (PrintAdapterHandlers) { | 128 if (PrintAdapterHandlers) { |
126 tty->print_cr("Decoding VtableStub %s[%d]@%d", | 129 tty->print_cr("Decoding VtableStub %s[%d]@%d", |
127 is_vtable_stub? "vtbl": "itbl", vtable_index, VtableStub::receiver_location()); | 130 is_vtable_stub? "vtbl": "itbl", vtable_index, VtableStub::receiver_location()); |
128 Disassembler::decode(s->code_begin(), s->code_end()); | 131 Disassembler::decode(s->code_begin(), s->code_end()); |