@@ -381,8 +381,9 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
381
381
transform_later (slow_region);
382
382
}
383
383
384
- Node* original_dest = dest;
385
- bool dest_uninitialized = false ;
384
+ Node* original_dest = dest;
385
+ bool dest_needs_zeroing = false ;
386
+ bool acopy_to_uninitialized = false ;
386
387
387
388
// See if this is the initialization of a newly-allocated array.
388
389
// If so, we will take responsibility here for initializing it to zero.
@@ -394,25 +395,34 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
394
395
&& basic_elem_type != T_CONFLICT // avoid corner case
395
396
&& !src->eqv_uncast (dest)
396
397
&& alloc != NULL
397
- && _igvn.find_int_con (alloc->in (AllocateNode::ALength), 1 ) > 0
398
- && alloc->maybe_set_complete (&_igvn)) {
399
- // "You break it, you buy it."
400
- InitializeNode* init = alloc->initialization ();
401
- assert (init->is_complete (), " we just did this" );
402
- init->set_complete_with_arraycopy ();
403
- assert (dest->is_CheckCastPP (), " sanity" );
404
- assert (dest->in (0 )->in (0 ) == init, " dest pinned" );
405
- adr_type = TypeRawPtr::BOTTOM; // all initializations are into raw memory
406
- // From this point on, every exit path is responsible for
407
- // initializing any non-copied parts of the object to zero.
408
- // Also, if this flag is set we make sure that arraycopy interacts properly
409
- // with G1, eliding pre-barriers. See CR 6627983.
410
- dest_uninitialized = true ;
398
+ && _igvn.find_int_con (alloc->in (AllocateNode::ALength), 1 ) > 0 ) {
399
+ assert (ac->is_alloc_tightly_coupled (), " sanity" );
400
+ // acopy to uninitialized tightly coupled allocations
401
+ // needs zeroing outside the copy range
402
+ // and the acopy itself will be to uninitialized memory
403
+ acopy_to_uninitialized = true ;
404
+ if (alloc->maybe_set_complete (&_igvn)) {
405
+ // "You break it, you buy it."
406
+ InitializeNode* init = alloc->initialization ();
407
+ assert (init->is_complete (), " we just did this" );
408
+ init->set_complete_with_arraycopy ();
409
+ assert (dest->is_CheckCastPP (), " sanity" );
410
+ assert (dest->in (0 )->in (0 ) == init, " dest pinned" );
411
+ adr_type = TypeRawPtr::BOTTOM; // all initializations are into raw memory
412
+ // From this point on, every exit path is responsible for
413
+ // initializing any non-copied parts of the object to zero.
414
+ // Also, if this flag is set we make sure that arraycopy interacts properly
415
+ // with G1, eliding pre-barriers. See CR 6627983.
416
+ dest_needs_zeroing = true ;
417
+ } else {
418
+ // dest_need_zeroing = false;
419
+ }
411
420
} else {
412
- // No zeroing elimination here.
413
- alloc = NULL ;
414
- // original_dest = dest;
415
- // dest_uninitialized = false;
421
+ // No zeroing elimination needed here.
422
+ alloc = NULL ;
423
+ acopy_to_uninitialized = false ;
424
+ // original_dest = dest;
425
+ // dest_needs_zeroing = false;
416
426
}
417
427
418
428
uint alias_idx = C->get_alias_index (adr_type);
@@ -446,11 +456,11 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
446
456
Node* checked_value = NULL ;
447
457
448
458
if (basic_elem_type == T_CONFLICT) {
449
- assert (!dest_uninitialized , " " );
459
+ assert (!dest_needs_zeroing , " " );
450
460
Node* cv = generate_generic_arraycopy (ctrl, &mem,
451
461
adr_type,
452
462
src, src_offset, dest, dest_offset,
453
- copy_length, dest_uninitialized );
463
+ copy_length, acopy_to_uninitialized );
454
464
if (cv == NULL ) cv = intcon (-1 ); // failure (no stub available)
455
465
checked_control = *ctrl;
456
466
checked_i_o = *io;
@@ -471,7 +481,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
471
481
}
472
482
473
483
// copy_length is 0.
474
- if (dest_uninitialized ) {
484
+ if (dest_needs_zeroing ) {
475
485
assert (!local_ctrl->is_top (), " no ctrl?" );
476
486
Node* dest_length = alloc->in (AllocateNode::ALength);
477
487
if (copy_length->eqv_uncast (dest_length)
@@ -506,7 +516,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
506
516
result_memory->init_req (zero_path, local_mem->memory_at (alias_idx));
507
517
}
508
518
509
- if (!(*ctrl)->is_top () && dest_uninitialized ) {
519
+ if (!(*ctrl)->is_top () && dest_needs_zeroing ) {
510
520
// We have to initialize the *uncopied* part of the array to zero.
511
521
// The copy destination is the slice dest[off..off+len]. The other slices
512
522
// are dest_head = dest[0..off] and dest_tail = dest[off+len..dest.length].
@@ -547,7 +557,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
547
557
didit = generate_block_arraycopy (&local_ctrl, &local_mem, local_io,
548
558
adr_type, basic_elem_type, alloc,
549
559
src, src_offset, dest, dest_offset,
550
- dest_size, dest_uninitialized );
560
+ dest_size, acopy_to_uninitialized );
551
561
if (didit) {
552
562
// Present the results of the block-copying fast call.
553
563
result_region->init_req (bcopy_path, local_ctrl);
@@ -635,7 +645,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
635
645
adr_type,
636
646
dest_elem_klass,
637
647
src, src_offset, dest, dest_offset,
638
- ConvI2X (copy_length), dest_uninitialized );
648
+ ConvI2X (copy_length), acopy_to_uninitialized );
639
649
if (cv == NULL ) cv = intcon (-1 ); // failure (no stub available)
640
650
checked_control = local_ctrl;
641
651
checked_i_o = *io;
@@ -660,11 +670,10 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
660
670
Node* local_ctrl = *ctrl;
661
671
MergeMemNode* local_mem = MergeMemNode::make (mem);
662
672
transform_later (local_mem);
663
-
664
673
is_partial_array_copy = generate_unchecked_arraycopy (&local_ctrl, &local_mem,
665
674
adr_type, copy_type, disjoint_bases,
666
675
src, src_offset, dest, dest_offset,
667
- ConvI2X (copy_length), dest_uninitialized );
676
+ ConvI2X (copy_length), acopy_to_uninitialized );
668
677
669
678
// Present the results of the fast call.
670
679
result_region->init_req (fast_path, local_ctrl);
@@ -753,7 +762,7 @@ Node* PhaseMacroExpand::generate_arraycopy(ArrayCopyNode *ac, AllocateArrayNode*
753
762
// Generate the slow path, if needed.
754
763
local_mem->set_memory_at (alias_idx, slow_mem);
755
764
756
- if (dest_uninitialized ) {
765
+ if (dest_needs_zeroing ) {
757
766
generate_clear_array (local_ctrl, local_mem,
758
767
adr_type, dest, basic_elem_type,
759
768
intcon (0 ), NULL ,
0 commit comments