64 const int aligned_mask = BytesPerWord -1;
65 const int hdr_offset = oopDesc::mark_offset_in_bytes();
66 assert_different_registers(hdr, obj, disp_hdr, temp, rscratch2);
67 int null_check_offset = -1;
68
69 verify_oop(obj);
70
71 // save object being locked into the BasicObjectLock
72 str(obj, Address(disp_hdr, BasicObjectLock::obj_offset()));
73
74 null_check_offset = offset();
75
76 if (DiagnoseSyncOnValueBasedClasses != 0) {
77 load_klass(hdr, obj);
78 ldrw(hdr, Address(hdr, Klass::access_flags_offset()));
79 tstw(hdr, JVM_ACC_IS_VALUE_BASED_CLASS);
80 br(Assembler::NE, slow_case);
81 }
82
83 if (LockingMode == LM_LIGHTWEIGHT) {
84 lightweight_lock(obj, hdr, temp, rscratch2, slow_case);
85 } else if (LockingMode == LM_LEGACY) {
86 Label done;
87 // Load object header
88 ldr(hdr, Address(obj, hdr_offset));
89 // and mark it as unlocked
90 orr(hdr, hdr, markWord::unlocked_value);
91 // save unlocked object header into the displaced header location on the stack
92 str(hdr, Address(disp_hdr, 0));
93 // test if object header is still the same (i.e. unlocked), and if so, store the
94 // displaced header address in the object header - if it is not the same, get the
95 // object header instead
96 lea(rscratch2, Address(obj, hdr_offset));
97 cmpxchgptr(hdr, disp_hdr, rscratch2, rscratch1, done, /*fallthough*/nullptr);
98 // if the object header was the same, we're done
99 // if the object header was not the same, it is now in the hdr register
100 // => test if it is a stack pointer into the same stack (recursive locking), i.e.:
101 //
102 // 1) (hdr & aligned_mask) == 0
103 // 2) sp <= hdr
104 // 3) hdr <= sp + page_size
158 cmpxchgptr(disp_hdr, hdr, obj, rscratch2, done, &slow_case);
159 }
160 // done
161 bind(done);
162 }
163 decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
164 }
165
166
167 // Defines obj, preserves var_size_in_bytes
168 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
169 if (UseTLAB) {
170 tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
171 } else {
172 b(slow_case);
173 }
174 }
175
176 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
177 assert_different_registers(obj, klass, len);
178 // This assumes that all prototype bits fit in an int32_t
179 mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
180 str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
181
182 if (UseCompressedClassPointers) { // Take care not to kill klass
183 encode_klass_not_null(t1, klass);
184 strw(t1, Address(obj, oopDesc::klass_offset_in_bytes()));
185 } else {
186 str(klass, Address(obj, oopDesc::klass_offset_in_bytes()));
187 }
188
189 if (len->is_valid()) {
190 strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
191 int base_offset = arrayOopDesc::length_offset_in_bytes() + BytesPerInt;
192 if (!is_aligned(base_offset, BytesPerWord)) {
193 assert(is_aligned(base_offset, BytesPerInt), "must be 4-byte aligned");
194 // Clear gap/first 4 bytes following the length field.
195 strw(zr, Address(obj, base_offset));
196 }
197 } else if (UseCompressedClassPointers) {
198 store_klass_gap(obj, zr);
199 }
200 }
201
202 // preserves obj, destroys len_in_bytes
203 //
204 // Scratch registers: t1 = r10, t2 = r11
205 //
206 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
207 assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
208 assert(t1 == r10 && t2 == r11, "must be");
209
210 Label done;
211
212 // len_in_bytes is positive and ptr sized
213 subs(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
214 br(Assembler::EQ, done);
215
216 // zero_words() takes ptr in r10 and count in words in r11
217 mov(rscratch1, len_in_bytes);
|
64 const int aligned_mask = BytesPerWord -1;
65 const int hdr_offset = oopDesc::mark_offset_in_bytes();
66 assert_different_registers(hdr, obj, disp_hdr, temp, rscratch2);
67 int null_check_offset = -1;
68
69 verify_oop(obj);
70
71 // save object being locked into the BasicObjectLock
72 str(obj, Address(disp_hdr, BasicObjectLock::obj_offset()));
73
74 null_check_offset = offset();
75
76 if (DiagnoseSyncOnValueBasedClasses != 0) {
77 load_klass(hdr, obj);
78 ldrw(hdr, Address(hdr, Klass::access_flags_offset()));
79 tstw(hdr, JVM_ACC_IS_VALUE_BASED_CLASS);
80 br(Assembler::NE, slow_case);
81 }
82
83 if (LockingMode == LM_LIGHTWEIGHT) {
84 lightweight_lock(disp_hdr, obj, hdr, temp, rscratch2, slow_case);
85 } else if (LockingMode == LM_LEGACY) {
86 Label done;
87 // Load object header
88 ldr(hdr, Address(obj, hdr_offset));
89 // and mark it as unlocked
90 orr(hdr, hdr, markWord::unlocked_value);
91 // save unlocked object header into the displaced header location on the stack
92 str(hdr, Address(disp_hdr, 0));
93 // test if object header is still the same (i.e. unlocked), and if so, store the
94 // displaced header address in the object header - if it is not the same, get the
95 // object header instead
96 lea(rscratch2, Address(obj, hdr_offset));
97 cmpxchgptr(hdr, disp_hdr, rscratch2, rscratch1, done, /*fallthough*/nullptr);
98 // if the object header was the same, we're done
99 // if the object header was not the same, it is now in the hdr register
100 // => test if it is a stack pointer into the same stack (recursive locking), i.e.:
101 //
102 // 1) (hdr & aligned_mask) == 0
103 // 2) sp <= hdr
104 // 3) hdr <= sp + page_size
158 cmpxchgptr(disp_hdr, hdr, obj, rscratch2, done, &slow_case);
159 }
160 // done
161 bind(done);
162 }
163 decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
164 }
165
166
167 // Defines obj, preserves var_size_in_bytes
168 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
169 if (UseTLAB) {
170 tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
171 } else {
172 b(slow_case);
173 }
174 }
175
176 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
177 assert_different_registers(obj, klass, len);
178
179 if (UseCompactObjectHeaders) {
180 ldr(t1, Address(klass, Klass::prototype_header_offset()));
181 str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
182 } else {
183 // This assumes that all prototype bits fit in an int32_t
184 mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
185 str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
186 if (UseCompressedClassPointers) { // Take care not to kill klass
187 encode_klass_not_null(t1, klass);
188 strw(t1, Address(obj, oopDesc::klass_offset_in_bytes()));
189 } else {
190 str(klass, Address(obj, oopDesc::klass_offset_in_bytes()));
191 }
192 }
193 if (len->is_valid()) {
194 strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
195 int base_offset = arrayOopDesc::length_offset_in_bytes() + BytesPerInt;
196 if (!is_aligned(base_offset, BytesPerWord)) {
197 assert(is_aligned(base_offset, BytesPerInt), "must be 4-byte aligned");
198 // Clear gap/first 4 bytes following the length field.
199 strw(zr, Address(obj, base_offset));
200 }
201 } else if (UseCompressedClassPointers && !UseCompactObjectHeaders) {
202 store_klass_gap(obj, zr);
203 }
204 }
205
206 // preserves obj, destroys len_in_bytes
207 //
208 // Scratch registers: t1 = r10, t2 = r11
209 //
210 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
211 assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
212 assert(t1 == r10 && t2 == r11, "must be");
213
214 Label done;
215
216 // len_in_bytes is positive and ptr sized
217 subs(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
218 br(Assembler::EQ, done);
219
220 // zero_words() takes ptr in r10 and count in words in r11
221 mov(rscratch1, len_in_bytes);
|