Mercurial > hg > truffle
comparison src/share/vm/runtime/sharedRuntime.cpp @ 4137:04b9a2566eec
Merge with hsx23/hotspot.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 17 Dec 2011 21:40:27 +0100 |
parents | be4ca325525a 2ec638646e86 |
children | 723df37192d6 |
comparison
equal
deleted
inserted
replaced
3737:9dc19b7d89a3 | 4137:04b9a2566eec |
---|---|
146 } | 146 } |
147 | 147 |
148 | 148 |
149 #include <math.h> | 149 #include <math.h> |
150 | 150 |
151 #ifndef USDT2 | |
151 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); | 152 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); |
152 HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int, | 153 HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int, |
153 char*, int, char*, int, char*, int); | 154 char*, int, char*, int, char*, int); |
154 HS_DTRACE_PROBE_DECL7(hotspot, method__return, int, | 155 HS_DTRACE_PROBE_DECL7(hotspot, method__return, int, |
155 char*, int, char*, int, char*, int); | 156 char*, int, char*, int, char*, int); |
157 #endif /* !USDT2 */ | |
156 | 158 |
157 // Implementation of SharedRuntime | 159 // Implementation of SharedRuntime |
158 | 160 |
159 #ifndef PRODUCT | 161 #ifndef PRODUCT |
160 // For statistics | 162 // For statistics |
657 | 659 |
658 int handler_bci = -1; | 660 int handler_bci = -1; |
659 int scope_depth = 0; | 661 int scope_depth = 0; |
660 if (!force_unwind) { | 662 if (!force_unwind) { |
661 int bci = sd->bci(); | 663 int bci = sd->bci(); |
664 bool recursive_exception = false; | |
662 do { | 665 do { |
663 bool skip_scope_increment = false; | 666 bool skip_scope_increment = false; |
664 // exception handler lookup | 667 // exception handler lookup |
665 KlassHandle ek (THREAD, exception->klass()); | 668 KlassHandle ek (THREAD, exception->klass()); |
666 handler_bci = sd->method()->fast_exception_handler_bci_for(ek, bci, THREAD); | 669 handler_bci = sd->method()->fast_exception_handler_bci_for(ek, bci, THREAD); |
667 if (HAS_PENDING_EXCEPTION) { | 670 if (HAS_PENDING_EXCEPTION) { |
671 recursive_exception = true; | |
668 // We threw an exception while trying to find the exception handler. | 672 // We threw an exception while trying to find the exception handler. |
669 // Transfer the new exception to the exception handle which will | 673 // Transfer the new exception to the exception handle which will |
670 // be set into thread local storage, and do another lookup for an | 674 // be set into thread local storage, and do another lookup for an |
671 // exception handler for this exception, this time starting at the | 675 // exception handler for this exception, this time starting at the |
672 // BCI of the exception handler which caused the exception to be | 676 // BCI of the exception handler which caused the exception to be |
678 bci = handler_bci; | 682 bci = handler_bci; |
679 handler_bci = -1; | 683 handler_bci = -1; |
680 skip_scope_increment = true; | 684 skip_scope_increment = true; |
681 } | 685 } |
682 } | 686 } |
687 else { | |
688 recursive_exception = false; | |
689 } | |
683 if (!top_frame_only && handler_bci < 0 && !skip_scope_increment) { | 690 if (!top_frame_only && handler_bci < 0 && !skip_scope_increment) { |
684 sd = sd->sender(); | 691 sd = sd->sender(); |
685 if (sd != NULL) { | 692 if (sd != NULL) { |
686 bci = sd->bci(); | 693 bci = sd->bci(); |
687 } | 694 } |
688 ++scope_depth; | 695 ++scope_depth; |
689 } | 696 } |
690 } while (!top_frame_only && handler_bci < 0 && sd != NULL); | 697 } while (recursive_exception || (!top_frame_only && handler_bci < 0 && sd != NULL)); |
691 } | 698 } |
692 | 699 |
693 // found handling method => lookup exception handler | 700 // found handling method => lookup exception handler |
694 int catch_pco = ret_pc - nm->code_begin(); | 701 int catch_pco = ret_pc - nm->code_begin(); |
695 | 702 |
983 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { | 990 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { |
984 assert(DTraceAllocProbes, "wrong call"); | 991 assert(DTraceAllocProbes, "wrong call"); |
985 Klass* klass = o->blueprint(); | 992 Klass* klass = o->blueprint(); |
986 int size = o->size(); | 993 int size = o->size(); |
987 Symbol* name = klass->name(); | 994 Symbol* name = klass->name(); |
995 #ifndef USDT2 | |
988 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), | 996 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), |
989 name->bytes(), name->utf8_length(), size * HeapWordSize); | 997 name->bytes(), name->utf8_length(), size * HeapWordSize); |
998 #else /* USDT2 */ | |
999 HOTSPOT_OBJECT_ALLOC( | |
1000 get_java_tid(thread), | |
1001 (char *) name->bytes(), name->utf8_length(), size * HeapWordSize); | |
1002 #endif /* USDT2 */ | |
990 return 0; | 1003 return 0; |
991 } | 1004 } |
992 | 1005 |
993 JRT_LEAF(int, SharedRuntime::dtrace_method_entry( | 1006 JRT_LEAF(int, SharedRuntime::dtrace_method_entry( |
994 JavaThread* thread, methodOopDesc* method)) | 1007 JavaThread* thread, methodOopDesc* method)) |
995 assert(DTraceMethodProbes, "wrong call"); | 1008 assert(DTraceMethodProbes, "wrong call"); |
996 Symbol* kname = method->klass_name(); | 1009 Symbol* kname = method->klass_name(); |
997 Symbol* name = method->name(); | 1010 Symbol* name = method->name(); |
998 Symbol* sig = method->signature(); | 1011 Symbol* sig = method->signature(); |
1012 #ifndef USDT2 | |
999 HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread), | 1013 HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread), |
1000 kname->bytes(), kname->utf8_length(), | 1014 kname->bytes(), kname->utf8_length(), |
1001 name->bytes(), name->utf8_length(), | 1015 name->bytes(), name->utf8_length(), |
1002 sig->bytes(), sig->utf8_length()); | 1016 sig->bytes(), sig->utf8_length()); |
1017 #else /* USDT2 */ | |
1018 HOTSPOT_METHOD_ENTRY( | |
1019 get_java_tid(thread), | |
1020 (char *) kname->bytes(), kname->utf8_length(), | |
1021 (char *) name->bytes(), name->utf8_length(), | |
1022 (char *) sig->bytes(), sig->utf8_length()); | |
1023 #endif /* USDT2 */ | |
1003 return 0; | 1024 return 0; |
1004 JRT_END | 1025 JRT_END |
1005 | 1026 |
1006 JRT_LEAF(int, SharedRuntime::dtrace_method_exit( | 1027 JRT_LEAF(int, SharedRuntime::dtrace_method_exit( |
1007 JavaThread* thread, methodOopDesc* method)) | 1028 JavaThread* thread, methodOopDesc* method)) |
1008 assert(DTraceMethodProbes, "wrong call"); | 1029 assert(DTraceMethodProbes, "wrong call"); |
1009 Symbol* kname = method->klass_name(); | 1030 Symbol* kname = method->klass_name(); |
1010 Symbol* name = method->name(); | 1031 Symbol* name = method->name(); |
1011 Symbol* sig = method->signature(); | 1032 Symbol* sig = method->signature(); |
1033 #ifndef USDT2 | |
1012 HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread), | 1034 HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread), |
1013 kname->bytes(), kname->utf8_length(), | 1035 kname->bytes(), kname->utf8_length(), |
1014 name->bytes(), name->utf8_length(), | 1036 name->bytes(), name->utf8_length(), |
1015 sig->bytes(), sig->utf8_length()); | 1037 sig->bytes(), sig->utf8_length()); |
1038 #else /* USDT2 */ | |
1039 HOTSPOT_METHOD_RETURN( | |
1040 get_java_tid(thread), | |
1041 (char *) kname->bytes(), kname->utf8_length(), | |
1042 (char *) name->bytes(), name->utf8_length(), | |
1043 (char *) sig->bytes(), sig->utf8_length()); | |
1044 #endif /* USDT2 */ | |
1016 return 0; | 1045 return 0; |
1017 JRT_END | 1046 JRT_END |
1018 | 1047 |
1019 | 1048 |
1020 // Finds receiver, CallInfo (i.e. receiver method), and calling bytecode) | 1049 // Finds receiver, CallInfo (i.e. receiver method), and calling bytecode) |
1672 | 1701 |
1673 // The check above makes sure this is a nmethod. | 1702 // The check above makes sure this is a nmethod. |
1674 nmethod* nm = cb->as_nmethod_or_null(); | 1703 nmethod* nm = cb->as_nmethod_or_null(); |
1675 assert(nm, "must be"); | 1704 assert(nm, "must be"); |
1676 | 1705 |
1677 // Don't fixup MethodHandle call sites as c2i/i2c adapters are used | 1706 // Get the return PC for the passed caller PC. |
1678 // to implement MethodHandle actions. | 1707 address return_pc = caller_pc + frame::pc_return_offset; |
1679 if (nm->is_method_handle_return(caller_pc)) { | 1708 |
1709 // Don't fixup method handle call sites as the executed method | |
1710 // handle adapters are doing the required MethodHandle chain work. | |
1711 if (nm->is_method_handle_return(return_pc)) { | |
1680 return; | 1712 return; |
1681 } | 1713 } |
1682 | 1714 |
1683 // There is a benign race here. We could be attempting to patch to a compiled | 1715 // There is a benign race here. We could be attempting to patch to a compiled |
1684 // entry point at the same time the callee is being deoptimized. If that is | 1716 // entry point at the same time the callee is being deoptimized. If that is |
1693 | 1725 |
1694 if (nm->is_in_use()) { | 1726 if (nm->is_in_use()) { |
1695 | 1727 |
1696 // Expect to find a native call there (unless it was no-inline cache vtable dispatch) | 1728 // Expect to find a native call there (unless it was no-inline cache vtable dispatch) |
1697 MutexLockerEx ml_patch(Patching_lock, Mutex::_no_safepoint_check_flag); | 1729 MutexLockerEx ml_patch(Patching_lock, Mutex::_no_safepoint_check_flag); |
1698 if (NativeCall::is_call_before(caller_pc + frame::pc_return_offset)) { | 1730 if (NativeCall::is_call_before(return_pc)) { |
1699 NativeCall *call = nativeCall_before(caller_pc + frame::pc_return_offset); | 1731 NativeCall *call = nativeCall_before(return_pc); |
1700 // | 1732 // |
1701 // bug 6281185. We might get here after resolving a call site to a vanilla | 1733 // bug 6281185. We might get here after resolving a call site to a vanilla |
1702 // virtual call. Because the resolvee uses the verified entry it may then | 1734 // virtual call. Because the resolvee uses the verified entry it may then |
1703 // see compiled code and attempt to patch the site by calling us. This would | 1735 // see compiled code and attempt to patch the site by calling us. This would |
1704 // then incorrectly convert the call site to optimized and its downhill from | 1736 // then incorrectly convert the call site to optimized and its downhill from |
1744 tty->print_cr(" to " INTPTR_FORMAT, entry_point); | 1776 tty->print_cr(" to " INTPTR_FORMAT, entry_point); |
1745 } | 1777 } |
1746 } | 1778 } |
1747 } | 1779 } |
1748 } | 1780 } |
1749 | |
1750 IRT_END | 1781 IRT_END |
1751 | 1782 |
1752 | 1783 |
1753 // same as JVM_Arraycopy, but called directly from compiled code | 1784 // same as JVM_Arraycopy, but called directly from compiled code |
1754 JRT_ENTRY(void, SharedRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos, | 1785 JRT_ENTRY(void, SharedRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos, |
2159 } | 2190 } |
2160 | 2191 |
2161 public: | 2192 public: |
2162 AdapterFingerPrint(int total_args_passed, BasicType* sig_bt) { | 2193 AdapterFingerPrint(int total_args_passed, BasicType* sig_bt) { |
2163 // The fingerprint is based on the BasicType signature encoded | 2194 // The fingerprint is based on the BasicType signature encoded |
2164 // into an array of ints with four entries per int. | 2195 // into an array of ints with eight entries per int. |
2165 int* ptr; | 2196 int* ptr; |
2166 int len = (total_args_passed + 3) >> 2; | 2197 int len = (total_args_passed + 7) >> 3; |
2167 if (len <= (int)(sizeof(_value._compact) / sizeof(int))) { | 2198 if (len <= (int)(sizeof(_value._compact) / sizeof(int))) { |
2168 _value._compact[0] = _value._compact[1] = _value._compact[2] = 0; | 2199 _value._compact[0] = _value._compact[1] = _value._compact[2] = 0; |
2169 // Storing the signature encoded as signed chars hits about 98% | 2200 // Storing the signature encoded as signed chars hits about 98% |
2170 // of the time. | 2201 // of the time. |
2171 _length = -len; | 2202 _length = -len; |
2174 _length = len; | 2205 _length = len; |
2175 _value._fingerprint = NEW_C_HEAP_ARRAY(int, _length); | 2206 _value._fingerprint = NEW_C_HEAP_ARRAY(int, _length); |
2176 ptr = _value._fingerprint; | 2207 ptr = _value._fingerprint; |
2177 } | 2208 } |
2178 | 2209 |
2179 // Now pack the BasicTypes with 4 per int | 2210 // Now pack the BasicTypes with 8 per int |
2180 int sig_index = 0; | 2211 int sig_index = 0; |
2181 for (int index = 0; index < len; index++) { | 2212 for (int index = 0; index < len; index++) { |
2182 int value = 0; | 2213 int value = 0; |
2183 for (int byte = 0; byte < 4; byte++) { | 2214 for (int byte = 0; byte < 8; byte++) { |
2184 if (sig_index < total_args_passed) { | 2215 if (sig_index < total_args_passed) { |
2185 value = (value << 4) | adapter_encoding(sig_bt[sig_index++]); | 2216 value = (value << 4) | adapter_encoding(sig_bt[sig_index++]); |
2186 } | 2217 } |
2187 } | 2218 } |
2188 ptr[index] = value; | 2219 ptr[index] = value; |
2219 return (unsigned int)hash; | 2250 return (unsigned int)hash; |
2220 } | 2251 } |
2221 | 2252 |
2222 const char* as_string() { | 2253 const char* as_string() { |
2223 stringStream st; | 2254 stringStream st; |
2255 st.print("0x"); | |
2224 for (int i = 0; i < length(); i++) { | 2256 for (int i = 0; i < length(); i++) { |
2225 st.print(PTR_FORMAT, value(i)); | 2257 st.print("%08x", value(i)); |
2226 } | 2258 } |
2227 return st.as_string(); | 2259 return st.as_string(); |
2228 } | 2260 } |
2229 | 2261 |
2230 bool equals(AdapterFingerPrint* other) { | 2262 bool equals(AdapterFingerPrint* other) { |