< prev index next >

src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp

Print this page

 42 void C1_MacroAssembler::float_cmp(bool is_float, int unordered_result,
 43                                   FloatRegister freg0, FloatRegister freg1,
 44                                   Register result)
 45 {
 46   if (is_float) {
 47     float_compare(result, freg0, freg1, unordered_result);
 48   } else {
 49     double_compare(result, freg0, freg1, unordered_result);
 50   }
 51 }
 52 
 53 int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
 54   const int aligned_mask = BytesPerWord - 1;
 55   const int hdr_offset = oopDesc::mark_offset_in_bytes();
 56   assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
 57   Label done;
 58   int null_check_offset = -1;
 59 
 60   verify_oop(obj);
 61 
 62   // save object being locked into the BasicObjectLock
 63   sd(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
 64 
 65   null_check_offset = offset();
 66 
 67   if (DiagnoseSyncOnValueBasedClasses != 0) {
 68     load_klass(hdr, obj);
 69     lwu(hdr, Address(hdr, Klass::access_flags_offset()));
 70     andi(t0, hdr, JVM_ACC_IS_VALUE_BASED_CLASS);
 71     bnez(t0, slow_case, true /* is_far */);
 72   }
 73 
 74   // Load object header
 75   ld(hdr, Address(obj, hdr_offset));
 76   // and mark it as unlocked
 77   ori(hdr, hdr, markWord::unlocked_value);
 78   // save unlocked object header into the displaced header location on the stack
 79   sd(hdr, Address(disp_hdr, 0));
 80   // test if object header is still the same (i.e. unlocked), and if so, store the
 81   // displaced header address in the object header - if it is not the same, get the
 82   // object header instead
 83   la(t1, Address(obj, hdr_offset));
 84   cmpxchgptr(hdr, disp_hdr, t1, t0, done, /*fallthough*/NULL);
 85   // if the object header was the same, we're done
 86   // if the object header was not the same, it is now in the hdr register
 87   // => test if it is a stack pointer into the same stack (recursive locking), i.e.:
 88   //
 89   // 1) (hdr & aligned_mask) == 0
 90   // 2) sp <= hdr
 91   // 3) hdr <= sp + page_size
 92   //
 93   // these 3 tests can be done by evaluating the following expression:
 94   //
 95   // (hdr -sp) & (aligned_mask - page_size)
 96   //
 97   // assuming both the stack pointer and page_size have their least
 98   // significant 2 bits cleared and page_size is a power of 2
 99   sub(hdr, hdr, sp);
100   mv(t0, aligned_mask - os::vm_page_size());
101   andr(hdr, hdr, t0);
102   // for recursive locking, the result is zero => save it in the displaced header
103   // location (NULL in the displaced hdr location indicates recursive locking)
104   sd(hdr, Address(disp_hdr, 0));
105   // otherwise we don't care about the result and handle locking via runtime call
106   bnez(hdr, slow_case, /* is_far */ true);
107   bind(done);
108   return null_check_offset;
109 }
110 
111 void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
112   const int aligned_mask = BytesPerWord - 1;
113   const int hdr_offset = oopDesc::mark_offset_in_bytes();
114   assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
115   Label done;
116 
117   // load displaced header
118   ld(hdr, Address(disp_hdr, 0));
119   // if the loaded hdr is NULL we had recursive locking
120   // if we had recursive locking, we are done
121   beqz(hdr, done);
122   // load object
123   ld(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()));
124   verify_oop(obj);
125   // test if object header is pointing to the displaced header, and if so, restore
126   // the displaced header in the object - if the object header is not pointing to
127   // the displaced header, get the object header instead
128   // if the object header was not pointing to the displaced header,
129   // we do unlocking via runtime call
130   if (hdr_offset) {
131     la(t0, Address(obj, hdr_offset));
132     cmpxchgptr(disp_hdr, hdr, t0, t1, done, &slow_case);
133   } else {
134     cmpxchgptr(disp_hdr, hdr, obj, t1, done, &slow_case);
135   }
136   bind(done);
137 }
138 
139 // Defines obj, preserves var_size_in_bytes
140 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register tmp1, Register tmp2, Label& slow_case) {
141   if (UseTLAB) {
142     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, tmp1, tmp2, slow_case, /* is_far */ true);
143   } else {
144     j(slow_case);
145   }
146 }
147 
148 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register tmp1, Register tmp2) {
149   assert_different_registers(obj, klass, len);
150   // This assumes that all prototype bits fitr in an int32_t
151   mv(tmp1, (int32_t)(intptr_t)markWord::prototype().value());
152   sd(tmp1, Address(obj, oopDesc::mark_offset_in_bytes()));
153 
154   if (UseCompressedClassPointers) { // Take care not to kill klass
155     encode_klass_not_null(tmp1, klass);
156     sw(tmp1, Address(obj, oopDesc::klass_offset_in_bytes()));

 42 void C1_MacroAssembler::float_cmp(bool is_float, int unordered_result,
 43                                   FloatRegister freg0, FloatRegister freg1,
 44                                   Register result)
 45 {
 46   if (is_float) {
 47     float_compare(result, freg0, freg1, unordered_result);
 48   } else {
 49     double_compare(result, freg0, freg1, unordered_result);
 50   }
 51 }
 52 
 53 int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
 54   const int aligned_mask = BytesPerWord - 1;
 55   const int hdr_offset = oopDesc::mark_offset_in_bytes();
 56   assert(hdr != obj && hdr != disp_hdr && obj != disp_hdr, "registers must be different");
 57   Label done;
 58   int null_check_offset = -1;
 59 
 60   verify_oop(obj);
 61 



 62   null_check_offset = offset();
 63 
 64   if (DiagnoseSyncOnValueBasedClasses != 0) {
 65     load_klass(hdr, obj);
 66     lwu(hdr, Address(hdr, Klass::access_flags_offset()));
 67     andi(t0, hdr, JVM_ACC_IS_VALUE_BASED_CLASS);
 68     bnez(t0, slow_case, true /* is_far */);
 69   }
 70 
 71   ld(hdr, Address(obj, oopDesc::mark_offset_in_bytes()));
 72   fast_lock(obj, hdr, disp_hdr, t0, t1, slow_case);
 73 































 74   return null_check_offset;
 75 }
 76 
 77 void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) {
 78   const int aligned_mask = BytesPerWord - 1;
 79   const int hdr_offset = oopDesc::mark_offset_in_bytes();
 80   assert_different_registers(hdr, obj, disp_hdr);

 81 







 82   verify_oop(obj);
 83 
 84   ld(hdr, Address(obj, oopDesc::mark_offset_in_bytes()));
 85   fast_unlock(obj, hdr, t0, t1, slow_case);









 86 }
 87 
 88 // Defines obj, preserves var_size_in_bytes
 89 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register tmp1, Register tmp2, Label& slow_case) {
 90   if (UseTLAB) {
 91     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, tmp1, tmp2, slow_case, /* is_far */ true);
 92   } else {
 93     j(slow_case);
 94   }
 95 }
 96 
 97 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register tmp1, Register tmp2) {
 98   assert_different_registers(obj, klass, len);
 99   // This assumes that all prototype bits fitr in an int32_t
100   mv(tmp1, (int32_t)(intptr_t)markWord::prototype().value());
101   sd(tmp1, Address(obj, oopDesc::mark_offset_in_bytes()));
102 
103   if (UseCompressedClassPointers) { // Take care not to kill klass
104     encode_klass_not_null(tmp1, klass);
105     sw(tmp1, Address(obj, oopDesc::klass_offset_in_bytes()));
< prev index next >