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
@@ -180,20 +180,24 @@ void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register
180
180
}
181
181
182
182
// preserves obj, destroys len_in_bytes
183
- void C1_MacroAssembler::initialize_body (Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1) {
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) {
184
187
assert (hdr_size_in_bytes >= 0 , " header size must be positive or 0" );
188
+ assert (t1 == r10 && t2 == r11, " must be" );
189
+
185
190
Label done;
186
191
187
192
// len_in_bytes is positive and ptr sized
188
193
subs (len_in_bytes, len_in_bytes, hdr_size_in_bytes);
189
194
br (Assembler::EQ, done);
190
195
191
- // Preserve obj
192
- if (hdr_size_in_bytes)
193
- add (obj, obj, hdr_size_in_bytes);
194
- zero_memory (obj, len_in_bytes, t1);
195
- if (hdr_size_in_bytes)
196
- sub (obj, obj, hdr_size_in_bytes);
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);
197
201
198
202
bind (done);
199
203
}
@@ -208,6 +212,7 @@ void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2,
208
212
initialize_object (obj, klass, noreg, object_size * HeapWordSize, t1, t2, UseTLAB);
209
213
}
210
214
215
+ // Scratch registers: t1 = r10, t2 = r11
211
216
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) {
212
217
assert ((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0 ,
213
218
" con_size_in_bytes is not multiple of alignment" );
@@ -218,45 +223,13 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register
218
223
if (!(UseTLAB && ZeroTLAB && is_tlab_allocated)) {
219
224
// clear rest of allocated space
220
225
const Register index = t2;
221
- const int threshold = 16 * BytesPerWord; // approximate break even point for code size (see comments below)
222
226
if (var_size_in_bytes != noreg) {
223
227
mov (index, var_size_in_bytes);
224
- initialize_body (obj, index, hdr_size_in_bytes, t1);
225
- } else if (con_size_in_bytes <= threshold) {
226
- // use explicit null stores
227
- int i = hdr_size_in_bytes;
228
- if (i < con_size_in_bytes && (con_size_in_bytes % (2 * BytesPerWord))) {
229
- str (zr, Address (obj, i));
230
- i += BytesPerWord;
231
- }
232
- for (; i < con_size_in_bytes; i += 2 * BytesPerWord)
233
- stp (zr, zr, Address (obj, i));
228
+ initialize_body (obj, index, hdr_size_in_bytes, t1, t2);
234
229
} else if (con_size_in_bytes > hdr_size_in_bytes) {
235
- block_comment (" zero memory" );
236
- // use loop to null out the fields
237
-
238
- int words = (con_size_in_bytes - hdr_size_in_bytes) / BytesPerWord;
239
- mov (index, words / 8 );
240
-
241
- const int unroll = 8 ; // Number of str(zr) instructions we'll unroll
242
- int remainder = words % unroll;
243
- lea (rscratch1, Address (obj, hdr_size_in_bytes + remainder * BytesPerWord));
244
-
245
- Label entry_point, loop;
246
- b (entry_point);
247
-
248
- bind (loop);
249
- sub (index, index, 1 );
250
- for (int i = -unroll; i < 0 ; i++) {
251
- if (-i == remainder)
252
- bind (entry_point);
253
- str (zr, Address (rscratch1, i * wordSize));
254
- }
255
- if (remainder == 0 )
256
- bind (entry_point);
257
- add (rscratch1, rscratch1, unroll * wordSize);
258
- cbnz (index, loop);
259
-
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);
260
233
}
261
234
}
262
235
@@ -291,8 +264,7 @@ void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1,
291
264
initialize_header (obj, klass, len, t1, t2);
292
265
293
266
// clear rest of allocated space
294
- const Register len_zero = len;
295
- initialize_body (obj, arr_size, header_size * BytesPerWord, len_zero);
267
+ initialize_body (obj, arr_size, header_size * BytesPerWord, t1, t2);
296
268
297
269
membar (StoreStore);
298
270
0 commit comments