< prev index next >

src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp

Print this page
rev 13551 : imported patch gcinterface-aarch64-5.patch


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


 858 
 859   // Move SP out of the way
 860   if (! native_call) {
 861     __ ldr(rscratch1, Address(rmethod, Method::const_offset()));
 862     __ ldrh(rscratch1, Address(rscratch1, ConstMethod::max_stack_offset()));
 863     __ add(rscratch1, rscratch1, frame::interpreter_frame_monitor_size() + 2);
 864     __ sub(rscratch1, sp, rscratch1, ext::uxtw, 3);
 865     __ andr(sp, rscratch1, -16);
 866   }
 867 }
 868 
 869 // End of helpers
 870 
 871 // Various method entries
 872 //------------------------------------------------------------------------------------------------------------------------
 873 //
 874 //
 875 
 876 // Method entry for java.lang.ref.Reference.get.
 877 address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {
 878 #if INCLUDE_ALL_GCS
 879   // Code: _aload_0, _getfield, _areturn
 880   // parameter size = 1
 881   //
 882   // The code that gets generated by this routine is split into 2 parts:
 883   //    1. The "intrinsified" code for G1 (or any SATB based GC),
 884   //    2. The slow path - which is an expansion of the regular method entry.
 885   //
 886   // Notes:-
 887   // * In the G1 code we do not check whether we need to block for
 888   //   a safepoint. If G1 is enabled then we must execute the specialized
 889   //   code for Reference.get (except when the Reference object is null)
 890   //   so that we can log the value in the referent field with an SATB
 891   //   update buffer.
 892   //   If the code for the getfield template is modified so that the
 893   //   G1 pre-barrier code is executed when the current method is
 894   //   Reference.get() then going through the normal method entry
 895   //   will be fine.
 896   // * The G1 code can, however, check the receiver object (the instance
 897   //   of java.lang.Reference) and jump to the slow path if null. If the
 898   //   Reference object is null then we obviously cannot fetch the referent
 899   //   and so we don't need to call the G1 pre-barrier. Thus we can use the
 900   //   regular method entry code to generate the NPE.
 901   //
 902   // This code is based on generate_accessor_entry.
 903   //
 904   // rmethod: Method*
 905   // r13: senderSP must preserve for slow path, set SP to it on fast path
 906 
 907   address entry = __ pc();
 908 
 909   const int referent_offset = java_lang_ref_Reference::referent_offset;
 910   guarantee(referent_offset > 0, "referent offset not initialized");
 911 
 912   if (UseG1GC) {
 913     Label slow_path;
 914     const Register local_0 = c_rarg0;
 915     // Check if local 0 != NULL
 916     // If the receiver is null then it is OK to jump to the slow path.
 917     __ ldr(local_0, Address(esp, 0));
 918     __ cbz(local_0, slow_path);
 919 


 920     // Load the value of the referent field.
 921     const Address field_address(local_0, referent_offset);
 922     __ load_heap_oop(local_0, field_address);

 923 
 924     __ mov(r19, r13);   // Move senderSP to a callee-saved register
 925     // Generate the G1 pre-barrier code to log the value of
 926     // the referent field in an SATB buffer.
 927     __ enter(); // g1_write may call runtime
 928     __ g1_write_barrier_pre(noreg /* obj */,
 929                             local_0 /* pre_val */,
 930                             rthread /* thread */,
 931                             rscratch2 /* tmp */,
 932                             true /* tosca_live */,
 933                             true /* expand_call */);
 934     __ leave();
 935     // areturn
 936     __ andr(sp, r19, -16);  // done with stack
 937     __ ret(lr);
 938 
 939     // generate a vanilla interpreter entry as the slow path
 940     __ bind(slow_path);
 941     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
 942     return entry;
 943   }
 944 #endif // INCLUDE_ALL_GCS
 945 
 946   // If G1 is not enabled then attempt to go through the accessor entry point
 947   // Reference.get is an accessor
 948   return NULL;
 949 }
 950 
 951 /**
 952  * Method entry for static native methods:
 953  *   int java.util.zip.CRC32.update(int crc, int b)
 954  */
 955 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
 956   if (UseCRC32Intrinsics) {
 957     address entry = __ pc();
 958 
 959     // rmethod: Method*
 960     // r13: senderSP must preserved for slow path
 961     // esp: args
 962 
 963     Label slow_path;
 964     // If we need a safepoint check, generate full interpreter entry.
 965     ExternalAddress state(SafepointSynchronize::address_of_state());
 966     unsigned long offset;
 967     __ adrp(rscratch1, ExternalAddress(SafepointSynchronize::address_of_state()), offset);
 968     __ ldrw(rscratch1, Address(rscratch1, offset));


1384 
1385   if (CheckJNICalls) {
1386     // clear_pending_jni_exception_check
1387     __ str(zr, Address(rthread, JavaThread::pending_jni_exception_check_fn_offset()));
1388   }
1389 
1390   // reset handle block
1391   __ ldr(t, Address(rthread, JavaThread::active_handles_offset()));
1392   __ str(zr, Address(t, JNIHandleBlock::top_offset_in_bytes()));
1393 
1394   // If result is an oop unbox and store it in frame where gc will see it
1395   // and result handler will pick it up
1396 
1397   {
1398     Label no_oop, not_weak, store_result;
1399     __ adr(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
1400     __ cmp(t, result_handler);
1401     __ br(Assembler::NE, no_oop);
1402     // Unbox oop result, e.g. JNIHandles::resolve result.
1403     __ pop(ltos);
1404     __ cbz(r0, store_result);   // Use NULL as-is.
1405     STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
1406     __ tbz(r0, 0, not_weak);    // Test for jweak tag.
1407     // Resolve jweak.
1408     __ ldr(r0, Address(r0, -JNIHandles::weak_tag_value));
1409 #if INCLUDE_ALL_GCS
1410     if (UseG1GC) {
1411       __ enter();                   // Barrier may call runtime.
1412       __ g1_write_barrier_pre(noreg /* obj */,
1413                               r0 /* pre_val */,
1414                               rthread /* thread */,
1415                               t /* tmp */,
1416                               true /* tosca_live */,
1417                               true /* expand_call */);
1418       __ leave();
1419     }
1420 #endif // INCLUDE_ALL_GCS
1421     __ b(store_result);
1422     __ bind(not_weak);
1423     // Resolve (untagged) jobject.
1424     __ ldr(r0, Address(r0, 0));
1425     __ bind(store_result);
1426     __ str(r0, Address(rfp, frame::interpreter_frame_oop_temp_offset*wordSize));
1427     // keep stack depth as expected by pushing oop which will eventually be discarded
1428     __ push(ltos);
1429     __ bind(no_oop);
1430   }
1431 
1432   {
1433     Label no_reguard;
1434     __ lea(rscratch1, Address(rthread, in_bytes(JavaThread::stack_guard_state_offset())));
1435     __ ldrw(rscratch1, Address(rscratch1));
1436     __ cmp(rscratch1, JavaThread::stack_guard_yellow_reserved_disabled);
1437     __ br(Assembler::NE, no_reguard);
1438 
1439     __ pusha(); // XXX only save smashed registers
1440     __ mov(c_rarg0, rthread);
1441     __ mov(rscratch2, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages));
1442     __ blrt(rscratch2, 0, 0, 0);
1443     __ popa(); // XXX only restore smashed registers
1444     __ bind(no_reguard);
1445   }




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


 859 
 860   // Move SP out of the way
 861   if (! native_call) {
 862     __ ldr(rscratch1, Address(rmethod, Method::const_offset()));
 863     __ ldrh(rscratch1, Address(rscratch1, ConstMethod::max_stack_offset()));
 864     __ add(rscratch1, rscratch1, frame::interpreter_frame_monitor_size() + 2);
 865     __ sub(rscratch1, sp, rscratch1, ext::uxtw, 3);
 866     __ andr(sp, rscratch1, -16);
 867   }
 868 }
 869 
 870 // End of helpers
 871 
 872 // Various method entries
 873 //------------------------------------------------------------------------------------------------------------------------
 874 //
 875 //
 876 
 877 // Method entry for java.lang.ref.Reference.get.
 878 address TemplateInterpreterGenerator::generate_Reference_get_entry(void) {

 879   // Code: _aload_0, _getfield, _areturn
 880   // parameter size = 1
 881   //
 882   // The code that gets generated by this routine is split into 2 parts:
 883   //    1. The "intrinsified" code for G1 (or any SATB based GC),
 884   //    2. The slow path - which is an expansion of the regular method entry.
 885   //
 886   // Notes:-
 887   // * In the G1 code we do not check whether we need to block for
 888   //   a safepoint. If G1 is enabled then we must execute the specialized
 889   //   code for Reference.get (except when the Reference object is null)
 890   //   so that we can log the value in the referent field with an SATB
 891   //   update buffer.
 892   //   If the code for the getfield template is modified so that the
 893   //   G1 pre-barrier code is executed when the current method is
 894   //   Reference.get() then going through the normal method entry
 895   //   will be fine.
 896   // * The G1 code can, however, check the receiver object (the instance
 897   //   of java.lang.Reference) and jump to the slow path if null. If the
 898   //   Reference object is null then we obviously cannot fetch the referent
 899   //   and so we don't need to call the G1 pre-barrier. Thus we can use the
 900   //   regular method entry code to generate the NPE.
 901   //
 902   // This code is based on generate_accessor_entry.
 903   //
 904   // rmethod: Method*
 905   // r13: senderSP must preserve for slow path, set SP to it on fast path
 906 
 907   address entry = __ pc();
 908 
 909   const int referent_offset = java_lang_ref_Reference::referent_offset;
 910   guarantee(referent_offset > 0, "referent offset not initialized");
 911 

 912   Label slow_path;
 913   const Register local_0 = c_rarg0;
 914   // Check if local 0 != NULL
 915   // If the receiver is null then it is OK to jump to the slow path.
 916   __ ldr(local_0, Address(esp, 0));
 917   __ cbz(local_0, slow_path);
 918 
 919   __ mov(r19, r13);   // Move senderSP to a callee-saved register
 920 
 921   // Load the value of the referent field.
 922   const Address field_address(local_0, referent_offset);
 923   BarrierSetCodeGen *code_gen = Universe::heap()->barrier_set()->code_gen();
 924   code_gen->load_at(_masm, ACCESS_IN_HEAP | ACCESS_ON_WEAK_OOP_REF, T_OBJECT, local_0, field_address, /*tmp1*/ rscratch2, /*tmp2*/ rscratch1);
 925 











 926   // areturn
 927   __ andr(sp, r19, -16);  // done with stack
 928   __ ret(lr);
 929 
 930   // generate a vanilla interpreter entry as the slow path
 931   __ bind(slow_path);
 932   __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
 933   return entry;


 934 



 935 }
 936 
 937 /**
 938  * Method entry for static native methods:
 939  *   int java.util.zip.CRC32.update(int crc, int b)
 940  */
 941 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
 942   if (UseCRC32Intrinsics) {
 943     address entry = __ pc();
 944 
 945     // rmethod: Method*
 946     // r13: senderSP must preserved for slow path
 947     // esp: args
 948 
 949     Label slow_path;
 950     // If we need a safepoint check, generate full interpreter entry.
 951     ExternalAddress state(SafepointSynchronize::address_of_state());
 952     unsigned long offset;
 953     __ adrp(rscratch1, ExternalAddress(SafepointSynchronize::address_of_state()), offset);
 954     __ ldrw(rscratch1, Address(rscratch1, offset));


1370 
1371   if (CheckJNICalls) {
1372     // clear_pending_jni_exception_check
1373     __ str(zr, Address(rthread, JavaThread::pending_jni_exception_check_fn_offset()));
1374   }
1375 
1376   // reset handle block
1377   __ ldr(t, Address(rthread, JavaThread::active_handles_offset()));
1378   __ str(zr, Address(t, JNIHandleBlock::top_offset_in_bytes()));
1379 
1380   // If result is an oop unbox and store it in frame where gc will see it
1381   // and result handler will pick it up
1382 
1383   {
1384     Label no_oop, not_weak, store_result;
1385     __ adr(t, ExternalAddress(AbstractInterpreter::result_handler(T_OBJECT)));
1386     __ cmp(t, result_handler);
1387     __ br(Assembler::NE, no_oop);
1388     // Unbox oop result, e.g. JNIHandles::resolve result.
1389     __ pop(ltos);
1390     __ resolve_jobject(r0, rthread, t);





















1391     __ str(r0, Address(rfp, frame::interpreter_frame_oop_temp_offset*wordSize));
1392     // keep stack depth as expected by pushing oop which will eventually be discarded
1393     __ push(ltos);
1394     __ bind(no_oop);
1395   }
1396 
1397   {
1398     Label no_reguard;
1399     __ lea(rscratch1, Address(rthread, in_bytes(JavaThread::stack_guard_state_offset())));
1400     __ ldrw(rscratch1, Address(rscratch1));
1401     __ cmp(rscratch1, JavaThread::stack_guard_yellow_reserved_disabled);
1402     __ br(Assembler::NE, no_reguard);
1403 
1404     __ pusha(); // XXX only save smashed registers
1405     __ mov(c_rarg0, rthread);
1406     __ mov(rscratch2, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages));
1407     __ blrt(rscratch2, 0, 0, 0);
1408     __ popa(); // XXX only restore smashed registers
1409     __ bind(no_reguard);
1410   }


< prev index next >