401 bool is_clone, bool is_clone_instance,
402 ArrayCopyPhase phase) const {
403 if (phase == ArrayCopyPhase::Parsing) {
404 return false;
405 }
406 if (phase == ArrayCopyPhase::Optimization) {
407 return is_clone_instance;
408 }
409 // else ArrayCopyPhase::Expansion
410 return type == T_OBJECT || type == T_ARRAY;
411 }
412
413 #define XTOP LP64_ONLY(COMMA phase->top())
414
415 void ZBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
416 Node* const src = ac->in(ArrayCopyNode::Src);
417 const TypeAryPtr* const ary_ptr = src->get_ptr_type()->isa_aryptr();
418
419 if (ac->is_clone_array() && ary_ptr != nullptr) {
420 BasicType bt = ary_ptr->elem()->array_element_basic_type();
421 if (is_reference_type(bt)) {
422 // Clone object array
423 bt = T_OBJECT;
424 } else {
425 // Clone primitive array
426 bt = T_LONG;
427 }
428
429 Node* const ctrl = ac->in(TypeFunc::Control);
430 Node* const mem = ac->in(TypeFunc::Memory);
431 Node* const src = ac->in(ArrayCopyNode::Src);
432 Node* src_offset = ac->in(ArrayCopyNode::SrcPos);
433 Node* const dest = ac->in(ArrayCopyNode::Dest);
434 Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
435 Node* length = ac->in(ArrayCopyNode::Length);
436
437 if (bt == T_OBJECT) {
438 // BarrierSetC2::clone sets the offsets via BarrierSetC2::arraycopy_payload_base_offset
439 // which 8-byte aligns them to allow for word size copies. Make sure the offsets point
440 // to the first element in the array when cloning object arrays. Otherwise, load
441 // barriers are applied to parts of the header. Also adjust the length accordingly.
442 assert(src_offset == dest_offset, "should be equal");
443 const jlong offset = src_offset->get_long();
444 if (offset != arrayOopDesc::base_offset_in_bytes(T_OBJECT)) {
445 assert(!UseCompressedClassPointers || UseCompactObjectHeaders, "should only happen without compressed class pointers");
446 assert((arrayOopDesc::base_offset_in_bytes(T_OBJECT) - offset) == BytesPerLong, "unexpected offset");
447 length = phase->transform_later(new SubLNode(length, phase->longcon(1))); // Size is in longs
448 src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT));
449 dest_offset = src_offset;
450 }
451 }
452 Node* const payload_src = phase->basic_plus_adr(src, src_offset);
453 Node* const payload_dst = phase->basic_plus_adr(dest, dest_offset);
454
455 const char* copyfunc_name = "arraycopy";
456 const address copyfunc_addr = phase->basictype2arraycopy(bt, nullptr, nullptr, true, copyfunc_name, true);
457
458 const TypePtr* const raw_adr_type = TypeRawPtr::BOTTOM;
459 const TypeFunc* const call_type = OptoRuntime::fast_arraycopy_Type();
460
461 Node* const call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP);
462 phase->transform_later(call);
463
464 phase->igvn().replace_node(ac, call);
465 return;
466 }
467
534 if (mach->barrier_data() != 0) {
535 atomics.push(mach);
536 load_dominators.push(mach);
537 store_dominators.push(mach);
538 atomic_dominators.push(mach);
539 }
540 break;
541
542 default:
543 break;
544 }
545 }
546 }
547
548 // Step 2 - Find dominating accesses or allocations for each access
549 elide_dominated_barriers(loads, load_dominators);
550 elide_dominated_barriers(stores, store_dominators);
551 elide_dominated_barriers(atomics, atomic_dominators);
552 }
553
554 void ZBarrierSetC2::eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const {
555 eliminate_gc_barrier_data(node);
556 }
557
558 void ZBarrierSetC2::eliminate_gc_barrier_data(Node* node) const {
559 if (node->is_LoadStore()) {
560 LoadStoreNode* loadstore = node->as_LoadStore();
561 loadstore->set_barrier_data(ZBarrierElided);
562 } else if (node->is_Mem()) {
563 MemNode* mem = node->as_Mem();
564 mem->set_barrier_data(ZBarrierElided);
565 }
566 }
567
568 #ifndef PRODUCT
569 void ZBarrierSetC2::dump_barrier_data(const MachNode* mach, outputStream* st) const {
570 if ((mach->barrier_data() & ZBarrierStrong) != 0) {
571 st->print("strong ");
572 }
573 if ((mach->barrier_data() & ZBarrierWeak) != 0) {
574 st->print("weak ");
|
401 bool is_clone, bool is_clone_instance,
402 ArrayCopyPhase phase) const {
403 if (phase == ArrayCopyPhase::Parsing) {
404 return false;
405 }
406 if (phase == ArrayCopyPhase::Optimization) {
407 return is_clone_instance;
408 }
409 // else ArrayCopyPhase::Expansion
410 return type == T_OBJECT || type == T_ARRAY;
411 }
412
413 #define XTOP LP64_ONLY(COMMA phase->top())
414
415 void ZBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
416 Node* const src = ac->in(ArrayCopyNode::Src);
417 const TypeAryPtr* const ary_ptr = src->get_ptr_type()->isa_aryptr();
418
419 if (ac->is_clone_array() && ary_ptr != nullptr) {
420 BasicType bt = ary_ptr->elem()->array_element_basic_type();
421 if (is_reference_type(bt) && !ary_ptr->is_flat()) {
422 // Clone object array
423 bt = T_OBJECT;
424 } else {
425 // Clone primitive array
426 bt = T_LONG;
427 }
428
429 Node* const ctrl = ac->in(TypeFunc::Control);
430 Node* const mem = ac->in(TypeFunc::Memory);
431 Node* const src = ac->in(ArrayCopyNode::Src);
432 Node* src_offset = ac->in(ArrayCopyNode::SrcPos);
433 Node* const dest = ac->in(ArrayCopyNode::Dest);
434 Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
435 Node* length = ac->in(ArrayCopyNode::Length);
436
437 if (bt == T_OBJECT) {
438 // BarrierSetC2::clone sets the offsets via BarrierSetC2::arraycopy_payload_base_offset
439 // which 8-byte aligns them to allow for word size copies. Make sure the offsets point
440 // to the first element in the array when cloning object arrays. Otherwise, load
441 // barriers are applied to parts of the header. Also adjust the length accordingly.
442 assert(src_offset == dest_offset, "should be equal");
443 const jlong offset = src_offset->get_long();
444 if (offset != arrayOopDesc::base_offset_in_bytes(T_OBJECT)) {
445 assert(!UseCompressedClassPointers || UseCompactObjectHeaders, "should only happen without compressed class pointers");
446 assert((arrayOopDesc::base_offset_in_bytes(T_OBJECT) - offset) == BytesPerLong, "unexpected offset");
447 length = phase->transform_later(new SubXNode(length, phase->longcon(1))); // Size is in longs
448 src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT));
449 dest_offset = src_offset;
450 }
451 }
452 Node* const payload_src = phase->basic_plus_adr(src, src_offset);
453 Node* const payload_dst = phase->basic_plus_adr(dest, dest_offset);
454
455 const char* copyfunc_name = "arraycopy";
456 const address copyfunc_addr = phase->basictype2arraycopy(bt, nullptr, nullptr, true, copyfunc_name, true);
457
458 const TypePtr* const raw_adr_type = TypeRawPtr::BOTTOM;
459 const TypeFunc* const call_type = OptoRuntime::fast_arraycopy_Type();
460
461 Node* const call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP);
462 phase->transform_later(call);
463
464 phase->igvn().replace_node(ac, call);
465 return;
466 }
467
534 if (mach->barrier_data() != 0) {
535 atomics.push(mach);
536 load_dominators.push(mach);
537 store_dominators.push(mach);
538 atomic_dominators.push(mach);
539 }
540 break;
541
542 default:
543 break;
544 }
545 }
546 }
547
548 // Step 2 - Find dominating accesses or allocations for each access
549 elide_dominated_barriers(loads, load_dominators);
550 elide_dominated_barriers(stores, store_dominators);
551 elide_dominated_barriers(atomics, atomic_dominators);
552 }
553
554
555 void ZBarrierSetC2::eliminate_gc_barrier(PhaseIterGVN* igvn, Node* node) const {
556 eliminate_gc_barrier_data(node);
557 }
558
559 void ZBarrierSetC2::eliminate_gc_barrier_data(Node* node) const {
560 if (node->is_LoadStore()) {
561 LoadStoreNode* loadstore = node->as_LoadStore();
562 loadstore->set_barrier_data(ZBarrierElided);
563 } else if (node->is_Mem()) {
564 MemNode* mem = node->as_Mem();
565 mem->set_barrier_data(ZBarrierElided);
566 }
567 }
568
569 #ifndef PRODUCT
570 void ZBarrierSetC2::dump_barrier_data(const MachNode* mach, outputStream* st) const {
571 if ((mach->barrier_data() & ZBarrierStrong) != 0) {
572 st->print("strong ");
573 }
574 if ((mach->barrier_data() & ZBarrierWeak) != 0) {
575 st->print("weak ");
|