< prev index next >

src/hotspot/cpu/aarch64/jniFastGetField_aarch64.cpp

Print this page


   1 /*
   2  * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   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.


  62     case T_LONG:    name = "jni_fast_GetLongField";    break;
  63     case T_FLOAT:   name = "jni_fast_GetFloatField";   break;
  64     case T_DOUBLE:  name = "jni_fast_GetDoubleField";  break;
  65     default:        ShouldNotReachHere();
  66       name = NULL;  // unreachable
  67   }
  68   ResourceMark rm;
  69   BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE);
  70   CodeBuffer cbuf(blob);
  71   MacroAssembler* masm = new MacroAssembler(&cbuf);
  72   address fast_entry = __ pc();
  73 
  74   Label slow;
  75 
  76   unsigned long offset;
  77   __ adrp(rcounter_addr,
  78           SafepointSynchronize::safepoint_counter_addr(), offset);
  79   Address safepoint_counter_addr(rcounter_addr, offset);
  80   __ ldrw(rcounter, safepoint_counter_addr);
  81   __ tbnz(rcounter, 0, slow);




  82 
  83   if (!UseBarriersForVolatile) {
  84     // Field may be volatile. See other usages of this flag.
  85     __ membar(MacroAssembler::AnyAny);
  86     __ mov(robj, c_rarg1);
  87   } else if (JvmtiExport::can_post_field_access()) {
  88     // Using barrier to order wrt. JVMTI check and load of result.
  89     __ membar(Assembler::LoadLoad);
  90     __ mov(robj, c_rarg1);
  91   } else {
  92     // Using address dependency to order wrt. load of result.
  93     __ eor(robj, c_rarg1, rcounter);
  94     __ eor(robj, robj, rcounter);         // obj, since
  95                                           // robj ^ rcounter ^ rcounter == robj
  96                                           // robj is address dependent on rcounter.
  97   }
  98 
  99   if (JvmtiExport::can_post_field_access()) {
 100     // Check to see if a field access watch has been set before we
 101     // take the fast path.
 102     unsigned long offset2;
 103     __ adrp(result,
 104             ExternalAddress((address) JvmtiExport::get_field_access_count_addr()),
 105             offset2);
 106     __ ldrw(result, Address(result, offset2));
 107     __ cbnzw(result, slow);
 108   }
 109 
 110   // Both robj and rscratch1 are clobbered by try_resolve_jobject_in_native.
 111   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
 112   bs->try_resolve_jobject_in_native(masm, c_rarg0, robj, rscratch1, slow);
 113 
 114   __ lsr(roffset, c_rarg2, 2);                // offset
 115   __ add(result, robj, roffset);
 116 
 117   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
 118   speculative_load_pclist[count] = __ pc();   // Used by the segfault handler
 119   // Using acquire: Order JVMTI check and load of result wrt. succeeding check
 120   // (LoadStore for volatile field).
 121   switch (type) {
 122     case T_BOOLEAN: __ ldarb(result, result); break;
 123     case T_BYTE:    __ ldarb(result, result); __ sxtb(result, result); break;
 124     case T_CHAR:    __ ldarh(result, result); break;
 125     case T_SHORT:   __ ldarh(result, result); __ sxth(result, result); break;
 126     case T_FLOAT:   __ ldarw(result, result); break;
 127     case T_INT:     __ ldarw(result, result); __ sxtw(result, result); break;
 128     case T_DOUBLE:
 129     case T_LONG:    __ ldar (result, result); break;
 130     default:        ShouldNotReachHere();
 131   }
 132 



 133   __ ldrw(rscratch1, safepoint_counter_addr);
 134   __ cmpw(rcounter, rscratch1);
 135   __ br (Assembler::NE, slow);
 136 
 137   switch (type) {
 138     case T_FLOAT:   __ fmovs(v0, result); break;
 139     case T_DOUBLE:  __ fmovd(v0, result); break;
 140     default:        __ mov(r0, result);   break;
 141   }
 142   __ ret(lr);
 143 
 144   slowcase_entry_pclist[count++] = __ pc();
 145   __ bind(slow);
 146   address slow_case_addr;
 147   switch (type) {
 148     case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
 149     case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
 150     case T_CHAR:    slow_case_addr = jni_GetCharField_addr();    break;
 151     case T_SHORT:   slow_case_addr = jni_GetShortField_addr();   break;
 152     case T_INT:     slow_case_addr = jni_GetIntField_addr();     break;


   1 /*
   2  * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   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.


  62     case T_LONG:    name = "jni_fast_GetLongField";    break;
  63     case T_FLOAT:   name = "jni_fast_GetFloatField";   break;
  64     case T_DOUBLE:  name = "jni_fast_GetDoubleField";  break;
  65     default:        ShouldNotReachHere();
  66       name = NULL;  // unreachable
  67   }
  68   ResourceMark rm;
  69   BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE);
  70   CodeBuffer cbuf(blob);
  71   MacroAssembler* masm = new MacroAssembler(&cbuf);
  72   address fast_entry = __ pc();
  73 
  74   Label slow;
  75 
  76   unsigned long offset;
  77   __ adrp(rcounter_addr,
  78           SafepointSynchronize::safepoint_counter_addr(), offset);
  79   Address safepoint_counter_addr(rcounter_addr, offset);
  80   __ ldrw(rcounter, safepoint_counter_addr);
  81   __ tbnz(rcounter, 0, slow);
  82   __ eor(robj, c_rarg1, rcounter);
  83   __ eor(robj, robj, rcounter);               // obj, since
  84                                               // robj ^ rcounter ^ rcounter == robj
  85                                               // robj is address dependent on rcounter.
  86 




























  87   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
  88   bs->try_resolve_jobject_in_native(masm, c_rarg0, robj, rscratch1, slow);
  89 
  90   __ lsr(roffset, c_rarg2, 2);                // offset

  91 
  92   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
  93   speculative_load_pclist[count] = __ pc();   // Used by the segfault handler


  94   switch (type) {
  95     case T_BOOLEAN: __ ldrb    (result, Address(robj, roffset)); break;
  96     case T_BYTE:    __ ldrsb   (result, Address(robj, roffset)); break;
  97     case T_CHAR:    __ ldrh    (result, Address(robj, roffset)); break;
  98     case T_SHORT:   __ ldrsh   (result, Address(robj, roffset)); break;
  99     case T_FLOAT:   __ ldrw    (result, Address(robj, roffset)); break;
 100     case T_INT:     __ ldrsw   (result, Address(robj, roffset)); break;
 101     case T_DOUBLE:
 102     case T_LONG:    __ ldr     (result, Address(robj, roffset)); break;
 103     default:        ShouldNotReachHere();
 104   }
 105 
 106   // counter_addr is address dependent on result.
 107   __ eor(rcounter_addr, rcounter_addr, result);
 108   __ eor(rcounter_addr, rcounter_addr, result);
 109   __ ldrw(rscratch1, safepoint_counter_addr);
 110   __ cmpw(rcounter, rscratch1);
 111   __ br (Assembler::NE, slow);
 112 
 113   switch (type) {
 114     case T_FLOAT:   __ fmovs(v0, result); break;
 115     case T_DOUBLE:  __ fmovd(v0, result); break;
 116     default:        __ mov(r0, result);   break;
 117   }
 118   __ ret(lr);
 119 
 120   slowcase_entry_pclist[count++] = __ pc();
 121   __ bind(slow);
 122   address slow_case_addr;
 123   switch (type) {
 124     case T_BOOLEAN: slow_case_addr = jni_GetBooleanField_addr(); break;
 125     case T_BYTE:    slow_case_addr = jni_GetByteField_addr();    break;
 126     case T_CHAR:    slow_case_addr = jni_GetCharField_addr();    break;
 127     case T_SHORT:   slow_case_addr = jni_GetShortField_addr();   break;
 128     case T_INT:     slow_case_addr = jni_GetIntField_addr();     break;


< prev index next >