提交 9dcc6c97 编写于 作者: R roland

Merge

......@@ -1385,13 +1385,13 @@ void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * fil
}
#endif
int len = strlen(file) + strlen(msg) + 1 + 4;
sprintf(buffer, "%d", line);
len += strlen(buffer);
sprintf(buffer, " at offset %d ", offset());
len += strlen(buffer);
char * real_msg = new char[len];
sprintf(real_msg, "%s%s(%s:%d)", msg, buffer, file, line);
const char* real_msg = NULL;
{
ResourceMark rm;
stringStream ss;
ss.print("%s at offset %d (%s:%d)", msg, offset(), file, line);
real_msg = code_string(ss.as_string());
}
// Call indirectly to solve generation ordering problem
AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
......@@ -1423,13 +1423,13 @@ void MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char
// plausibility check for oops
if (!VerifyOops) return;
char buffer[64];
sprintf(buffer, "%d", line);
int len = strlen(file) + strlen(msg) + 1 + 4 + strlen(buffer);
sprintf(buffer, " at SP+%d ", addr.disp());
len += strlen(buffer);
char * real_msg = new char[len];
sprintf(real_msg, "%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
const char* real_msg = NULL;
{
ResourceMark rm;
stringStream ss;
ss.print("%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
real_msg = code_string(ss.as_string());
}
// Call indirectly to solve generation ordering problem
AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
......@@ -1622,9 +1622,13 @@ void MacroAssembler::untested(const char* what) {
// in order to run automated test scripts on the VM
// Use the flag ShowMessageBoxOnError
char* b = new char[1024];
sprintf(b, "untested: %s", what);
const char* b = NULL;
{
ResourceMark rm;
stringStream ss;
ss.print("untested: %s", what);
b = code_string(ss.as_string());
}
if (ShowMessageBoxOnError) { STOP(b); }
else { warn(b); }
}
......
......@@ -4262,8 +4262,13 @@ void MacroAssembler::verify_oop(Register reg, const char* s) {
if (!VerifyOops) return;
// Pass register number to verify_oop_subroutine
char* b = new char[strlen(s) + 50];
sprintf(b, "verify_oop: %s: %s", reg->name(), s);
const char* b = NULL;
{
ResourceMark rm;
stringStream ss;
ss.print("verify_oop: %s: %s", reg->name(), s);
b = code_string(ss.as_string());
}
BLOCK_COMMENT("verify_oop {");
#ifdef _LP64
push(rscratch1); // save r10, trashed by movptr()
......@@ -4297,9 +4302,14 @@ RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_ad
{ Label L;
testptr(tmp, tmp);
if (WizardMode) {
const char* buf = NULL;
{
ResourceMark rm;
stringStream ss;
ss.print("DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]);
buf = code_string(ss.as_string());
}
jcc(Assembler::notZero, L);
char* buf = new char[40];
sprintf(buf, "DelayedValue="INTPTR_FORMAT, delayed_value_addr[1]);
STOP(buf);
} else {
jccb(Assembler::notZero, L);
......@@ -4343,9 +4353,13 @@ void MacroAssembler::verify_oop_addr(Address addr, const char* s) {
// Address adjust(addr.base(), addr.index(), addr.scale(), addr.disp() + BytesPerWord);
// Pass register number to verify_oop_subroutine
char* b = new char[strlen(s) + 50];
sprintf(b, "verify_oop_addr: %s", s);
const char* b = NULL;
{
ResourceMark rm;
stringStream ss;
ss.print("verify_oop_addr: %s", s);
b = code_string(ss.as_string());
}
#ifdef _LP64
push(rscratch1); // save r10, trashed by movptr()
#endif
......
......@@ -284,15 +284,19 @@ void AbstractAssembler::update_delayed_values() {
DelayedConstant::update_all();
}
void AbstractAssembler::block_comment(const char* comment) {
if (sect() == CodeBuffer::SECT_INSTS) {
code_section()->outer()->block_comment(offset(), comment);
}
}
const char* AbstractAssembler::code_string(const char* str) {
if (sect() == CodeBuffer::SECT_INSTS || sect() == CodeBuffer::SECT_STUBS) {
return code_section()->outer()->code_string(str);
}
return NULL;
}
bool MacroAssembler::needs_explicit_null_check(intptr_t offset) {
// Exception handler checks the nmethod's implicit null checks table
// only when this method returns false.
......
......@@ -336,6 +336,8 @@ class AbstractAssembler : public ResourceObj {
// along with the disassembly when printing nmethods. Currently
// only supported in the instruction section of the code buffer.
void block_comment(const char* comment);
// Copy str to a buffer that has the same lifetime as the CodeBuffer
const char* code_string(const char* str);
// Label functions
void bind(Label& L); // binds an unbound label L to the current code position
......
......@@ -703,8 +703,8 @@ void CodeBuffer::copy_code_to(CodeBlob* dest_blob) {
this->compute_final_layout(&dest);
relocate_code_to(&dest);
// transfer comments from buffer to blob
dest_blob->set_comments(_comments);
// transfer strings and comments from buffer to blob
dest_blob->set_strings(_strings);
// Done moving code bytes; were they the right size?
assert(round_to(dest.total_content_size(), oopSize) == dest_blob->content_size(), "sanity");
......@@ -1003,58 +1003,78 @@ void CodeSection::decode() {
void CodeBuffer::block_comment(intptr_t offset, const char * comment) {
_comments.add_comment(offset, comment);
_strings.add_comment(offset, comment);
}
class CodeComment: public CHeapObj<mtCode> {
const char* CodeBuffer::code_string(const char* str) {
return _strings.add_string(str);
}
class CodeString: public CHeapObj<mtCode> {
private:
friend class CodeComments;
friend class CodeStrings;
const char * _string;
CodeString* _next;
intptr_t _offset;
const char * _comment;
CodeComment* _next;
~CodeComment() {
~CodeString() {
assert(_next == NULL, "wrong interface for freeing list");
os::free((void*)_comment, mtCode);
os::free((void*)_string, mtCode);
}
bool is_comment() const { return _offset >= 0; }
public:
CodeComment(intptr_t offset, const char * comment) {
_offset = offset;
_comment = os::strdup(comment, mtCode);
_next = NULL;
CodeString(const char * string, intptr_t offset = -1)
: _next(NULL), _offset(offset) {
_string = os::strdup(string, mtCode);
}
intptr_t offset() const { return _offset; }
const char * comment() const { return _comment; }
CodeComment* next() { return _next; }
const char * string() const { return _string; }
intptr_t offset() const { assert(_offset >= 0, "offset for non comment?"); return _offset; }
CodeString* next() const { return _next; }
void set_next(CodeComment* next) { _next = next; }
void set_next(CodeString* next) { _next = next; }
CodeComment* find(intptr_t offset) {
CodeComment* a = this;
while (a != NULL && a->_offset != offset) {
a = a->_next;
CodeString* first_comment() {
if (is_comment()) {
return this;
} else {
return next_comment();
}
return a;
}
// Convenience for add_comment.
CodeComment* find_last(intptr_t offset) {
CodeComment* a = find(offset);
if (a != NULL) {
while ((a->_next != NULL) && (a->_next->_offset == offset)) {
a = a->_next;
}
CodeString* next_comment() const {
CodeString* s = _next;
while (s != NULL && !s->is_comment()) {
s = s->_next;
}
return a;
return s;
}
};
CodeString* CodeStrings::find(intptr_t offset) const {
CodeString* a = _strings->first_comment();
while (a != NULL && a->offset() != offset) {
a = a->next_comment();
}
return a;
}
// Convenience for add_comment.
CodeString* CodeStrings::find_last(intptr_t offset) const {
CodeString* a = find(offset);
if (a != NULL) {
CodeString* c = NULL;
while (((c = a->next_comment()) != NULL) && (c->offset() == offset)) {
a = c;
}
}
return a;
}
void CodeComments::add_comment(intptr_t offset, const char * comment) {
CodeComment* c = new CodeComment(offset, comment);
CodeComment* inspos = (_comments == NULL) ? NULL : _comments->find_last(offset);
void CodeStrings::add_comment(intptr_t offset, const char * comment) {
CodeString* c = new CodeString(comment, offset);
CodeString* inspos = (_strings == NULL) ? NULL : find_last(offset);
if (inspos) {
// insert after already existing comments with same offset
......@@ -1062,43 +1082,47 @@ void CodeComments::add_comment(intptr_t offset, const char * comment) {
inspos->set_next(c);
} else {
// no comments with such offset, yet. Insert before anything else.
c->set_next(_comments);
_comments = c;
c->set_next(_strings);
_strings = c;
}
}
void CodeComments::assign(CodeComments& other) {
_comments = other._comments;
void CodeStrings::assign(CodeStrings& other) {
_strings = other._strings;
}
void CodeComments::print_block_comment(outputStream* stream, intptr_t offset) const {
if (_comments != NULL) {
CodeComment* c = _comments->find(offset);
void CodeStrings::print_block_comment(outputStream* stream, intptr_t offset) const {
if (_strings != NULL) {
CodeString* c = find(offset);
while (c && c->offset() == offset) {
stream->bol();
stream->print(" ;; ");
stream->print_cr(c->comment());
c = c->next();
stream->print_cr(c->string());
c = c->next_comment();
}
}
}
void CodeComments::free() {
CodeComment* n = _comments;
void CodeStrings::free() {
CodeString* n = _strings;
while (n) {
// unlink the node from the list saving a pointer to the next
CodeComment* p = n->_next;
n->_next = NULL;
CodeString* p = n->next();
n->set_next(NULL);
delete n;
n = p;
}
_comments = NULL;
_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();
}
void CodeBuffer::decode() {
ttyLocker ttyl;
......
......@@ -28,7 +28,7 @@
#include "code/oopRecorder.hpp"
#include "code/relocInfo.hpp"
class CodeComments;
class CodeStrings;
class PhaseCFG;
class Compile;
class BufferBlob;
......@@ -240,27 +240,31 @@ class CodeSection VALUE_OBJ_CLASS_SPEC {
#endif //PRODUCT
};
class CodeComment;
class CodeComments VALUE_OBJ_CLASS_SPEC {
class CodeString;
class CodeStrings VALUE_OBJ_CLASS_SPEC {
private:
#ifndef PRODUCT
CodeComment* _comments;
CodeString* _strings;
#endif
CodeString* find(intptr_t offset) const;
CodeString* find_last(intptr_t offset) const;
public:
CodeComments() {
CodeStrings() {
#ifndef PRODUCT
_comments = NULL;
_strings = NULL;
#endif
}
const char* add_string(const char * string) PRODUCT_RETURN_(return NULL;);
void add_comment(intptr_t offset, const char * comment) PRODUCT_RETURN;
void print_block_comment(outputStream* stream, intptr_t offset) const PRODUCT_RETURN;
void assign(CodeComments& other) PRODUCT_RETURN;
void assign(CodeStrings& other) PRODUCT_RETURN;
void free() PRODUCT_RETURN;
};
// A CodeBuffer describes a memory space into which assembly
// code is generated. This memory space usually occupies the
// interior of a single BufferBlob, but in some cases it may be
......@@ -326,7 +330,7 @@ class CodeBuffer: public StackObj {
csize_t _total_size; // size in bytes of combined memory buffer
OopRecorder* _oop_recorder;
CodeComments _comments;
CodeStrings _strings;
OopRecorder _default_oop_recorder; // override with initialize_oop_recorder
Arena* _overflow_arena;
......@@ -527,7 +531,7 @@ class CodeBuffer: public StackObj {
void initialize_oop_recorder(OopRecorder* r);
OopRecorder* oop_recorder() const { return _oop_recorder; }
CodeComments& comments() { return _comments; }
CodeStrings& strings() { return _strings; }
// Code generation
void relocate(address at, RelocationHolder const& rspec, int format = 0) {
......@@ -556,6 +560,7 @@ class CodeBuffer: public StackObj {
address transform_address(const CodeBuffer &cb, address addr) const;
void block_comment(intptr_t offset, const char * comment) PRODUCT_RETURN;
const char* code_string(const char* str) PRODUCT_RETURN_(return NULL;);
// Log a little info about section usage in the CodeBuffer
void log_section_sizes(const char* name);
......
......@@ -186,7 +186,7 @@ void CodeBlob::flush() {
FREE_C_HEAP_ARRAY(unsigned char, _oop_maps, mtCode);
_oop_maps = NULL;
}
_comments.free();
_strings.free();
}
......
......@@ -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);
}
};
......
......@@ -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
......
......@@ -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();
......
......@@ -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
......
......@@ -158,7 +158,7 @@ class decode_env {
private:
nmethod* _nm;
CodeBlob* _code;
CodeComments _comments;
CodeStrings _strings;
outputStream* _output;
address _start, _end;
......@@ -198,7 +198,7 @@ class decode_env {
void print_address(address value);
public:
decode_env(CodeBlob* code, outputStream* output, CodeComments c = CodeComments());
decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings());
address decode_instructions(address start, address end);
......@@ -242,13 +242,13 @@ class decode_env {
const char* options() { return _option_buf; }
};
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeComments c) {
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
memset(this, 0, sizeof(*this));
_output = output ? output : tty;
_code = code;
if (code != NULL && code->is_nmethod())
_nm = (nmethod*) code;
_comments.assign(c);
_strings.assign(c);
// by default, output pc but not bytes:
_print_pc = true;
......@@ -370,7 +370,7 @@ void decode_env::print_insn_labels() {
if (cb != NULL) {
cb->print_block_comment(st, p);
}
_comments.print_block_comment(st, (intptr_t)(p - _start));
_strings.print_block_comment(st, (intptr_t)(p - _start));
if (_print_pc) {
st->print(" " PTR_FORMAT ": ", p);
}
......@@ -498,7 +498,7 @@ void Disassembler::decode(CodeBlob* cb, outputStream* st) {
env.decode_instructions(cb->code_begin(), cb->code_end());
}
void Disassembler::decode(address start, address end, outputStream* st, CodeComments c) {
void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
if (!load_library()) return;
decode_env env(CodeCache::find_blob_unsafe(start), st, c);
env.decode_instructions(start, end);
......
......@@ -100,7 +100,7 @@ class Disassembler {
}
static void decode(CodeBlob *cb, outputStream* st = NULL);
static void decode(nmethod* nm, outputStream* st = NULL);
static void decode(address begin, address end, outputStream* st = NULL, CodeComments c = CodeComments());
static void decode(address begin, address end, outputStream* st = NULL, CodeStrings c = CodeStrings());
};
#endif // SHARE_VM_COMPILER_DISASSEMBLER_HPP
......@@ -76,7 +76,7 @@ void InterpreterCodelet::print_on(outputStream* st) const {
if (PrintInterpreter) {
st->cr();
Disassembler::decode(code_begin(), code_end(), st, DEBUG_ONLY(_comments) NOT_DEBUG(CodeComments()));
Disassembler::decode(code_begin(), code_end(), st, DEBUG_ONLY(_strings) NOT_DEBUG(CodeStrings()));
}
}
......
......@@ -48,12 +48,12 @@ class InterpreterCodelet: public Stub {
int _size; // the size in bytes
const char* _description; // a description of the codelet, for debugging & printing
Bytecodes::Code _bytecode; // associated bytecode if any
DEBUG_ONLY(CodeComments _comments;) // Comments for annotating assembler output.
DEBUG_ONLY(CodeStrings _strings;) // Comments for annotating assembler output.
public:
// Initialization/finalization
void initialize(int size,
CodeComments& comments) { _size = size; DEBUG_ONLY(_comments.assign(comments);) }
CodeStrings& strings) { _size = size; DEBUG_ONLY(_strings.assign(strings);) }
void finalize() { ShouldNotCallThis(); }
// General info/converters
......@@ -131,7 +131,7 @@ class CodeletMark: ResourceMark {
// commit Codelet
AbstractInterpreter::code()->commit((*_masm)->code()->pure_insts_size(), (*_masm)->code()->comments());
AbstractInterpreter::code()->commit((*_masm)->code()->pure_insts_size(), (*_masm)->code()->strings());
// make sure nobody can use _masm outside a CodeletMark lifespan
*_masm = NULL;
}
......
......@@ -87,7 +87,7 @@ StubCodeGenerator::~StubCodeGenerator() {
CodeBuffer* cbuf = _masm->code();
CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
if (blob != NULL) {
blob->set_comments(cbuf->comments());
blob->set_strings(cbuf->strings());
}
bool saw_first = false;
StubCodeDesc* toprint[1000];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册