comparison src/share/vm/runtime/sharedRuntime.cpp @ 3464:be4ca325525a

Merge.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Jul 2011 17:32:44 -0700
parents fecdb0a65fb2 38fa55e5e792
children 04b9a2566eec
comparison
equal deleted inserted replaced
3239:7c4b4daac19b 3464:be4ca325525a
78 #endif 78 #endif
79 #ifdef COMPILER1 79 #ifdef COMPILER1
80 #include "c1/c1_Runtime1.hpp" 80 #include "c1/c1_Runtime1.hpp"
81 #endif 81 #endif
82 82
83 // Shared stub locations
84 RuntimeStub* SharedRuntime::_wrong_method_blob;
85 RuntimeStub* SharedRuntime::_ic_miss_blob;
86 RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob;
87 RuntimeStub* SharedRuntime::_resolve_virtual_call_blob;
88 RuntimeStub* SharedRuntime::_resolve_static_call_blob;
89
90 DeoptimizationBlob* SharedRuntime::_deopt_blob;
91 RicochetBlob* SharedRuntime::_ricochet_blob;
92
93 SafepointBlob* SharedRuntime::_polling_page_safepoint_handler_blob;
94 SafepointBlob* SharedRuntime::_polling_page_return_handler_blob;
95
96 #ifdef COMPILER2
97 UncommonTrapBlob* SharedRuntime::_uncommon_trap_blob;
98 #endif // COMPILER2
99
100
101 //----------------------------generate_stubs-----------------------------------
102 void SharedRuntime::generate_stubs() {
103 _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub");
104 _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub");
105 _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call");
106 _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call");
107 _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call");
108
109 _polling_page_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), false);
110 _polling_page_return_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), true);
111
112 generate_ricochet_blob();
113 generate_deopt_blob();
114
115 #ifdef COMPILER2
116 generate_uncommon_trap_blob();
117 #endif // COMPILER2
118 }
119
120 //----------------------------generate_ricochet_blob---------------------------
121 void SharedRuntime::generate_ricochet_blob() {
122 if (!EnableInvokeDynamic) return; // leave it as a null
123
124 #ifndef TARGET_ARCH_NYI_6939861
125 // allocate space for the code
126 ResourceMark rm;
127 // setup code generation tools
128 CodeBuffer buffer("ricochet_blob", 256 LP64_ONLY(+ 256), 256); // XXX x86 LP64L: 512, 512
129 MacroAssembler* masm = new MacroAssembler(&buffer);
130
131 int bounce_offset = -1, exception_offset = -1, frame_size_in_words = -1;
132 MethodHandles::RicochetFrame::generate_ricochet_blob(masm, &bounce_offset, &exception_offset, &frame_size_in_words);
133
134 // -------------
135 // make sure all code is generated
136 masm->flush();
137
138 // failed to generate?
139 if (bounce_offset < 0 || exception_offset < 0 || frame_size_in_words < 0) {
140 assert(false, "bad ricochet blob");
141 return;
142 }
143
144 _ricochet_blob = RicochetBlob::create(&buffer, bounce_offset, exception_offset, frame_size_in_words);
145 #endif
146 }
147
148
83 #include <math.h> 149 #include <math.h>
84 150
85 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); 151 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t);
86 HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int, 152 HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int,
87 char*, int, char*, int, char*, int); 153 char*, int, char*, int, char*, int);
139 205
140 int SharedRuntime::_ICmiss_index = 0; 206 int SharedRuntime::_ICmiss_index = 0;
141 int SharedRuntime::_ICmiss_count[SharedRuntime::maxICmiss_count]; 207 int SharedRuntime::_ICmiss_count[SharedRuntime::maxICmiss_count];
142 address SharedRuntime::_ICmiss_at[SharedRuntime::maxICmiss_count]; 208 address SharedRuntime::_ICmiss_at[SharedRuntime::maxICmiss_count];
143 209
210
144 void SharedRuntime::trace_ic_miss(address at) { 211 void SharedRuntime::trace_ic_miss(address at) {
145 for (int i = 0; i < _ICmiss_index; i++) { 212 for (int i = 0; i < _ICmiss_index; i++) {
146 if (_ICmiss_at[i] == at) { 213 if (_ICmiss_at[i] == at) {
147 _ICmiss_count[i]++; 214 _ICmiss_count[i]++;
148 return; 215 return;
457 return StubRoutines::catch_exception_entry(); 524 return StubRoutines::catch_exception_entry();
458 } 525 }
459 // Interpreted code 526 // Interpreted code
460 if (Interpreter::contains(return_address)) { 527 if (Interpreter::contains(return_address)) {
461 return Interpreter::rethrow_exception_entry(); 528 return Interpreter::rethrow_exception_entry();
529 }
530 // Ricochet frame unwind code
531 if (SharedRuntime::ricochet_blob() != NULL && SharedRuntime::ricochet_blob()->returns_to_bounce_addr(return_address)) {
532 return SharedRuntime::ricochet_blob()->exception_addr();
462 } 533 }
463 534
464 guarantee(blob == NULL || !blob->is_runtime_stub(), "caller should have skipped stub"); 535 guarantee(blob == NULL || !blob->is_runtime_stub(), "caller should have skipped stub");
465 guarantee(!VtableStubs::contains(return_address), "NULL exceptions in vtables should have been handled already!"); 536 guarantee(!VtableStubs::contains(return_address), "NULL exceptions in vtables should have been handled already!");
466 537
706 } 777 }
707 thread->_ScratchA = (intptr_t)pc; 778 thread->_ScratchA = (intptr_t)pc;
708 return (SharedRuntime::deopt_blob()->jmp_uncommon_trap()); 779 return (SharedRuntime::deopt_blob()->jmp_uncommon_trap());
709 } 780 }
710 781
782 JRT_ENTRY(void, SharedRuntime::throw_WrongMethodTypeException(JavaThread* thread, oopDesc* required, oopDesc* actual))
783 assert(thread == JavaThread::current() && required->is_oop() && actual->is_oop(), "bad args");
784 ResourceMark rm;
785 char* message = SharedRuntime::generate_wrong_method_type_message(thread, required, actual);
786 throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_invoke_WrongMethodTypeException(), message);
787 JRT_END
788
711 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, 789 address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread,
712 address pc, 790 address pc,
713 SharedRuntime::ImplicitExceptionKind exception_kind) 791 SharedRuntime::ImplicitExceptionKind exception_kind)
714 { 792 {
715 address target_pc = NULL; 793 address target_pc = NULL;
1203 RegisterMap reg_map(thread, false); 1281 RegisterMap reg_map(thread, false);
1204 frame stub_frame = thread->last_frame(); 1282 frame stub_frame = thread->last_frame();
1205 assert(stub_frame.is_runtime_frame(), "sanity check"); 1283 assert(stub_frame.is_runtime_frame(), "sanity check");
1206 frame caller_frame = stub_frame.sender(&reg_map); 1284 frame caller_frame = stub_frame.sender(&reg_map);
1207 assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame(), "unexpected frame"); 1285 assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame(), "unexpected frame");
1286 assert(!caller_frame.is_ricochet_frame(), "unexpected frame");
1208 #endif /* ASSERT */ 1287 #endif /* ASSERT */
1209 1288
1210 methodHandle callee_method; 1289 methodHandle callee_method;
1211 JRT_BLOCK 1290 JRT_BLOCK
1212 callee_method = SharedRuntime::handle_ic_miss_helper(thread, CHECK_NULL); 1291 callee_method = SharedRuntime::handle_ic_miss_helper(thread, CHECK_NULL);
1251 } 1330 }
1252 } 1331 }
1253 1332
1254 if (caller_frame.is_interpreted_frame() || 1333 if (caller_frame.is_interpreted_frame() ||
1255 caller_frame.is_entry_frame() || 1334 caller_frame.is_entry_frame() ||
1335 caller_frame.is_ricochet_frame() ||
1256 is_mh_invoke_via_adapter) { 1336 is_mh_invoke_via_adapter) {
1257 methodOop callee = thread->callee_target(); 1337 methodOop callee = thread->callee_target();
1258 guarantee(callee != NULL && callee->is_method(), "bad handshake"); 1338 guarantee(callee != NULL && callee->is_method(), "bad handshake");
1259 thread->set_vm_result(callee); 1339 thread->set_vm_result(callee);
1260 thread->set_callee_target(NULL); 1340 thread->set_callee_target(NULL);
1750 && required == target->method_handle_type()) { 1830 && required == target->method_handle_type()) {
1751 targetType = target->signature()->as_C_string(); 1831 targetType = target->signature()->as_C_string();
1752 targetArity = ArgumentCount(target->signature()).size(); 1832 targetArity = ArgumentCount(target->signature()).size();
1753 } 1833 }
1754 } 1834 }
1755 klassOop kignore; int dmf_flags = 0; 1835 KlassHandle kignore; int dmf_flags = 0;
1756 methodOop actual_method = MethodHandles::decode_method(actual, kignore, dmf_flags); 1836 methodHandle actual_method = MethodHandles::decode_method(actual, kignore, dmf_flags);
1757 if ((dmf_flags & ~(MethodHandles::_dmf_has_receiver | 1837 if ((dmf_flags & ~(MethodHandles::_dmf_has_receiver |
1758 MethodHandles::_dmf_does_dispatch | 1838 MethodHandles::_dmf_does_dispatch |
1759 MethodHandles::_dmf_from_interface)) != 0) 1839 MethodHandles::_dmf_from_interface)) != 0)
1760 actual_method = NULL; // MH does extra binds, drops, etc. 1840 actual_method = methodHandle(); // MH does extra binds, drops, etc.
1761 bool has_receiver = ((dmf_flags & MethodHandles::_dmf_has_receiver) != 0); 1841 bool has_receiver = ((dmf_flags & MethodHandles::_dmf_has_receiver) != 0);
1762 if (actual_method != NULL) { 1842 if (actual_method.not_null()) {
1763 mhName = actual_method->signature()->as_C_string(); 1843 mhName = actual_method->signature()->as_C_string();
1764 mhArity = ArgumentCount(actual_method->signature()).size(); 1844 mhArity = ArgumentCount(actual_method->signature()).size();
1765 if (!actual_method->is_static()) mhArity += 1; 1845 if (!actual_method->is_static()) mhArity += 1;
1766 } else if (java_lang_invoke_MethodHandle::is_instance(actual)) { 1846 } else if (java_lang_invoke_MethodHandle::is_instance(actual)) {
1767 oopDesc* mhType = java_lang_invoke_MethodHandle::type(actual); 1847 oopDesc* mhType = java_lang_invoke_MethodHandle::type(actual);