src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54825 1b03400e5a8f
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    30 #include "gc/shared/barrierSet.hpp"
    30 #include "gc/shared/barrierSet.hpp"
    31 #include "gc/shared/barrierSetAssembler.hpp"
    31 #include "gc/shared/barrierSetAssembler.hpp"
    32 #include "interpreter/interpreter.hpp"
    32 #include "interpreter/interpreter.hpp"
    33 #include "memory/resourceArea.hpp"
    33 #include "memory/resourceArea.hpp"
    34 #include "nativeInst_ppc.hpp"
    34 #include "nativeInst_ppc.hpp"
       
    35 #include "oops/klass.inline.hpp"
    35 #include "prims/methodHandles.hpp"
    36 #include "prims/methodHandles.hpp"
    36 #include "runtime/biasedLocking.hpp"
    37 #include "runtime/biasedLocking.hpp"
    37 #include "runtime/icache.hpp"
    38 #include "runtime/icache.hpp"
    38 #include "runtime/interfaceSupport.inline.hpp"
    39 #include "runtime/interfaceSupport.inline.hpp"
    39 #include "runtime/objectMonitor.hpp"
    40 #include "runtime/objectMonitor.hpp"
  2009   check_klass_subtype_fast_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success, &L_failure);
  2010   check_klass_subtype_fast_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success, &L_failure);
  2010   check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success);
  2011   check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success);
  2011   bind(L_failure); // Fallthru if not successful.
  2012   bind(L_failure); // Fallthru if not successful.
  2012 }
  2013 }
  2013 
  2014 
  2014 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
  2015 void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fast_path, Label* L_slow_path) {
  2015                                               Register temp_reg,
  2016   assert(L_fast_path != NULL || L_slow_path != NULL, "at least one is required");
  2016                                               Label& wrong_method_type) {
  2017 
  2017   assert_different_registers(mtype_reg, mh_reg, temp_reg);
  2018   Label L_fallthrough;
  2018   // Compare method type against that of the receiver.
  2019   if (L_fast_path == NULL) {
  2019   load_heap_oop(temp_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg), mh_reg,
  2020     L_fast_path = &L_fallthrough;
  2020                 noreg, noreg, false, IS_NOT_NULL);
  2021   } else if (L_slow_path == NULL) {
  2021   cmpd(CCR0, temp_reg, mtype_reg);
  2022     L_slow_path = &L_fallthrough;
  2022   bne(CCR0, wrong_method_type);
  2023   }
       
  2024 
       
  2025   // Fast path check: class is fully initialized
       
  2026   lbz(R0, in_bytes(InstanceKlass::init_state_offset()), klass);
       
  2027   cmpwi(CCR0, R0, InstanceKlass::fully_initialized);
       
  2028   beq(CCR0, *L_fast_path);
       
  2029 
       
  2030   // Fast path check: current thread is initializer thread
       
  2031   ld(R0, in_bytes(InstanceKlass::init_thread_offset()), klass);
       
  2032   cmpd(CCR0, thread, R0);
       
  2033   if (L_slow_path == &L_fallthrough) {
       
  2034     beq(CCR0, *L_fast_path);
       
  2035   } else if (L_fast_path == &L_fallthrough) {
       
  2036     bne(CCR0, *L_slow_path);
       
  2037   } else {
       
  2038     Unimplemented();
       
  2039   }
       
  2040 
       
  2041   bind(L_fallthrough);
  2023 }
  2042 }
  2024 
  2043 
  2025 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
  2044 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
  2026                                                    Register temp_reg,
  2045                                                    Register temp_reg,
  2027                                                    int extra_slot_offset) {
  2046                                                    int extra_slot_offset) {
  2058   // Biased locking
  2077   // Biased locking
  2059   // See whether the lock is currently biased toward our thread and
  2078   // See whether the lock is currently biased toward our thread and
  2060   // whether the epoch is still valid
  2079   // whether the epoch is still valid
  2061   // Note that the runtime guarantees sufficient alignment of JavaThread
  2080   // Note that the runtime guarantees sufficient alignment of JavaThread
  2062   // pointers to allow age to be placed into low bits
  2081   // pointers to allow age to be placed into low bits
  2063   assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits,
  2082   assert(markWord::age_shift == markWord::lock_bits + markWord::biased_lock_bits,
  2064          "biased locking makes assumptions about bit layout");
  2083          "biased locking makes assumptions about bit layout");
  2065 
  2084 
  2066   if (PrintBiasedLockingStatistics) {
  2085   if (PrintBiasedLockingStatistics) {
  2067     load_const(temp2_reg, (address) BiasedLocking::total_entry_count_addr(), temp_reg);
  2086     load_const(temp2_reg, (address) BiasedLocking::total_entry_count_addr(), temp_reg);
  2068     lwzx(temp_reg, temp2_reg);
  2087     lwzx(temp_reg, temp2_reg);
  2069     addi(temp_reg, temp_reg, 1);
  2088     addi(temp_reg, temp_reg, 1);
  2070     stwx(temp_reg, temp2_reg);
  2089     stwx(temp_reg, temp2_reg);
  2071   }
  2090   }
  2072 
  2091 
  2073   andi(temp_reg, mark_reg, markOopDesc::biased_lock_mask_in_place);
  2092   andi(temp_reg, mark_reg, markWord::biased_lock_mask_in_place);
  2074   cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern);
  2093   cmpwi(cr_reg, temp_reg, markWord::biased_lock_pattern);
  2075   bne(cr_reg, cas_label);
  2094   bne(cr_reg, cas_label);
  2076 
  2095 
  2077   load_klass(temp_reg, obj_reg);
  2096   load_klass(temp_reg, obj_reg);
  2078 
  2097 
  2079   load_const_optimized(temp2_reg, ~((int) markOopDesc::age_mask_in_place));
  2098   load_const_optimized(temp2_reg, ~((int) markWord::age_mask_in_place));
  2080   ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
  2099   ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
  2081   orr(temp_reg, R16_thread, temp_reg);
  2100   orr(temp_reg, R16_thread, temp_reg);
  2082   xorr(temp_reg, mark_reg, temp_reg);
  2101   xorr(temp_reg, mark_reg, temp_reg);
  2083   andr(temp_reg, temp_reg, temp2_reg);
  2102   andr(temp_reg, temp_reg, temp2_reg);
  2084   cmpdi(cr_reg, temp_reg, 0);
  2103   cmpdi(cr_reg, temp_reg, 0);
  2105   // header.
  2124   // header.
  2106 
  2125 
  2107   // If the low three bits in the xor result aren't clear, that means
  2126   // If the low three bits in the xor result aren't clear, that means
  2108   // the prototype header is no longer biased and we have to revoke
  2127   // the prototype header is no longer biased and we have to revoke
  2109   // the bias on this object.
  2128   // the bias on this object.
  2110   andi(temp2_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
  2129   andi(temp2_reg, temp_reg, markWord::biased_lock_mask_in_place);
  2111   cmpwi(cr_reg, temp2_reg, 0);
  2130   cmpwi(cr_reg, temp2_reg, 0);
  2112   bne(cr_reg, try_revoke_bias);
  2131   bne(cr_reg, try_revoke_bias);
  2113 
  2132 
  2114   // Biasing is still enabled for this data type. See whether the
  2133   // Biasing is still enabled for this data type. See whether the
  2115   // epoch of the current bias is still valid, meaning that the epoch
  2134   // epoch of the current bias is still valid, meaning that the epoch
  2119   // toward the current thread. Note that we must be absolutely sure
  2138   // toward the current thread. Note that we must be absolutely sure
  2120   // that the current epoch is invalid in order to do this because
  2139   // that the current epoch is invalid in order to do this because
  2121   // otherwise the manipulations it performs on the mark word are
  2140   // otherwise the manipulations it performs on the mark word are
  2122   // illegal.
  2141   // illegal.
  2123 
  2142 
  2124   int shift_amount = 64 - markOopDesc::epoch_shift;
  2143   int shift_amount = 64 - markWord::epoch_shift;
  2125   // rotate epoch bits to right (little) end and set other bits to 0
  2144   // rotate epoch bits to right (little) end and set other bits to 0
  2126   // [ big part | epoch | little part ] -> [ 0..0 | epoch ]
  2145   // [ big part | epoch | little part ] -> [ 0..0 | epoch ]
  2127   rldicl_(temp2_reg, temp_reg, shift_amount, 64 - markOopDesc::epoch_bits);
  2146   rldicl_(temp2_reg, temp_reg, shift_amount, 64 - markWord::epoch_bits);
  2128   // branch if epoch bits are != 0, i.e. they differ, because the epoch has been incremented
  2147   // branch if epoch bits are != 0, i.e. they differ, because the epoch has been incremented
  2129   bne(CCR0, try_rebias);
  2148   bne(CCR0, try_rebias);
  2130 
  2149 
  2131   // The epoch of the current bias is still valid but we know nothing
  2150   // The epoch of the current bias is still valid but we know nothing
  2132   // about the owner; it might be set or it might be clear. Try to
  2151   // about the owner; it might be set or it might be clear. Try to
  2133   // acquire the bias of the object using an atomic operation. If this
  2152   // acquire the bias of the object using an atomic operation. If this
  2134   // fails we will go in to the runtime to revoke the object's bias.
  2153   // fails we will go in to the runtime to revoke the object's bias.
  2135   // Note that we first construct the presumed unbiased header so we
  2154   // Note that we first construct the presumed unbiased header so we
  2136   // don't accidentally blow away another thread's valid bias.
  2155   // don't accidentally blow away another thread's valid bias.
  2137   andi(mark_reg, mark_reg, (markOopDesc::biased_lock_mask_in_place |
  2156   andi(mark_reg, mark_reg, (markWord::biased_lock_mask_in_place |
  2138                                 markOopDesc::age_mask_in_place |
  2157                                 markWord::age_mask_in_place |
  2139                                 markOopDesc::epoch_mask_in_place));
  2158                                 markWord::epoch_mask_in_place));
  2140   orr(temp_reg, R16_thread, mark_reg);
  2159   orr(temp_reg, R16_thread, mark_reg);
  2141 
  2160 
  2142   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  2161   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  2143 
  2162 
  2144   // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
  2163   // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
  2167   // circumstances _only_, we are allowed to use the current header's
  2186   // circumstances _only_, we are allowed to use the current header's
  2168   // value as the comparison value when doing the cas to acquire the
  2187   // value as the comparison value when doing the cas to acquire the
  2169   // bias in the current epoch. In other words, we allow transfer of
  2188   // bias in the current epoch. In other words, we allow transfer of
  2170   // the bias from one thread to another directly in this situation.
  2189   // the bias from one thread to another directly in this situation.
  2171   load_klass(temp_reg, obj_reg);
  2190   load_klass(temp_reg, obj_reg);
  2172   andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place);
  2191   andi(temp2_reg, mark_reg, markWord::age_mask_in_place);
  2173   orr(temp2_reg, R16_thread, temp2_reg);
  2192   orr(temp2_reg, R16_thread, temp2_reg);
  2174   ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
  2193   ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
  2175   orr(temp_reg, temp2_reg, temp_reg);
  2194   orr(temp_reg, temp2_reg, temp_reg);
  2176 
  2195 
  2177   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  2196   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  2204   // that another thread raced us for the privilege of revoking the
  2223   // that another thread raced us for the privilege of revoking the
  2205   // bias of this particular object, so it's okay to continue in the
  2224   // bias of this particular object, so it's okay to continue in the
  2206   // normal locking code.
  2225   // normal locking code.
  2207   load_klass(temp_reg, obj_reg);
  2226   load_klass(temp_reg, obj_reg);
  2208   ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
  2227   ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
  2209   andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place);
  2228   andi(temp2_reg, mark_reg, markWord::age_mask_in_place);
  2210   orr(temp_reg, temp_reg, temp2_reg);
  2229   orr(temp_reg, temp_reg, temp2_reg);
  2211 
  2230 
  2212   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  2231   assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
  2213 
  2232 
  2214   // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
  2233   // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
  2216                  /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
  2235                  /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
  2217                  /*where=*/obj_reg,
  2236                  /*where=*/obj_reg,
  2218                  MacroAssembler::MemBarAcq,
  2237                  MacroAssembler::MemBarAcq,
  2219                  MacroAssembler::cmpxchgx_hint_acquire_lock());
  2238                  MacroAssembler::cmpxchgx_hint_acquire_lock());
  2220 
  2239 
  2221   // reload markOop in mark_reg before continuing with lightweight locking
  2240   // reload markWord in mark_reg before continuing with lightweight locking
  2222   ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
  2241   ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
  2223 
  2242 
  2224   // Fall through to the normal CAS-based lock, because no matter what
  2243   // Fall through to the normal CAS-based lock, because no matter what
  2225   // the result of the above CAS, some thread must have succeeded in
  2244   // the result of the above CAS, some thread must have succeeded in
  2226   // removing the bias bit from the object's header.
  2245   // removing the bias bit from the object's header.
  2244   // a higher level. Second, if the bias was revoked while we held the
  2263   // a higher level. Second, if the bias was revoked while we held the
  2245   // lock, the object could not be rebiased toward another thread, so
  2264   // lock, the object could not be rebiased toward another thread, so
  2246   // the bias bit would be clear.
  2265   // the bias bit would be clear.
  2247 
  2266 
  2248   ld(temp_reg, 0, mark_addr);
  2267   ld(temp_reg, 0, mark_addr);
  2249   andi(temp_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
  2268   andi(temp_reg, temp_reg, markWord::biased_lock_mask_in_place);
  2250 
  2269 
  2251   cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern);
  2270   cmpwi(cr_reg, temp_reg, markWord::biased_lock_pattern);
  2252   beq(cr_reg, done);
  2271   beq(cr_reg, done);
  2253 }
  2272 }
  2254 
  2273 
  2255 // allocation (for C1)
  2274 // allocation (for C1)
  2256 void MacroAssembler::eden_allocate(
  2275 void MacroAssembler::eden_allocate(
  2667 
  2686 
  2668   if (RTMRetryCount > 0) {
  2687   if (RTMRetryCount > 0) {
  2669     load_const_optimized(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort
  2688     load_const_optimized(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort
  2670     bind(L_rtm_retry);
  2689     bind(L_rtm_retry);
  2671   }
  2690   }
  2672   andi_(R0, mark_word, markOopDesc::monitor_value);  // inflated vs stack-locked|neutral|biased
  2691   andi_(R0, mark_word, markWord::monitor_value);  // inflated vs stack-locked|neutral|biased
  2673   bne(CCR0, IsInflated);
  2692   bne(CCR0, IsInflated);
  2674 
  2693 
  2675   if (PrintPreciseRTMLockingStatistics || profile_rtm) {
  2694   if (PrintPreciseRTMLockingStatistics || profile_rtm) {
  2676     Label L_noincrement;
  2695     Label L_noincrement;
  2677     if (RTMTotalCountIncrRate > 1) {
  2696     if (RTMTotalCountIncrRate > 1) {
  2685     stdx(mark_word, tmp);
  2704     stdx(mark_word, tmp);
  2686     bind(L_noincrement);
  2705     bind(L_noincrement);
  2687   }
  2706   }
  2688   tbegin_();
  2707   tbegin_();
  2689   beq(CCR0, L_on_abort);
  2708   beq(CCR0, L_on_abort);
  2690   ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);         // Reload in transaction, conflicts need to be tracked.
  2709   ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);      // Reload in transaction, conflicts need to be tracked.
  2691   andi(R0, mark_word, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits
  2710   andi(R0, mark_word, markWord::biased_lock_mask_in_place); // look at 3 lock bits
  2692   cmpwi(flag, R0, markOopDesc::unlocked_value);                // bits = 001 unlocked
  2711   cmpwi(flag, R0, markWord::unlocked_value);                // bits = 001 unlocked
  2693   beq(flag, DONE_LABEL);                                       // all done if unlocked
  2712   beq(flag, DONE_LABEL);                                    // all done if unlocked
  2694 
  2713 
  2695   if (UseRTMXendForLockBusy) {
  2714   if (UseRTMXendForLockBusy) {
  2696     tend_();
  2715     tend_();
  2697     b(L_decrement_retry);
  2716     b(L_decrement_retry);
  2698   } else {
  2717   } else {
  2724                                           Metadata* method_data, bool profile_rtm,
  2743                                           Metadata* method_data, bool profile_rtm,
  2725                                           Label& DONE_LABEL) {
  2744                                           Label& DONE_LABEL) {
  2726   assert(UseRTMLocking, "why call this otherwise?");
  2745   assert(UseRTMLocking, "why call this otherwise?");
  2727   Label L_rtm_retry, L_decrement_retry, L_on_abort;
  2746   Label L_rtm_retry, L_decrement_retry, L_on_abort;
  2728   // Clean monitor_value bit to get valid pointer.
  2747   // Clean monitor_value bit to get valid pointer.
  2729   int owner_offset = ObjectMonitor::owner_offset_in_bytes() - markOopDesc::monitor_value;
  2748   int owner_offset = ObjectMonitor::owner_offset_in_bytes() - markWord::monitor_value;
  2730 
  2749 
  2731   // Store non-null, using boxReg instead of (intptr_t)markOopDesc::unused_mark().
  2750   // Store non-null, using boxReg instead of (intptr_t)markWord::unused_mark().
  2732   std(boxReg, BasicLock::displaced_header_offset_in_bytes(), boxReg);
  2751   std(boxReg, BasicLock::displaced_header_offset_in_bytes(), boxReg);
  2733   const Register tmpReg = boxReg;
  2752   const Register tmpReg = boxReg;
  2734   const Register owner_addr_Reg = mark_word;
  2753   const Register owner_addr_Reg = mark_word;
  2735   addi(owner_addr_Reg, mark_word, owner_offset);
  2754   addi(owner_addr_Reg, mark_word, owner_offset);
  2736 
  2755 
  2771   if (PrintPreciseRTMLockingStatistics || profile_rtm) {
  2790   if (PrintPreciseRTMLockingStatistics || profile_rtm) {
  2772     rtm_profiling(abort_status_Reg, /*temp*/ owner_addr_Reg, rtm_counters, method_data, profile_rtm);
  2791     rtm_profiling(abort_status_Reg, /*temp*/ owner_addr_Reg, rtm_counters, method_data, profile_rtm);
  2773     // Restore owner_addr_Reg
  2792     // Restore owner_addr_Reg
  2774     ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);
  2793     ld(mark_word, oopDesc::mark_offset_in_bytes(), obj);
  2775 #ifdef ASSERT
  2794 #ifdef ASSERT
  2776     andi_(R0, mark_word, markOopDesc::monitor_value);
  2795     andi_(R0, mark_word, markWord::monitor_value);
  2777     asm_assert_ne("must be inflated", 0xa754); // Deflating only allowed at safepoint.
  2796     asm_assert_ne("must be inflated", 0xa754); // Deflating only allowed at safepoint.
  2778 #endif
  2797 #endif
  2779     addi(owner_addr_Reg, mark_word, owner_offset);
  2798     addi(owner_addr_Reg, mark_word, owner_offset);
  2780   }
  2799   }
  2781   if (RTMRetryCount > 0) {
  2800   if (RTMRetryCount > 0) {
  2813   assert(flag != CCR0, "bad condition register");
  2832   assert(flag != CCR0, "bad condition register");
  2814   Label cont;
  2833   Label cont;
  2815   Label object_has_monitor;
  2834   Label object_has_monitor;
  2816   Label cas_failed;
  2835   Label cas_failed;
  2817 
  2836 
  2818   // Load markOop from object into displaced_header.
  2837   // Load markWord from object into displaced_header.
  2819   ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop);
  2838   ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop);
  2820 
  2839 
  2821 
  2840 
  2822   if (try_bias) {
  2841   if (try_bias) {
  2823     biased_locking_enter(flag, oop, displaced_header, temp, current_header, cont);
  2842     biased_locking_enter(flag, oop, displaced_header, temp, current_header, cont);
  2831   }
  2850   }
  2832 #endif // INCLUDE_RTM_OPT
  2851 #endif // INCLUDE_RTM_OPT
  2833 
  2852 
  2834   // Handle existing monitor.
  2853   // Handle existing monitor.
  2835   // The object has an existing monitor iff (mark & monitor_value) != 0.
  2854   // The object has an existing monitor iff (mark & monitor_value) != 0.
  2836   andi_(temp, displaced_header, markOopDesc::monitor_value);
  2855   andi_(temp, displaced_header, markWord::monitor_value);
  2837   bne(CCR0, object_has_monitor);
  2856   bne(CCR0, object_has_monitor);
  2838 
  2857 
  2839   // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
  2858   // Set displaced_header to be (markWord of object | UNLOCK_VALUE).
  2840   ori(displaced_header, displaced_header, markOopDesc::unlocked_value);
  2859   ori(displaced_header, displaced_header, markWord::unlocked_value);
  2841 
  2860 
  2842   // Load Compare Value application register.
  2861   // Load Compare Value application register.
  2843 
  2862 
  2844   // Initialize the box. (Must happen before we update the object mark!)
  2863   // Initialize the box. (Must happen before we update the object mark!)
  2845   std(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box);
  2864   std(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box);
  2846 
  2865 
  2847   // Must fence, otherwise, preceding store(s) may float below cmpxchg.
  2866   // Must fence, otherwise, preceding store(s) may float below cmpxchg.
  2848   // Compare object markOop with mark and if equal exchange scratch1 with object markOop.
  2867   // Compare object markWord with mark and if equal exchange scratch1 with object markWord.
  2849   cmpxchgd(/*flag=*/flag,
  2868   cmpxchgd(/*flag=*/flag,
  2850            /*current_value=*/current_header,
  2869            /*current_value=*/current_header,
  2851            /*compare_value=*/displaced_header,
  2870            /*compare_value=*/displaced_header,
  2852            /*exchange_value=*/box,
  2871            /*exchange_value=*/box,
  2853            /*where=*/oop,
  2872            /*where=*/oop,
  2863   b(cont);
  2882   b(cont);
  2864 
  2883 
  2865   bind(cas_failed);
  2884   bind(cas_failed);
  2866   // We did not see an unlocked object so try the fast recursive case.
  2885   // We did not see an unlocked object so try the fast recursive case.
  2867 
  2886 
  2868   // Check if the owner is self by comparing the value in the markOop of object
  2887   // Check if the owner is self by comparing the value in the markWord of object
  2869   // (current_header) with the stack pointer.
  2888   // (current_header) with the stack pointer.
  2870   sub(current_header, current_header, R1_SP);
  2889   sub(current_header, current_header, R1_SP);
  2871   load_const_optimized(temp, ~(os::vm_page_size()-1) | markOopDesc::lock_mask_in_place);
  2890   load_const_optimized(temp, ~(os::vm_page_size()-1) | markWord::lock_mask_in_place);
  2872 
  2891 
  2873   and_(R0/*==0?*/, current_header, temp);
  2892   and_(R0/*==0?*/, current_header, temp);
  2874   // If condition is true we are cont and hence we can store 0 as the
  2893   // If condition is true we are cont and hence we can store 0 as the
  2875   // displaced header in the box, which indicates that it is a recursive lock.
  2894   // displaced header in the box, which indicates that it is a recursive lock.
  2876   mcrf(flag,CCR0);
  2895   mcrf(flag,CCR0);
  2890                          rtm_counters, method_data, profile_rtm, cont);
  2909                          rtm_counters, method_data, profile_rtm, cont);
  2891   } else {
  2910   } else {
  2892 #endif // INCLUDE_RTM_OPT
  2911 #endif // INCLUDE_RTM_OPT
  2893 
  2912 
  2894   // Try to CAS m->owner from NULL to current thread.
  2913   // Try to CAS m->owner from NULL to current thread.
  2895   addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value);
  2914   addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markWord::monitor_value);
  2896   cmpxchgd(/*flag=*/flag,
  2915   cmpxchgd(/*flag=*/flag,
  2897            /*current_value=*/current_header,
  2916            /*current_value=*/current_header,
  2898            /*compare_value=*/(intptr_t)0,
  2917            /*compare_value=*/(intptr_t)0,
  2899            /*exchange_value=*/R16_thread,
  2918            /*exchange_value=*/R16_thread,
  2900            /*where=*/temp,
  2919            /*where=*/temp,
  2937 
  2956 
  2938 #if INCLUDE_RTM_OPT
  2957 #if INCLUDE_RTM_OPT
  2939   if (UseRTMForStackLocks && use_rtm) {
  2958   if (UseRTMForStackLocks && use_rtm) {
  2940     assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking");
  2959     assert(!UseBiasedLocking, "Biased locking is not supported with RTM locking");
  2941     Label L_regular_unlock;
  2960     Label L_regular_unlock;
  2942     ld(current_header, oopDesc::mark_offset_in_bytes(), oop);         // fetch markword
  2961     ld(current_header, oopDesc::mark_offset_in_bytes(), oop);      // fetch markword
  2943     andi(R0, current_header, markOopDesc::biased_lock_mask_in_place); // look at 3 lock bits
  2962     andi(R0, current_header, markWord::biased_lock_mask_in_place); // look at 3 lock bits
  2944     cmpwi(flag, R0, markOopDesc::unlocked_value);                     // bits = 001 unlocked
  2963     cmpwi(flag, R0, markWord::unlocked_value);                     // bits = 001 unlocked
  2945     bne(flag, L_regular_unlock);                                      // else RegularLock
  2964     bne(flag, L_regular_unlock);                                   // else RegularLock
  2946     tend_();                                                          // otherwise end...
  2965     tend_();                                                       // otherwise end...
  2947     b(cont);                                                          // ... and we're done
  2966     b(cont);                                                       // ... and we're done
  2948     bind(L_regular_unlock);
  2967     bind(L_regular_unlock);
  2949   }
  2968   }
  2950 #endif
  2969 #endif
  2951 
  2970 
  2952   // Find the lock address and load the displaced header from the stack.
  2971   // Find the lock address and load the displaced header from the stack.
  2958 
  2977 
  2959   // Handle existing monitor.
  2978   // Handle existing monitor.
  2960   // The object has an existing monitor iff (mark & monitor_value) != 0.
  2979   // The object has an existing monitor iff (mark & monitor_value) != 0.
  2961   RTM_OPT_ONLY( if (!(UseRTMForStackLocks && use_rtm)) ) // skip load if already done
  2980   RTM_OPT_ONLY( if (!(UseRTMForStackLocks && use_rtm)) ) // skip load if already done
  2962   ld(current_header, oopDesc::mark_offset_in_bytes(), oop);
  2981   ld(current_header, oopDesc::mark_offset_in_bytes(), oop);
  2963   andi_(R0, current_header, markOopDesc::monitor_value);
  2982   andi_(R0, current_header, markWord::monitor_value);
  2964   bne(CCR0, object_has_monitor);
  2983   bne(CCR0, object_has_monitor);
  2965 
  2984 
  2966   // Check if it is still a light weight lock, this is is true if we see
  2985   // Check if it is still a light weight lock, this is is true if we see
  2967   // the stack address of the basicLock in the markOop of the object.
  2986   // the stack address of the basicLock in the markWord of the object.
  2968   // Cmpxchg sets flag to cmpd(current_header, box).
  2987   // Cmpxchg sets flag to cmpd(current_header, box).
  2969   cmpxchgd(/*flag=*/flag,
  2988   cmpxchgd(/*flag=*/flag,
  2970            /*current_value=*/current_header,
  2989            /*current_value=*/current_header,
  2971            /*compare_value=*/box,
  2990            /*compare_value=*/box,
  2972            /*exchange_value=*/displaced_header,
  2991            /*exchange_value=*/displaced_header,
  2980 
  2999 
  2981   // Handle existing monitor.
  3000   // Handle existing monitor.
  2982   b(cont);
  3001   b(cont);
  2983 
  3002 
  2984   bind(object_has_monitor);
  3003   bind(object_has_monitor);
  2985   addi(current_header, current_header, -markOopDesc::monitor_value); // monitor
  3004   STATIC_ASSERT(markWord::monitor_value <= INT_MAX);
       
  3005   addi(current_header, current_header, -(int)markWord::monitor_value); // monitor
  2986   ld(temp,             ObjectMonitor::owner_offset_in_bytes(), current_header);
  3006   ld(temp,             ObjectMonitor::owner_offset_in_bytes(), current_header);
  2987 
  3007 
  2988     // It's inflated.
  3008     // It's inflated.
  2989 #if INCLUDE_RTM_OPT
  3009 #if INCLUDE_RTM_OPT
  2990   if (use_rtm) {
  3010   if (use_rtm) {
  3190 void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) {
  3210 void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) {
  3191   ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method);
  3211   ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method);
  3192   ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
  3212   ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror);
  3193   ld(mirror, in_bytes(Klass::java_mirror_offset()), mirror);
  3213   ld(mirror, in_bytes(Klass::java_mirror_offset()), mirror);
  3194   resolve_oop_handle(mirror);
  3214   resolve_oop_handle(mirror);
       
  3215 }
       
  3216 
       
  3217 void MacroAssembler::load_method_holder(Register holder, Register method) {
       
  3218   ld(holder, in_bytes(Method::const_offset()), method);
       
  3219   ld(holder, in_bytes(ConstMethod::constants_offset()), holder);
       
  3220   ld(holder, ConstantPool::pool_holder_offset_in_bytes(), holder);
  3195 }
  3221 }
  3196 
  3222 
  3197 // Clear Array
  3223 // Clear Array
  3198 // For very short arrays. tmp == R0 is allowed.
  3224 // For very short arrays. tmp == R0 is allowed.
  3199 void MacroAssembler::clear_memory_unrolled(Register base_ptr, int cnt_dwords, Register tmp, int offset) {
  3225 void MacroAssembler::clear_memory_unrolled(Register base_ptr, int cnt_dwords, Register tmp, int offset) {