src/share/vm/asm/codeBuffer.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/share/vm/asm/codeBuffer.cpp
src/share/vm/asm/codeBuffer.cpp
Print this page
*** 132,141 ****
--- 132,145 ----
}
// free any overflow storage
delete _overflow_arena;
+ // Claim is that stack allocation ensures resources are cleaned up.
+ // This is resource clean up, let's hope that all were properly copied out.
+ free_strings();
+
#ifdef ASSERT
// Save allocation type to execute assert in ~ResourceObj()
// which is called after this destructor.
assert(_default_oop_recorder.allocated_on_stack(), "should be embedded object");
ResourceObj::allocation_type at = _default_oop_recorder.get_allocation_type();
*** 1073,1082 ****
--- 1077,1087 ----
}
return a;
}
void CodeStrings::add_comment(intptr_t offset, const char * comment) {
+ check_valid();
CodeString* c = new CodeString(comment, offset);
CodeString* inspos = (_strings == NULL) ? NULL : find_last(offset);
if (inspos) {
// insert after already existing comments with same offset
*** 1088,1101 ****
--- 1093,1127 ----
_strings = c;
}
}
void CodeStrings::assign(CodeStrings& other) {
+ other.check_valid();
+ // Cannot do following because CodeStrings constructor is not alway run!
+ // assert(isNull(), "Cannot assign onto non-empty CodeStrings");
_strings = other._strings;
+ other.set_null_and_invalidate();
+ }
+
+ // Deep copy of CodeStrings for consistent memory management.
+ // Only used for actual disassembly so this is cheaper than reference counting
+ // for the "normal" fastdebug case.
+ void CodeStrings::copy(CodeStrings& other) {
+ other.check_valid();
+ check_valid();
+ assert(isNull(), "Cannot copy onto non-empty CodeStrings");
+ CodeString* n = other._strings;
+ CodeString** ps = &_strings;
+ while (n != NULL) {
+ *ps = new CodeString(n->string(),n->offset());
+ ps = &((*ps)->_next);
+ n = n->next();
+ }
}
void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) const {
+ check_valid();
if (_strings != NULL) {
CodeString* c = find(offset);
while (c && c->offset() == offset) {
stream->bol();
stream->print(" ;; ");
*** 1103,1126 ****
c = c->next_comment();
}
}
}
!
void CodeStrings::free() {
CodeString* n = _strings;
while (n) {
// unlink the node from the list saving a pointer to the next
CodeString* p = n->next();
n->set_next(NULL);
delete n;
n = p;
}
! _strings = NULL;
}
const char* CodeStrings::add_string(const char * string) {
CodeString* s = new CodeString(string);
s->set_next(_strings);
_strings = s;
assert(s->string() != NULL, "should have a string");
return s->string();
--- 1129,1153 ----
c = c->next_comment();
}
}
}
! // Also sets isNull()
void CodeStrings::free() {
CodeString* n = _strings;
while (n) {
// unlink the node from the list saving a pointer to the next
CodeString* p = n->next();
n->set_next(NULL);
delete n;
n = p;
}
! set_null_and_invalidate();
}
const char* CodeStrings::add_string(const char * string) {
+ check_valid();
CodeString* s = new CodeString(string);
s->set_next(_strings);
_strings = s;
assert(s->string() != NULL, "should have a string");
return s->string();
src/share/vm/asm/codeBuffer.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File