1
1
/*
2
2
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
3
3
* Copyright (c) 2014, 2025, Red Hat Inc. All rights reserved.
4
- * Copyright (c) 2020, 2023 , Huawei Technologies Co., Ltd. All rights reserved.
4
+ * Copyright (c) 2020, 2025 , Huawei Technologies Co., Ltd. All rights reserved.
5
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
6
*
7
7
* This code is free software; you can redistribute it and/or modify it
@@ -2196,26 +2196,26 @@ class StubGenerator: public StubCodeGenerator {
2196
2196
switch (t) {
2197
2197
case T_BYTE:
2198
2198
// One byte misalignment happens only for byte arrays.
2199
- __ test_bit (t0 , to, 0 );
2200
- __ beqz (t0 , L_skip_align1);
2199
+ __ test_bit (tmp_reg , to, 0 );
2200
+ __ beqz (tmp_reg , L_skip_align1);
2201
2201
__ sb (value, Address (to, 0 ));
2202
2202
__ addi (to, to, 1 );
2203
2203
__ subiw (count, count, 1 );
2204
2204
__ bind (L_skip_align1);
2205
2205
// Fallthrough
2206
2206
case T_SHORT:
2207
2207
// Two bytes misalignment happens only for byte and short (char) arrays.
2208
- __ test_bit (t0 , to, 1 );
2209
- __ beqz (t0 , L_skip_align2);
2208
+ __ test_bit (tmp_reg , to, 1 );
2209
+ __ beqz (tmp_reg , L_skip_align2);
2210
2210
__ sh (value, Address (to, 0 ));
2211
2211
__ addi (to, to, 2 );
2212
2212
__ subiw (count, count, 2 >> shift);
2213
2213
__ bind (L_skip_align2);
2214
2214
// Fallthrough
2215
2215
case T_INT:
2216
2216
// Align to 8 bytes, we know we are 4 byte aligned to start.
2217
- __ test_bit (t0 , to, 2 );
2218
- __ beqz (t0 , L_skip_align4);
2217
+ __ test_bit (tmp_reg , to, 2 );
2218
+ __ beqz (tmp_reg , L_skip_align4);
2219
2219
__ sw (value, Address (to, 0 ));
2220
2220
__ addi (to, to, 4 );
2221
2221
__ subiw (count, count, 4 >> shift);
@@ -2241,69 +2241,51 @@ class StubGenerator: public StubCodeGenerator {
2241
2241
__ fill_words (to, cnt_words, value);
2242
2242
}
2243
2243
2244
- // Remaining count is less than 8 bytes and address is heapword aligned.
2245
- Label L_fill_1, L_fill_2, L_exit1;
2244
+ // Handle copies less than 8 bytes.
2245
+ // Address may not be heapword aligned.
2246
+ Label L_fill_1, L_fill_2, L_exit;
2247
+ __ bind (L_fill_elements);
2246
2248
switch (t) {
2247
2249
case T_BYTE:
2248
- __ test_bit (t0, count, 2 );
2249
- __ beqz (t0, L_fill_2);
2250
- __ sw (value, Address (to, 0 ));
2250
+ __ test_bit (tmp_reg, count, 2 );
2251
+ __ beqz (tmp_reg, L_fill_2);
2252
+ __ sb (value, Address (to, 0 ));
2253
+ __ sb (value, Address (to, 1 ));
2254
+ __ sb (value, Address (to, 2 ));
2255
+ __ sb (value, Address (to, 3 ));
2251
2256
__ addi (to, to, 4 );
2257
+
2252
2258
__ bind (L_fill_2);
2253
- __ test_bit (t0, count, 1 );
2254
- __ beqz (t0, L_fill_1);
2255
- __ sh (value, Address (to, 0 ));
2259
+ __ test_bit (tmp_reg, count, 1 );
2260
+ __ beqz (tmp_reg, L_fill_1);
2261
+ __ sb (value, Address (to, 0 ));
2262
+ __ sb (value, Address (to, 1 ));
2256
2263
__ addi (to, to, 2 );
2264
+
2257
2265
__ bind (L_fill_1);
2258
- __ test_bit (t0 , count, 0 );
2259
- __ beqz (t0, L_exit1 );
2266
+ __ test_bit (tmp_reg , count, 0 );
2267
+ __ beqz (tmp_reg, L_exit );
2260
2268
__ sb (value, Address (to, 0 ));
2261
2269
break ;
2262
2270
case T_SHORT:
2263
- __ test_bit (t0, count, 1 );
2264
- __ beqz (t0, L_fill_2);
2265
- __ sw (value, Address (to, 0 ));
2266
- __ addi (to, to, 4 );
2267
- __ bind (L_fill_2);
2268
- __ test_bit (t0, count, 0 );
2269
- __ beqz (t0, L_exit1);
2271
+ __ test_bit (tmp_reg, count, 1 );
2272
+ __ beqz (tmp_reg, L_fill_2);
2270
2273
__ sh (value, Address (to, 0 ));
2271
- break ;
2272
- case T_INT:
2273
- __ beqz (count, L_exit1);
2274
- __ sw (value, Address (to, 0 ));
2275
- break ;
2276
- default : ShouldNotReachHere ();
2277
- }
2278
- __ bind (L_exit1);
2279
- __ leave ();
2280
- __ ret ();
2274
+ __ sh (value, Address (to, 2 ));
2275
+ __ addi (to, to, 4 );
2281
2276
2282
- // Handle copies less than 8 bytes.
2283
- Label L_loop1, L_loop2, L_exit2;
2284
- __ bind (L_fill_elements);
2285
- __ beqz (count, L_exit2);
2286
- switch (t) {
2287
- case T_BYTE:
2288
- __ bind (L_loop1);
2289
- __ sb (value, Address (to, 0 ));
2290
- __ addi (to, to, 1 );
2291
- __ subiw (count, count, 1 );
2292
- __ bnez (count, L_loop1);
2293
- break ;
2294
- case T_SHORT:
2295
- __ bind (L_loop2);
2277
+ __ bind (L_fill_2);
2278
+ __ test_bit (tmp_reg, count, 0 );
2279
+ __ beqz (tmp_reg, L_exit);
2296
2280
__ sh (value, Address (to, 0 ));
2297
- __ addi (to, to, 2 );
2298
- __ subiw (count, count, 2 >> shift);
2299
- __ bnez (count, L_loop2);
2300
2281
break ;
2301
2282
case T_INT:
2283
+ __ beqz (count, L_exit);
2302
2284
__ sw (value, Address (to, 0 ));
2303
2285
break ;
2304
2286
default : ShouldNotReachHere ();
2305
2287
}
2306
- __ bind (L_exit2 );
2288
+ __ bind (L_exit );
2307
2289
__ leave ();
2308
2290
__ ret ();
2309
2291
0 commit comments