< prev index next >

src/cpu/aarch64/vm/jniFastGetField_aarch64.cpp

Print this page




  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 "memory/resourceArea.hpp"
  29 #include "prims/jniFastGetField.hpp"
  30 #include "prims/jvm_misc.hpp"
  31 #include "runtime/safepoint.hpp"

  32 
  33 #define __ masm->
  34 
  35 #define BUFFER_SIZE 30*wordSize
  36 
  37 // Instead of issuing a LoadLoad barrier we create an address
  38 // dependency between loads; this might be more efficient.
  39 
  40 // Common register usage:
  41 // r0/v0:      result
  42 // c_rarg0:    jni env
  43 // c_rarg1:    obj
  44 // c_rarg2:    jfield id
  45 
  46 static const Register robj          = r3;
  47 static const Register rcounter      = r4;
  48 static const Register roffset       = r5;
  49 static const Register rcounter_addr = r6;
  50 static const Register result        = r7;
  51 


  65   ResourceMark rm;
  66   BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE);
  67   CodeBuffer cbuf(blob);
  68   MacroAssembler* masm = new MacroAssembler(&cbuf);
  69   address fast_entry = __ pc();
  70 
  71   Label slow;
  72 
  73   unsigned long offset;
  74   __ adrp(rcounter_addr,
  75           SafepointSynchronize::safepoint_counter_addr(), offset);
  76   Address safepoint_counter_addr(rcounter_addr, offset);
  77   __ ldrw(rcounter, safepoint_counter_addr);
  78   __ andw(rscratch1, rcounter, 1);
  79   __ cbnzw(rscratch1, slow);
  80   __ eor(robj, c_rarg1, rcounter);
  81   __ eor(robj, robj, rcounter);               // obj, since
  82                                               // robj ^ rcounter ^ rcounter == robj
  83                                               // robj is address dependent on rcounter.
  84   __ ldr(robj, Address(robj, 0));             // *obj
  85   __ lsr(roffset, c_rarg2, 2);                // offset
  86 
  87   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
  88   speculative_load_pclist[count] = __ pc();   // Used by the segfault handler
  89   switch (type) {
  90     case T_BOOLEAN: __ ldrb    (result, Address(robj, roffset)); break;
  91     case T_BYTE:    __ ldrsb   (result, Address(robj, roffset)); break;
  92     case T_CHAR:    __ ldrh    (result, Address(robj, roffset)); break;
  93     case T_SHORT:   __ ldrsh   (result, Address(robj, roffset)); break;
  94     case T_FLOAT:   __ ldrw    (result, Address(robj, roffset)); break;
  95     case T_INT:     __ ldrsw   (result, Address(robj, roffset)); break;
  96     case T_DOUBLE:
  97     case T_LONG:    __ ldr     (result, Address(robj, roffset)); break;
  98     default:        ShouldNotReachHere();
  99   }
 100 
 101   // counter_addr is address dependent on result.
 102   __ eor(rcounter_addr, rcounter_addr, result);
 103   __ eor(rcounter_addr, rcounter_addr, result);
 104   __ ldrw(rscratch1, safepoint_counter_addr);
 105   __ cmpw(rcounter, rscratch1);




  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 "memory/resourceArea.hpp"
  29 #include "prims/jniFastGetField.hpp"
  30 #include "prims/jvm_misc.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "runtime/jfieldIDWorkaround.hpp"
  33 
  34 #define __ masm->
  35 
  36 #define BUFFER_SIZE 30*wordSize
  37 
  38 // Instead of issuing a LoadLoad barrier we create an address
  39 // dependency between loads; this might be more efficient.
  40 
  41 // Common register usage:
  42 // r0/v0:      result
  43 // c_rarg0:    jni env
  44 // c_rarg1:    obj
  45 // c_rarg2:    jfield id
  46 
  47 static const Register robj          = r3;
  48 static const Register rcounter      = r4;
  49 static const Register roffset       = r5;
  50 static const Register rcounter_addr = r6;
  51 static const Register result        = r7;
  52 


  66   ResourceMark rm;
  67   BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE);
  68   CodeBuffer cbuf(blob);
  69   MacroAssembler* masm = new MacroAssembler(&cbuf);
  70   address fast_entry = __ pc();
  71 
  72   Label slow;
  73 
  74   unsigned long offset;
  75   __ adrp(rcounter_addr,
  76           SafepointSynchronize::safepoint_counter_addr(), offset);
  77   Address safepoint_counter_addr(rcounter_addr, offset);
  78   __ ldrw(rcounter, safepoint_counter_addr);
  79   __ andw(rscratch1, rcounter, 1);
  80   __ cbnzw(rscratch1, slow);
  81   __ eor(robj, c_rarg1, rcounter);
  82   __ eor(robj, robj, rcounter);               // obj, since
  83                                               // robj ^ rcounter ^ rcounter == robj
  84                                               // robj is address dependent on rcounter.
  85   __ ldr(robj, Address(robj, 0));             // *obj
  86   __ lsr(roffset, c_rarg2, jfieldIDWorkaround::offset_shift); // offset
  87 
  88   assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
  89   speculative_load_pclist[count] = __ pc();   // Used by the segfault handler
  90   switch (type) {
  91     case T_BOOLEAN: __ ldrb    (result, Address(robj, roffset)); break;
  92     case T_BYTE:    __ ldrsb   (result, Address(robj, roffset)); break;
  93     case T_CHAR:    __ ldrh    (result, Address(robj, roffset)); break;
  94     case T_SHORT:   __ ldrsh   (result, Address(robj, roffset)); break;
  95     case T_FLOAT:   __ ldrw    (result, Address(robj, roffset)); break;
  96     case T_INT:     __ ldrsw   (result, Address(robj, roffset)); break;
  97     case T_DOUBLE:
  98     case T_LONG:    __ ldr     (result, Address(robj, roffset)); break;
  99     default:        ShouldNotReachHere();
 100   }
 101 
 102   // counter_addr is address dependent on result.
 103   __ eor(rcounter_addr, rcounter_addr, result);
 104   __ eor(rcounter_addr, rcounter_addr, result);
 105   __ ldrw(rscratch1, safepoint_counter_addr);
 106   __ cmpw(rcounter, rscratch1);


< prev index next >