Mercurial > hg > graal-jvmci-8
comparison src/share/vm/runtime/javaCalls.cpp @ 18929:8f2fb6bec986
removed GPU code
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 23 Jan 2015 10:54:21 +0100 |
parents | f503236c022e |
children | 96ec4e5d3292 |
comparison
equal
deleted
inserted
replaced
18928:c8fc6e2d128b | 18929:8f2fb6bec986 |
---|---|
46 #endif | 46 #endif |
47 | 47 |
48 // ----------------------------------------------------- | 48 // ----------------------------------------------------- |
49 // Implementation of JavaCallWrapper | 49 // Implementation of JavaCallWrapper |
50 | 50 |
51 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, JavaValue* result, TRAPS) { | 51 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) { |
52 JavaThread* thread = (JavaThread *)THREAD; | 52 JavaThread* thread = (JavaThread *)THREAD; |
53 bool clear_pending_exception = true; | 53 bool clear_pending_exception = true; |
54 | 54 |
55 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code"); | 55 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code"); |
56 assert(!thread->owns_locks(), "must release all locks when leaving VM"); | 56 assert(!thread->owns_locks(), "must release all locks when leaving VM"); |
77 | 77 |
78 | 78 |
79 // Make sure to set the oop's after the thread transition - since we can block there. No one is GC'ing | 79 // Make sure to set the oop's after the thread transition - since we can block there. No one is GC'ing |
80 // the JavaCallWrapper before the entry frame is on the stack. | 80 // the JavaCallWrapper before the entry frame is on the stack. |
81 _callee_method = callee_method(); | 81 _callee_method = callee_method(); |
82 _receiver = receiver(); | |
82 | 83 |
83 #ifdef CHECK_UNHANDLED_OOPS | 84 #ifdef CHECK_UNHANDLED_OOPS |
84 // THREAD->allow_unhandled_oop(&_receiver); | 85 THREAD->allow_unhandled_oop(&_receiver); |
85 #endif // CHECK_UNHANDLED_OOPS | 86 #endif // CHECK_UNHANDLED_OOPS |
86 | 87 |
87 _thread = (JavaThread *)thread; | 88 _thread = (JavaThread *)thread; |
88 _handles = _thread->active_handles(); // save previous handle block & Java frame linkage | 89 _handles = _thread->active_handles(); // save previous handle block & Java frame linkage |
89 | 90 |
143 JNIHandleBlock::release_block(_old_handles, _thread); | 144 JNIHandleBlock::release_block(_old_handles, _thread); |
144 } | 145 } |
145 | 146 |
146 | 147 |
147 void JavaCallWrapper::oops_do(OopClosure* f) { | 148 void JavaCallWrapper::oops_do(OopClosure* f) { |
149 f->do_oop((oop*)&_receiver); | |
148 handles()->oops_do(f); | 150 handles()->oops_do(f); |
149 } | 151 } |
150 | 152 |
151 | 153 |
152 // Helper methods | 154 // Helper methods |
319 | 321 |
320 void JavaCalls::call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS) { | 322 void JavaCalls::call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS) { |
321 // Check if we need to wrap a potential OS exception handler around thread | 323 // Check if we need to wrap a potential OS exception handler around thread |
322 // This is used for e.g. Win32 structured exception handlers | 324 // This is used for e.g. Win32 structured exception handlers |
323 assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls"); | 325 assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls"); |
324 // Need to wrap each and everytime, since there might be native code down the | 326 // Need to wrap each and every time, since there might be native code down the |
325 // stack that has installed its own exception handlers | 327 // stack that has installed its own exception handlers |
326 os::os_exception_wrapper(call_helper, result, &method, args, THREAD); | 328 os::os_exception_wrapper(call_helper, result, &method, args, THREAD); |
327 } | 329 } |
328 | 330 |
329 void JavaCalls::call_helper(JavaValue* result, methodHandle* m, JavaCallArguments* args, TRAPS) { | 331 void JavaCalls::call_helper(JavaValue* result, methodHandle* m, JavaCallArguments* args, TRAPS) { |
335 assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here"); | 337 assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here"); |
336 | 338 |
337 | 339 |
338 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) | 340 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) |
339 | 341 |
340 #ifdef GRAAL | |
341 nmethod* nm = args->alternative_target(); | |
342 if (nm == NULL) { | |
343 #endif | |
344 // Verify the arguments | 342 // Verify the arguments |
345 | 343 |
346 if (CheckJNICalls) { | 344 if (CheckJNICalls) { |
347 args->verify(method, result->get_type(), thread); | 345 args->verify(method, result->get_type(), thread); |
348 } | 346 } |
349 else debug_only(args->verify(method, result->get_type(), thread)); | 347 else debug_only(args->verify(method, result->get_type(), thread)); |
350 #ifdef GRAAL | 348 |
351 } | |
352 #else | |
353 // Ignore call if method is empty | 349 // Ignore call if method is empty |
354 if (method->is_empty_method()) { | 350 if (method->is_empty_method()) { |
355 assert(result->get_type() == T_VOID, "an empty method must return a void value"); | 351 assert(result->get_type() == T_VOID, "an empty method must return a void value"); |
356 return; | 352 return; |
357 } | 353 } |
358 #endif | |
359 | 354 |
360 | 355 |
361 #ifdef ASSERT | 356 #ifdef ASSERT |
362 { InstanceKlass* holder = method->method_holder(); | 357 { InstanceKlass* holder = method->method_holder(); |
363 // A klass might not be initialized since JavaCall's might be used during the executing of | 358 // A klass might not be initialized since JavaCall's might be used during the executing of |
364 // the <clinit>. For example, a Thread.start might start executing on an object that is | 359 // the <clinit>. For example, a Thread.start might start executing on an object that is |
365 // not fully initialized! (bad Java programming style) | 360 // not fully initialized! (bad Java programming style) |
366 assert(holder->is_linked(), "rewritting must have taken place"); | 361 assert(holder->is_linked(), "rewriting must have taken place"); |
367 } | 362 } |
368 #endif | 363 #endif |
369 | 364 |
370 | 365 |
371 assert(thread->can_call_java(), "cannot compile from the compiler"); | 366 assert(thread->can_call_java(), "cannot compile from the compiler"); |
389 bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY); | 384 bool oop_result_flag = (result->get_type() == T_OBJECT || result->get_type() == T_ARRAY); |
390 | 385 |
391 // NOTE: if we move the computation of the result_val_address inside | 386 // NOTE: if we move the computation of the result_val_address inside |
392 // the call to call_stub, the optimizer produces wrong code. | 387 // the call to call_stub, the optimizer produces wrong code. |
393 intptr_t* result_val_address = (intptr_t*)(result->get_value_addr()); | 388 intptr_t* result_val_address = (intptr_t*)(result->get_value_addr()); |
389 | |
390 // Find receiver | |
391 Handle receiver = (!method->is_static()) ? args->receiver() : Handle(); | |
394 | 392 |
395 // 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 |
396 // might already be disabled when we are in VM. | 394 // might already be disabled when we are in VM. |
397 if (thread->stack_yellow_zone_disabled()) { | 395 if (thread->stack_yellow_zone_disabled()) { |
398 thread->reguard_stack(); | 396 thread->reguard_stack(); |
408 // 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. |
409 os::bang_stack_shadow_pages(); | 407 os::bang_stack_shadow_pages(); |
410 } | 408 } |
411 | 409 |
412 #ifdef GRAAL | 410 #ifdef GRAAL |
411 nmethod* nm = args->alternative_target(); | |
413 if (nm != NULL) { | 412 if (nm != NULL) { |
414 if (nm->is_alive()) { | 413 if (nm->is_alive()) { |
415 ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point()); | 414 ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point()); |
416 oop graalInstalledCode = nm->graal_installed_code(); | 415 entry_point = method->adapter()->get_i2c_entry(); |
417 if (graalInstalledCode != NULL && graalInstalledCode->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isExternal(graalInstalledCode)) { | |
418 entry_point = GraalRuntime::get_external_deopt_i2c_entry(); | |
419 } else { | |
420 entry_point = method->adapter()->get_i2c_entry(); | |
421 } | |
422 } else { | 416 } else { |
423 THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException()); | 417 THROW(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException()); |
424 } | 418 } |
425 } | 419 } |
426 #endif | 420 #endif |
427 | 421 |
428 // do call | 422 // do call |
429 { JavaCallWrapper link(method, result, CHECK); | 423 { JavaCallWrapper link(method, receiver, result, CHECK); |
430 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner | 424 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner |
431 | 425 |
432 StubRoutines::call_stub()( | 426 StubRoutines::call_stub()( |
433 (address)&link, | 427 (address)&link, |
434 // (intptr_t*)&(result->_value), // see NOTE above (compiler problem) | 428 // (intptr_t*)&(result->_value), // see NOTE above (compiler problem) |