mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
7200163: add CodeComments functionality to assember stubs
Pass the codeBuffer to the Stub constructor, and adapts the disassembler to print the comments. Reviewed-by: jrose, kvn, twisti
This commit is contained in:
parent
302540691b
commit
5ada196961
14 changed files with 73 additions and 42 deletions
|
@ -162,8 +162,10 @@ void CodeBlob::trace_new_stub(CodeBlob* stub, const char* name1, const char* nam
|
|||
assert(strlen(name1) + strlen(name2) < sizeof(stub_id), "");
|
||||
jio_snprintf(stub_id, sizeof(stub_id), "%s%s", name1, name2);
|
||||
if (PrintStubCode) {
|
||||
ttyLocker ttyl;
|
||||
tty->print_cr("Decoding %s " INTPTR_FORMAT, stub_id, (intptr_t) stub);
|
||||
Disassembler::decode(stub->code_begin(), stub->code_end());
|
||||
tty->cr();
|
||||
}
|
||||
Forte::register_stub(stub_id, stub->code_begin(), stub->code_end());
|
||||
|
||||
|
@ -548,6 +550,7 @@ void RuntimeStub::verify() {
|
|||
}
|
||||
|
||||
void RuntimeStub::print_on(outputStream* st) const {
|
||||
ttyLocker ttyl;
|
||||
CodeBlob::print_on(st);
|
||||
st->print("Runtime Stub (" INTPTR_FORMAT "): ", this);
|
||||
st->print_cr(name());
|
||||
|
@ -563,6 +566,7 @@ void SingletonBlob::verify() {
|
|||
}
|
||||
|
||||
void SingletonBlob::print_on(outputStream* st) const {
|
||||
ttyLocker ttyl;
|
||||
CodeBlob::print_on(st);
|
||||
st->print_cr(name());
|
||||
Disassembler::decode((CodeBlob*)this, st);
|
||||
|
|
|
@ -184,7 +184,7 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC {
|
|||
static void trace_new_stub(CodeBlob* blob, const char* name1, const char* name2 = "");
|
||||
|
||||
// Print the comment associated with offset on stream, if there is one
|
||||
virtual void print_block_comment(outputStream* stream, address block_begin) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#ifndef SHARE_VM_CODE_ICBUFFER_HPP
|
||||
#define SHARE_VM_CODE_ICBUFFER_HPP
|
||||
|
||||
#include "asm/codeBuffer.hpp"
|
||||
#include "code/stubs.hpp"
|
||||
#include "interpreter/bytecodes.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
|
@ -48,7 +49,8 @@ class ICStub: public Stub {
|
|||
protected:
|
||||
friend class ICStubInterface;
|
||||
// This will be called only by ICStubInterface
|
||||
void initialize(int size) { _size = size; _ic_site = NULL; }
|
||||
void initialize(int size,
|
||||
CodeComments comments) { _size = size; _ic_site = NULL; }
|
||||
void finalize(); // called when a method is removed
|
||||
|
||||
// General info
|
||||
|
|
|
@ -2672,7 +2672,7 @@ ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void nmethod::print_nmethod_labels(outputStream* stream, address block_begin) {
|
||||
void nmethod::print_nmethod_labels(outputStream* stream, address block_begin) const {
|
||||
if (block_begin == entry_point()) stream->print_cr("[Entry Point]");
|
||||
if (block_begin == verified_entry_point()) stream->print_cr("[Verified Entry Point]");
|
||||
if (block_begin == exception_begin()) stream->print_cr("[Exception Handler]");
|
||||
|
|
|
@ -653,11 +653,11 @@ public:
|
|||
void log_state_change() const;
|
||||
|
||||
// Prints block-level comments, including nmethod specific block labels:
|
||||
virtual void print_block_comment(outputStream* stream, address block_begin) {
|
||||
virtual void print_block_comment(outputStream* stream, address block_begin) const {
|
||||
print_nmethod_labels(stream, block_begin);
|
||||
CodeBlob::print_block_comment(stream, block_begin);
|
||||
}
|
||||
void print_nmethod_labels(outputStream* stream, address block_begin);
|
||||
void print_nmethod_labels(outputStream* stream, address block_begin) const;
|
||||
|
||||
// Prints a comment for one native instruction (reloc info, pc desc)
|
||||
void print_code_comment_on(outputStream* st, int column, address begin, address end);
|
||||
|
|
|
@ -101,7 +101,8 @@ Stub* StubQueue::stub_containing(address pc) const {
|
|||
|
||||
Stub* StubQueue::request_committed(int code_size) {
|
||||
Stub* s = request(code_size);
|
||||
if (s != NULL) commit(code_size);
|
||||
CodeComments comments;
|
||||
if (s != NULL) commit(code_size, comments);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -118,7 +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
|
||||
stub_initialize(s, requested_size);
|
||||
CodeComments comments;
|
||||
stub_initialize(s, requested_size, comments);
|
||||
return s;
|
||||
} else {
|
||||
// stub doesn't fit in at the queue end
|
||||
|
@ -135,7 +137,8 @@ Stub* StubQueue::request(int requested_code_size) {
|
|||
// Queue: |XXX|.......|XXXXXXX|.......|
|
||||
// ^0 ^end ^begin ^limit ^size
|
||||
s = current_stub();
|
||||
stub_initialize(s, requested_size);
|
||||
CodeComments comments;
|
||||
stub_initialize(s, requested_size, comments);
|
||||
return s;
|
||||
}
|
||||
// Not enough space left
|
||||
|
@ -144,12 +147,12 @@ Stub* StubQueue::request(int requested_code_size) {
|
|||
}
|
||||
|
||||
|
||||
void StubQueue::commit(int committed_code_size) {
|
||||
void StubQueue::commit(int committed_code_size, CodeComments& comments) {
|
||||
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);
|
||||
stub_initialize(s, committed_size, comments);
|
||||
_queue_end += committed_size;
|
||||
_number_of_stubs++;
|
||||
if (_mutex != NULL) _mutex->unlock();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#ifndef SHARE_VM_CODE_STUBS_HPP
|
||||
#define SHARE_VM_CODE_STUBS_HPP
|
||||
|
||||
#include "asm/codeBuffer.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#ifdef TARGET_OS_FAMILY_linux
|
||||
# include "os_linux.inline.hpp"
|
||||
|
@ -71,7 +72,8 @@
|
|||
class Stub VALUE_OBJ_CLASS_SPEC {
|
||||
public:
|
||||
// Initialization/finalization
|
||||
void initialize(int size) { ShouldNotCallThis(); } // called to initialize/specify the stub's size
|
||||
void initialize(int size,
|
||||
CodeComments& comments) { ShouldNotCallThis(); } // called to initialize/specify the stub's size
|
||||
void finalize() { ShouldNotCallThis(); } // called before the stub is deallocated
|
||||
|
||||
// General info/converters
|
||||
|
@ -104,7 +106,8 @@ class Stub VALUE_OBJ_CLASS_SPEC {
|
|||
class StubInterface: public CHeapObj<mtCode> {
|
||||
public:
|
||||
// Initialization/finalization
|
||||
virtual void initialize(Stub* self, int size) = 0; // called after creation (called twice if allocated via (request, commit))
|
||||
virtual void initialize(Stub* self, int size,
|
||||
CodeComments& comments) = 0; // called after creation (called twice if allocated via (request, commit))
|
||||
virtual void finalize(Stub* self) = 0; // called before deallocation
|
||||
|
||||
// General info/converters
|
||||
|
@ -132,7 +135,8 @@ class StubInterface: public CHeapObj<mtCode> {
|
|||
\
|
||||
public: \
|
||||
/* Initialization/finalization */ \
|
||||
virtual void initialize(Stub* self, int size) { cast(self)->initialize(size); } \
|
||||
virtual void initialize(Stub* self, int size, \
|
||||
CodeComments& comments) { cast(self)->initialize(size, comments); } \
|
||||
virtual void finalize(Stub* self) { cast(self)->finalize(); } \
|
||||
\
|
||||
/* General info */ \
|
||||
|
@ -171,7 +175,8 @@ class StubQueue: public CHeapObj<mtCode> {
|
|||
Stub* current_stub() const { return stub_at(_queue_end); }
|
||||
|
||||
// Stub functionality accessed via interface
|
||||
void stub_initialize(Stub* s, int size) { assert(size % CodeEntryAlignment == 0, "size not aligned"); _stub_interface->initialize(s, size); }
|
||||
void stub_initialize(Stub* s, int size,
|
||||
CodeComments& comments) { assert(size % CodeEntryAlignment == 0, "size not aligned"); _stub_interface->initialize(s, size, comments); }
|
||||
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); }
|
||||
|
@ -200,7 +205,8 @@ class StubQueue: public CHeapObj<mtCode> {
|
|||
// Stub allocation (atomic transactions)
|
||||
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); // commit the previously requested stub - unlocks the queue
|
||||
void commit (int committed_code_size,
|
||||
CodeComments& comments); // commit the previously requested stub - unlocks the queue
|
||||
|
||||
// Stub deallocation
|
||||
void remove_first(); // remove the first stub in the queue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue