8008555: Debugging code in compiled method sometimes leaks memory

Support for strings that have same life-time as code that uses them.

Reviewed-by: kvn, twisti
This commit is contained in:
Roland Westrelin 2013-03-18 13:19:06 +01:00
parent d824b431de
commit 8f1814d874
16 changed files with 174 additions and 121 deletions

View file

@ -186,7 +186,7 @@ void CodeBlob::flush() {
FREE_C_HEAP_ARRAY(unsigned char, _oop_maps, mtCode);
_oop_maps = NULL;
}
_comments.free();
_strings.free();
}

View file

@ -66,7 +66,7 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC {
int _data_offset; // offset to where data region begins
int _frame_size; // size of stack frame
OopMapSet* _oop_maps; // OopMap for this CodeBlob
CodeComments _comments;
CodeStrings _strings;
public:
// Returns the space needed for CodeBlob
@ -186,12 +186,12 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC {
// Print the comment associated with offset on stream, if there is one
virtual void print_block_comment(outputStream* stream, address block_begin) const {
intptr_t offset = (intptr_t)(block_begin - code_begin());
_comments.print_block_comment(stream, offset);
_strings.print_block_comment(stream, offset);
}
// Transfer ownership of comments to this CodeBlob
void set_comments(CodeComments& comments) {
_comments.assign(comments);
void set_strings(CodeStrings& strings) {
_strings.assign(strings);
}
};

View file

@ -50,7 +50,7 @@ class ICStub: public Stub {
friend class ICStubInterface;
// This will be called only by ICStubInterface
void initialize(int size,
CodeComments comments) { _size = size; _ic_site = NULL; }
CodeStrings strings) { _size = size; _ic_site = NULL; }
void finalize(); // called when a method is removed
// General info

View file

@ -101,8 +101,8 @@ Stub* StubQueue::stub_containing(address pc) const {
Stub* StubQueue::request_committed(int code_size) {
Stub* s = request(code_size);
CodeComments comments;
if (s != NULL) commit(code_size, comments);
CodeStrings strings;
if (s != NULL) commit(code_size, strings);
return s;
}
@ -119,8 +119,8 @@ Stub* StubQueue::request(int requested_code_size) {
assert(_buffer_limit == _buffer_size, "buffer must be fully usable");
if (_queue_end + requested_size <= _buffer_size) {
// code fits in at the end => nothing to do
CodeComments comments;
stub_initialize(s, requested_size, comments);
CodeStrings strings;
stub_initialize(s, requested_size, strings);
return s;
} else {
// stub doesn't fit in at the queue end
@ -137,8 +137,8 @@ Stub* StubQueue::request(int requested_code_size) {
// Queue: |XXX|.......|XXXXXXX|.......|
// ^0 ^end ^begin ^limit ^size
s = current_stub();
CodeComments comments;
stub_initialize(s, requested_size, comments);
CodeStrings strings;
stub_initialize(s, requested_size, strings);
return s;
}
// Not enough space left
@ -147,12 +147,12 @@ Stub* StubQueue::request(int requested_code_size) {
}
void StubQueue::commit(int committed_code_size, CodeComments& comments) {
void StubQueue::commit(int committed_code_size, CodeStrings& strings) {
assert(committed_code_size > 0, "committed_code_size must be > 0");
int committed_size = round_to(stub_code_size_to_size(committed_code_size), CodeEntryAlignment);
Stub* s = current_stub();
assert(committed_size <= stub_size(s), "committed size must not exceed requested size");
stub_initialize(s, committed_size, comments);
stub_initialize(s, committed_size, strings);
_queue_end += committed_size;
_number_of_stubs++;
if (_mutex != NULL) _mutex->unlock();

View file

@ -73,7 +73,7 @@ class Stub VALUE_OBJ_CLASS_SPEC {
public:
// Initialization/finalization
void initialize(int size,
CodeComments& comments) { ShouldNotCallThis(); } // called to initialize/specify the stub's size
CodeStrings& strings) { ShouldNotCallThis(); } // called to initialize/specify the stub's size
void finalize() { ShouldNotCallThis(); } // called before the stub is deallocated
// General info/converters
@ -107,7 +107,7 @@ class StubInterface: public CHeapObj<mtCode> {
public:
// Initialization/finalization
virtual void initialize(Stub* self, int size,
CodeComments& comments) = 0; // called after creation (called twice if allocated via (request, commit))
CodeStrings& strings) = 0; // called after creation (called twice if allocated via (request, commit))
virtual void finalize(Stub* self) = 0; // called before deallocation
// General info/converters
@ -136,7 +136,7 @@ class StubInterface: public CHeapObj<mtCode> {
public: \
/* Initialization/finalization */ \
virtual void initialize(Stub* self, int size, \
CodeComments& comments) { cast(self)->initialize(size, comments); } \
CodeStrings& strings) { cast(self)->initialize(size, strings); } \
virtual void finalize(Stub* self) { cast(self)->finalize(); } \
\
/* General info */ \
@ -176,7 +176,7 @@ class StubQueue: public CHeapObj<mtCode> {
// Stub functionality accessed via interface
void stub_initialize(Stub* s, int size,
CodeComments& comments) { assert(size % CodeEntryAlignment == 0, "size not aligned"); _stub_interface->initialize(s, size, comments); }
CodeStrings& strings) { assert(size % CodeEntryAlignment == 0, "size not aligned"); _stub_interface->initialize(s, size, strings); }
void stub_finalize(Stub* s) { _stub_interface->finalize(s); }
int stub_size(Stub* s) const { return _stub_interface->size(s); }
bool stub_contains(Stub* s, address pc) const { return _stub_interface->code_begin(s) <= pc && pc < _stub_interface->code_end(s); }
@ -206,7 +206,7 @@ class StubQueue: public CHeapObj<mtCode> {
Stub* request_committed(int code_size); // request a stub that provides exactly code_size space for code
Stub* request(int requested_code_size); // request a stub with a (maximum) code space - locks the queue
void commit (int committed_code_size,
CodeComments& comments); // commit the previously requested stub - unlocks the queue
CodeStrings& strings); // commit the previously requested stub - unlocks the queue
// Stub deallocation
void remove_first(); // remove the first stub in the queue