< prev index next >
src/share/vm/runtime/javaCalls.cpp
Print this page
*** 39,59 ****
#include "runtime/mutexLocker.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/thread.inline.hpp"
// -----------------------------------------------------
// Implementation of JavaCallWrapper
JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
JavaThread* thread = (JavaThread *)THREAD;
bool clear_pending_exception = true;
guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
assert(!thread->owns_locks(), "must release all locks when leaving VM");
! guarantee(!thread->is_Compiler_thread(), "cannot make java calls from the compiler");
_result = result;
// Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub,
// since it can potentially block.
JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread);
--- 39,63 ----
#include "runtime/mutexLocker.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/thread.inline.hpp"
+ #if INCLUDE_JVMCI
+ #include "jvmci/jvmciJavaClasses.hpp"
+ #include "jvmci/jvmciRuntime.hpp"
+ #endif
// -----------------------------------------------------
// Implementation of JavaCallWrapper
JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
JavaThread* thread = (JavaThread *)THREAD;
bool clear_pending_exception = true;
guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
assert(!thread->owns_locks(), "must release all locks when leaving VM");
! guarantee(thread->can_call_java(), "cannot make java calls from the native compiler");
_result = result;
// Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub,
// since it can potentially block.
JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread);
*** 307,329 ****
assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here");
CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
! // Verify the arguments
if (CheckJNICalls) {
args->verify(method, result->get_type(), thread);
}
else debug_only(args->verify(method, result->get_type(), thread));
// Ignore call if method is empty
if (method->is_empty_method()) {
assert(result->get_type() == T_VOID, "an empty method must return a void value");
return;
}
!
#ifdef ASSERT
{ InstanceKlass* holder = method->method_holder();
// A klass might not be initialized since JavaCall's might be used during the executing of
// the <clinit>. For example, a Thread.start might start executing on an object that is
--- 311,341 ----
assert(!thread->handle_area()->no_handle_mark_active(), "cannot call out to Java here");
CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();)
! #if INCLUDE_JVMCI
! // Gets the nmethod (if any) that should be called instead of normal target
! nmethod* alternative_target = args->alternative_target();
! if (alternative_target == NULL) {
! #endif
! // Verify the arguments
if (CheckJNICalls) {
args->verify(method, result->get_type(), thread);
}
else debug_only(args->verify(method, result->get_type(), thread));
+ #if INCLUDE_JVMCI
+ }
+ #else
// Ignore call if method is empty
if (method->is_empty_method()) {
assert(result->get_type() == T_VOID, "an empty method must return a void value");
return;
}
! #endif
#ifdef ASSERT
{ InstanceKlass* holder = method->method_holder();
// A klass might not be initialized since JavaCall's might be used during the executing of
// the <clinit>. For example, a Thread.start might start executing on an object that is
*** 331,341 ****
assert(holder->is_linked(), "rewriting must have taken place");
}
#endif
! assert(!thread->is_Compiler_thread(), "cannot compile from the compiler");
if (CompilationPolicy::must_be_compiled(method)) {
CompileBroker::compile_method(method, InvocationEntryBci,
CompilationPolicy::policy()->initial_compile_level(),
methodHandle(), 0, "must_be_compiled", CHECK);
}
--- 343,353 ----
assert(holder->is_linked(), "rewriting must have taken place");
}
#endif
! assert(thread->can_call_java(), "cannot compile from the native compiler");
if (CompilationPolicy::must_be_compiled(method)) {
CompileBroker::compile_method(method, InvocationEntryBci,
CompilationPolicy::policy()->initial_compile_level(),
methodHandle(), 0, "must_be_compiled", CHECK);
}
*** 375,384 ****
--- 387,407 ----
} else {
// Touch pages checked if the OS needs them to be touched to be mapped.
os::bang_stack_shadow_pages();
}
+ #if INCLUDE_JVMCI
+ if (alternative_target != NULL) {
+ if (alternative_target->is_alive()) {
+ thread->set_jvmci_alternate_call_target(alternative_target->verified_entry_point());
+ entry_point = method->adapter()->get_i2c_entry();
+ } else {
+ THROW(vmSymbols::jdk_vm_ci_code_InvalidInstalledCodeException());
+ }
+ }
+ #endif
+
// do call
{ JavaCallWrapper link(method, receiver, result, CHECK);
{ HandleMark hm(thread); // HandleMark used by HandleMarkCleaner
StubRoutines::call_stub()(
< prev index next >