< prev index next >

src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp

Print this page




  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.inline.hpp"
  28 #include "c1/c1_MacroAssembler.hpp"
  29 #include "c1/c1_Runtime1.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "oops/arrayOop.hpp"
  34 #include "oops/markWord.hpp"
  35 #include "runtime/basicLock.hpp"
  36 #include "runtime/biasedLocking.hpp"
  37 #include "runtime/os.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/stubRoutines.hpp"
  40 #include "utilities/align.hpp"
  41 
  42 
  43 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
  44   const Register temp_reg = R12_scratch2;
  45   Label Lmiss;
  46 
  47   verify_oop(receiver);
  48   MacroAssembler::null_check(receiver, oopDesc::klass_offset_in_bytes(), &Lmiss);
  49   load_klass(temp_reg, receiver);
  50 
  51   if (TrapBasedICMissChecks && TrapBasedNullChecks) {
  52     trap_ic_miss_check(temp_reg, iCache);
  53   } else {
  54     Label Lok;


  93 void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox, Register Rscratch, Label& slow_case) {
  94   assert_different_registers(Rmark, Roop, Rbox, Rscratch);
  95 
  96   Label done, cas_failed, slow_int;
  97 
  98   // The following move must be the first instruction of emitted since debug
  99   // information may be generated for it.
 100   // Load object header.
 101   ld(Rmark, oopDesc::mark_offset_in_bytes(), Roop);
 102 
 103   verify_oop(Roop);
 104 
 105   // Save object being locked into the BasicObjectLock...
 106   std(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox);
 107 
 108   if (UseBiasedLocking) {
 109     biased_locking_enter(CCR0, Roop, Rmark, Rscratch, R0, done, &slow_int);
 110   }
 111 
 112   // ... and mark it unlocked.
 113   ori(Rmark, Rmark, markWord::unlocked_value);
 114 
 115   // Save unlocked object header into the displaced header location on the stack.
 116   std(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox);
 117 
 118   // Compare object markWord with Rmark and if equal exchange Rscratch with object markWord.
 119   assert(oopDesc::mark_offset_in_bytes() == 0, "cas must take a zero displacement");
 120   cmpxchgd(/*flag=*/CCR0,
 121            /*current_value=*/Rscratch,
 122            /*compare_value=*/Rmark,
 123            /*exchange_value=*/Rbox,
 124            /*where=*/Roop/*+0==mark_offset_in_bytes*/,
 125            MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
 126            MacroAssembler::cmpxchgx_hint_acquire_lock(),
 127            noreg,
 128            &cas_failed,
 129            /*check without membar and ldarx first*/true);
 130   // If compare/exchange succeeded we found an unlocked object and we now have locked it
 131   // hence we are done.
 132   b(done);
 133 
 134   bind(slow_int);
 135   b(slow_case); // far
 136 
 137   bind(cas_failed);
 138   // We did not find an unlocked object so see if this is a recursive case.
 139   sub(Rscratch, Rscratch, R1_SP);
 140   load_const_optimized(R0, (~(os::vm_page_size()-1) | markWord::lock_mask_in_place));
 141   and_(R0/*==0?*/, Rscratch, R0);
 142   std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), Rbox);
 143   bne(CCR0, slow_int);
 144 
 145   bind(done);
 146 }
 147 
 148 
 149 void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rbox, Label& slow_case) {
 150   assert_different_registers(Rmark, Roop, Rbox);
 151 
 152   Label slow_int, done;
 153 
 154   Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
 155   assert(mark_addr.disp() == 0, "cas must take a zero displacement");
 156 
 157   if (UseBiasedLocking) {
 158     // Load the object out of the BasicObjectLock.
 159     ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox);
 160     verify_oop(Roop);
 161     biased_locking_exit(CCR0, Roop, R0, done);
 162   }
 163   // Test first it it is a fast recursive unlock.
 164   ld(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox);
 165   cmpdi(CCR0, Rmark, 0);
 166   beq(CCR0, done);
 167   if (!UseBiasedLocking) {
 168     // Load object.
 169     ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox);
 170     verify_oop(Roop);
 171   }
 172 
 173   // Check if it is still a light weight lock, this is is true if we see
 174   // the stack address of the basicLock in the markWord of the object.
 175   cmpxchgd(/*flag=*/CCR0,
 176            /*current_value=*/R0,
 177            /*compare_value=*/Rbox,
 178            /*exchange_value=*/Rmark,
 179            /*where=*/Roop,
 180            MacroAssembler::MemBarRel,
 181            MacroAssembler::cmpxchgx_hint_release_lock(),
 182            noreg,
 183            &slow_int);
 184   b(done);
 185   bind(slow_int);
 186   b(slow_case); // far
 187 
 188   // Done
 189   bind(done);
 190 }
 191 
 192 
 193 void C1_MacroAssembler::try_allocate(
 194   Register obj,                        // result: pointer to object after successful allocation


 198   Register t2,                         // temp register
 199   Label&   slow_case                   // continuation point if fast allocation fails
 200 ) {
 201   if (UseTLAB) {
 202     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);
 203   } else {
 204     eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
 205     RegisterOrConstant size_in_bytes = var_size_in_bytes->is_valid()
 206                                        ? RegisterOrConstant(var_size_in_bytes)
 207                                        : RegisterOrConstant(con_size_in_bytes);
 208     incr_allocated_bytes(size_in_bytes, t1, t2);
 209   }
 210 }
 211 
 212 
 213 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
 214   assert_different_registers(obj, klass, len, t1, t2);
 215   if (UseBiasedLocking && !len->is_valid()) {
 216     ld(t1, in_bytes(Klass::prototype_header_offset()), klass);
 217   } else {
 218     load_const_optimized(t1, (intx)markWord::prototype().value());
 219   }
 220   std(t1, oopDesc::mark_offset_in_bytes(), obj);
 221   store_klass(obj, klass);
 222   if (len->is_valid()) {
 223     stw(len, arrayOopDesc::length_offset_in_bytes(), obj);
 224   } else if (UseCompressedClassPointers) {
 225     // Otherwise length is in the class gap.
 226     store_klass_gap(obj);
 227   }
 228 }
 229 
 230 
 231 void C1_MacroAssembler::initialize_body(Register base, Register index) {
 232   assert_different_registers(base, index);
 233   srdi(index, index, LogBytesPerWord);
 234   clear_memory_doubleword(base, index);
 235 }
 236 
 237 void C1_MacroAssembler::initialize_body(Register obj, Register tmp1, Register tmp2,
 238                                         int obj_size_in_bytes, int hdr_size_in_bytes) {




  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.inline.hpp"
  28 #include "c1/c1_MacroAssembler.hpp"
  29 #include "c1/c1_Runtime1.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "gc/shared/collectedHeap.hpp"
  32 #include "interpreter/interpreter.hpp"
  33 #include "oops/arrayOop.hpp"
  34 #include "oops/markOop.hpp"
  35 #include "runtime/basicLock.hpp"
  36 #include "runtime/biasedLocking.hpp"
  37 #include "runtime/os.hpp"
  38 #include "runtime/sharedRuntime.hpp"
  39 #include "runtime/stubRoutines.hpp"
  40 #include "utilities/align.hpp"
  41 
  42 
  43 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
  44   const Register temp_reg = R12_scratch2;
  45   Label Lmiss;
  46 
  47   verify_oop(receiver);
  48   MacroAssembler::null_check(receiver, oopDesc::klass_offset_in_bytes(), &Lmiss);
  49   load_klass(temp_reg, receiver);
  50 
  51   if (TrapBasedICMissChecks && TrapBasedNullChecks) {
  52     trap_ic_miss_check(temp_reg, iCache);
  53   } else {
  54     Label Lok;


  93 void C1_MacroAssembler::lock_object(Register Rmark, Register Roop, Register Rbox, Register Rscratch, Label& slow_case) {
  94   assert_different_registers(Rmark, Roop, Rbox, Rscratch);
  95 
  96   Label done, cas_failed, slow_int;
  97 
  98   // The following move must be the first instruction of emitted since debug
  99   // information may be generated for it.
 100   // Load object header.
 101   ld(Rmark, oopDesc::mark_offset_in_bytes(), Roop);
 102 
 103   verify_oop(Roop);
 104 
 105   // Save object being locked into the BasicObjectLock...
 106   std(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox);
 107 
 108   if (UseBiasedLocking) {
 109     biased_locking_enter(CCR0, Roop, Rmark, Rscratch, R0, done, &slow_int);
 110   }
 111 
 112   // ... and mark it unlocked.
 113   ori(Rmark, Rmark, markOopDesc::unlocked_value);
 114 
 115   // Save unlocked object header into the displaced header location on the stack.
 116   std(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox);
 117 
 118   // Compare object markOop with Rmark and if equal exchange Rscratch with object markOop.
 119   assert(oopDesc::mark_offset_in_bytes() == 0, "cas must take a zero displacement");
 120   cmpxchgd(/*flag=*/CCR0,
 121            /*current_value=*/Rscratch,
 122            /*compare_value=*/Rmark,
 123            /*exchange_value=*/Rbox,
 124            /*where=*/Roop/*+0==mark_offset_in_bytes*/,
 125            MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
 126            MacroAssembler::cmpxchgx_hint_acquire_lock(),
 127            noreg,
 128            &cas_failed,
 129            /*check without membar and ldarx first*/true);
 130   // If compare/exchange succeeded we found an unlocked object and we now have locked it
 131   // hence we are done.
 132   b(done);
 133 
 134   bind(slow_int);
 135   b(slow_case); // far
 136 
 137   bind(cas_failed);
 138   // We did not find an unlocked object so see if this is a recursive case.
 139   sub(Rscratch, Rscratch, R1_SP);
 140   load_const_optimized(R0, (~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place));
 141   and_(R0/*==0?*/, Rscratch, R0);
 142   std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), Rbox);
 143   bne(CCR0, slow_int);
 144 
 145   bind(done);
 146 }
 147 
 148 
 149 void C1_MacroAssembler::unlock_object(Register Rmark, Register Roop, Register Rbox, Label& slow_case) {
 150   assert_different_registers(Rmark, Roop, Rbox);
 151 
 152   Label slow_int, done;
 153 
 154   Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
 155   assert(mark_addr.disp() == 0, "cas must take a zero displacement");
 156 
 157   if (UseBiasedLocking) {
 158     // Load the object out of the BasicObjectLock.
 159     ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox);
 160     verify_oop(Roop);
 161     biased_locking_exit(CCR0, Roop, R0, done);
 162   }
 163   // Test first it it is a fast recursive unlock.
 164   ld(Rmark, BasicLock::displaced_header_offset_in_bytes(), Rbox);
 165   cmpdi(CCR0, Rmark, 0);
 166   beq(CCR0, done);
 167   if (!UseBiasedLocking) {
 168     // Load object.
 169     ld(Roop, BasicObjectLock::obj_offset_in_bytes(), Rbox);
 170     verify_oop(Roop);
 171   }
 172 
 173   // Check if it is still a light weight lock, this is is true if we see
 174   // the stack address of the basicLock in the markOop of the object.
 175   cmpxchgd(/*flag=*/CCR0,
 176            /*current_value=*/R0,
 177            /*compare_value=*/Rbox,
 178            /*exchange_value=*/Rmark,
 179            /*where=*/Roop,
 180            MacroAssembler::MemBarRel,
 181            MacroAssembler::cmpxchgx_hint_release_lock(),
 182            noreg,
 183            &slow_int);
 184   b(done);
 185   bind(slow_int);
 186   b(slow_case); // far
 187 
 188   // Done
 189   bind(done);
 190 }
 191 
 192 
 193 void C1_MacroAssembler::try_allocate(
 194   Register obj,                        // result: pointer to object after successful allocation


 198   Register t2,                         // temp register
 199   Label&   slow_case                   // continuation point if fast allocation fails
 200 ) {
 201   if (UseTLAB) {
 202     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);
 203   } else {
 204     eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
 205     RegisterOrConstant size_in_bytes = var_size_in_bytes->is_valid()
 206                                        ? RegisterOrConstant(var_size_in_bytes)
 207                                        : RegisterOrConstant(con_size_in_bytes);
 208     incr_allocated_bytes(size_in_bytes, t1, t2);
 209   }
 210 }
 211 
 212 
 213 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
 214   assert_different_registers(obj, klass, len, t1, t2);
 215   if (UseBiasedLocking && !len->is_valid()) {
 216     ld(t1, in_bytes(Klass::prototype_header_offset()), klass);
 217   } else {
 218     load_const_optimized(t1, (intx)markOopDesc::prototype());
 219   }
 220   std(t1, oopDesc::mark_offset_in_bytes(), obj);
 221   store_klass(obj, klass);
 222   if (len->is_valid()) {
 223     stw(len, arrayOopDesc::length_offset_in_bytes(), obj);
 224   } else if (UseCompressedClassPointers) {
 225     // Otherwise length is in the class gap.
 226     store_klass_gap(obj);
 227   }
 228 }
 229 
 230 
 231 void C1_MacroAssembler::initialize_body(Register base, Register index) {
 232   assert_different_registers(base, index);
 233   srdi(index, index, LogBytesPerWord);
 234   clear_memory_doubleword(base, index);
 235 }
 236 
 237 void C1_MacroAssembler::initialize_body(Register obj, Register tmp1, Register tmp2,
 238                                         int obj_size_in_bytes, int hdr_size_in_bytes) {


< prev index next >