< prev index next >

src/hotspot/cpu/aarch64/c1_MacroAssembler_aarch64.cpp

Print this page

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






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

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

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

165   str(t1, Address(obj, oopDesc::mark_offset_in_bytes()));
166 







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


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

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