comparison src/share/vm/runtime/javaCalls.cpp @ 14768:3e9a960f0da1

HSAIL: preliminary deopt support Contributed-by: Tom Deneau <tom.deneau@amd.com>
author Doug Simon <doug.simon@oracle.com>
date Wed, 26 Mar 2014 17:33:54 +0100
parents d8041d695d19
children 4ca6dc0799b6
comparison
equal deleted inserted replaced
14767:ded08e344e4a 14768:3e9a960f0da1
38 #include "runtime/javaCalls.hpp" 38 #include "runtime/javaCalls.hpp"
39 #include "runtime/mutexLocker.hpp" 39 #include "runtime/mutexLocker.hpp"
40 #include "runtime/signature.hpp" 40 #include "runtime/signature.hpp"
41 #include "runtime/stubRoutines.hpp" 41 #include "runtime/stubRoutines.hpp"
42 #include "runtime/thread.inline.hpp" 42 #include "runtime/thread.inline.hpp"
43 #include "graal/graalJavaAccess.hpp"
44 #include "graal/graalCompiler.hpp"
43 45
44 // ----------------------------------------------------- 46 // -----------------------------------------------------
45 // Implementation of JavaCallWrapper 47 // Implementation of JavaCallWrapper
46 48
47 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) { 49 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, JavaValue* result, TRAPS) {
48 JavaThread* thread = (JavaThread *)THREAD; 50 JavaThread* thread = (JavaThread *)THREAD;
49 bool clear_pending_exception = true; 51 bool clear_pending_exception = true;
50 52
51 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code"); 53 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
52 assert(!thread->owns_locks(), "must release all locks when leaving VM"); 54 assert(!thread->owns_locks(), "must release all locks when leaving VM");
73 75
74 76
75 // Make sure to set the oop's after the thread transition - since we can block there. No one is GC'ing 77 // Make sure to set the oop's after the thread transition - since we can block there. No one is GC'ing
76 // the JavaCallWrapper before the entry frame is on the stack. 78 // the JavaCallWrapper before the entry frame is on the stack.
77 _callee_method = callee_method(); 79 _callee_method = callee_method();
78 _receiver = receiver();
79 80
80 #ifdef CHECK_UNHANDLED_OOPS 81 #ifdef CHECK_UNHANDLED_OOPS
81 THREAD->allow_unhandled_oop(&_receiver); 82 // THREAD->allow_unhandled_oop(&_receiver);
82 #endif // CHECK_UNHANDLED_OOPS 83 #endif // CHECK_UNHANDLED_OOPS
83 84
84 _thread = (JavaThread *)thread; 85 _thread = (JavaThread *)thread;
85 _handles = _thread->active_handles(); // save previous handle block & Java frame linkage 86 _handles = _thread->active_handles(); // save previous handle block & Java frame linkage
86 87
140 JNIHandleBlock::release_block(_old_handles, _thread); 141 JNIHandleBlock::release_block(_old_handles, _thread);
141 } 142 }
142 143
143 144
144 void JavaCallWrapper::oops_do(OopClosure* f) { 145 void JavaCallWrapper::oops_do(OopClosure* f) {
145 f->do_oop((oop*)&_receiver);
146 handles()->oops_do(f); 146 handles()->oops_do(f);
147 } 147 }
148 148
149 149
150 // Helper methods 150 // Helper methods
333 assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here"); 333 assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here");
334 334
335 335
336 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) 336 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
337 337
338 #ifdef GRAAL
339 nmethod* nm = args->alternative_target();
340 if (nm == NULL) {
341 #endif
338 // Verify the arguments 342 // Verify the arguments
339 343
340 if (CheckJNICalls) { 344 if (CheckJNICalls) {
341 args->verify(method, result->get_type(), thread); 345 args->verify(method, result->get_type(), thread);
342 } 346 }
343 else debug_only(args->verify(method, result->get_type(), thread)); 347 else debug_only(args->verify(method, result->get_type(), thread));
344 348 #ifdef GRAAL
345 #ifndef GRAAL 349 }
350 #else
346 // Ignore call if method is empty 351 // Ignore call if method is empty
347 if (method->is_empty_method()) { 352 if (method->is_empty_method()) {
348 assert(result->get_type() == T_VOID, "an empty method must return a void value"); 353 assert(result->get_type() == T_VOID, "an empty method must return a void value");
349 return; 354 return;
350 } 355 }
382 bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY); 387 bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY);
383 388
384 // NOTE: if we move the computation of the result_val_address inside 389 // NOTE: if we move the computation of the result_val_address inside
385 // the call to call_stub, the optimizer produces wrong code. 390 // the call to call_stub, the optimizer produces wrong code.
386 intptr_t* result_val_address = (intptr_t*)(result->get_value_addr()); 391 intptr_t* result_val_address = (intptr_t*)(result->get_value_addr());
387
388 // Find receiver
389 Handle receiver = (!method->is_static()) ? args->receiver() : Handle();
390 392
391 // When we reenter Java, we need to reenable the yellow zone which 393 // When we reenter Java, we need to reenable the yellow zone which
392 // might already be disabled when we are in VM. 394 // might already be disabled when we are in VM.
393 if (thread->stack_yellow_zone_disabled()) { 395 if (thread->stack_yellow_zone_disabled()) {
394 thread->reguard_stack(); 396 thread->reguard_stack();
404 // Touch pages checked if the OS needs them to be touched to be mapped. 406 // Touch pages checked if the OS needs them to be touched to be mapped.
405 os::bang_stack_shadow_pages(); 407 os::bang_stack_shadow_pages();
406 } 408 }
407 409
408 #ifdef GRAAL 410 #ifdef GRAAL
409 nmethod* nm = args->alternative_target();
410 if (nm != NULL) { 411 if (nm != NULL) {
411 if (nm->is_alive()) { 412 if (nm->is_alive()) {
412 ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point()); 413 ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point());
414 oop graalInstalledCode = nm->graal_installed_code();
415 if (graalInstalledCode != NULL && HotSpotNmethod::isExternal(graalInstalledCode)) {
416 entry_point = GraalCompiler::instance()->get_external_deopt_i2c_entry();
417 } else {
413 entry_point = method->adapter()->get_i2c_entry(); 418 entry_point = method->adapter()->get_i2c_entry();
419 }
414 } else { 420 } else {
415 THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException()); 421 THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException());
416 } 422 }
417 } 423 }
418 #endif 424 #endif
419 425
420 // do call 426 // do call
421 { JavaCallWrapper link(method, receiver, result, CHECK); 427 { JavaCallWrapper link(method, result, CHECK);
422 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner 428 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner
423 429
424 StubRoutines::call_stub()( 430 StubRoutines::call_stub()(
425 (address)&link, 431 (address)&link,
426 // (intptr_t*)&(result->_value), // see NOTE above (compiler problem) 432 // (intptr_t*)&(result->_value), // see NOTE above (compiler problem)