Mercurial > hg > truffle
comparison src/share/vm/runtime/sharedRuntime.cpp @ 1216:7f8790caccb0
Merge
author | apangin |
---|---|
date | Thu, 04 Feb 2010 15:50:59 -0800 |
parents | 6deeaebad47a 74c848d437ab |
children | 7b4415a18c8a |
comparison
equal
deleted
inserted
replaced
1215:f19bf22685cc | 1216:7f8790caccb0 |
---|---|
1031 // MethodHandle invokes don't have a CompiledIC and should always | 1031 // MethodHandle invokes don't have a CompiledIC and should always |
1032 // simply redispatch to the callee_target. | 1032 // simply redispatch to the callee_target. |
1033 address sender_pc = caller_frame.pc(); | 1033 address sender_pc = caller_frame.pc(); |
1034 CodeBlob* sender_cb = caller_frame.cb(); | 1034 CodeBlob* sender_cb = caller_frame.cb(); |
1035 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); | 1035 nmethod* sender_nm = sender_cb->as_nmethod_or_null(); |
1036 bool is_mh_invoke_via_adapter = false; // Direct c2c call or via adapter? | |
1037 if (sender_nm != NULL && sender_nm->is_method_handle_return(sender_pc)) { | |
1038 // If the callee_target is set, then we have come here via an i2c | |
1039 // adapter. | |
1040 methodOop callee = thread->callee_target(); | |
1041 if (callee != NULL) { | |
1042 assert(callee->is_method(), "sanity"); | |
1043 is_mh_invoke_via_adapter = true; | |
1044 } | |
1045 } | |
1036 | 1046 |
1037 if (caller_frame.is_interpreted_frame() || | 1047 if (caller_frame.is_interpreted_frame() || |
1038 caller_frame.is_entry_frame() || | 1048 caller_frame.is_entry_frame() || |
1039 (sender_nm != NULL && sender_nm->is_method_handle_return(sender_pc))) { | 1049 is_mh_invoke_via_adapter) { |
1040 methodOop callee = thread->callee_target(); | 1050 methodOop callee = thread->callee_target(); |
1041 guarantee(callee != NULL && callee->is_method(), "bad handshake"); | 1051 guarantee(callee != NULL && callee->is_method(), "bad handshake"); |
1042 thread->set_vm_result(callee); | 1052 thread->set_vm_result(callee); |
1043 thread->set_callee_target(NULL); | 1053 thread->set_callee_target(NULL); |
1044 return callee->get_c2i_entry(); | 1054 return callee->get_c2i_entry(); |
1349 | 1359 |
1350 // --------------------------------------------------------------------------- | 1360 // --------------------------------------------------------------------------- |
1351 // We are calling the interpreter via a c2i. Normally this would mean that | 1361 // We are calling the interpreter via a c2i. Normally this would mean that |
1352 // we were called by a compiled method. However we could have lost a race | 1362 // we were called by a compiled method. However we could have lost a race |
1353 // where we went int -> i2c -> c2i and so the caller could in fact be | 1363 // where we went int -> i2c -> c2i and so the caller could in fact be |
1354 // interpreted. If the caller is compiled we attampt to patch the caller | 1364 // interpreted. If the caller is compiled we attempt to patch the caller |
1355 // so he no longer calls into the interpreter. | 1365 // so he no longer calls into the interpreter. |
1356 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(methodOopDesc* method, address caller_pc)) | 1366 IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(methodOopDesc* method, address caller_pc)) |
1357 methodOop moop(method); | 1367 methodOop moop(method); |
1358 | 1368 |
1359 address entry_point = moop->from_compiled_entry(); | 1369 address entry_point = moop->from_compiled_entry(); |
1365 // Also it is possible that we lost a race in that from_compiled_entry | 1375 // Also it is possible that we lost a race in that from_compiled_entry |
1366 // is now back to the i2c in that case we don't need to patch and if | 1376 // is now back to the i2c in that case we don't need to patch and if |
1367 // we did we'd leap into space because the callsite needs to use | 1377 // we did we'd leap into space because the callsite needs to use |
1368 // "to interpreter" stub in order to load up the methodOop. Don't | 1378 // "to interpreter" stub in order to load up the methodOop. Don't |
1369 // ask me how I know this... | 1379 // ask me how I know this... |
1370 // | |
1371 | 1380 |
1372 CodeBlob* cb = CodeCache::find_blob(caller_pc); | 1381 CodeBlob* cb = CodeCache::find_blob(caller_pc); |
1373 if ( !cb->is_nmethod() || entry_point == moop->get_c2i_entry()) { | 1382 if (!cb->is_nmethod() || entry_point == moop->get_c2i_entry()) { |
1383 return; | |
1384 } | |
1385 | |
1386 // The check above makes sure this is a nmethod. | |
1387 nmethod* nm = cb->as_nmethod_or_null(); | |
1388 assert(nm, "must be"); | |
1389 | |
1390 // Don't fixup MethodHandle call sites as c2i/i2c adapters are used | |
1391 // to implement MethodHandle actions. | |
1392 if (nm->is_method_handle_return(caller_pc)) { | |
1374 return; | 1393 return; |
1375 } | 1394 } |
1376 | 1395 |
1377 // There is a benign race here. We could be attempting to patch to a compiled | 1396 // There is a benign race here. We could be attempting to patch to a compiled |
1378 // entry point at the same time the callee is being deoptimized. If that is | 1397 // entry point at the same time the callee is being deoptimized. If that is |
1383 // from_compiled_entry and the NULL isn't present yet then we lose the race | 1402 // from_compiled_entry and the NULL isn't present yet then we lose the race |
1384 // and patch the code with the same old data. Asi es la vida. | 1403 // and patch the code with the same old data. Asi es la vida. |
1385 | 1404 |
1386 if (moop->code() == NULL) return; | 1405 if (moop->code() == NULL) return; |
1387 | 1406 |
1388 if (((nmethod*)cb)->is_in_use()) { | 1407 if (nm->is_in_use()) { |
1389 | 1408 |
1390 // Expect to find a native call there (unless it was no-inline cache vtable dispatch) | 1409 // Expect to find a native call there (unless it was no-inline cache vtable dispatch) |
1391 MutexLockerEx ml_patch(Patching_lock, Mutex::_no_safepoint_check_flag); | 1410 MutexLockerEx ml_patch(Patching_lock, Mutex::_no_safepoint_check_flag); |
1392 if (NativeCall::is_call_before(caller_pc + frame::pc_return_offset)) { | 1411 if (NativeCall::is_call_before(caller_pc + frame::pc_return_offset)) { |
1393 NativeCall *call = nativeCall_before(caller_pc + frame::pc_return_offset); | 1412 NativeCall *call = nativeCall_before(caller_pc + frame::pc_return_offset); |
1415 CodeBlob* callee = CodeCache::find_blob(destination); | 1434 CodeBlob* callee = CodeCache::find_blob(destination); |
1416 // callee == cb seems weird. It means calling interpreter thru stub. | 1435 // callee == cb seems weird. It means calling interpreter thru stub. |
1417 if (callee == cb || callee->is_adapter_blob()) { | 1436 if (callee == cb || callee->is_adapter_blob()) { |
1418 // static call or optimized virtual | 1437 // static call or optimized virtual |
1419 if (TraceCallFixup) { | 1438 if (TraceCallFixup) { |
1420 tty->print("fixup callsite at " INTPTR_FORMAT " to compiled code for", caller_pc); | 1439 tty->print("fixup callsite at " INTPTR_FORMAT " to compiled code for", caller_pc); |
1421 moop->print_short_name(tty); | 1440 moop->print_short_name(tty); |
1422 tty->print_cr(" to " INTPTR_FORMAT, entry_point); | 1441 tty->print_cr(" to " INTPTR_FORMAT, entry_point); |
1423 } | 1442 } |
1424 call->set_destination_mt_safe(entry_point); | 1443 call->set_destination_mt_safe(entry_point); |
1425 } else { | 1444 } else { |
1431 // assert is too strong could also be resolve destinations. | 1450 // assert is too strong could also be resolve destinations. |
1432 // assert(InlineCacheBuffer::contains(destination) || VtableStubs::contains(destination), "must be"); | 1451 // assert(InlineCacheBuffer::contains(destination) || VtableStubs::contains(destination), "must be"); |
1433 } | 1452 } |
1434 } else { | 1453 } else { |
1435 if (TraceCallFixup) { | 1454 if (TraceCallFixup) { |
1436 tty->print("already patched callsite at " INTPTR_FORMAT " to compiled code for", caller_pc); | 1455 tty->print("already patched callsite at " INTPTR_FORMAT " to compiled code for", caller_pc); |
1437 moop->print_short_name(tty); | 1456 moop->print_short_name(tty); |
1438 tty->print_cr(" to " INTPTR_FORMAT, entry_point); | 1457 tty->print_cr(" to " INTPTR_FORMAT, entry_point); |
1439 } | 1458 } |
1440 } | 1459 } |
1441 } | 1460 } |
1785 // A simple wrapper class around the calling convention information | 1804 // A simple wrapper class around the calling convention information |
1786 // that allows sharing of adapters for the same calling convention. | 1805 // that allows sharing of adapters for the same calling convention. |
1787 class AdapterFingerPrint : public CHeapObj { | 1806 class AdapterFingerPrint : public CHeapObj { |
1788 private: | 1807 private: |
1789 union { | 1808 union { |
1790 signed char _compact[12]; | 1809 int _compact[3]; |
1791 int _compact_int[3]; | 1810 int* _fingerprint; |
1792 intptr_t* _fingerprint; | |
1793 } _value; | 1811 } _value; |
1794 int _length; // A negative length indicates that _value._fingerprint is the array. | 1812 int _length; // A negative length indicates the fingerprint is in the compact form, |
1795 // Otherwise it's in the compact form. | 1813 // Otherwise _value._fingerprint is the array. |
1814 | |
1815 // Remap BasicTypes that are handled equivalently by the adapters. | |
1816 // These are correct for the current system but someday it might be | |
1817 // necessary to make this mapping platform dependent. | |
1818 static BasicType adapter_encoding(BasicType in) { | |
1819 assert((~0xf & in) == 0, "must fit in 4 bits"); | |
1820 switch(in) { | |
1821 case T_BOOLEAN: | |
1822 case T_BYTE: | |
1823 case T_SHORT: | |
1824 case T_CHAR: | |
1825 // There are all promoted to T_INT in the calling convention | |
1826 return T_INT; | |
1827 | |
1828 case T_OBJECT: | |
1829 case T_ARRAY: | |
1830 if (!TaggedStackInterpreter) { | |
1831 #ifdef _LP64 | |
1832 return T_LONG; | |
1833 #else | |
1834 return T_INT; | |
1835 #endif | |
1836 } | |
1837 return T_OBJECT; | |
1838 | |
1839 case T_INT: | |
1840 case T_LONG: | |
1841 case T_FLOAT: | |
1842 case T_DOUBLE: | |
1843 case T_VOID: | |
1844 return in; | |
1845 | |
1846 default: | |
1847 ShouldNotReachHere(); | |
1848 return T_CONFLICT; | |
1849 } | |
1850 } | |
1796 | 1851 |
1797 public: | 1852 public: |
1798 AdapterFingerPrint(int total_args_passed, VMRegPair* regs) { | 1853 AdapterFingerPrint(int total_args_passed, BasicType* sig_bt) { |
1799 assert(sizeof(_value._compact) == sizeof(_value._compact_int), "must match"); | 1854 // The fingerprint is based on the BasicType signature encoded |
1800 _length = total_args_passed * 2; | 1855 // into an array of ints with four entries per int. |
1801 if (_length < (int)sizeof(_value._compact)) { | 1856 int* ptr; |
1802 _value._compact_int[0] = _value._compact_int[1] = _value._compact_int[2] = 0; | 1857 int len = (total_args_passed + 3) >> 2; |
1858 if (len <= (int)(sizeof(_value._compact) / sizeof(int))) { | |
1859 _value._compact[0] = _value._compact[1] = _value._compact[2] = 0; | |
1803 // Storing the signature encoded as signed chars hits about 98% | 1860 // Storing the signature encoded as signed chars hits about 98% |
1804 // of the time. | 1861 // of the time. |
1805 signed char* ptr = _value._compact; | 1862 _length = -len; |
1806 int o = 0; | 1863 ptr = _value._compact; |
1807 for (int i = 0; i < total_args_passed; i++) { | 1864 } else { |
1808 VMRegPair pair = regs[i]; | 1865 _length = len; |
1809 intptr_t v1 = pair.first()->value(); | 1866 _value._fingerprint = NEW_C_HEAP_ARRAY(int, _length); |
1810 intptr_t v2 = pair.second()->value(); | 1867 ptr = _value._fingerprint; |
1811 if (v1 == (signed char) v1 && | 1868 } |
1812 v2 == (signed char) v2) { | 1869 |
1813 _value._compact[o++] = v1; | 1870 // Now pack the BasicTypes with 4 per int |
1814 _value._compact[o++] = v2; | 1871 int sig_index = 0; |
1815 } else { | 1872 for (int index = 0; index < len; index++) { |
1816 goto big; | 1873 int value = 0; |
1874 for (int byte = 0; byte < 4; byte++) { | |
1875 if (sig_index < total_args_passed) { | |
1876 value = (value << 4) | adapter_encoding(sig_bt[sig_index++]); | |
1817 } | 1877 } |
1818 } | 1878 } |
1819 _length = -_length; | 1879 ptr[index] = value; |
1820 return; | 1880 } |
1821 } | |
1822 big: | |
1823 _value._fingerprint = NEW_C_HEAP_ARRAY(intptr_t, _length); | |
1824 int o = 0; | |
1825 for (int i = 0; i < total_args_passed; i++) { | |
1826 VMRegPair pair = regs[i]; | |
1827 intptr_t v1 = pair.first()->value(); | |
1828 intptr_t v2 = pair.second()->value(); | |
1829 _value._fingerprint[o++] = v1; | |
1830 _value._fingerprint[o++] = v2; | |
1831 } | |
1832 } | |
1833 | |
1834 AdapterFingerPrint(AdapterFingerPrint* orig) { | |
1835 _length = orig->_length; | |
1836 _value = orig->_value; | |
1837 // take ownership of any storage by destroying the length | |
1838 orig->_length = 0; | |
1839 } | 1881 } |
1840 | 1882 |
1841 ~AdapterFingerPrint() { | 1883 ~AdapterFingerPrint() { |
1842 if (_length > 0) { | 1884 if (_length > 0) { |
1843 FREE_C_HEAP_ARRAY(int, _value._fingerprint); | 1885 FREE_C_HEAP_ARRAY(int, _value._fingerprint); |
1844 } | 1886 } |
1845 } | 1887 } |
1846 | 1888 |
1847 AdapterFingerPrint* allocate() { | 1889 int value(int index) { |
1848 return new AdapterFingerPrint(this); | |
1849 } | |
1850 | |
1851 intptr_t value(int index) { | |
1852 if (_length < 0) { | 1890 if (_length < 0) { |
1853 return _value._compact[index]; | 1891 return _value._compact[index]; |
1854 } | 1892 } |
1855 return _value._fingerprint[index]; | 1893 return _value._fingerprint[index]; |
1856 } | 1894 } |
1862 bool is_compact() { | 1900 bool is_compact() { |
1863 return _length <= 0; | 1901 return _length <= 0; |
1864 } | 1902 } |
1865 | 1903 |
1866 unsigned int compute_hash() { | 1904 unsigned int compute_hash() { |
1867 intptr_t hash = 0; | 1905 int hash = 0; |
1868 for (int i = 0; i < length(); i++) { | 1906 for (int i = 0; i < length(); i++) { |
1869 intptr_t v = value(i); | 1907 int v = value(i); |
1870 hash = (hash << 8) ^ v ^ (hash >> 5); | 1908 hash = (hash << 8) ^ v ^ (hash >> 5); |
1871 } | 1909 } |
1872 return (unsigned int)hash; | 1910 return (unsigned int)hash; |
1873 } | 1911 } |
1874 | 1912 |
1883 bool equals(AdapterFingerPrint* other) { | 1921 bool equals(AdapterFingerPrint* other) { |
1884 if (other->_length != _length) { | 1922 if (other->_length != _length) { |
1885 return false; | 1923 return false; |
1886 } | 1924 } |
1887 if (_length < 0) { | 1925 if (_length < 0) { |
1888 return _value._compact_int[0] == other->_value._compact_int[0] && | 1926 return _value._compact[0] == other->_value._compact[0] && |
1889 _value._compact_int[1] == other->_value._compact_int[1] && | 1927 _value._compact[1] == other->_value._compact[1] && |
1890 _value._compact_int[2] == other->_value._compact_int[2]; | 1928 _value._compact[2] == other->_value._compact[2]; |
1891 } else { | 1929 } else { |
1892 for (int i = 0; i < _length; i++) { | 1930 for (int i = 0; i < _length; i++) { |
1893 if (_value._fingerprint[i] != other->_value._fingerprint[i]) { | 1931 if (_value._fingerprint[i] != other->_value._fingerprint[i]) { |
1894 return false; | 1932 return false; |
1895 } | 1933 } |
1933 void add(AdapterHandlerEntry* entry) { | 1971 void add(AdapterHandlerEntry* entry) { |
1934 int index = hash_to_index(entry->hash()); | 1972 int index = hash_to_index(entry->hash()); |
1935 add_entry(index, entry); | 1973 add_entry(index, entry); |
1936 } | 1974 } |
1937 | 1975 |
1976 void free_entry(AdapterHandlerEntry* entry) { | |
1977 entry->deallocate(); | |
1978 BasicHashtable::free_entry(entry); | |
1979 } | |
1980 | |
1938 // Find a entry with the same fingerprint if it exists | 1981 // Find a entry with the same fingerprint if it exists |
1939 AdapterHandlerEntry* lookup(int total_args_passed, VMRegPair* regs) { | 1982 AdapterHandlerEntry* lookup(int total_args_passed, BasicType* sig_bt) { |
1940 debug_only(_lookups++); | 1983 debug_only(_lookups++); |
1941 AdapterFingerPrint fp(total_args_passed, regs); | 1984 AdapterFingerPrint fp(total_args_passed, sig_bt); |
1942 unsigned int hash = fp.compute_hash(); | 1985 unsigned int hash = fp.compute_hash(); |
1943 int index = hash_to_index(hash); | 1986 int index = hash_to_index(hash); |
1944 for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) { | 1987 for (AdapterHandlerEntry* e = bucket(index); e != NULL; e = e->next()) { |
1945 debug_only(_buckets++); | 1988 debug_only(_buckets++); |
1946 if (e->hash() == hash) { | 1989 if (e->hash() == hash) { |
2108 if (ss.type() == T_LONG || ss.type() == T_DOUBLE) | 2151 if (ss.type() == T_LONG || ss.type() == T_DOUBLE) |
2109 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots | 2152 sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots |
2110 } | 2153 } |
2111 assert(i == total_args_passed, ""); | 2154 assert(i == total_args_passed, ""); |
2112 | 2155 |
2156 // Lookup method signature's fingerprint | |
2157 entry = _adapters->lookup(total_args_passed, sig_bt); | |
2158 | |
2159 #ifdef ASSERT | |
2160 AdapterHandlerEntry* shared_entry = NULL; | |
2161 if (VerifyAdapterSharing && entry != NULL) { | |
2162 shared_entry = entry; | |
2163 entry = NULL; | |
2164 } | |
2165 #endif | |
2166 | |
2167 if (entry != NULL) { | |
2168 return entry; | |
2169 } | |
2170 | |
2113 // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage | 2171 // Get a description of the compiled java calling convention and the largest used (VMReg) stack slot usage |
2114 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); | 2172 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); |
2115 | 2173 |
2116 // Lookup method signature's fingerprint | |
2117 entry = _adapters->lookup(total_args_passed, regs); | |
2118 if (entry != NULL) { | |
2119 return entry; | |
2120 } | |
2121 | |
2122 // Make a C heap allocated version of the fingerprint to store in the adapter | 2174 // Make a C heap allocated version of the fingerprint to store in the adapter |
2123 fingerprint = new AdapterFingerPrint(total_args_passed, regs); | 2175 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt); |
2124 | 2176 |
2125 // Create I2C & C2I handlers | 2177 // Create I2C & C2I handlers |
2126 | 2178 |
2127 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2179 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2128 if (buf != NULL) { | 2180 if (buf != NULL) { |
2137 comp_args_on_stack, | 2189 comp_args_on_stack, |
2138 sig_bt, | 2190 sig_bt, |
2139 regs, | 2191 regs, |
2140 fingerprint); | 2192 fingerprint); |
2141 | 2193 |
2194 #ifdef ASSERT | |
2195 if (VerifyAdapterSharing) { | |
2196 if (shared_entry != NULL) { | |
2197 assert(shared_entry->compare_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt), | |
2198 "code must match"); | |
2199 // Release the one just created and return the original | |
2200 _adapters->free_entry(entry); | |
2201 return shared_entry; | |
2202 } else { | |
2203 entry->save_code(buf->instructions_begin(), buffer.code_size(), total_args_passed, sig_bt); | |
2204 } | |
2205 } | |
2206 #endif | |
2207 | |
2142 B = BufferBlob::create(AdapterHandlerEntry::name, &buffer); | 2208 B = BufferBlob::create(AdapterHandlerEntry::name, &buffer); |
2143 NOT_PRODUCT(code_size = buffer.code_size()); | 2209 NOT_PRODUCT(code_size = buffer.code_size()); |
2144 } | 2210 } |
2145 if (B == NULL) { | 2211 if (B == NULL) { |
2146 // CodeCache is full, disable compilation | 2212 // CodeCache is full, disable compilation |
2147 // Ought to log this but compile log is only per compile thread | 2213 // Ought to log this but compile log is only per compile thread |
2148 // and we're some non descript Java thread. | 2214 // and we're some non descript Java thread. |
2149 UseInterpreter = true; | 2215 MutexUnlocker mu(AdapterHandlerLibrary_lock); |
2150 if (UseCompiler || AlwaysCompileLoopMethods ) { | 2216 CompileBroker::handle_full_code_cache(); |
2151 #ifndef PRODUCT | |
2152 warning("CodeCache is full. Compiler has been disabled"); | |
2153 if (CompileTheWorld || ExitOnFullCodeCache) { | |
2154 before_exit(JavaThread::current()); | |
2155 exit_globals(); // will delete tty | |
2156 vm_direct_exit(CompileTheWorld ? 0 : 1); | |
2157 } | |
2158 #endif | |
2159 UseCompiler = false; | |
2160 AlwaysCompileLoopMethods = false; | |
2161 } | |
2162 return NULL; // Out of CodeCache space | 2217 return NULL; // Out of CodeCache space |
2163 } | 2218 } |
2164 entry->relocate(B->instructions_begin()); | 2219 entry->relocate(B->instructions_begin()); |
2165 #ifndef PRODUCT | 2220 #ifndef PRODUCT |
2166 // debugging suppport | 2221 // debugging suppport |
2201 ptrdiff_t delta = new_base - _i2c_entry; | 2256 ptrdiff_t delta = new_base - _i2c_entry; |
2202 _i2c_entry += delta; | 2257 _i2c_entry += delta; |
2203 _c2i_entry += delta; | 2258 _c2i_entry += delta; |
2204 _c2i_unverified_entry += delta; | 2259 _c2i_unverified_entry += delta; |
2205 } | 2260 } |
2261 | |
2262 | |
2263 void AdapterHandlerEntry::deallocate() { | |
2264 delete _fingerprint; | |
2265 #ifdef ASSERT | |
2266 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code); | |
2267 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig); | |
2268 #endif | |
2269 } | |
2270 | |
2271 | |
2272 #ifdef ASSERT | |
2273 // Capture the code before relocation so that it can be compared | |
2274 // against other versions. If the code is captured after relocation | |
2275 // then relative instructions won't be equivalent. | |
2276 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | |
2277 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length); | |
2278 _code_length = length; | |
2279 memcpy(_saved_code, buffer, length); | |
2280 _total_args_passed = total_args_passed; | |
2281 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed); | |
2282 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); | |
2283 } | |
2284 | |
2285 | |
2286 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | |
2287 if (length != _code_length) { | |
2288 return false; | |
2289 } | |
2290 for (int i = 0; i < length; i++) { | |
2291 if (buffer[i] != _saved_code[i]) { | |
2292 return false; | |
2293 } | |
2294 } | |
2295 return true; | |
2296 } | |
2297 #endif | |
2298 | |
2206 | 2299 |
2207 // Create a native wrapper for this native method. The wrapper converts the | 2300 // Create a native wrapper for this native method. The wrapper converts the |
2208 // java compiled calling convention to the native convention, handlizes | 2301 // java compiled calling convention to the native convention, handlizes |
2209 // arguments, and transitions to native. On return from the native we transition | 2302 // arguments, and transitions to native. On return from the native we transition |
2210 // back to java blocking if a safepoint is in progress. | 2303 // back to java blocking if a safepoint is in progress. |
2280 nm->post_compiled_method_load_event(); | 2373 nm->post_compiled_method_load_event(); |
2281 } else { | 2374 } else { |
2282 // CodeCache is full, disable compilation | 2375 // CodeCache is full, disable compilation |
2283 // Ought to log this but compile log is only per compile thread | 2376 // Ought to log this but compile log is only per compile thread |
2284 // and we're some non descript Java thread. | 2377 // and we're some non descript Java thread. |
2285 UseInterpreter = true; | 2378 MutexUnlocker mu(AdapterHandlerLibrary_lock); |
2286 if (UseCompiler || AlwaysCompileLoopMethods ) { | 2379 CompileBroker::handle_full_code_cache(); |
2287 #ifndef PRODUCT | |
2288 warning("CodeCache is full. Compiler has been disabled"); | |
2289 if (CompileTheWorld || ExitOnFullCodeCache) { | |
2290 before_exit(JavaThread::current()); | |
2291 exit_globals(); // will delete tty | |
2292 vm_direct_exit(CompileTheWorld ? 0 : 1); | |
2293 } | |
2294 #endif | |
2295 UseCompiler = false; | |
2296 AlwaysCompileLoopMethods = false; | |
2297 } | |
2298 } | 2380 } |
2299 return nm; | 2381 return nm; |
2300 } | 2382 } |
2301 | 2383 |
2302 #ifdef HAVE_DTRACE_H | 2384 #ifdef HAVE_DTRACE_H |