1760 tty->print_cr("\t %9d (%3.0f%%) inlined ", _nof_inlined_static_calls, percent(_nof_inlined_static_calls, _nof_static_calls));
1761 tty->cr();
1762 tty->print_cr("Note 1: counter updates are not MT-safe.");
1763 tty->print_cr("Note 2: %% in major categories are relative to total non-inlined calls;");
1764 tty->print_cr(" %% in nested categories are relative to their category");
1765 tty->print_cr(" (and thus add up to more than 100%% with inlining)");
1766 tty->cr();
1767
1768 MethodArityHistogram h;
1769 }
1770 #endif
1771
1772
1773 // ---------------------------------------------------------------------------
1774 // Implementation of AdapterHandlerLibrary
1775 const char* AdapterHandlerEntry::name = "I2C/C2I adapters";
1776 GrowableArray<uint64_t>* AdapterHandlerLibrary::_fingerprints = NULL;
1777 GrowableArray<AdapterHandlerEntry* >* AdapterHandlerLibrary::_handlers = NULL;
1778 const int AdapterHandlerLibrary_size = 16*K;
1779 u_char AdapterHandlerLibrary::_buffer[AdapterHandlerLibrary_size + 32];
1780
1781 void AdapterHandlerLibrary::initialize() {
1782 if (_fingerprints != NULL) return;
1783 _fingerprints = new(ResourceObj::C_HEAP)GrowableArray<uint64_t>(32, true);
1784 _handlers = new(ResourceObj::C_HEAP)GrowableArray<AdapterHandlerEntry*>(32, true);
1785 // Index 0 reserved for the slow path handler
1786 _fingerprints->append(0/*the never-allowed 0 fingerprint*/);
1787 _handlers->append(NULL);
1788
1789 // Create a special handler for abstract methods. Abstract methods
1790 // are never compiled so an i2c entry is somewhat meaningless, but
1791 // fill it in with something appropriate just in case. Pass handle
1792 // wrong method for the c2i transitions.
1793 address wrong_method = SharedRuntime::get_handle_wrong_method_stub();
1794 _fingerprints->append(0/*the never-allowed 0 fingerprint*/);
1795 assert(_handlers->length() == AbstractMethodHandler, "in wrong slot");
1796 _handlers->append(new AdapterHandlerEntry(StubRoutines::throw_AbstractMethodError_entry(),
1797 wrong_method, wrong_method));
1798 }
1799
1965 ttyLocker ttyl;
1966 tty->print("--- n%s ", (method->is_synchronized() ? "s" : " "));
1967 method->print_short_name(tty);
1968 if (method->is_static()) {
1969 tty->print(" (static)");
1970 }
1971 tty->cr();
1972 }
1973
1974 assert(method->has_native_function(), "must have something valid to call!");
1975
1976 {
1977 // perform the work while holding the lock, but perform any printing outside the lock
1978 MutexLocker mu(AdapterHandlerLibrary_lock);
1979 // See if somebody beat us to it
1980 nm = method->code();
1981 if (nm) {
1982 return nm;
1983 }
1984
1985 // Improve alignment slightly
1986 u_char* buf = (u_char*)(((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
1987 CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
1988 // Need a few relocation entries
1989 double locs_buf[20];
1990 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
1991 MacroAssembler _masm(&buffer);
1992
1993 // Fill in the signature array, for the calling-convention call.
1994 int total_args_passed = method->size_of_parameters();
1995
1996 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
1997 VMRegPair * regs = NEW_RESOURCE_ARRAY(VMRegPair ,total_args_passed);
1998 int i=0;
1999 if( !method->is_static() ) // Pass in receiver first
2000 sig_bt[i++] = T_OBJECT;
2001 SignatureStream ss(method->signature());
2002 for( ; !ss.at_return_type(); ss.next()) {
2003 sig_bt[i++] = ss.type(); // Collect remaining bits of signature
2004 if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
2005 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots
2006 }
2007 assert( i==total_args_passed, "" );
2008 BasicType ret_type = ss.type();
2009
2010 // Now get the compiled-Java layout as input arguments
2011 int comp_args_on_stack;
2012 comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
2013
2014 // Generate the compiled-to-native wrapper code
2015 nm = SharedRuntime::generate_native_wrapper(&_masm,
2016 method,
2017 total_args_passed,
2018 comp_args_on_stack,
2019 sig_bt,regs,
2020 ret_type);
2021 }
2022
2023 // Must unlock before calling set_code
2024 // Install the generated code.
2025 if (nm != NULL) {
2026 method->set_code(method, nm);
2027 nm->post_compiled_method_load_event();
2028 } else {
2029 // CodeCache is full, disable compilation
2030 // Ought to log this but compile log is only per compile thread
2031 // and we're some non descript Java thread.
2032 UseInterpreter = true;
2033 if (UseCompiler || AlwaysCompileLoopMethods ) {
2034 #ifndef PRODUCT
2035 warning("CodeCache is full. Compiler has been disabled");
2036 if (CompileTheWorld || ExitOnFullCodeCache) {
2037 before_exit(JavaThread::current());
2038 exit_globals(); // will delete tty
2039 vm_direct_exit(CompileTheWorld ? 0 : 1);
2040 }
2041 #endif
2060 if (PrintCompilation) {
2061 ttyLocker ttyl;
2062 tty->print("--- n%s ");
2063 method->print_short_name(tty);
2064 if (method->is_static()) {
2065 tty->print(" (static)");
2066 }
2067 tty->cr();
2068 }
2069
2070 {
2071 // perform the work while holding the lock, but perform any printing
2072 // outside the lock
2073 MutexLocker mu(AdapterHandlerLibrary_lock);
2074 // See if somebody beat us to it
2075 nm = method->code();
2076 if (nm) {
2077 return nm;
2078 }
2079
2080 // Improve alignment slightly
2081 u_char* buf = (u_char*)
2082 (((intptr_t)_buffer + CodeEntryAlignment-1) & ~(CodeEntryAlignment-1));
2083 CodeBuffer buffer(buf, AdapterHandlerLibrary_size);
2084 // Need a few relocation entries
2085 double locs_buf[20];
2086 buffer.insts()->initialize_shared_locs(
2087 (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
2088 MacroAssembler _masm(&buffer);
2089
2090 // Generate the compiled-to-native wrapper code
2091 nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method);
2092 }
2093 return nm;
2094 }
2095
2096 // the dtrace method needs to convert java lang string to utf8 string.
2097 void SharedRuntime::get_utf(oopDesc* src, address dst) {
2098 typeArrayOop jlsValue = java_lang_String::value(src);
2099 int jlsOffset = java_lang_String::offset(src);
2100 int jlsLen = java_lang_String::length(src);
2101 jchar* jlsPos = (jlsLen == 0) ? NULL :
2102 jlsValue->char_at_addr(jlsOffset);
2103 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size);
2104 }
2105 #endif // ndef HAVE_DTRACE_H
2106
2107 // -------------------------------------------------------------------------
2108 // Java-Java calling convention
2109 // (what you use when Java calls Java)
2110
2111 //------------------------------name_for_receiver----------------------------------
2112 // For a given signature, return the VMReg for parameter 0.
|
1760 tty->print_cr("\t %9d (%3.0f%%) inlined ", _nof_inlined_static_calls, percent(_nof_inlined_static_calls, _nof_static_calls));
1761 tty->cr();
1762 tty->print_cr("Note 1: counter updates are not MT-safe.");
1763 tty->print_cr("Note 2: %% in major categories are relative to total non-inlined calls;");
1764 tty->print_cr(" %% in nested categories are relative to their category");
1765 tty->print_cr(" (and thus add up to more than 100%% with inlining)");
1766 tty->cr();
1767
1768 MethodArityHistogram h;
1769 }
1770 #endif
1771
1772
1773 // ---------------------------------------------------------------------------
1774 // Implementation of AdapterHandlerLibrary
1775 const char* AdapterHandlerEntry::name = "I2C/C2I adapters";
1776 GrowableArray<uint64_t>* AdapterHandlerLibrary::_fingerprints = NULL;
1777 GrowableArray<AdapterHandlerEntry* >* AdapterHandlerLibrary::_handlers = NULL;
1778 const int AdapterHandlerLibrary_size = 16*K;
1779 u_char AdapterHandlerLibrary::_buffer[AdapterHandlerLibrary_size + 32];
1780 BufferBlob* AdapterHandlerLibrary::_buffer_blob = NULL;
1781
1782 void AdapterHandlerLibrary::initialize() {
1783 if (_fingerprints != NULL) return;
1784 _fingerprints = new(ResourceObj::C_HEAP)GrowableArray<uint64_t>(32, true);
1785 _handlers = new(ResourceObj::C_HEAP)GrowableArray<AdapterHandlerEntry*>(32, true);
1786 // Index 0 reserved for the slow path handler
1787 _fingerprints->append(0/*the never-allowed 0 fingerprint*/);
1788 _handlers->append(NULL);
1789
1790 // Create a special handler for abstract methods. Abstract methods
1791 // are never compiled so an i2c entry is somewhat meaningless, but
1792 // fill it in with something appropriate just in case. Pass handle
1793 // wrong method for the c2i transitions.
1794 address wrong_method = SharedRuntime::get_handle_wrong_method_stub();
1795 _fingerprints->append(0/*the never-allowed 0 fingerprint*/);
1796 assert(_handlers->length() == AbstractMethodHandler, "in wrong slot");
1797 _handlers->append(new AdapterHandlerEntry(StubRoutines::throw_AbstractMethodError_entry(),
1798 wrong_method, wrong_method));
1799 }
1800
1966 ttyLocker ttyl;
1967 tty->print("--- n%s ", (method->is_synchronized() ? "s" : " "));
1968 method->print_short_name(tty);
1969 if (method->is_static()) {
1970 tty->print(" (static)");
1971 }
1972 tty->cr();
1973 }
1974
1975 assert(method->has_native_function(), "must have something valid to call!");
1976
1977 {
1978 // perform the work while holding the lock, but perform any printing outside the lock
1979 MutexLocker mu(AdapterHandlerLibrary_lock);
1980 // See if somebody beat us to it
1981 nm = method->code();
1982 if (nm) {
1983 return nm;
1984 }
1985
1986 // Fill in the signature array, for the calling-convention call.
1987 int total_args_passed = method->size_of_parameters();
1988
1989 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType,total_args_passed);
1990 VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair,total_args_passed);
1991 int i=0;
1992 if( !method->is_static() ) // Pass in receiver first
1993 sig_bt[i++] = T_OBJECT;
1994 SignatureStream ss(method->signature());
1995 for( ; !ss.at_return_type(); ss.next()) {
1996 sig_bt[i++] = ss.type(); // Collect remaining bits of signature
1997 if( ss.type() == T_LONG || ss.type() == T_DOUBLE )
1998 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots
1999 }
2000 assert( i==total_args_passed, "" );
2001 BasicType ret_type = ss.type();
2002
2003 // Now get the compiled-Java layout as input arguments
2004 int comp_args_on_stack;
2005 comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
2006
2007 if (_buffer_blob == NULL) // Initialize lazily
2008 _buffer_blob = BufferBlob::create("Native wrapper/DTrace nmethod", AdapterHandlerLibrary_size);
2009
2010 if (_buffer_blob != NULL) {
2011 CodeBuffer buffer(_buffer_blob->instructions_begin(), _buffer_blob->instructions_size());
2012 double locs_buf[20];
2013 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
2014 MacroAssembler _masm(&buffer);
2015
2016 // Generate the compiled-to-native wrapper code
2017 nm = SharedRuntime::generate_native_wrapper(&_masm,
2018 method,
2019 total_args_passed,
2020 comp_args_on_stack,
2021 sig_bt,regs,
2022 ret_type);
2023 }
2024 }
2025
2026 // Must unlock before calling set_code
2027 // Install the generated code.
2028 if (nm != NULL) {
2029 method->set_code(method, nm);
2030 nm->post_compiled_method_load_event();
2031 } else {
2032 // CodeCache is full, disable compilation
2033 // Ought to log this but compile log is only per compile thread
2034 // and we're some non descript Java thread.
2035 UseInterpreter = true;
2036 if (UseCompiler || AlwaysCompileLoopMethods ) {
2037 #ifndef PRODUCT
2038 warning("CodeCache is full. Compiler has been disabled");
2039 if (CompileTheWorld || ExitOnFullCodeCache) {
2040 before_exit(JavaThread::current());
2041 exit_globals(); // will delete tty
2042 vm_direct_exit(CompileTheWorld ? 0 : 1);
2043 }
2044 #endif
2063 if (PrintCompilation) {
2064 ttyLocker ttyl;
2065 tty->print("--- n%s ");
2066 method->print_short_name(tty);
2067 if (method->is_static()) {
2068 tty->print(" (static)");
2069 }
2070 tty->cr();
2071 }
2072
2073 {
2074 // perform the work while holding the lock, but perform any printing
2075 // outside the lock
2076 MutexLocker mu(AdapterHandlerLibrary_lock);
2077 // See if somebody beat us to it
2078 nm = method->code();
2079 if (nm) {
2080 return nm;
2081 }
2082
2083 if (_buffer_blob == NULL) // Initialize lazily
2084 _buffer_blob = BufferBlob::create("Native wrapper/DTrace nmethod", AdapterHandlerLibrary_size);
2085
2086 if (_buffer_blob != NULL) {
2087 CodeBuffer buffer(_buffer_blob->instructions_begin(), _buffer_blob->instructions_size());
2088 // Need a few relocation entries
2089 double locs_buf[20];
2090 buffer.insts()->initialize_shared_locs(
2091 (relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo));
2092 MacroAssembler _masm(&buffer);
2093
2094 // Generate the compiled-to-native wrapper code
2095 nm = SharedRuntime::generate_dtrace_nmethod(&_masm, method);
2096 }
2097 }
2098 return nm;
2099 }
2100
2101 // the dtrace method needs to convert java lang string to utf8 string.
2102 void SharedRuntime::get_utf(oopDesc* src, address dst) {
2103 typeArrayOop jlsValue = java_lang_String::value(src);
2104 int jlsOffset = java_lang_String::offset(src);
2105 int jlsLen = java_lang_String::length(src);
2106 jchar* jlsPos = (jlsLen == 0) ? NULL :
2107 jlsValue->char_at_addr(jlsOffset);
2108 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size);
2109 }
2110 #endif // ndef HAVE_DTRACE_H
2111
2112 // -------------------------------------------------------------------------
2113 // Java-Java calling convention
2114 // (what you use when Java calls Java)
2115
2116 //------------------------------name_for_receiver----------------------------------
2117 // For a given signature, return the VMReg for parameter 0.
|