2661
2662 insert_mem_bar(Op_MemBarRelease);
2663 insert_mem_bar(Op_MemBarCPUOrder);
2664
2665 // 4984716: MemBars must be inserted before this
2666 // memory node in order to avoid a false
2667 // dependency which will confuse the scheduler.
2668 Node *mem = memory(alias_idx);
2669
2670 // For now, we handle only those cases that actually exist: ints,
2671 // longs, and Object. Adding others should be straightforward.
2672 Node* cas;
2673 switch(type) {
2674 case T_INT:
2675 cas = _gvn.transform(new (C, 5) CompareAndSwapINode(control(), mem, adr, newval, oldval));
2676 break;
2677 case T_LONG:
2678 cas = _gvn.transform(new (C, 5) CompareAndSwapLNode(control(), mem, adr, newval, oldval));
2679 break;
2680 case T_OBJECT:
2681 // reference stores need a store barrier.
2682 // (They don't if CAS fails, but it isn't worth checking.)
2683 pre_barrier(true /* do_load*/,
2684 control(), base, adr, alias_idx, newval, value_type->make_oopptr(),
2685 NULL /* pre_val*/,
2686 T_OBJECT);
2687 #ifdef _LP64
2688 if (adr->bottom_type()->is_ptr_to_narrowoop()) {
2689 Node *newval_enc = _gvn.transform(new (C, 2) EncodePNode(newval, newval->bottom_type()->make_narrowoop()));
2690 Node *oldval_enc = _gvn.transform(new (C, 2) EncodePNode(oldval, oldval->bottom_type()->make_narrowoop()));
2691 cas = _gvn.transform(new (C, 5) CompareAndSwapNNode(control(), mem, adr,
2692 newval_enc, oldval_enc));
2693 } else
2694 #endif
2695 {
2696 cas = _gvn.transform(new (C, 5) CompareAndSwapPNode(control(), mem, adr, newval, oldval));
2697 }
2698 post_barrier(control(), cas, base, adr, alias_idx, newval, T_OBJECT, true);
2699 break;
2700 default:
2701 ShouldNotReachHere();
|
2661
2662 insert_mem_bar(Op_MemBarRelease);
2663 insert_mem_bar(Op_MemBarCPUOrder);
2664
2665 // 4984716: MemBars must be inserted before this
2666 // memory node in order to avoid a false
2667 // dependency which will confuse the scheduler.
2668 Node *mem = memory(alias_idx);
2669
2670 // For now, we handle only those cases that actually exist: ints,
2671 // longs, and Object. Adding others should be straightforward.
2672 Node* cas;
2673 switch(type) {
2674 case T_INT:
2675 cas = _gvn.transform(new (C, 5) CompareAndSwapINode(control(), mem, adr, newval, oldval));
2676 break;
2677 case T_LONG:
2678 cas = _gvn.transform(new (C, 5) CompareAndSwapLNode(control(), mem, adr, newval, oldval));
2679 break;
2680 case T_OBJECT:
2681 // Transformation of a value which could be NULL pointer (CastPP #NULL)
2682 // could be delayed during Parse (for example, in adjust_map_after_if()).
2683 // Execute transformation here to avoid barrier generation in such case.
2684 if (_gvn.type(newval) == TypePtr::NULL_PTR)
2685 newval = _gvn.makecon(TypePtr::NULL_PTR);
2686
2687 // Reference stores need a store barrier.
2688 // (They don't if CAS fails, but it isn't worth checking.)
2689 pre_barrier(true /* do_load*/,
2690 control(), base, adr, alias_idx, newval, value_type->make_oopptr(),
2691 NULL /* pre_val*/,
2692 T_OBJECT);
2693 #ifdef _LP64
2694 if (adr->bottom_type()->is_ptr_to_narrowoop()) {
2695 Node *newval_enc = _gvn.transform(new (C, 2) EncodePNode(newval, newval->bottom_type()->make_narrowoop()));
2696 Node *oldval_enc = _gvn.transform(new (C, 2) EncodePNode(oldval, oldval->bottom_type()->make_narrowoop()));
2697 cas = _gvn.transform(new (C, 5) CompareAndSwapNNode(control(), mem, adr,
2698 newval_enc, oldval_enc));
2699 } else
2700 #endif
2701 {
2702 cas = _gvn.transform(new (C, 5) CompareAndSwapPNode(control(), mem, adr, newval, oldval));
2703 }
2704 post_barrier(control(), cas, base, adr, alias_idx, newval, T_OBJECT, true);
2705 break;
2706 default:
2707 ShouldNotReachHere();
|