1633 xor_shift_res,
1634 LIR_OprDesc::illegalOpr());
1635 }
1636
1637 if (!new_val->is_register()) {
1638 LIR_Opr new_val_reg = new_register(T_OBJECT);
1639 __ leal(new_val, new_val_reg);
1640 new_val = new_val_reg;
1641 }
1642 assert(new_val->is_register(), "must be a register at this point");
1643
1644 __ cmp(lir_cond_notEqual, xor_shift_res, LIR_OprFact::intptrConst(NULL_WORD));
1645
1646 CodeStub* slow = new G1PostBarrierStub(addr, new_val);
1647 __ branch(lir_cond_notEqual, LP64_ONLY(T_LONG) NOT_LP64(T_INT), slow);
1648 __ branch_destination(slow->continuation());
1649 }
1650
1651 void LIRGenerator::Shenandoah_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val,
1652 bool do_load, bool patch, CodeEmitInfo* info) {
1653 if (ShenandoahConditionalSATBBarrier) {
1654 LIR_Opr gc_state_addr = new_pointer_register();
1655 __ move(LIR_OprFact::intptrConst((intptr_t) ShenandoahHeap::gc_state_addr()), gc_state_addr);
1656 LIR_Opr gc_state = new_register(T_INT);
1657 __ move(new LIR_Address(gc_state_addr, T_BYTE), gc_state);
1658 __ logical_and(gc_state, LIR_OprFact::intConst(ShenandoahHeap::MARKING), gc_state);
1659 __ cmp(lir_cond_equal, gc_state, LIR_OprFact::intConst(0));
1660
1661 LIR_PatchCode pre_val_patch_code = lir_patch_none;
1662
1663 CodeStub* slow;
1664
1665 if (do_load) {
1666 assert(pre_val == LIR_OprFact::illegalOpr, "sanity");
1667 assert(addr_opr != LIR_OprFact::illegalOpr, "sanity");
1668
1669 if (patch)
1670 pre_val_patch_code = lir_patch_normal;
1671
1672 pre_val = new_register(T_OBJECT);
1673
1674 if (!addr_opr->is_address()) {
1675 assert(addr_opr->is_register(), "must be");
1676 addr_opr = LIR_OprFact::address(new LIR_Address(addr_opr, T_OBJECT));
1677 }
1678 slow = new G1PreBarrierStub(addr_opr, pre_val, pre_val_patch_code, info);
1679 } else {
1680 assert(addr_opr == LIR_OprFact::illegalOpr, "sanity");
1681 assert(pre_val->is_register(), "must be");
1682 assert(pre_val->type() == T_OBJECT, "must be an object");
1683 assert(info == NULL, "sanity");
1684
1685 slow = new G1PreBarrierStub(pre_val);
1686 }
1687
1688 __ branch(lir_cond_notEqual, T_CHAR, slow);
1689 __ branch_destination(slow->continuation());
1690 }
1691 if (ShenandoahSATBBarrier) {
1692 G1BarrierSet_pre_barrier(addr_opr, pre_val, do_load, patch, info);
1693 }
1694 }
1695
1696 void LIRGenerator::Shenandoah_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
1697 if (! UseShenandoahMatrix) {
1698 // No need for that barrier if not using matrix.
1699 return;
1700 }
1701
1702 // If the "new_val" is a constant NULL, no barrier is necessary.
1703 if (new_val->is_constant() &&
1704 new_val->as_constant_ptr()->as_jobject() == NULL) return;
1705
1706 if (!new_val->is_register()) {
1707 LIR_Opr new_val_reg = new_register(T_OBJECT);
1708 if (new_val->is_constant()) {
1709 __ move(new_val, new_val_reg);
1710 } else {
2060 if (need_null_check) {
2061 __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
2062 __ branch(lir_cond_equal, T_LONG, done->label());
2063 }
2064 LIR_Address* brooks_ptr_address = generate_address(result, BrooksPointer::byte_offset(), T_ADDRESS);
2065 __ load(brooks_ptr_address, result, info ? new CodeEmitInfo(info) : NULL, lir_patch_none);
2066
2067 __ branch_destination(done->label());
2068 return result;
2069 }
2070
2071 LIR_Opr LIRGenerator::shenandoah_write_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
2072 if (UseShenandoahGC && ShenandoahWriteBarrier) {
2073 return shenandoah_write_barrier_impl(obj, info, need_null_check);
2074 } else {
2075 return obj;
2076 }
2077 }
2078
2079 LIR_Opr LIRGenerator::shenandoah_write_barrier_impl(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
2080 assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled");
2081 LIR_Opr result = new_register(T_OBJECT);
2082 __ shenandoah_wb(obj, result, info ? new CodeEmitInfo(info) : NULL, need_null_check);
2083 return result;
2084 }
2085
2086 LIR_Opr LIRGenerator::shenandoah_storeval_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
2087 if (UseShenandoahGC) {
2088 if (ShenandoahStoreValWriteBarrier || ShenandoahStoreValEnqueueBarrier) {
2089 // TODO: Maybe we can simply avoid this stuff on constants?
2090 if (! obj->is_register()) {
2091 LIR_Opr result = new_register(T_OBJECT);
2092 __ move(obj, result);
2093 obj = result;
2094 }
2095 obj = shenandoah_write_barrier_impl(obj, info, need_null_check);
2096 }
2097 if (ShenandoahStoreValEnqueueBarrier) {
2098 G1BarrierSet_pre_barrier(LIR_OprFact::illegalOpr, obj, false, false, NULL);
2099 }
2100 if (ShenandoahStoreValReadBarrier) {
2101 obj = shenandoah_read_barrier_impl(obj, info, need_null_check);
2102 }
2103 }
2104 return obj;
2105 }
2106 //------------------------java.nio.Buffer.checkIndex------------------------
2107
2108 // int java.nio.Buffer.checkIndex(int)
2109 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
2110 // NOTE: by the time we are in checkIndex() we are guaranteed that
2111 // the buffer is non-null (because checkIndex is package-private and
2112 // only called from within other methods in the buffer).
2113 assert(x->number_of_arguments() == 2, "wrong type");
2114 LIRItem buf (x->argument_at(0), this);
2115 LIRItem index(x->argument_at(1), this);
2116 buf.load_item();
2117 index.load_item();
|
1633 xor_shift_res,
1634 LIR_OprDesc::illegalOpr());
1635 }
1636
1637 if (!new_val->is_register()) {
1638 LIR_Opr new_val_reg = new_register(T_OBJECT);
1639 __ leal(new_val, new_val_reg);
1640 new_val = new_val_reg;
1641 }
1642 assert(new_val->is_register(), "must be a register at this point");
1643
1644 __ cmp(lir_cond_notEqual, xor_shift_res, LIR_OprFact::intptrConst(NULL_WORD));
1645
1646 CodeStub* slow = new G1PostBarrierStub(addr, new_val);
1647 __ branch(lir_cond_notEqual, LP64_ONLY(T_LONG) NOT_LP64(T_INT), slow);
1648 __ branch_destination(slow->continuation());
1649 }
1650
1651 void LIRGenerator::Shenandoah_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val,
1652 bool do_load, bool patch, CodeEmitInfo* info) {
1653 if (ShenandoahSATBBarrier) {
1654 G1BarrierSet_pre_barrier(addr_opr, pre_val, do_load, patch, info);
1655 }
1656 }
1657
1658 void LIRGenerator::Shenandoah_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val) {
1659 if (! UseShenandoahMatrix) {
1660 // No need for that barrier if not using matrix.
1661 return;
1662 }
1663
1664 // If the "new_val" is a constant NULL, no barrier is necessary.
1665 if (new_val->is_constant() &&
1666 new_val->as_constant_ptr()->as_jobject() == NULL) return;
1667
1668 if (!new_val->is_register()) {
1669 LIR_Opr new_val_reg = new_register(T_OBJECT);
1670 if (new_val->is_constant()) {
1671 __ move(new_val, new_val_reg);
1672 } else {
2022 if (need_null_check) {
2023 __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
2024 __ branch(lir_cond_equal, T_LONG, done->label());
2025 }
2026 LIR_Address* brooks_ptr_address = generate_address(result, BrooksPointer::byte_offset(), T_ADDRESS);
2027 __ load(brooks_ptr_address, result, info ? new CodeEmitInfo(info) : NULL, lir_patch_none);
2028
2029 __ branch_destination(done->label());
2030 return result;
2031 }
2032
2033 LIR_Opr LIRGenerator::shenandoah_write_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
2034 if (UseShenandoahGC && ShenandoahWriteBarrier) {
2035 return shenandoah_write_barrier_impl(obj, info, need_null_check);
2036 } else {
2037 return obj;
2038 }
2039 }
2040
2041 LIR_Opr LIRGenerator::shenandoah_write_barrier_impl(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
2042 assert(UseShenandoahGC && (ShenandoahWriteBarrier || ShenandoahStoreValEnqueueBarrier), "Should be enabled");
2043 LIR_Opr result = new_register(T_OBJECT);
2044 __ shenandoah_wb(obj, result, info ? new CodeEmitInfo(info) : NULL, need_null_check);
2045 return result;
2046 }
2047
2048 LIR_Opr LIRGenerator::shenandoah_storeval_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
2049 if (UseShenandoahGC) {
2050 if (ShenandoahStoreValEnqueueBarrier) {
2051 // TODO: Maybe we can simply avoid this stuff on constants?
2052 if (! obj->is_register()) {
2053 LIR_Opr result = new_register(T_OBJECT);
2054 __ move(obj, result);
2055 obj = result;
2056 }
2057 obj = shenandoah_write_barrier_impl(obj, info, need_null_check);
2058 G1BarrierSet_pre_barrier(LIR_OprFact::illegalOpr, obj, false, false, NULL);
2059 }
2060 if (ShenandoahStoreValReadBarrier) {
2061 obj = shenandoah_read_barrier_impl(obj, info, need_null_check);
2062 }
2063 }
2064 return obj;
2065 }
2066 //------------------------java.nio.Buffer.checkIndex------------------------
2067
2068 // int java.nio.Buffer.checkIndex(int)
2069 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
2070 // NOTE: by the time we are in checkIndex() we are guaranteed that
2071 // the buffer is non-null (because checkIndex is package-private and
2072 // only called from within other methods in the buffer).
2073 assert(x->number_of_arguments() == 2, "wrong type");
2074 LIRItem buf (x->argument_at(0), this);
2075 LIRItem index(x->argument_at(1), this);
2076 buf.load_item();
2077 index.load_item();
|