comparison src/share/vm/runtime/javaCalls.cpp @ 8151:b8f261ba79c6

Minimize diff to plain HotSpot version.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 07 Mar 2013 21:00:29 +0100
parents f10843a2d961
children f94bb5d20e5d
comparison
equal deleted inserted replaced
8150:b66f831ac5ab 8151:b8f261ba79c6
37 #include "runtime/interfaceSupport.hpp" 37 #include "runtime/interfaceSupport.hpp"
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 #ifdef HIGH_LEVEL_INTERPRETER 42 #include "runtime/thread.inline.hpp"
43 # include "graal/graalVMToInterpreter.hpp"
44 #endif
45 #ifdef TARGET_OS_FAMILY_linux
46 # include "thread_linux.inline.hpp"
47 #endif
48 #ifdef TARGET_OS_FAMILY_solaris
49 # include "thread_solaris.inline.hpp"
50 #endif
51 #ifdef TARGET_OS_FAMILY_windows
52 # include "thread_windows.inline.hpp"
53 #endif
54 #ifdef TARGET_OS_FAMILY_bsd
55 # include "thread_bsd.inline.hpp"
56 #endif
57 43
58 // ----------------------------------------------------- 44 // -----------------------------------------------------
59 // Implementation of JavaCallWrapper 45 // Implementation of JavaCallWrapper
60 46
61 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) { 47 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
333 // Check if we need to wrap a potential OS exception handler around thread 319 // Check if we need to wrap a potential OS exception handler around thread
334 // This is used for e.g. Win32 structured exception handlers 320 // This is used for e.g. Win32 structured exception handlers
335 assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls"); 321 assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls");
336 // Need to wrap each and everytime, since there might be native code down the 322 // Need to wrap each and everytime, since there might be native code down the
337 // stack that has installed its own exception handlers 323 // stack that has installed its own exception handlers
338 os::os_exception_wrapper(call_helper, result, &method, NULL, args, THREAD); 324 os::os_exception_wrapper(call_helper, result, &method, args, THREAD);
339 } 325 }
340 326
341 void JavaCalls::call(JavaValue* result, methodHandle method, nmethod* nm, JavaCallArguments* args, TRAPS) { 327 void JavaCalls::call_helper(JavaValue* result, methodHandle* m, JavaCallArguments* args, TRAPS) {
342 // Check if we need to wrap a potential OS exception handler around thread
343 // This is used for e.g. Win32 structured exception handlers
344 assert(THREAD->is_Java_thread(), "only JavaThreads can make JavaCalls");
345 // Need to wrap each and everytime, since there might be native code down the
346 // stack that has installed its own exception handlers
347 os::os_exception_wrapper(call_helper, result, &method, nm, args, THREAD);
348 }
349
350 void JavaCalls::call_helper(JavaValue* result, methodHandle* m, nmethod* nm, JavaCallArguments* args, TRAPS) {
351 methodHandle method = *m; 328 methodHandle method = *m;
352 JavaThread* thread = (JavaThread*)THREAD; 329 JavaThread* thread = (JavaThread*)THREAD;
353 assert(thread->is_Java_thread(), "must be called by a java thread"); 330 assert(thread->is_Java_thread(), "must be called by a java thread");
354 assert(method.not_null(), "must have a method to call"); 331 assert(method.not_null(), "must have a method to call");
355 assert(!SafepointSynchronize::is_at_safepoint(), "call to Java code during VM operation"); 332 assert(!SafepointSynchronize::is_at_safepoint(), "call to Java code during VM operation");
370 if (method->is_empty_method()) { 347 if (method->is_empty_method()) {
371 assert(result->get_type() == T_VOID, "an empty method must return a void value"); 348 assert(result->get_type() == T_VOID, "an empty method must return a void value");
372 return; 349 return;
373 } 350 }
374 #endif 351 #endif
352
375 353
376 #ifdef ASSERT 354 #ifdef ASSERT
377 { InstanceKlass* holder = method->method_holder(); 355 { InstanceKlass* holder = method->method_holder();
378 // A klass might not be initialized since JavaCall's might be used during the executing of 356 // A klass might not be initialized since JavaCall's might be used during the executing of
379 // the <clinit>. For example, a Thread.start might start executing on an object that is 357 // the <clinit>. For example, a Thread.start might start executing on an object that is
425 } else { 403 } else {
426 // Touch pages checked if the OS needs them to be touched to be mapped. 404 // Touch pages checked if the OS needs them to be touched to be mapped.
427 os::bang_stack_shadow_pages(); 405 os::bang_stack_shadow_pages();
428 } 406 }
429 407
408 #ifdef GRAAL
409 nmethod* nm = args->alternative_target();
430 if (nm != NULL) { 410 if (nm != NULL) {
431 #ifdef GRAAL
432 if (nm->is_alive()) { 411 if (nm->is_alive()) {
433 ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point()); 412 ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point());
434 entry_point = method->adapter()->get_i2c_entry(); 413 entry_point = method->adapter()->get_i2c_entry();
435 } else { 414 } else {
436 THROW(vmSymbols::MethodInvalidatedException()); 415 THROW(vmSymbols::MethodInvalidatedException());
437 } 416 }
438 #else 417 }
439 ShouldNotReachHere();
440 #endif 418 #endif
441 }
442 419
443 #ifdef HIGH_LEVEL_INTERPRETER
444 if (thread->high_level_interpreter_in_vm() && !method->is_native() && Interpreter::contains(entry_point)) {
445 assert(nm == NULL || !nm->is_alive(), "otherwise nm should be invoked");
446 VMToInterpreter::execute(result, m, args, result->get_type(), thread);
447 oop_result_flag = false; // result already holds the correct value
448 } else
449 #endif
450 // do call 420 // do call
451 { JavaCallWrapper link(method, receiver, result, CHECK); 421 { JavaCallWrapper link(method, receiver, result, CHECK);
452 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner 422 { HandleMark hm(thread); // HandleMark used by HandleMarkCleaner
453 423
454 StubRoutines::call_stub()( 424 StubRoutines::call_stub()(
479 if (oop_result_flag) { 449 if (oop_result_flag) {
480 result->set_jobject((jobject)thread->vm_result()); 450 result->set_jobject((jobject)thread->vm_result());
481 thread->set_vm_result(NULL); 451 thread->set_vm_result(NULL);
482 } 452 }
483 } 453 }
454
484 455
485 //-------------------------------------------------------------------------------------- 456 //--------------------------------------------------------------------------------------
486 // Implementation of JavaCallArguments 457 // Implementation of JavaCallArguments
487 458
488 intptr_t* JavaCallArguments::parameters() { 459 intptr_t* JavaCallArguments::parameters() {