/* * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// For debugging purposes: // To force FullGCALot inside a runtime function, add the following two lines // // Universe::release_fullgc_alot_dummy(); // MarkSweep::invoke(0, "Debugging"); // // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000
// This should be called in an assertion at the start of OptoRuntime routines // which are entered from compiled code (all of them) #ifdef ASSERT staticbool check_compiled_frame(JavaThread* thread) {
assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
RegisterMap map(thread,
RegisterMap::UpdateMap::skip,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::skip);
frame caller = thread->last_frame().sender(&map);
assert(caller.is_compiled_frame(), "not being called from compiled like code"); returntrue;
} #endif// ASSERT
#define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, return_pc) \
var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, return_pc); \ if (var == NULL) { returnfalse; }
//=============================allocation====================================== // We failed the fast-path allocation. Now we need to do a scavenge or GC // and try allocation again.
// These checks are cheap to make and support reflective allocation. int lh = klass->layout_helper(); if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
Handle holder(current, klass->klass_holder()); // keep the klass alive
klass->check_valid_for_instantiation(false, THREAD); if (!HAS_PENDING_EXCEPTION) {
InstanceKlass::cast(klass)->initialize(THREAD);
}
}
if (!HAS_PENDING_EXCEPTION) { // Scavenge and allocate an instance.
Handle holder(current, klass->klass_holder()); // keep the klass alive
oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
current->set_vm_result(result);
// Pass oops back through thread local storage. Our apparent type to Java // is that we return an oop, but we can block on exit from this routine and // a GC can trash the oop in C's return register. The generated stub will // fetch the oop from TLS after any possible GC.
}
if (array_type->is_typeArray_klass()) { // The oopFactory likes to work with the element type. // (We could bypass the oopFactory, since it doesn't add much value.)
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
result = oopFactory::new_typeArray(elem_type, len, THREAD);
} else { // Although the oopFactory likes to work with the elem_type, // the compiler prefers the array_type, since it must already have // that latter value in hand for the fast path.
Handle holder(current, array_type->klass_holder()); // keep the array klass alive
Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
result = oopFactory::new_objArray(elem_type, len, THREAD);
}
// Pass oops back through thread local storage. Our apparent type to Java // is that we return an oop, but we can block on exit from this routine and // a GC can trash the oop in C's return register. The generated stub will // fetch the oop from TLS after any possible GC.
deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
current->set_vm_result(result);
JRT_BLOCK_END;
// inform GC that we won't do card marks for initializing writes.
SharedRuntime::on_slowpath_allocation_exit(current);
JRT_END
// array allocation without zeroing
JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread* current))
JRT_BLOCK; #ifndef PRODUCT
SharedRuntime::_new_array_ctr++; // new array requires GC #endif
assert(check_compiled_frame(current), "incorrect caller");
// Scavenge and allocate an instance.
oop result;
assert(array_type->is_typeArray_klass(), "should be called only for type array"); // The oopFactory likes to work with the element type.
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
// Pass oops back through thread local storage. Our apparent type to Java // is that we return an oop, but we can block on exit from this routine and // a GC can trash the oop in C's return register. The generated stub will // fetch the oop from TLS after any possible GC.
deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
current->set_vm_result(result);
JRT_BLOCK_END;
// inform GC that we won't do card marks for initializing writes.
SharedRuntime::on_slowpath_allocation_exit(current);
oop result = current->vm_result(); if ((len > 0) && (result != NULL) &&
is_deoptimized_caller_frame(current)) { // Zero array here if the caller is deoptimized. const size_t size = TypeArrayKlass::cast(array_type)->oop_size(result);
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); const size_t hs = arrayOopDesc::header_size(elem_type); // Align to next 8 bytes to avoid trashing arrays's length. const size_t aligned_hs = align_object_offset(hs);
HeapWord* obj = cast_from_oop<HeapWord*>(result); if (aligned_hs > hs) {
Copy::zero_to_words(obj+hs, aligned_hs-hs);
} // Optimized zeroing.
Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
}
JRT_END
// Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
// multianewarray for 2 dimensions
JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current)) #ifndef PRODUCT
SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension #endif
assert(check_compiled_frame(current), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[2];
dims[0] = len1;
dims[1] = len2;
Handle holder(current, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
current->set_vm_result(obj);
JRT_END
// multianewarray for 3 dimensions
JRT_ENTRY(void, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread* current)) #ifndef PRODUCT
SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension #endif
assert(check_compiled_frame(current), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[3];
dims[0] = len1;
dims[1] = len2;
dims[2] = len3;
Handle holder(current, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD);
deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
current->set_vm_result(obj);
JRT_END
// multianewarray for 4 dimensions
JRT_ENTRY(void, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread* current)) #ifndef PRODUCT
SharedRuntime::_multi4_ctr++; // multianewarray for 1 dimension #endif
assert(check_compiled_frame(current), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[4];
dims[0] = len1;
dims[1] = len2;
dims[2] = len3;
dims[3] = len4;
Handle holder(current, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD);
deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
current->set_vm_result(obj);
JRT_END
// multianewarray for 5 dimensions
JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread* current)) #ifndef PRODUCT
SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension #endif
assert(check_compiled_frame(current), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
jint dims[5];
dims[0] = len1;
dims[1] = len2;
dims[2] = len3;
dims[3] = len4;
dims[4] = len5;
Handle holder(current, elem_type->klass_holder()); // keep the klass alive
oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD);
deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
current->set_vm_result(obj);
JRT_END
JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread* current))
assert(check_compiled_frame(current), "incorrect caller");
assert(elem_type->is_klass(), "not a class");
assert(oop(dims)->is_typeArray(), "not an array");
// Very few notify/notifyAll operations find any threads on the waitset, so // the dominant fast-path is to simply return. // Relatedly, it's critical that notify/notifyAll be fast in order to // reduce lock hold times. if (!SafepointSynchronize::is_synchronizing()) { if (ObjectSynchronizer::quick_notify(obj, current, false)) { return;
}
}
// This is the case the fast-path above isn't provisioned to handle. // The fast-path is designed to handle frequently arising cases in an efficient manner. // (The fast-path is just a degenerate variant of the slow-path). // Perform the dreaded state transition and pass control into the slow-path.
JRT_BLOCK;
Handle h_obj(current, obj);
ObjectSynchronizer::notify(h_obj, CHECK);
JRT_BLOCK_END;
JRT_END
if (!SafepointSynchronize::is_synchronizing() ) { if (ObjectSynchronizer::quick_notify(obj, current, true)) { return;
}
}
// This is the case the fast-path above isn't provisioned to handle. // The fast-path is designed to handle frequently arising cases in an efficient manner. // (The fast-path is just a degenerate variant of the slow-path). // Perform the dreaded state transition and pass control into the slow-path.
JRT_BLOCK;
Handle h_obj(current, obj);
ObjectSynchronizer::notifyall(h_obj, CHECK);
JRT_BLOCK_END;
JRT_END
const TypeFunc *OptoRuntime::new_instance_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
// create result type (range)
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
const TypeFunc *OptoRuntime::Math_D_D_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(2); // Symbol* name of class to be loaded
fields[TypeFunc::Parms+0] = Type::DOUBLE;
fields[TypeFunc::Parms+1] = Type::HALF; const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
// create result type (range)
fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = Type::DOUBLE;
fields[TypeFunc::Parms+1] = Type::HALF; const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type) { // create input type (domain) const Type **fields = TypeTuple::fields(num_arg); // Symbol* name of class to be loaded
assert(num_arg > 0, "must have at least 1 input"); for (uint i = 0; i < num_arg; i++) {
fields[TypeFunc::Parms+i] = in_type;
} const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+num_arg, fields);
staticconst TypeFunc* make_arraycopy_Type(ArrayCopyType act) { // create input type (domain) int num_args = (act == ac_fast ? 3 : 5); int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0); int argcnt = num_args;
LP64_ONLY(argcnt += num_size_args); // halfwords for lengths const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // src if (num_size_args == 0) {
fields[argp++] = TypeInt::INT; // src_pos
}
fields[argp++] = TypePtr::NOTNULL; // dest if (num_size_args == 0) {
fields[argp++] = TypeInt::INT; // dest_pos
fields[argp++] = TypeInt::INT; // length
} while (num_size_args-- > 0) {
fields[argp++] = TypeX_X; // size in whatevers (size_t)
LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
} if (act == ac_checkcast) {
fields[argp++] = TypePtr::NOTNULL; // super_klass
}
assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act"); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
// create result type if needed int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0);
fields = TypeTuple::fields(1); if (retcnt == 0)
fields[TypeFunc::Parms+0] = NULL; // void else
fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields); return TypeFunc::make(domain, range);
}
const TypeFunc* OptoRuntime::fast_arraycopy_Type() { // This signature is simple: Two base pointers and a size_t. return make_arraycopy_Type(ac_fast);
}
const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() { // An extension of fast_arraycopy_Type which adds type checking. return make_arraycopy_Type(ac_checkcast);
}
const TypeFunc* OptoRuntime::slow_arraycopy_Type() { // This signature is exactly the same as System.arraycopy. // There are no intptr_t (int/long) arguments. return make_arraycopy_Type(ac_slow);
}
const TypeFunc* OptoRuntime::generic_arraycopy_Type() { // This signature is like System.arraycopy, except that it returns status. return make_arraycopy_Type(ac_generic);
}
const TypeFunc* OptoRuntime::array_fill_Type() { const Type** fields; int argp = TypeFunc::Parms; // create input type (domain): pointer, int, size_t
fields = TypeTuple::fields(3 LP64_ONLY( + 1));
fields[argp++] = TypePtr::NOTNULL;
fields[argp++] = TypeInt::INT;
fields[argp++] = TypeX_X; // size in whatevers (size_t)
LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length const TypeTuple *domain = TypeTuple::make(argp, fields);
// create result type
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
return TypeFunc::make(domain, range);
}
// for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant) const TypeFunc* OptoRuntime::aescrypt_block_Type() { // create input type (domain) int num_args = 3; int argcnt = num_args; const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypePtr::NOTNULL; // dest
fields[argp++] = TypePtr::NOTNULL; // k array
assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
// no result type needed
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = NULL; // void const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); return TypeFunc::make(domain, range);
}
/** * int updateBytesCRC32(int crc, byte* b, int len)
*/ const TypeFunc* OptoRuntime::updateBytesCRC32_Type() { // create input type (domain) int num_args = 3; int argcnt = num_args; const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms;
fields[argp++] = TypeInt::INT; // crc
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypeInt::INT; // len
assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
// result type needed
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); return TypeFunc::make(domain, range);
}
/** * int updateBytesCRC32C(int crc, byte* buf, int len, int* table)
*/ const TypeFunc* OptoRuntime::updateBytesCRC32C_Type() { // create input type (domain) int num_args = 4; int argcnt = num_args; const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms;
fields[argp++] = TypeInt::INT; // crc
fields[argp++] = TypePtr::NOTNULL; // buf
fields[argp++] = TypeInt::INT; // len
fields[argp++] = TypePtr::NOTNULL; // table
assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
// result type needed
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); return TypeFunc::make(domain, range);
}
/** * int updateBytesAdler32(int adler, bytes* b, int off, int len)
*/ const TypeFunc* OptoRuntime::updateBytesAdler32_Type() { // create input type (domain) int num_args = 3; int argcnt = num_args; const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms;
fields[argp++] = TypeInt::INT; // crc
fields[argp++] = TypePtr::NOTNULL; // src + offset
fields[argp++] = TypeInt::INT; // len
assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
// result type needed
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); return TypeFunc::make(domain, range);
}
// for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { // create input type (domain) int num_args = 5; int argcnt = num_args; const Type** fields = TypeTuple::fields(argcnt); int argp = TypeFunc::Parms;
fields[argp++] = TypePtr::NOTNULL; // src
fields[argp++] = TypePtr::NOTNULL; // dest
fields[argp++] = TypePtr::NOTNULL; // k array
fields[argp++] = TypePtr::NOTNULL; // r array
fields[argp++] = TypeInt::INT; // src len
assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
// The method is an entry that is always called by a C++ method not // directly from compiled code. Compiled code will call the C++ method following. // We can't allow async exception to be installed during exception processing.
JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* current, nmethod* &nm)) // The frame we rethrow the exception to might not have been processed by the GC yet. // The stack watermark barrier takes care of detecting that and ensuring the frame // has updated oops.
StackWatermarkSet::after_unwind(current);
// Do not confuse exception_oop with pending_exception. The exception_oop // is only used to pass arguments into the method. Not for general // exception handling. DO NOT CHANGE IT to use pending_exception, since // the runtime stubs checks this on exit.
assert(current->exception_oop() != NULL, "exception oop is found");
address handler_address = NULL;
Handle exception(current, current->exception_oop());
address pc = current->exception_pc();
// Clear out the exception oop and pc since looking up an // exception handler can cause class loading, which might throw an // exception and those fields are expected to be clear during // normal bytecode execution.
current->clear_exception_oop_and_pc();
// for AbortVMOnException flag
Exceptions::debug_check_abort(exception);
#ifdef ASSERT if (!(exception->is_a(vmClasses::Throwable_klass()))) { // should throw an exception here
ShouldNotReachHere();
} #endif
// new exception handling: this method is entered only from adapters // exceptions from compiled java methods are handled in compiled code // using rethrow node
nm = CodeCache::find_nmethod(pc);
assert(nm != NULL, "No NMethod found"); if (nm->is_native_method()) {
fatal("Native method should not have path to exception handling");
} else { // we are switching to old paradigm: search for exception handler in caller_frame // instead in exception handler of caller_frame.sender()
if (JvmtiExport::can_post_on_exceptions()) { // "Full-speed catching" is not necessary here, // since we're notifying the VM on every catch. // Force deoptimization and the rest of the lookup // will be fine.
deoptimize_caller_frame(current);
}
// Check the stack guard pages. If enabled, look for handler in this frame; // otherwise, forcibly unwind the frame. // // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate. bool force_unwind = !current->stack_overflow_state()->reguard_stack(); bool deopting = false; if (nm->is_deopt_pc(pc)) {
deopting = true;
RegisterMap map(current,
RegisterMap::UpdateMap::skip,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::skip);
frame deoptee = current->last_frame().sender(&map);
assert(deoptee.is_deoptimized_frame(), "must be deopted"); // Adjust the pc back to the original throwing pc
pc = deoptee.pc();
}
// If we are forcing an unwind because of stack overflow then deopt is // irrelevant since we are throwing the frame away anyway.
if (handler_address == NULL) { bool recursive_exception = false;
handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
assert (handler_address != NULL, "must have compiled handler"); // Update the exception cache only when the unwind was not forced // and there didn't happen another exception during the computation of the // compiled exception handler. Checking for exception oop equality is not // sufficient because some exceptions are pre-allocated and reused. if (!force_unwind && !recursive_exception) {
nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
}
} else { #ifdef ASSERT bool recursive_exception = false;
address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
vmassert(recursive_exception || (handler_address == computed_address), "Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
p2i(handler_address), p2i(computed_address)); #endif
}
}
// We are entering here from exception_blob // If there is a compiled exception handler in this method, we will continue there; // otherwise we will unwind the stack and continue at the caller of top frame method // Note we enter without the usual JRT wrapper. We will call a helper routine that // will do the normal VM entry. We do it this way so that we can see if the nmethod // we looked up the handler for has been deoptimized in the meantime. If it has been // we must not use the handler and instead return the deopt blob.
address OptoRuntime::handle_exception_C(JavaThread* current) { // // We are in Java not VM and in debug mode we have a NoHandleMark // #ifndef PRODUCT
SharedRuntime::_find_handler_ctr++; // find exception handler #endif
debug_only(NoHandleMark __hm;)
nmethod* nm = NULL;
address handler_address = NULL;
{ // Enter the VM
//------------------------------rethrow---------------------------------------- // We get here after compiled code has executed a 'RethrowNode'. The callee // is either throwing or rethrowing an exception. The callee-save registers // have been restored, synchronized objects have been unlocked and the callee // stack frame has been removed. The return address was passed in. // Exception oop is passed as the 1st argument. This routine is then called // from the stub. On exit, we know where to jump in the caller's code. // After this C code exits, the stub will pop his frame and end in a jump // (instead of a return). We enter the caller's default handler. // // This must be JRT_LEAF: // - caller will not change its state as we cannot block on exit, // therefore raw_exception_handler_for_return_address is all it takes // to handle deoptimized blobs // // However, there needs to be a safepoint check in the middle! So compiled // safepoints are completely watertight. // // Thus, it cannot be a leaf since it contains the NoSafepointVerifier. // // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE* //
address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) {
// Enable WXWrite: the function called directly by compiled code.
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
// ret_pc will have been loaded from the stack, so for AArch64 will be signed. // This needs authenticating, but to do that here requires the fp of the previous frame. // A better way of doing it would be authenticate in the caller by adding a // AuthPAuthNode and using it in GraphKit::gen_stub. For now, just strip it.
AARCH64_PORT_ONLY(ret_pc = pauth_strip_pointer(ret_pc));
#ifndef PRODUCT
SharedRuntime::_rethrow_ctr++; // count rethrows #endif
assert (exception != NULL, "should have thrown a NULLPointerException"); #ifdef ASSERT if (!(exception->is_a(vmClasses::Throwable_klass()))) { // should throw an exception here
ShouldNotReachHere();
} #endif
// create result type (range)
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) { // Deoptimize the caller before continuing, as the compiled // exception handler table may not be valid. if (!StressCompiledExceptionHandlers && doit) {
deoptimize_caller_frame(thread);
}
}
void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) { // Called from within the owner thread, so no need for safepoint
RegisterMap reg_map(thread,
RegisterMap::UpdateMap::include,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::skip);
frame stub_frame = thread->last_frame();
assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
frame caller_frame = stub_frame.sender(®_map);
// Deoptimize the caller frame.
Deoptimization::deoptimize_frame(thread, caller_frame.id());
}
bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) { // Called from within the owner thread, so no need for safepoint
RegisterMap reg_map(thread,
RegisterMap::UpdateMap::include,
RegisterMap::ProcessFrames::include,
RegisterMap::WalkContinuation::skip);
frame stub_frame = thread->last_frame();
assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
frame caller_frame = stub_frame.sender(®_map); return caller_frame.is_deoptimized_frame();
}
const TypeFunc *OptoRuntime::register_finalizer_Type() { // create input type (domain) const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver // // The JavaThread* is passed to each routine as the last argument // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
// create result type (range)
fields = TypeTuple::fields(0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.