1
1
/*
2
2
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
3
- * Copyright (c) 2014, Red Hat Inc. All rights reserved.
3
+ * Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved.
4
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
5
*
6
6
* This code is free software; you can redistribute it and/or modify it
@@ -203,20 +203,24 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register
203
203
}
204
204
205
205
// preserves obj, destroys len_in_bytes
206
- void C1_MacroAssembler::initialize_body (Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1) {
206
+ //
207
+ // Scratch registers: t1 = r10, t2 = r11
208
+ //
209
+ void C1_MacroAssembler::initialize_body (Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1, Register t2) {
207
210
assert (hdr_size_in_bytes >= 0 , " header size must be positive or 0" );
211
+ assert (t1 == r10 && t2 == r11, " must be" );
212
+
208
213
Label done;
209
214
210
215
// len_in_bytes is positive and ptr sized
211
216
subs (len_in_bytes, len_in_bytes, hdr_size_in_bytes);
212
217
br (Assembler::EQ, done);
213
218
214
- // Preserve obj
215
- if (hdr_size_in_bytes)
216
- add (obj, obj, hdr_size_in_bytes);
217
- zero_memory (obj, len_in_bytes, t1);
218
- if (hdr_size_in_bytes)
219
- sub (obj, obj, hdr_size_in_bytes);
219
+ // zero_words() takes ptr in r10 and count in words in r11
220
+ mov (rscratch1, len_in_bytes);
221
+ lea (t1, Address (obj, hdr_size_in_bytes));
222
+ lsr (t2, rscratch1, LogBytesPerWord);
223
+ zero_words (t1, t2);
220
224
221
225
bind (done);
222
226
}
@@ -231,6 +235,7 @@ void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2,
231
235
initialize_object (obj, klass, noreg, object_size * HeapWordSize, t1, t2, UseTLAB);
232
236
}
233
237
238
+ // Scratch registers: t1 = r10, t2 = r11
234
239
void C1_MacroAssembler::initialize_object (Register obj, Register klass, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, bool is_tlab_allocated) {
235
240
assert ((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0 ,
236
241
" con_size_in_bytes is not multiple of alignment" );
@@ -241,45 +246,13 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register
241
246
if (!(UseTLAB && ZeroTLAB && is_tlab_allocated)) {
242
247
// clear rest of allocated space
243
248
const Register index = t2;
244
- const int threshold = 16 * BytesPerWord; // approximate break even point for code size (see comments below)
245
249
if (var_size_in_bytes != noreg) {
246
250
mov (index, var_size_in_bytes);
247
- initialize_body (obj, index, hdr_size_in_bytes, t1);
248
- } else if (con_size_in_bytes <= threshold) {
249
- // use explicit null stores
250
- int i = hdr_size_in_bytes;
251
- if (i < con_size_in_bytes && (con_size_in_bytes % (2 * BytesPerWord))) {
252
- str (zr, Address (obj, i));
253
- i += BytesPerWord;
254
- }
255
- for (; i < con_size_in_bytes; i += 2 * BytesPerWord)
256
- stp (zr, zr, Address (obj, i));
251
+ initialize_body (obj, index, hdr_size_in_bytes, t1, t2);
257
252
} else if (con_size_in_bytes > hdr_size_in_bytes) {
258
- block_comment (" zero memory" );
259
- // use loop to null out the fields
260
-
261
- int words = (con_size_in_bytes - hdr_size_in_bytes) / BytesPerWord;
262
- mov (index, words / 8 );
263
-
264
- const int unroll = 8 ; // Number of str(zr) instructions we'll unroll
265
- int remainder = words % unroll;
266
- lea (rscratch1, Address (obj, hdr_size_in_bytes + remainder * BytesPerWord));
267
-
268
- Label entry_point, loop;
269
- b (entry_point);
270
-
271
- bind (loop);
272
- sub (index, index, 1 );
273
- for (int i = -unroll; i < 0 ; i++) {
274
- if (-i == remainder)
275
- bind (entry_point);
276
- str (zr, Address (rscratch1, i * wordSize));
277
- }
278
- if (remainder == 0 )
279
- bind (entry_point);
280
- add (rscratch1, rscratch1, unroll * wordSize);
281
- cbnz (index, loop);
282
-
253
+ con_size_in_bytes -= hdr_size_in_bytes;
254
+ lea (t1, Address (obj, hdr_size_in_bytes));
255
+ zero_words (t1, con_size_in_bytes / BytesPerWord);
283
256
}
284
257
}
285
258
@@ -314,8 +287,7 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1,
314
287
initialize_header (obj, klass, len, t1, t2);
315
288
316
289
// clear rest of allocated space
317
- const Register len_zero = len;
318
- initialize_body (obj, arr_size, header_size * BytesPerWord, len_zero);
290
+ initialize_body (obj, arr_size, header_size * BytesPerWord, t1, t2);
319
291
320
292
membar (StoreStore);
321
293
0 commit comments