提交 9ddc0bcc 编写于 作者: K kvn

Merge

......@@ -60,6 +60,11 @@ jlong DTraceJSDT::activate(
methodHandle h_method =
methodHandle(THREAD, JNIHandles::resolve_jmethod_id(probe->method));
nmethod* nm = AdapterHandlerLibrary::create_dtrace_nmethod(h_method);
if (nm == NULL) {
delete probes;
THROW_MSG_0(vmSymbols::java_lang_RuntimeException(),
"Unable to register DTrace probes (CodeCache: no room for DTrace nmethods).");
}
h_method()->set_not_compilable(CompLevel_highest_tier);
h_method()->set_code(h_method, nm);
probes->nmethod_at_put(count++, nm);
......
......@@ -1776,7 +1776,14 @@ const char* AdapterHandlerEntry::name = "I2C/C2I adapters";
GrowableArray<uint64_t>* AdapterHandlerLibrary::_fingerprints = NULL;
GrowableArray<AdapterHandlerEntry* >* AdapterHandlerLibrary::_handlers = NULL;
const int AdapterHandlerLibrary_size = 16*K;
u_char AdapterHandlerLibrary::_buffer[AdapterHandlerLibrary_size + 32];
BufferBlob* AdapterHandlerLibrary::_buffer = NULL;
BufferBlob* AdapterHandlerLibrary::buffer_blob() {
// Should be called only when AdapterHandlerLibrary_lock is active.
if (_buffer == NULL) // Initialize lazily
_buffer = BufferBlob::create("adapters", AdapterHandlerLibrary_size);
return _buffer;
}
void AdapterHandlerLibrary::initialize() {
if (_fingerprints != NULL) return;
......@@ -1812,7 +1819,9 @@ int AdapterHandlerLibrary::get_create_adapter_index(methodHandle method) {
assert(ic_miss != NULL, "must have handler");
int result;
NOT_PRODUCT(int code_size);
BufferBlob *B = NULL;
AdapterHandlerEntry* entry = NULL;
uint64_t fingerprint;
{
MutexLocker mu(AdapterHandlerLibrary_lock);
......@@ -1850,9 +1859,10 @@ int AdapterHandlerLibrary::get_create_adapter_index(methodHandle method) {
// Create I2C & C2I handlers
ResourceMark rm;
// Improve alignment slightly
u_char *buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache
if (buf != NULL) {
CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
short buffer_locs[20];
buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs,
sizeof(buffer_locs)/sizeof(relocInfo));
......@@ -1879,13 +1889,15 @@ int AdapterHandlerLibrary::get_create_adapter_index(methodHandle method) {
// Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
AdapterHandlerEntry* entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
total_args_passed,
comp_args_on_stack,
sig_bt,
regs);
B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
NOT_PRODUCT(code_size = buffer.code_size());
}
if (B == NULL) {
// CodeCache is full, disable compilation
// Ought to log this but compile log is only per compile thread
......@@ -1912,9 +1924,9 @@ int AdapterHandlerLibrary::get_create_adapter_index(methodHandle method) {
tty->cr();
tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = 0x%llx, %d bytes generated)",
_handlers->length(), (method->is_static() ? "static" : "receiver"),
method->signature()->as_C_string(), fingerprint, buffer.code_size() );
method->signature()->as_C_string(), fingerprint, code_size );
tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());
Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + buffer.code_size());
Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + code_size);
}
#endif
......@@ -1982,10 +1994,11 @@ nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method) {
return nm;
}
// Improve alignment slightly
u_char* buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
// Need a few relocation entries
ResourceMark rm;
BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache
if (buf != NULL) {
CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
double locs_buf[20];
buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
MacroAssembler _masm(&buffer);
......@@ -1994,7 +2007,7 @@ nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method) {
int total_args_passed = method->size_of_parameters();
BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
VMRegPair * regs = NEW_RESOURCE_ARRAY(VMRegPair ,total_args_passed);
VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair,total_args_passed);
int i=0;
if( !method->is_static() ) // Pass in receiver first
sig_bt[i++] = T_OBJECT;
......@@ -2019,6 +2032,7 @@ nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method) {
sig_bt,regs,
ret_type);
}
}
// Must unlock before calling set_code
// Install the generated code.
......@@ -2077,10 +2091,11 @@ nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) {
return nm;
}
// Improve alignment slightly
u_char* buf = (u_char*)
(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
ResourceMark rm;
BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache
if (buf != NULL) {
CodeBuffer buffer(buf->instructions_begin(), buf->instructions_size());
// Need a few relocation entries
double locs_buf[20];
buffer.insts()->initialize_shared_locs(
......@@ -2090,6 +2105,7 @@ nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) {
// Generate the compiled-to-native wrapper code
nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method);
}
}
return nm;
}
......
......@@ -557,12 +557,13 @@ class AdapterHandlerEntry : public CHeapObj {
class AdapterHandlerLibrary: public AllStatic {
private:
static u_char _buffer[]; // the temporary code buffer
static BufferBlob* _buffer; // the temporary code buffer in CodeCache
static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection
static GrowableArray<AdapterHandlerEntry*> * _handlers; // the corresponding handlers
enum {
AbstractMethodHandler = 1 // special handler for abstract methods
};
static BufferBlob* buffer_blob();
static void initialize();
static int get_create_adapter_index(methodHandle method);
static address get_i2c_entry( int index ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册