1886
1887 // Now get the re-packed compiled-Java layout.
1888 int comp_args_on_stack;
1889
1890 // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
1891 comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
1892
1893 entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
1894 total_args_passed,
1895 comp_args_on_stack,
1896 sig_bt,
1897 regs);
1898
1899 B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
1900 NOT_PRODUCT(code_size = buffer.code_size());
1901 }
1902 if (B == NULL) {
1903 // CodeCache is full, disable compilation
1904 // Ought to log this but compile log is only per compile thread
1905 // and we're some non descript Java thread.
1906 UseInterpreter = true;
1907 if (UseCompiler || AlwaysCompileLoopMethods ) {
1908 #ifndef PRODUCT
1909 warning("CodeCache is full. Compiler has been disabled");
1910 if (CompileTheWorld || ExitOnFullCodeCache) {
1911 before_exit(JavaThread::current());
1912 exit_globals(); // will delete tty
1913 vm_direct_exit(CompileTheWorld ? 0 : 1);
1914 }
1915 #endif
1916 UseCompiler = false;
1917 AlwaysCompileLoopMethods = false;
1918 }
1919 return 0; // Out of CodeCache space (_handlers[0] == NULL)
1920 }
1921 entry->relocate(B->instructions_begin());
1922 #ifndef PRODUCT
1923 // debugging suppport
1924 if (PrintAdapterHandlers) {
1925 tty->cr();
1926 tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = 0x%llx, %d bytes generated)",
1927 _handlers->length(), (method->is_static() ? "static" : "receiver"),
1928 method->signature()->as_C_string(), fingerprint, code_size );
1929 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());
1930 Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + code_size);
1931 }
1932 #endif
1933
1934 // add handlers to library
1935 _fingerprints->append(fingerprint);
1936 _handlers->append(entry);
1937 // set handler index
1938 assert(_fingerprints->length() == _handlers->length(), "sanity check");
2027
2028 // Generate the compiled-to-native wrapper code
2029 nm = SharedRuntime::generate_native_wrapper(&_masm,
2030 method,
2031 total_args_passed,
2032 comp_args_on_stack,
2033 sig_bt,regs,
2034 ret_type);
2035 }
2036 }
2037
2038 // Must unlock before calling set_code
2039 // Install the generated code.
2040 if (nm != NULL) {
2041 method->set_code(method, nm);
2042 nm->post_compiled_method_load_event();
2043 } else {
2044 // CodeCache is full, disable compilation
2045 // Ought to log this but compile log is only per compile thread
2046 // and we're some non descript Java thread.
2047 UseInterpreter = true;
2048 if (UseCompiler || AlwaysCompileLoopMethods ) {
2049 #ifndef PRODUCT
2050 warning("CodeCache is full. Compiler has been disabled");
2051 if (CompileTheWorld || ExitOnFullCodeCache) {
2052 before_exit(JavaThread::current());
2053 exit_globals(); // will delete tty
2054 vm_direct_exit(CompileTheWorld ? 0 : 1);
2055 }
2056 #endif
2057 UseCompiler = false;
2058 AlwaysCompileLoopMethods = false;
2059 }
2060 }
2061 return nm;
2062 }
2063
2064 #ifdef HAVE_DTRACE_H
2065 // Create a dtrace nmethod for this method. The wrapper converts the
2066 // java compiled calling convention to the native convention, makes a dummy call
2067 // (actually nops for the size of the call instruction, which become a trap if
2068 // probe is enabled). The returns to the caller. Since this all looks like a
2069 // leaf no thread transition is needed.
2070
2071 nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) {
2072 ResourceMark rm;
2073 nmethod* nm = NULL;
2074
2075 if (PrintCompilation) {
2076 ttyLocker ttyl;
2077 tty->print("--- n%s ");
2078 method->print_short_name(tty);
2079 if (method->is_static()) {
|
1886
1887 // Now get the re-packed compiled-Java layout.
1888 int comp_args_on_stack;
1889
1890 // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage
1891 comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false);
1892
1893 entry = SharedRuntime::generate_i2c2i_adapters(&_masm,
1894 total_args_passed,
1895 comp_args_on_stack,
1896 sig_bt,
1897 regs);
1898
1899 B = BufferBlob::create(AdapterHandlerEntry::name, &buffer);
1900 NOT_PRODUCT(code_size = buffer.code_size());
1901 }
1902 if (B == NULL) {
1903 // CodeCache is full, disable compilation
1904 // Ought to log this but compile log is only per compile thread
1905 // and we're some non descript Java thread.
1906 MutexUnlocker mu(AdapterHandlerLibrary_lock);
1907 CompileBroker::handle_full_code_cache();
1908 return 0; // Out of CodeCache space (_handlers[0] == NULL)
1909 }
1910 entry->relocate(B->instructions_begin());
1911 #ifndef PRODUCT
1912 // debugging suppport
1913 if (PrintAdapterHandlers) {
1914 tty->cr();
1915 tty->print_cr("i2c argument handler #%d for: %s %s (fingerprint = 0x%llx, %d bytes generated)",
1916 _handlers->length(), (method->is_static() ? "static" : "receiver"),
1917 method->signature()->as_C_string(), fingerprint, code_size );
1918 tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry());
1919 Disassembler::decode(entry->get_i2c_entry(), entry->get_i2c_entry() + code_size);
1920 }
1921 #endif
1922
1923 // add handlers to library
1924 _fingerprints->append(fingerprint);
1925 _handlers->append(entry);
1926 // set handler index
1927 assert(_fingerprints->length() == _handlers->length(), "sanity check");
2016
2017 // Generate the compiled-to-native wrapper code
2018 nm = SharedRuntime::generate_native_wrapper(&_masm,
2019 method,
2020 total_args_passed,
2021 comp_args_on_stack,
2022 sig_bt,regs,
2023 ret_type);
2024 }
2025 }
2026
2027 // Must unlock before calling set_code
2028 // Install the generated code.
2029 if (nm != NULL) {
2030 method->set_code(method, nm);
2031 nm->post_compiled_method_load_event();
2032 } else {
2033 // CodeCache is full, disable compilation
2034 // Ought to log this but compile log is only per compile thread
2035 // and we're some non descript Java thread.
2036 MutexUnlocker mu(AdapterHandlerLibrary_lock);
2037 CompileBroker::handle_full_code_cache();
2038 }
2039 return nm;
2040 }
2041
2042 #ifdef HAVE_DTRACE_H
2043 // Create a dtrace nmethod for this method. The wrapper converts the
2044 // java compiled calling convention to the native convention, makes a dummy call
2045 // (actually nops for the size of the call instruction, which become a trap if
2046 // probe is enabled). The returns to the caller. Since this all looks like a
2047 // leaf no thread transition is needed.
2048
2049 nmethod *AdapterHandlerLibrary::create_dtrace_nmethod(methodHandle method) {
2050 ResourceMark rm;
2051 nmethod* nm = NULL;
2052
2053 if (PrintCompilation) {
2054 ttyLocker ttyl;
2055 tty->print("--- n%s ");
2056 method->print_short_name(tty);
2057 if (method->is_static()) {
|