src/share/vm/c1/c1_LIRGenerator.cpp

changeset 2786
59766fd005ff
parent 2781
e1162778c1c8
child 2787
5d046bf49ce7
     1.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp	Fri Apr 08 14:53:16 2011 -0700
     1.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Apr 13 17:56:43 2011 -0700
     1.3 @@ -2062,9 +2062,12 @@
     1.4      bool gen_source_check = true;       // Assume the code stub has to check the src object for null.
     1.5  
     1.6      if (off.is_constant()) {
     1.7 -      jint off_con = off.get_jint_constant();
     1.8 -
     1.9 -      if (off_con != java_lang_ref_Reference::referent_offset) {
    1.10 +      jlong off_con = (off.type()->is_int() ?
    1.11 +                        (jlong) off.get_jint_constant() :
    1.12 +                        off.get_jlong_constant());
    1.13 +
    1.14 +
    1.15 +      if (off_con != (jlong) java_lang_ref_Reference::referent_offset) {
    1.16          // The constant offset is something other than referent_offset.
    1.17          // We can skip generating/checking the remaining guards and
    1.18          // skip generation of the code stub.
    1.19 @@ -2112,15 +2115,29 @@
    1.20        // the offset check.
    1.21        if (gen_offset_check) {
    1.22          // if (offset == referent_offset) -> slow code stub
    1.23 -        __ cmp(lir_cond_equal, off.result(),
    1.24 -               LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset));
    1.25 +        // If offset is an int then we can do the comparison with the
    1.26 +        // referent_offset constant; otherwise we need to move
    1.27 +        // referent_offset into a temporary register and generate
    1.28 +        // a reg-reg compare.
    1.29 +
    1.30 +        LIR_Opr referent_off;
    1.31 +
    1.32 +        if (off.type()->is_int()) {
    1.33 +          referent_off = LIR_OprFact::intConst(java_lang_ref_Reference::referent_offset);
    1.34 +        } else {
    1.35 +          assert(off.type()->is_long(), "what else?");
    1.36 +          referent_off = new_register(T_LONG);
    1.37 +          __ move(LIR_OprFact::longConst(java_lang_ref_Reference::referent_offset), referent_off);
    1.38 +        }
    1.39 +
    1.40 +        __ cmp(lir_cond_equal, off.result(), referent_off);
    1.41  
    1.42          // Optionally generate "src == null" check.
    1.43          stub = new G1UnsafeGetObjSATBBarrierStub(reg, src.result(),
    1.44                                                      src_klass, thread,
    1.45                                                      gen_source_check);
    1.46  
    1.47 -        __ branch(lir_cond_equal, T_INT, stub);
    1.48 +        __ branch(lir_cond_equal, as_BasicType(off.type()), stub);
    1.49        } else {
    1.50          if (gen_source_check) {
    1.51            // offset is a const and equals referent offset

mercurial