< prev index next >

src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp

Print this page
rev 12172 : 8170100: AArch64: Crash in C1-compiled code accessing References
Reviewed-by: duke


  46 #include "runtime/stubRoutines.hpp"
  47 #include "runtime/synchronizer.hpp"
  48 #include "runtime/timer.hpp"
  49 #include "runtime/vframeArray.hpp"
  50 #include "utilities/debug.hpp"
  51 #include <sys/types.h>
  52 
  53 #ifndef PRODUCT
  54 #include "oops/method.hpp"
  55 #endif // !PRODUCT
  56 
  57 #ifdef BUILTIN_SIM
  58 #include "../../../../../../simulator/simulator.hpp"
  59 #endif
  60 
  61 // Size of interpreter code.  Increase if too small.  Interpreter will
  62 // fail with a guarantee ("not enough space for interpreter generation");
  63 // if too small.
  64 // Run with +PrintInterpreter to get the VM to print out the size.
  65 // Max size with JVMTI
  66 int TemplateInterpreter::InterpreterCodeSize = 200 * 1024;
  67 
  68 #define __ _masm->
  69 
  70 //-----------------------------------------------------------------------------
  71 
  72 extern "C" void entry(CodeBuffer*);
  73 
  74 //-----------------------------------------------------------------------------
  75 
  76 address TemplateInterpreterGenerator::generate_slow_signature_handler() {
  77   address entry = __ pc();
  78 
  79   __ andr(esp, esp, -16);
  80   __ mov(c_rarg3, esp);
  81   // rmethod
  82   // rlocals
  83   // c_rarg3: first stack arg - wordSize
  84 
  85   // adjust sp
  86   __ sub(sp, c_rarg3, 18 * wordSize);


 855   // The code that gets generated by this routine is split into 2 parts:
 856   //    1. The "intrinsified" code for G1 (or any SATB based GC),
 857   //    2. The slow path - which is an expansion of the regular method entry.
 858   //
 859   // Notes:-
 860   // * In the G1 code we do not check whether we need to block for
 861   //   a safepoint. If G1 is enabled then we must execute the specialized
 862   //   code for Reference.get (except when the Reference object is null)
 863   //   so that we can log the value in the referent field with an SATB
 864   //   update buffer.
 865   //   If the code for the getfield template is modified so that the
 866   //   G1 pre-barrier code is executed when the current method is
 867   //   Reference.get() then going through the normal method entry
 868   //   will be fine.
 869   // * The G1 code can, however, check the receiver object (the instance
 870   //   of java.lang.Reference) and jump to the slow path if null. If the
 871   //   Reference object is null then we obviously cannot fetch the referent
 872   //   and so we don't need to call the G1 pre-barrier. Thus we can use the
 873   //   regular method entry code to generate the NPE.
 874   //
 875   // This code is based on generate_accessor_enty.
 876   //
 877   // rmethod: Method*
 878   // r13: senderSP must preserve for slow path, set SP to it on fast path
 879 
 880   address entry = __ pc();
 881 
 882   const int referent_offset = java_lang_ref_Reference::referent_offset;
 883   guarantee(referent_offset > 0, "referent offset not initialized");
 884 
 885   if (UseG1GC) {
 886     Label slow_path;
 887     const Register local_0 = c_rarg0;
 888     // Check if local 0 != NULL
 889     // If the receiver is null then it is OK to jump to the slow path.
 890     __ ldr(local_0, Address(esp, 0));
 891     __ cbz(local_0, slow_path);
 892 
 893 
 894     // Load the value of the referent field.
 895     const Address field_address(local_0, referent_offset);
 896     __ load_heap_oop(local_0, field_address);
 897 

 898     // Generate the G1 pre-barrier code to log the value of
 899     // the referent field in an SATB buffer.
 900     __ enter(); // g1_write may call runtime
 901     __ g1_write_barrier_pre(noreg /* obj */,
 902                             local_0 /* pre_val */,
 903                             rthread /* thread */,
 904                             rscratch2 /* tmp */,
 905                             true /* tosca_live */,
 906                             true /* expand_call */);
 907     __ leave();
 908     // areturn
 909     __ andr(sp, r13, -16);  // done with stack
 910     __ ret(lr);
 911 
 912     // generate a vanilla interpreter entry as the slow path
 913     __ bind(slow_path);
 914     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
 915     return entry;
 916   }
 917 #endif // INCLUDE_ALL_GCS
 918 
 919   // If G1 is not enabled then attempt to go through the accessor entry point
 920   // Reference.get is an accessor
 921   return NULL;
 922 }
 923 
 924 /**
 925  * Method entry for static native methods:
 926  *   int java.util.zip.CRC32.update(int crc, int b)
 927  */
 928 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
 929   if (UseCRC32Intrinsics) {




  46 #include "runtime/stubRoutines.hpp"
  47 #include "runtime/synchronizer.hpp"
  48 #include "runtime/timer.hpp"
  49 #include "runtime/vframeArray.hpp"
  50 #include "utilities/debug.hpp"
  51 #include <sys/types.h>
  52 
  53 #ifndef PRODUCT
  54 #include "oops/method.hpp"
  55 #endif // !PRODUCT
  56 
  57 #ifdef BUILTIN_SIM
  58 #include "../../../../../../simulator/simulator.hpp"
  59 #endif
  60 
  61 // Size of interpreter code.  Increase if too small.  Interpreter will
  62 // fail with a guarantee ("not enough space for interpreter generation");
  63 // if too small.
  64 // Run with +PrintInterpreter to get the VM to print out the size.
  65 // Max size with JVMTI
  66 int TemplateInterpreter::InterpreterCodeSize = JVMCI_ONLY(268) NOT_JVMCI(256) * 1024;
  67 
  68 #define __ _masm->
  69 
  70 //-----------------------------------------------------------------------------
  71 
  72 extern "C" void entry(CodeBuffer*);
  73 
  74 //-----------------------------------------------------------------------------
  75 
  76 address TemplateInterpreterGenerator::generate_slow_signature_handler() {
  77   address entry = __ pc();
  78 
  79   __ andr(esp, esp, -16);
  80   __ mov(c_rarg3, esp);
  81   // rmethod
  82   // rlocals
  83   // c_rarg3: first stack arg - wordSize
  84 
  85   // adjust sp
  86   __ sub(sp, c_rarg3, 18 * wordSize);


 855   // The code that gets generated by this routine is split into 2 parts:
 856   //    1. The "intrinsified" code for G1 (or any SATB based GC),
 857   //    2. The slow path - which is an expansion of the regular method entry.
 858   //
 859   // Notes:-
 860   // * In the G1 code we do not check whether we need to block for
 861   //   a safepoint. If G1 is enabled then we must execute the specialized
 862   //   code for Reference.get (except when the Reference object is null)
 863   //   so that we can log the value in the referent field with an SATB
 864   //   update buffer.
 865   //   If the code for the getfield template is modified so that the
 866   //   G1 pre-barrier code is executed when the current method is
 867   //   Reference.get() then going through the normal method entry
 868   //   will be fine.
 869   // * The G1 code can, however, check the receiver object (the instance
 870   //   of java.lang.Reference) and jump to the slow path if null. If the
 871   //   Reference object is null then we obviously cannot fetch the referent
 872   //   and so we don't need to call the G1 pre-barrier. Thus we can use the
 873   //   regular method entry code to generate the NPE.
 874   //
 875   // This code is based on generate_accessor_entry.
 876   //
 877   // rmethod: Method*
 878   // r13: senderSP must preserve for slow path, set SP to it on fast path
 879 
 880   address entry = __ pc();
 881 
 882   const int referent_offset = java_lang_ref_Reference::referent_offset;
 883   guarantee(referent_offset > 0, "referent offset not initialized");
 884 
 885   if (UseG1GC) {
 886     Label slow_path;
 887     const Register local_0 = c_rarg0;
 888     // Check if local 0 != NULL
 889     // If the receiver is null then it is OK to jump to the slow path.
 890     __ ldr(local_0, Address(esp, 0));
 891     __ cbz(local_0, slow_path);
 892 

 893     // Load the value of the referent field.
 894     const Address field_address(local_0, referent_offset);
 895     __ load_heap_oop(local_0, field_address);
 896 
 897     __ mov(r19, r13);   // Move senderSP to a callee-saved register
 898     // Generate the G1 pre-barrier code to log the value of
 899     // the referent field in an SATB buffer.
 900     __ enter(); // g1_write may call runtime
 901     __ g1_write_barrier_pre(noreg /* obj */,
 902                             local_0 /* pre_val */,
 903                             rthread /* thread */,
 904                             rscratch2 /* tmp */,
 905                             true /* tosca_live */,
 906                             true /* expand_call */);
 907     __ leave();
 908     // areturn
 909     __ andr(sp, r19, -16);  // done with stack
 910     __ ret(lr);
 911 
 912     // generate a vanilla interpreter entry as the slow path
 913     __ bind(slow_path);
 914     __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::zerolocals));
 915     return entry;
 916   }
 917 #endif // INCLUDE_ALL_GCS
 918 
 919   // If G1 is not enabled then attempt to go through the accessor entry point
 920   // Reference.get is an accessor
 921   return NULL;
 922 }
 923 
 924 /**
 925  * Method entry for static native methods:
 926  *   int java.util.zip.CRC32.update(int crc, int b)
 927  */
 928 address TemplateInterpreterGenerator::generate_CRC32_update_entry() {
 929   if (UseCRC32Intrinsics) {


< prev index next >