< prev index next >

src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp

Print this page
rev 12906 : [mq]: gc_interface


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"

  27 #include "interpreter/bytecodeHistogram.hpp"
  28 #include "interpreter/interpreter.hpp"
  29 #include "interpreter/interpreterRuntime.hpp"
  30 #include "interpreter/interp_masm.hpp"
  31 #include "interpreter/templateInterpreterGenerator.hpp"
  32 #include "interpreter/templateTable.hpp"
  33 #include "oops/arrayOop.hpp"
  34 #include "oops/methodData.hpp"
  35 #include "oops/method.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/jvmtiExport.hpp"
  38 #include "prims/jvmtiThreadState.hpp"
  39 #include "runtime/arguments.hpp"
  40 #include "runtime/deoptimization.hpp"
  41 #include "runtime/frame.inline.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "runtime/stubRoutines.hpp"
  44 #include "runtime/synchronizer.hpp"
  45 #include "runtime/timer.hpp"
  46 #include "runtime/vframeArray.hpp"


 819   __ sub(FP, rounded_vm_local_words * BytesPerWord, Lmonitors ); // set Lmonitors
 820   __ add( Lmonitors, STACK_BIAS, Lmonitors );   // Account for 64 bit stack bias
 821   __ sub(Lmonitors, BytesPerWord, Lesp);       // set Lesp
 822 
 823   // setup interpreter activation registers
 824   __ sub(Gargs, BytesPerWord, Llocals);        // set Llocals
 825 
 826   if (ProfileInterpreter) {
 827 #ifdef FAST_DISPATCH
 828     // FAST_DISPATCH and ProfileInterpreter are mutually exclusive since
 829     // they both use I2.
 830     assert(0, "FAST_DISPATCH and +ProfileInterpreter are mutually exclusive");
 831 #endif // FAST_DISPATCH
 832     __ set_method_data_pointer();
 833   }
 834 
 835 }
 836 
 837 // Method entry for java.lang.ref.Reference.get.
 838 address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
 839 #if INCLUDE_ALL_GCS
 840   // Code: _aload_0, _getfield, _areturn
 841   // parameter size = 1
 842   //
 843   // The code that gets generated by this routine is split into 2 parts:
 844   //    1. The "intrinsified" code for G1 (or any SATB based GC),
 845   //    2. The slow path - which is an expansion of the regular method entry.
 846   //
 847   // Notes:-
 848   // * In the G1 code we do not check whether we need to block for
 849   //   a safepoint. If G1 is enabled then we must execute the specialized
 850   //   code for Reference.get (except when the Reference object is null)
 851   //   so that we can log the value in the referent field with an SATB
 852   //   update buffer.
 853   //   If the code for the getfield template is modified so that the
 854   //   G1 pre-barrier code is executed when the current method is
 855   //   Reference.get() then going through the normal method entry
 856   //   will be fine.
 857   // * The G1 code can, however, check the receiver object (the instance
 858   //   of java.lang.Reference) and jump to the slow path if null. If the
 859   //   Reference object is null then we obviously cannot fetch the referent
 860   //   and so we don't need to call the G1 pre-barrier. Thus we can use the
 861   //   regular method entry code to generate the NPE.
 862   //
 863   // This code is based on generate_accessor_enty.
 864 
 865   address entry = __ pc();
 866 
 867   const int referent_offset = java_lang_ref_Reference::referent_offset;
 868   guarantee(referent_offset > 0, "referent offset not initialized");
 869 
 870   if (UseG1GC) {
 871      Label slow_path;
 872 
 873     // In the G1 code we don't check if we need to reach a safepoint. We
 874     // continue and the thread will safepoint at the next bytecode dispatch.
 875 
 876     // Check if local 0 != NULL
 877     // If the receiver is null then it is OK to jump to the slow path.
 878     __ ld_ptr(Gargs, G0, Otos_i ); // get local 0
 879     // check if local 0 == NULL and go the slow path
 880     __ cmp_and_brx_short(Otos_i, 0, Assembler::equal, Assembler::pn, slow_path);
 881 
 882 
 883     // Load the value of the referent field.
 884     if (Assembler::is_simm13(referent_offset)) {
 885       __ load_heap_oop(Otos_i, referent_offset, Otos_i);
 886     } else {
 887       __ set(referent_offset, G3_scratch);
 888       __ load_heap_oop(Otos_i, G3_scratch, Otos_i);
 889     }
 890 
 891     // Generate the G1 pre-barrier code to log the value of
 892     // the referent field in an SATB buffer. Note with
 893     // these parameters the pre-barrier does not generate
 894     // the load of the previous value
 895 
 896     __ g1_write_barrier_pre(noreg /* obj */, noreg /* index */, 0 /* offset */,
 897                             Otos_i /* pre_val */,
 898                             G3_scratch /* tmp */,
 899                             true /* preserve_o_regs */);
 900 
 901     // _areturn
 902     __ retl();                      // return from leaf routine
 903     __ delayed()->mov(O5_savedSP, SP);
 904 
 905     // Generate regular method entry
 906     __ bind(slow_path);
 907     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
 908     return entry;
 909   }
 910 #endif // INCLUDE_ALL_GCS
 911 
 912   // If G1 is not enabled then attempt to go through the accessor entry point
 913   // Reference.get is an accessor
 914   return NULL;
 915 }
 916 
 917 /**
 918  * Method entry for static native methods:
 919  *   int java.util.zip.CRC32.update(int crc, int b)
 920  */
 921 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
 922 
 923   if (UseCRC32Intrinsics) {
 924     address entry = __ pc();
 925 
 926     Label L_slow_path;
 927     // If we need a safepoint check, generate full interpreter entry.
 928     ExternalAddress state(SafepointSynchronize::address_of_state());
 929     __ set(ExternalAddress(SafepointSynchronize::address_of_state()), O2);
 930     __ set(SafepointSynchronize::_not_synchronized, O3);
 931     __ cmp_and_br_short(O2, O3, Assembler::notEqual, Assembler::pt, L_slow_path);
 932 
 933     // Load parameters
 934     const Register crc   = O0; // initial crc


1419 
1420   // Back in normal (native) interpreter frame. State is thread_in_native_trans
1421   // switch to thread_in_Java.
1422 
1423   __ set(_thread_in_Java, G3_scratch);
1424   __ st(G3_scratch, thread_state);
1425 
1426   if (CheckJNICalls) {
1427     // clear_pending_jni_exception_check
1428     __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset());
1429   }
1430 
1431   // reset handle block
1432   __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch);
1433   __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
1434 
1435   // If we have an oop result store it where it will be safe for any further gc
1436   // until we return now that we've released the handle it might be protected by
1437 
1438   {
1439     Label no_oop, store_result;
1440 
1441     __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
1442     __ cmp_and_brx_short(G3_scratch, Lscratch, Assembler::notEqual, Assembler::pt, no_oop);
1443     // Unbox oop result, e.g. JNIHandles::resolve value in O0.
1444     __ br_null(O0, false, Assembler::pn, store_result); // Use NULL as-is.
1445     __ delayed()->andcc(O0, JNIHandles::weak_tag_mask, G0); // Test for jweak
1446     __ brx(Assembler::zero, true, Assembler::pt, store_result);
1447     __ delayed()->ld_ptr(O0, 0, O0); // Maybe resolve (untagged) jobject.
1448     // Resolve jweak.
1449     __ ld_ptr(O0, -JNIHandles::weak_tag_value, O0);
1450 #if INCLUDE_ALL_GCS
1451     if (UseG1GC) {
1452       __ g1_write_barrier_pre(noreg /* obj */,
1453                               noreg /* index */,
1454                               0 /* offset */,
1455                               O0 /* pre_val */,
1456                               G3_scratch /* tmp */,
1457                               true /* preserve_o_regs */);
1458     }
1459 #endif // INCLUDE_ALL_GCS
1460     __ bind(store_result);
1461     // Store it where gc will look for it and result handler expects it.
1462     __ st_ptr(O0, FP, (frame::interpreter_frame_oop_temp_offset*wordSize) + STACK_BIAS);
1463 
1464     __ bind(no_oop);
1465 
1466   }
1467 
1468 
1469   // handle exceptions (exception handling will handle unlocking!)
1470   { Label L;
1471     Address exception_addr(G2_thread, Thread::pending_exception_offset());
1472     __ ld_ptr(exception_addr, Gtemp);
1473     __ br_null_short(Gtemp, Assembler::pt, L);
1474     // Note: This could be handled more efficiently since we know that the native
1475     //       method doesn't have an exception handler. We could directly return
1476     //       to the exception handler for the caller.
1477     __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_pending_exception));
1478     __ should_not_reach_here();
1479     __ bind(L);
1480   }
1481 
1482   // JVMTI support (preserves thread register)
1483   __ notify_method_exit(true, ilgl, InterpreterMacroAssembler::NotifyJVMTI);
1484 
1485   if (synchronized) {




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "gc/shared/barrierSetCodeGen.hpp"
  28 #include "interpreter/bytecodeHistogram.hpp"
  29 #include "interpreter/interpreter.hpp"
  30 #include "interpreter/interpreterRuntime.hpp"
  31 #include "interpreter/interp_masm.hpp"
  32 #include "interpreter/templateInterpreterGenerator.hpp"
  33 #include "interpreter/templateTable.hpp"
  34 #include "oops/arrayOop.hpp"
  35 #include "oops/methodData.hpp"
  36 #include "oops/method.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "prims/jvmtiExport.hpp"
  39 #include "prims/jvmtiThreadState.hpp"
  40 #include "runtime/arguments.hpp"
  41 #include "runtime/deoptimization.hpp"
  42 #include "runtime/frame.inline.hpp"
  43 #include "runtime/sharedRuntime.hpp"
  44 #include "runtime/stubRoutines.hpp"
  45 #include "runtime/synchronizer.hpp"
  46 #include "runtime/timer.hpp"
  47 #include "runtime/vframeArray.hpp"


 820   __ sub(FP, rounded_vm_local_words * BytesPerWord, Lmonitors ); // set Lmonitors
 821   __ add( Lmonitors, STACK_BIAS, Lmonitors );   // Account for 64 bit stack bias
 822   __ sub(Lmonitors, BytesPerWord, Lesp);       // set Lesp
 823 
 824   // setup interpreter activation registers
 825   __ sub(Gargs, BytesPerWord, Llocals);        // set Llocals
 826 
 827   if (ProfileInterpreter) {
 828 #ifdef FAST_DISPATCH
 829     // FAST_DISPATCH and ProfileInterpreter are mutually exclusive since
 830     // they both use I2.
 831     assert(0, "FAST_DISPATCH and +ProfileInterpreter are mutually exclusive");
 832 #endif // FAST_DISPATCH
 833     __ set_method_data_pointer();
 834   }
 835 
 836 }
 837 
 838 // Method entry for java.lang.ref.Reference.get.
 839 address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {

 840   // Code: _aload_0, _getfield, _areturn
 841   // parameter size = 1
 842   //
 843   // The code that gets generated by this routine is split into 2 parts:
 844   //    1. The "intrinsified" code for G1 (or any SATB based GC),
 845   //    2. The slow path - which is an expansion of the regular method entry.
 846   //
 847   // Notes:-
 848   // * In the G1 code we do not check whether we need to block for
 849   //   a safepoint. If G1 is enabled then we must execute the specialized
 850   //   code for Reference.get (except when the Reference object is null)
 851   //   so that we can log the value in the referent field with an SATB
 852   //   update buffer.
 853   //   If the code for the getfield template is modified so that the
 854   //   G1 pre-barrier code is executed when the current method is
 855   //   Reference.get() then going through the normal method entry
 856   //   will be fine.
 857   // * The G1 code can, however, check the receiver object (the instance
 858   //   of java.lang.Reference) and jump to the slow path if null. If the
 859   //   Reference object is null then we obviously cannot fetch the referent
 860   //   and so we don't need to call the G1 pre-barrier. Thus we can use the
 861   //   regular method entry code to generate the NPE.
 862   //
 863   // This code is based on generate_accessor_enty.
 864 
 865   address entry = __ pc();
 866 
 867   const int referent_offset = java_lang_ref_Reference::referent_offset;
 868   guarantee(referent_offset > 0, "referent offset not initialized");
 869 

 870   Label slow_path;
 871 
 872   // In the G1 code we don't check if we need to reach a safepoint. We
 873   // continue and the thread will safepoint at the next bytecode dispatch.
 874 
 875   // Check if local 0 != NULL
 876   // If the receiver is null then it is OK to jump to the slow path.
 877   __ ld_ptr(Gargs, G0, Otos_i ); // get local 0
 878   // check if local 0 == NULL and go the slow path
 879   __ cmp_and_brx_short(Otos_i, 0, Assembler::equal, Assembler::pn, slow_path);
 880 
 881   BarrierSetCodeGen *code_gen = Universe::heap()->barrier_set()->code_gen();
 882   code_gen->load_at(_masm, ACCESS_ON_HEAP | GC_ACCESS_ON_WEAK, T_OBJECT,
 883                     Otos_i, noreg, referent_offset, Otos_i, G3_scratch);















 884 
 885   // _areturn
 886   __ retl();                      // return from leaf routine
 887   __ delayed()->mov(O5_savedSP, SP);
 888 
 889   // Generate regular method entry
 890   __ bind(slow_path);
 891   __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
 892   return entry;






 893 }
 894 
 895 /**
 896  * Method entry for static native methods:
 897  *   int java.util.zip.CRC32.update(int crc, int b)
 898  */
 899 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
 900 
 901   if (UseCRC32Intrinsics) {
 902     address entry = __ pc();
 903 
 904     Label L_slow_path;
 905     // If we need a safepoint check, generate full interpreter entry.
 906     ExternalAddress state(SafepointSynchronize::address_of_state());
 907     __ set(ExternalAddress(SafepointSynchronize::address_of_state()), O2);
 908     __ set(SafepointSynchronize::_not_synchronized, O3);
 909     __ cmp_and_br_short(O2, O3, Assembler::notEqual, Assembler::pt, L_slow_path);
 910 
 911     // Load parameters
 912     const Register crc   = O0; // initial crc


1397 
1398   // Back in normal (native) interpreter frame. State is thread_in_native_trans
1399   // switch to thread_in_Java.
1400 
1401   __ set(_thread_in_Java, G3_scratch);
1402   __ st(G3_scratch, thread_state);
1403 
1404   if (CheckJNICalls) {
1405     // clear_pending_jni_exception_check
1406     __ st_ptr(G0, G2_thread, JavaThread::pending_jni_exception_check_fn_offset());
1407   }
1408 
1409   // reset handle block
1410   __ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch);
1411   __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
1412 
1413   // If we have an oop result store it where it will be safe for any further gc
1414   // until we return now that we've released the handle it might be protected by
1415 
1416   {
1417     Label no_oop;
1418 
1419     __ set((intptr_t)AbstractInterpreter::result_handler(T_OBJECT), G3_scratch);
1420     __ cmp_and_brx_short(G3_scratch, Lscratch, Assembler::notEqual, Assembler::pt, no_oop);
1421     __ resolve_jobject(O0, G3_scratch);

















1422     // Store it where gc will look for it and result handler expects it.
1423     __ st_ptr(O0, FP, (frame::interpreter_frame_oop_temp_offset*wordSize) + STACK_BIAS);
1424 
1425     __ bind(no_oop);

1426   }
1427 
1428 
1429   // handle exceptions (exception handling will handle unlocking!)
1430   { Label L;
1431     Address exception_addr(G2_thread, Thread::pending_exception_offset());
1432     __ ld_ptr(exception_addr, Gtemp);
1433     __ br_null_short(Gtemp, Assembler::pt, L);
1434     // Note: This could be handled more efficiently since we know that the native
1435     //       method doesn't have an exception handler. We could directly return
1436     //       to the exception handler for the caller.
1437     __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_pending_exception));
1438     __ should_not_reach_here();
1439     __ bind(L);
1440   }
1441 
1442   // JVMTI support (preserves thread register)
1443   __ notify_method_exit(true, ilgl, InterpreterMacroAssembler::NotifyJVMTI);
1444 
1445   if (synchronized) {


< prev index next >