runtime.cpp revision 1027
0N/A * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A#
include "incls/_precompiled.incl" 0N/A// For debugging purposes: 0N/A// To force FullGCALot inside a runtime function, add the following two lines 0N/A// Universe::release_fullgc_alot_dummy(); 0N/A// MarkSweep::invoke(0, "Debugging"); 0N/A// At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000 0N/A// Compiled code entry points 0N/A// This should be called in an assertion at the start of OptoRuntime routines 0N/A// which are entered from compiled code (all of them) 0N/A // Note: tls: Means fetching the return oop out of the thread-local storage 0N/A // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc 0N/A // ------------------------------------------------------------------------------------------------------------------------------- 0N/A// Helper method to do generation of RunTimeStub's 0N/A // Fast implementation for product mode (maybe it should be inlined too) 0N/A return "runtime stub";
0N/A//============================================================================= 0N/A// Opto compiler runtime routines 0N/A//============================================================================= 0N/A//=============================allocation====================================== 0N/A// We failed the fast-path allocation. Now we need to do a scavenge or GC 0N/A// and try allocation again. 0N/A // After any safepoint, just before going back to compiled code, 1027N/A // we inform the GC that we will be doing initializing writes to 1027N/A // this object in the future without emitting card-marks, so 1027N/A // GC may take any compensating steps. 1027N/A // NOTE: Keep this code consistent with GraphKit::store_barrier. 0N/A "compiler must check this first");
1027N/A // GC may decide to give back a safer copy of new_obj. 0N/A // These checks are cheap to make and support reflective allocation. 0N/A // Scavenge and allocate an instance. 0N/A // Pass oops back through thread local storage. Our apparent type to Java 0N/A // is that we return an oop, but we can block on exit from this routine and 0N/A // a GC can trash the oop in C's return register. The generated stub will 0N/A // fetch the oop from TLS after any possible GC. 1027N/A // inform GC that we won't do card marks for initializing writes. 0N/A // Scavenge and allocate an instance. 0N/A // The oopFactory likes to work with the element type. 0N/A // (We could bypass the oopFactory, since it doesn't add much value.) 0N/A // Although the oopFactory likes to work with the elem_type, 0N/A // the compiler prefers the array_type, since it must already have 0N/A // that latter value in hand for the fast path. 0N/A // Pass oops back through thread local storage. Our apparent type to Java 0N/A // is that we return an oop, but we can block on exit from this routine and 0N/A // a GC can trash the oop in C's return register. The generated stub will 0N/A // fetch the oop from TLS after any possible GC. 1027N/A // inform GC that we won't do card marks for initializing writes. 0N/A// Note: multianewarray for one dimension is handled inline by GraphKit::new_array. 0N/A// multianewarray for 2 dimensions 0N/A// multianewarray for 3 dimensions 0N/A// multianewarray for 4 dimensions 0N/A// multianewarray for 5 dimensions 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // create input type (domain) 0N/A // create result type (range) 342N/A // create result type (range) 342N/A // create result type (range) 0N/A // create input type (domain) 0N/A // symbolOop name of class to be loaded 0N/A // create result type (range) 0N/A// Type used for stub generation for zap_dead_locals. 0N/A// No inputs or outputs 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A//----------------------------------------------------------------------------- 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A//----------------------------------------------------------------------------- 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // create input type (domain) 0N/A // create result type 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // create result type (range) 0N/A // create input type (domain) 0N/A // symbolOop name of class to be loaded 0N/A // create result type (range) 0N/A // create result type (range) 0N/A//-------------- currentTimeMillis 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A// arraycopy stub variations: 0N/A // create input type (domain) 0N/A // create result type if needed 0N/A // This signature is simple: Two base pointers and a size_t. 0N/A // An extension of fast_arraycopy_Type which adds type checking. 0N/A // This signature is exactly the same as System.arraycopy. 0N/A // This signature is like System.arraycopy, except that it returns status. 0N/A//------------- Interpreter state access for on stack replacement 0N/A // create input type (domain) 0N/A // create result type 0N/A // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop 0N/A//-------------- methodData update helpers 0N/A // create input type (domain) 0N/A // create result type 0N/A // ReceiverTypeData* vc = new ReceiverTypeData(mdp); 0N/A // if (vc->receiver(row) == receiver_klass) 0N/A // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment); 0N/A // else if (vc->receiver(row) == NULL) 0N/A // vc->set_receiver(empty_row, receiver_klass); 0N/A // vc->set_receiver_count(empty_row, DataLayout::counter_increment); 0N/A//----------------------------------------------------------------------------- 0N/A// implicit exception support. 0N/A tty->
print_cr(
"# HotSpot Runtime Error, null exception in generated code");
0N/A const char*
title =
"HotSpot Runtime Error";
0N/A const char*
question =
"Do you want to exclude compilation of this method in future runs?";
0N/A fatal(
"Implicit null exception happened in compiled method");
0N/A fatal(
"Implicit null exception happened in generated stub");
0N/A fatal(
"Implicit null exception at wrong place");
0N/A//------------------------------------------------------------------------------------- 0N/A case 'C':
return false;
//SOC 0N/A case 'E':
return true ;
//SOE 0N/A case 'N':
return false;
//NS 0N/A case 'A':
return false;
//AS 0N/A//----------------------------------------------------------------------- 0N/A// The method is an entry that is always called by a C++ method not 0N/A// directly from compiled code. Compiled code will call the C++ method following. 0N/A// We can't allow async exception to be installed during exception processing. 0N/A // Do not confuse exception_oop with pending_exception. The exception_oop 0N/A // is only used to pass arguments into the method. Not for general 0N/A // exception handling. DO NOT CHANGE IT to use pending_exception, since 0N/A // the runtime stubs checks this on exit. 0N/A // for AbortVMOnException flag 0N/A // should throw an exception here 0N/A // new exception handling: this method is entered only from adapters 0N/A // exceptions from compiled java methods are handled in compiled code 0N/A // using rethrow node 0N/A fatal(
"Native mathod should not have path to exception handling");
0N/A // we are switching to old paradigm: search for exception handler in caller_frame 0N/A // "Full-speed catching" is not necessary here, 0N/A // since we're notifying the VM on every catch. 0N/A // Force deoptimization and the rest of the lookup 0N/A // Check the stack guard pages. If enabled, look for handler in this frame; 0N/A // otherwise, forcibly unwind the frame. 0N/A // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate. 0N/A // Adjust the pc back to the original throwing pc 0N/A // If we are forcing an unwind because of stack overflow then deopt is 0N/A // irrelevant sice we are throwing the frame away anyway. 0N/A // Update the exception cache only when the unwind was not forced. 0N/A // Restore correct return pc. Was saved above. 0N/A// We are entering here from exception_blob 0N/A// If there is a compiled exception handler in this method, we will continue there; 0N/A// otherwise we will unwind the stack and continue at the caller of top frame method 0N/A// Note we enter without the usual JRT wrapper. We will call a helper routine that 0N/A// will do the normal VM entry. We do it this way so that we can see if the nmethod 0N/A// we looked up the handler for has been deoptimized in the meantime. If it has been 0N/A// we must not use the handler and instread return the deopt blob. 0N/A// We are in Java not VM and in debug mode we have a NoHandleMark 0N/A // Back in java: Use no oops, DON'T safepoint 0N/A // Now check to see if the handler we are returning is in a now 0N/A // deoptimized frame 0N/A//------------------------------rethrow---------------------------------------- 0N/A// We get here after compiled code has executed a 'RethrowNode'. The callee 0N/A// is either throwing or rethrowing an exception. The callee-save registers 0N/A// have been restored, synchronized objects have been unlocked and the callee 0N/A// stack frame has been removed. The return address was passed in. 0N/A// Exception oop is passed as the 1st argument. This routine is then called 0N/A// from the stub. On exit, we know where to jump in the caller's code. 0N/A// After this C code exits, the stub will pop his frame and end in a jump 0N/A// (instead of a return). We enter the caller's default handler. 0N/A// This must be JRT_LEAF: 0N/A// - caller will not change its state as we cannot block on exit, 0N/A// therefore raw_exception_handler_for_return_address is all it takes 0N/A// to handle deoptimized blobs 0N/A// However, there needs to be a safepoint check in the middle! So compiled 0N/A// safepoints are completely watertight. 0N/A// Thus, it cannot be a leaf since it contains the No_GC_Verifier. 0N/A// *THIS IS NOT RECOMMENDED PROGRAMMING STYLE* 0N/A // should throw an exception here 0N/A // Frame not compiled (handles deoptimization blob) 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // Called from within the owner thread, so no need for safepoint 0N/A // create input type (domain) 0N/A // // The JavaThread* is passed to each routine as the last argument 0N/A // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread 0N/A // create result type (range) 0N/A//----------------------------------------------------------------------------- 0N/A// Dtrace support. entry and exit probes have the same signature 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A // create input type (domain) 0N/A // create result type (range) 0N/A//----------------------------------------------------------------------------- 0N/A// dump the collected NamedCounters. 0N/A// Allocate a new NamedCounter. The JVMState is used to generate the 0N/A// name which consists of method@line for the inlining tree. 0N/A // Visit scopes from youngest to oldest. 0N/A // To print linenumbers instead of bci use: m->line_number_from_bci(bci) 0N/A // atomically add the new counter to the head of the list. We only 0N/A // add counters so this is safe. 0N/A//----------------------------------------------------------------------------- 0N/A// Called from call sites in compiled code with oop maps (actually safepoints) 0N/A// Zaps dead locals in first java frame. 0N/A// Is entry because may need to lock to generate oop maps 0N/A// Currently, only used for compiler frames, but someday may be used 0N/A// for interpreter frames, too. 0N/A// avoid pointers to member funcs with these helpers 0N/A // find java frame and zap it 0N/A warning(
"no frame found to zap in zap_dead_Java_locals_C");
0N/A// The following does not work because for one thing, the 0N/A// thread state is wrong; it expects java, but it is native. 605N/A// Also, the invariants in a native stub are different and 0N/A// I'm not sure it is safe to have a MachCalRuntimeDirectNode 0N/A// So for now, we do not zap in native stubs.