提交 9ae3a3cd 编写于 作者: N never

6911204: generated adapters with large signatures can fill up the code cache

Reviewed-by: kvn, jrose
上级 0b9139fb
/* /*
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1189,7 +1189,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm ...@@ -1189,7 +1189,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
// VMReg max_arg, // VMReg max_arg,
int comp_args_on_stack, // VMRegStackSlots int comp_args_on_stack, // VMRegStackSlots
const BasicType *sig_bt, const BasicType *sig_bt,
const VMRegPair *regs) { const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
address i2c_entry = __ pc(); address i2c_entry = __ pc();
AdapterGenerator agen(masm); AdapterGenerator agen(masm);
...@@ -1258,7 +1259,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm ...@@ -1258,7 +1259,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
agen.gen_c2i_adapter(total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup); agen.gen_c2i_adapter(total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
__ flush(); __ flush();
return new AdapterHandlerEntry(i2c_entry, c2i_entry, c2i_unverified_entry); return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
} }
......
/* /*
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -907,7 +907,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm ...@@ -907,7 +907,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
int total_args_passed, int total_args_passed,
int comp_args_on_stack, int comp_args_on_stack,
const BasicType *sig_bt, const BasicType *sig_bt,
const VMRegPair *regs) { const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
address i2c_entry = __ pc(); address i2c_entry = __ pc();
gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs); gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
...@@ -954,7 +955,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm ...@@ -954,7 +955,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup); gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
__ flush(); __ flush();
return new AdapterHandlerEntry(i2c_entry, c2i_entry, c2i_unverified_entry); return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
} }
int SharedRuntime::c_calling_convention(const BasicType *sig_bt, int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
......
/* /*
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -778,7 +778,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm ...@@ -778,7 +778,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
int total_args_passed, int total_args_passed,
int comp_args_on_stack, int comp_args_on_stack,
const BasicType *sig_bt, const BasicType *sig_bt,
const VMRegPair *regs) { const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
address i2c_entry = __ pc(); address i2c_entry = __ pc();
gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs); gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
...@@ -824,7 +825,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm ...@@ -824,7 +825,7 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup); gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);
__ flush(); __ flush();
return new AdapterHandlerEntry(i2c_entry, c2i_entry, c2i_unverified_entry); return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
} }
int SharedRuntime::c_calling_convention(const BasicType *sig_bt, int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
......
...@@ -921,6 +921,7 @@ classFileStream.hpp top.hpp ...@@ -921,6 +921,7 @@ classFileStream.hpp top.hpp
classLoader.cpp allocation.inline.hpp classLoader.cpp allocation.inline.hpp
classLoader.cpp arguments.hpp classLoader.cpp arguments.hpp
classLoader.cpp bytecodeStream.hpp
classLoader.cpp classFileParser.hpp classLoader.cpp classFileParser.hpp
classLoader.cpp classFileStream.hpp classLoader.cpp classFileStream.hpp
classLoader.cpp classLoader.hpp classLoader.cpp classLoader.hpp
...@@ -948,6 +949,7 @@ classLoader.cpp jvm_misc.hpp ...@@ -948,6 +949,7 @@ classLoader.cpp jvm_misc.hpp
classLoader.cpp management.hpp classLoader.cpp management.hpp
classLoader.cpp oop.inline.hpp classLoader.cpp oop.inline.hpp
classLoader.cpp oopFactory.hpp classLoader.cpp oopFactory.hpp
classLoader.cpp oopMapCache.hpp
classLoader.cpp os_<os_family>.inline.hpp classLoader.cpp os_<os_family>.inline.hpp
classLoader.cpp symbolOop.hpp classLoader.cpp symbolOop.hpp
classLoader.cpp systemDictionary.hpp classLoader.cpp systemDictionary.hpp
...@@ -3724,6 +3726,7 @@ sharedRuntime.cpp events.hpp ...@@ -3724,6 +3726,7 @@ sharedRuntime.cpp events.hpp
sharedRuntime.cpp forte.hpp sharedRuntime.cpp forte.hpp
sharedRuntime.cpp gcLocker.inline.hpp sharedRuntime.cpp gcLocker.inline.hpp
sharedRuntime.cpp handles.inline.hpp sharedRuntime.cpp handles.inline.hpp
sharedRuntime.cpp hashtable.inline.hpp
sharedRuntime.cpp init.hpp sharedRuntime.cpp init.hpp
sharedRuntime.cpp interfaceSupport.hpp sharedRuntime.cpp interfaceSupport.hpp
sharedRuntime.cpp interpreterRuntime.hpp sharedRuntime.cpp interpreterRuntime.hpp
...@@ -3751,6 +3754,7 @@ sharedRuntime.cpp xmlstream.hpp ...@@ -3751,6 +3754,7 @@ sharedRuntime.cpp xmlstream.hpp
sharedRuntime.hpp allocation.hpp sharedRuntime.hpp allocation.hpp
sharedRuntime.hpp bytecodeHistogram.hpp sharedRuntime.hpp bytecodeHistogram.hpp
sharedRuntime.hpp bytecodeTracer.hpp sharedRuntime.hpp bytecodeTracer.hpp
sharedRuntime.hpp hashtable.hpp
sharedRuntime.hpp linkResolver.hpp sharedRuntime.hpp linkResolver.hpp
sharedRuntime.hpp resourceArea.hpp sharedRuntime.hpp resourceArea.hpp
sharedRuntime.hpp threadLocalStorage.hpp sharedRuntime.hpp threadLocalStorage.hpp
......
...@@ -688,7 +688,7 @@ address methodOopDesc::make_adapters(methodHandle mh, TRAPS) { ...@@ -688,7 +688,7 @@ address methodOopDesc::make_adapters(methodHandle mh, TRAPS) {
// so making them eagerly shouldn't be too expensive. // so making them eagerly shouldn't be too expensive.
AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh); AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
if (adapter == NULL ) { if (adapter == NULL ) {
THROW_0(vmSymbols::java_lang_OutOfMemoryError()); THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "out of space in CodeCache for adapters");
} }
mh->set_adapter_entry(adapter); mh->set_adapter_entry(adapter);
......
/* /*
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
*/ */
class AdapterHandlerEntry; class AdapterHandlerEntry;
class AdapterHandlerTable;
class AdapterFingerPrint;
class vframeStream; class vframeStream;
// Runtime is the base class for various runtime interfaces // Runtime is the base class for various runtime interfaces
...@@ -337,7 +339,8 @@ class SharedRuntime: AllStatic { ...@@ -337,7 +339,8 @@ class SharedRuntime: AllStatic {
int total_args_passed, int total_args_passed,
int max_arg, int max_arg,
const BasicType *sig_bt, const BasicType *sig_bt,
const VMRegPair *regs); const VMRegPair *regs,
AdapterFingerPrint* fingerprint);
// OSR support // OSR support
...@@ -528,28 +531,41 @@ class SharedRuntime: AllStatic { ...@@ -528,28 +531,41 @@ class SharedRuntime: AllStatic {
// used by the adapters. The code generation happens here because it's very // used by the adapters. The code generation happens here because it's very
// similar to what the adapters have to do. // similar to what the adapters have to do.
class AdapterHandlerEntry : public CHeapObj { class AdapterHandlerEntry : public BasicHashtableEntry {
friend class AdapterHandlerTable;
private: private:
AdapterFingerPrint* _fingerprint;
address _i2c_entry; address _i2c_entry;
address _c2i_entry; address _c2i_entry;
address _c2i_unverified_entry; address _c2i_unverified_entry;
public: void init(AdapterFingerPrint* fingerprint, address i2c_entry, address c2i_entry, address c2i_unverified_entry) {
_fingerprint = fingerprint;
_i2c_entry = i2c_entry;
_c2i_entry = c2i_entry;
_c2i_unverified_entry = c2i_unverified_entry;
}
// should never be used
AdapterHandlerEntry();
public:
// The name we give all buffer blobs // The name we give all buffer blobs
static const char* name; static const char* name;
AdapterHandlerEntry(address i2c_entry, address c2i_entry, address c2i_unverified_entry):
_i2c_entry(i2c_entry),
_c2i_entry(c2i_entry),
_c2i_unverified_entry(c2i_unverified_entry) {
}
address get_i2c_entry() { return _i2c_entry; } address get_i2c_entry() { return _i2c_entry; }
address get_c2i_entry() { return _c2i_entry; } address get_c2i_entry() { return _c2i_entry; }
address get_c2i_unverified_entry() { return _c2i_unverified_entry; } address get_c2i_unverified_entry() { return _c2i_unverified_entry; }
void relocate(address new_base); void relocate(address new_base);
AdapterFingerPrint* fingerprint() { return _fingerprint; }
AdapterHandlerEntry* next() {
return (AdapterHandlerEntry*)BasicHashtableEntry::next();
}
#ifndef PRODUCT #ifndef PRODUCT
void print(); void print();
#endif /* PRODUCT */ #endif /* PRODUCT */
...@@ -558,30 +574,18 @@ class AdapterHandlerEntry : public CHeapObj { ...@@ -558,30 +574,18 @@ class AdapterHandlerEntry : public CHeapObj {
class AdapterHandlerLibrary: public AllStatic { class AdapterHandlerLibrary: public AllStatic {
private: private:
static BufferBlob* _buffer; // the temporary code buffer in CodeCache static BufferBlob* _buffer; // the temporary code buffer in CodeCache
static GrowableArray<uint64_t>* _fingerprints; // the fingerprint collection static AdapterHandlerTable* _adapters;
static GrowableArray<AdapterHandlerEntry*> * _handlers; // the corresponding handlers static AdapterHandlerEntry* _abstract_method_handler;
enum {
AbstractMethodHandler = 1 // special handler for abstract methods
};
static BufferBlob* buffer_blob(); static BufferBlob* buffer_blob();
static void initialize(); static void initialize();
static int get_create_adapter_index(methodHandle method);
static address get_i2c_entry( int index ) {
return get_entry(index)->get_i2c_entry();
}
static address get_c2i_entry( int index ) {
return get_entry(index)->get_c2i_entry();
}
static address get_c2i_unverified_entry( int index ) {
return get_entry(index)->get_c2i_unverified_entry();
}
public: public:
static AdapterHandlerEntry* get_entry( int index ) { return _handlers->at(index); }
static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
address i2c_entry, address c2i_entry, address c2i_unverified_entry);
static nmethod* create_native_wrapper(methodHandle method); static nmethod* create_native_wrapper(methodHandle method);
static AdapterHandlerEntry* get_adapter(methodHandle method) { static AdapterHandlerEntry* get_adapter(methodHandle method);
return get_entry(get_create_adapter_index(method));
}
#ifdef HAVE_DTRACE_H #ifdef HAVE_DTRACE_H
static nmethod* create_dtrace_nmethod (methodHandle method); static nmethod* create_dtrace_nmethod (methodHandle method);
#endif // HAVE_DTRACE_H #endif // HAVE_DTRACE_H
...@@ -589,6 +593,7 @@ class AdapterHandlerLibrary: public AllStatic { ...@@ -589,6 +593,7 @@ class AdapterHandlerLibrary: public AllStatic {
#ifndef PRODUCT #ifndef PRODUCT
static void print_handler(CodeBlob* b); static void print_handler(CodeBlob* b);
static bool contains(CodeBlob* b); static bool contains(CodeBlob* b);
static void print_statistics();
#endif /* PRODUCT */ #endif /* PRODUCT */
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册