changeset 2351:59766fd005ff

7035117: G1: nsk/stress/jni/jnistress002 fails with assertion failure Summary: Allow long type for offset in G1 code in compiler implementations of Unsafe.getObject Reviewed-by: never, iveresov
author johnc
date Wed, 13 Apr 2011 17:56:43 -0700
parents f177ddd59c60
children 5d046bf49ce7 c69b1043dfb1
files src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp src/cpu/x86/vm/c1_CodeStubs_x86.cpp src/share/vm/c1/c1_LIRGenerator.cpp src/share/vm/opto/library_call.cpp
diffstat 4 files changed, 26 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Fri Apr 08 14:53:16 2011 -0700
+++ b/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Wed Apr 13 17:56:43 2011 -0700
@@ -489,7 +489,7 @@
 
   // Is marking active?
   assert(thread()->is_register(), "precondition");
-  Register thread_reg = thread()->as_register();
+  Register thread_reg = NOT_LP64(thread()->as_register()) LP64_ONLY(thread()->as_register_lo());
 
   Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() +
                                        PtrQueue::byte_offset_of_active()));
--- a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Fri Apr 08 14:53:16 2011 -0700
+++ b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Wed Apr 13 17:56:43 2011 -0700
@@ -523,7 +523,7 @@
 
   // Is marking active?
   assert(thread()->is_register(), "precondition");
-  Register thread_reg = thread()->as_register();
+  Register thread_reg = NOT_LP64(thread()->as_register()) LP64_ONLY(thread()->as_register_lo());
 
   Address in_progress(thread_reg, in_bytes(JavaThread::satb_mark_queue_offset() +
                                        PtrQueue::byte_offset_of_active()));
--- a/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Apr 08 14:53:16 2011 -0700
+++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Apr 13 17:56:43 2011 -0700
@@ -2062,9 +2062,12 @@
     bool gen_source_check = true;       // Assume the code stub has to check the src object for null.
 
     if (off.is_constant()) {
-      jint off_con = off.get_jint_constant();
-
-      if (off_con != java_lang_ref_Reference::referent_offset) {
+      jlong off_con = (off.type()->is_int() ?
+                        (jlong) off.get_jint_constant() :
+                        off.get_jlong_constant());
+
+
+      if (off_con != (jlong) java_lang_ref_Reference::referent_offset) {
         // The constant offset is something other than referent_offset.
         // We can skip generating/checking the remaining guards and
         // skip generation of the code stub.
@@ -2112,15 +2115,29 @@
       // the offset check.
       if (gen_offset_check) {
         // if (offset == referent_offset) -> slow code stub
-        __ cmp(lir_cond_equal, off.result(),
-               LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset));
+        // If offset is an int then we can do the comparison with the
+        // referent_offset constant; otherwise we need to move
+        // referent_offset into a temporary register and generate
+        // a reg-reg compare.
+
+        LIR_Opr referent_off;
+
+        if (off.type()->is_int()) {
+          referent_off = LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset);
+        } else {
+          assert(off.type()->is_long(), "what else?");
+          referent_off = new_register(T_LONG);
+          __ move(LIR_OprFact::longConst(java_lang_ref_Reference::referent_offset), referent_off);
+        }
+
+        __ cmp(lir_cond_equal, off.result(), referent_off);
 
         // Optionally generate "src == null" check.
         stub = new G1UnsafeGetObjSATBBarrierStub(reg, src.result(),
                                                     src_klass, thread,
                                                     gen_source_check);
 
-        __ branch(lir_cond_equal, T_INT, stub);
+        __ branch(lir_cond_equal, as_BasicType(off.type()), stub);
       } else {
         if (gen_source_check) {
           // offset is a const and equals referent offset
--- a/src/share/vm/opto/library_call.cpp	Fri Apr 08 14:53:16 2011 -0700
+++ b/src/share/vm/opto/library_call.cpp	Wed Apr 13 17:56:43 2011 -0700
@@ -2169,7 +2169,7 @@
   const int reference_type_offset = instanceKlass::reference_type_offset_in_bytes() +
                                         sizeof(oopDesc);
 
-  Node* referent_off = __ ConI(java_lang_ref_Reference::referent_offset);
+  Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset);
 
   __ if_then(offset, BoolTest::eq, referent_off, unlikely); {
     __ if_then(base_oop, BoolTest::ne, null(), likely); {