< prev index next >

src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp

Print this page

146   } else {
147     cmpxchgptr(disp_hdr, hdr, obj, rscratch2, done, &slow_case);
148   }
149   // done
150   bind(done);
151   decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
152 }
153 
154 
155 // Defines obj, preserves var_size_in_bytes
156 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
157   if (UseTLAB) {
158     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
159   } else {
160     b(slow_case);
161   }
162 }
163 
164 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
165   assert_different_registers(obj, klass, len);
166   // This assumes that all prototype bits fit in an int32_t
167   mov(t1, (int32_t)(intptr_t)markWord::prototype().value());
168   str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
169 
170   if (UseCompressedClassPointers) { // Take care not to kill klass
171     encode_klass_not_null(t1, klass);
172     strw(t1, Address(obj, oopDesc::klass_offset_in_bytes()));
173   } else {
174     str(klass, Address(obj, oopDesc::klass_offset_in_bytes()));
175   }
176 
177   if (len->is_valid()) {
178     strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));
179   } else if (UseCompressedClassPointers) {
180     store_klass_gap(obj, zr);
181   }
182 }
183 
184 // preserves obj, destroys len_in_bytes
185 //
186 // Scratch registers: t1 = r10, t2 = r11
187 //
188 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
189   assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
190   assert(t1 == r10 && t2 == r11, "must be");
191 
192   Label done;
193 
194   // len_in_bytes is positive and ptr sized
195   subs(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
196   br(Assembler::EQ, done);
197 






198   // zero_words() takes ptr in r10 and count in words in r11
199   mov(rscratch1, len_in_bytes);
200   lea(t1, Address(obj, hdr_size_in_bytes));
201   lsr(t2, rscratch1, LogBytesPerWord);
202   zero_words(t1, t2);
203 
204   bind(done);
205 }
206 
207 
208 void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) {
209   assert_different_registers(obj, t1, t2); // XXX really?
210   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");
211 
212   try_allocate(obj, noreg, object_size * BytesPerWord, t1, t2, slow_case);
213 
214   initialize_object(obj, klass, noreg, object_size * HeapWordSize, t1, t2, UseTLAB);
215 }
216 
217 // Scratch registers: t1 = r10, t2 = r11

227      const Register index = t2;
228      if (var_size_in_bytes != noreg) {
229        mov(index, var_size_in_bytes);
230        initialize_body(obj, index, hdr_size_in_bytes, t1, t2);
231      } else if (con_size_in_bytes > hdr_size_in_bytes) {
232        con_size_in_bytes -= hdr_size_in_bytes;
233        lea(t1, Address(obj, hdr_size_in_bytes));
234        zero_words(t1, con_size_in_bytes / BytesPerWord);
235      }
236   }
237 
238   membar(StoreStore);
239 
240   if (CURRENT_ENV->dtrace_alloc_probes()) {
241     assert(obj == r0, "must be");
242     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
243   }
244 
245   verify_oop(obj);
246 }
247 void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int header_size, int f, Register klass, Label& slow_case) {
248   assert_different_registers(obj, len, t1, t2, klass);
249 
250   // determine alignment mask
251   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
252 
253   // check for negative or excessive length
254   mov(rscratch1, (int32_t)max_array_allocation_length);
255   cmp(len, rscratch1);
256   br(Assembler::HS, slow_case);
257 
258   const Register arr_size = t2; // okay to be the same
259   // align object end
260   mov(arr_size, (int32_t)header_size * BytesPerWord + MinObjAlignmentInBytesMask);
261   add(arr_size, arr_size, len, ext::uxtw, f);
262   andr(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
263 
264   try_allocate(obj, arr_size, 0, t1, t2, slow_case);
265 
266   initialize_header(obj, klass, len, t1, t2);
267 
268   // clear rest of allocated space
269   initialize_body(obj, arr_size, header_size * BytesPerWord, t1, t2);
270 
271   membar(StoreStore);
272 
273   if (CURRENT_ENV->dtrace_alloc_probes()) {
274     assert(obj == r0, "must be");
275     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
276   }
277 
278   verify_oop(obj);
279 }
280 
281 
282 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
283   verify_oop(receiver);
284   // explicit NULL check not needed since load from [klass_offset] causes a trap
285   // check against inline cache
286   assert(!MacroAssembler::needs_explicit_null_check(oopDesc::klass_offset_in_bytes()), "must add explicit null check");
287 
288   cmp_klass(receiver, iCache, rscratch1);
289 }
290 
291 
292 void C1_MacroAssembler::build_frame(int framesize, int bang_size_in_bytes) {
293   assert(bang_size_in_bytes >= framesize, "stack bang size incorrect");
294   // Make sure there is enough stack space for this method's activation.
295   // Note that we do this before creating a frame.
296   generate_stack_overflow_check(bang_size_in_bytes);
297   MacroAssembler::build_frame(framesize);
298 
299   // Insert nmethod entry barrier into frame.
300   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
301   bs->nmethod_entry_barrier(this, NULL /* slow_path */, NULL /* continuation */, NULL /* guard */);
302 }
303 
304 void C1_MacroAssembler::remove_frame(int framesize) {
305   MacroAssembler::remove_frame(framesize);
306 }

146   } else {
147     cmpxchgptr(disp_hdr, hdr, obj, rscratch2, done, &slow_case);
148   }
149   // done
150   bind(done);
151   decrement(Address(rthread, JavaThread::held_monitor_count_offset()));
152 }
153 
154 
155 // Defines obj, preserves var_size_in_bytes
156 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
157   if (UseTLAB) {
158     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
159   } else {
160     b(slow_case);
161   }
162 }
163 
164 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
165   assert_different_registers(obj, klass, len);
166   ldr(t1, Address(klass, Klass::prototype_header_offset()));

167   str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
168 







169   if (len->is_valid()) {
170     strw(len, Address(obj, arrayOopDesc::length_offset_in_bytes()));


171   }
172 }
173 
174 // preserves obj, destroys len_in_bytes
175 //
176 // Scratch registers: t1 = r10, t2 = r11
177 //
178 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
179   assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
180   assert(t1 == r10 && t2 == r11, "must be");
181 
182   Label done;
183 
184   // len_in_bytes is positive and ptr sized
185   subs(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
186   br(Assembler::EQ, done);
187 
188   // Zero first 4 bytes, if start offset is not word aligned.
189   if (!is_aligned(hdr_size_in_bytes, BytesPerWord)) {
190     strw(zr, Address(obj, hdr_size_in_bytes));
191     hdr_size_in_bytes += BytesPerInt;
192   }
193 
194   // zero_words() takes ptr in r10 and count in words in r11
195   mov(rscratch1, len_in_bytes);
196   lea(t1, Address(obj, hdr_size_in_bytes));
197   lsr(t2, rscratch1, LogBytesPerWord);
198   zero_words(t1, t2);
199 
200   bind(done);
201 }
202 
203 
204 void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) {
205   assert_different_registers(obj, t1, t2); // XXX really?
206   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");
207 
208   try_allocate(obj, noreg, object_size * BytesPerWord, t1, t2, slow_case);
209 
210   initialize_object(obj, klass, noreg, object_size * HeapWordSize, t1, t2, UseTLAB);
211 }
212 
213 // Scratch registers: t1 = r10, t2 = r11

223      const Register index = t2;
224      if (var_size_in_bytes != noreg) {
225        mov(index, var_size_in_bytes);
226        initialize_body(obj, index, hdr_size_in_bytes, t1, t2);
227      } else if (con_size_in_bytes > hdr_size_in_bytes) {
228        con_size_in_bytes -= hdr_size_in_bytes;
229        lea(t1, Address(obj, hdr_size_in_bytes));
230        zero_words(t1, con_size_in_bytes / BytesPerWord);
231      }
232   }
233 
234   membar(StoreStore);
235 
236   if (CURRENT_ENV->dtrace_alloc_probes()) {
237     assert(obj == r0, "must be");
238     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
239   }
240 
241   verify_oop(obj);
242 }
243 void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int base_offset_in_bytes, int f, Register klass, Label& slow_case) {
244   assert_different_registers(obj, len, t1, t2, klass);
245 
246   // determine alignment mask
247   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
248 
249   // check for negative or excessive length
250   mov(rscratch1, (int32_t)max_array_allocation_length);
251   cmp(len, rscratch1);
252   br(Assembler::HS, slow_case);
253 
254   const Register arr_size = t2; // okay to be the same
255   // align object end
256   mov(arr_size, (int32_t)base_offset_in_bytes + MinObjAlignmentInBytesMask);
257   add(arr_size, arr_size, len, ext::uxtw, f);
258   andr(arr_size, arr_size, ~MinObjAlignmentInBytesMask);
259 
260   try_allocate(obj, arr_size, 0, t1, t2, slow_case);
261 
262   initialize_header(obj, klass, len, t1, t2);
263 
264   // clear rest of allocated space
265   initialize_body(obj, arr_size, base_offset_in_bytes, t1, t2);
266 
267   membar(StoreStore);
268 
269   if (CURRENT_ENV->dtrace_alloc_probes()) {
270     assert(obj == r0, "must be");
271     far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
272   }
273 
274   verify_oop(obj);
275 }
276 
277 
278 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
279   verify_oop(receiver);
280   // explicit NULL check not needed since load from [klass_offset] causes a trap
281   // check against inline cache
282   assert(!MacroAssembler::needs_explicit_null_check(oopDesc::mark_offset_in_bytes()), "must add explicit null check");
283 
284   cmp_klass(receiver, iCache, rscratch1);
285 }
286 
287 
288 void C1_MacroAssembler::build_frame(int framesize, int bang_size_in_bytes) {
289   assert(bang_size_in_bytes >= framesize, "stack bang size incorrect");
290   // Make sure there is enough stack space for this method's activation.
291   // Note that we do this before creating a frame.
292   generate_stack_overflow_check(bang_size_in_bytes);
293   MacroAssembler::build_frame(framesize);
294 
295   // Insert nmethod entry barrier into frame.
296   BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
297   bs->nmethod_entry_barrier(this, NULL /* slow_path */, NULL /* continuation */, NULL /* guard */);
298 }
299 
300 void C1_MacroAssembler::remove_frame(int framesize) {
301   MacroAssembler::remove_frame(framesize);
302 }
< prev index next >