1848 LIR_Opr LIRGenerator::shenandoah_read_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
1849 if (UseShenandoahGC && ShenandoahReadBarrier) {
1850
1851 LabelObj* done = new LabelObj();
1852 LIR_Opr result = new_register(T_OBJECT);
1853 __ move(obj, result);
1854 if (need_null_check) {
1855 __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
1856 __ branch(lir_cond_equal, T_LONG, done->label());
1857 }
1858 LIR_Address* brooks_ptr_address = generate_address(result, BrooksPointer::byte_offset(), T_ADDRESS);
1859 __ load(brooks_ptr_address, result, info ? new CodeEmitInfo(info) : NULL, lir_patch_none);
1860
1861 __ branch_destination(done->label());
1862 return result;
1863 } else {
1864 return obj;
1865 }
1866 }
1867
1868 LIR_Opr LIRGenerator::shenandoah_write_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
1869 if (UseShenandoahGC && ShenandoahWriteBarrier) {
1870
1871 LIR_Opr result = new_register(T_OBJECT);
1872 __ shenandoah_wb(obj, result, info ? new CodeEmitInfo(info) : NULL, need_null_check);
1873 return result;
1874
1875 } else {
1876 return obj;
1877 }
1878 }
1879 #endif
1880
1881 //------------------------java.nio.Buffer.checkIndex------------------------
1882
1883 // int java.nio.Buffer.checkIndex(int)
1884 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
1885 // NOTE: by the time we are in checkIndex() we are guaranteed that
1886 // the buffer is non-null (because checkIndex is package-private and
1887 // only called from within other methods in the buffer).
1888 assert(x->number_of_arguments() == 2, "wrong type");
1889 LIRItem buf (x->argument_at(0), this);
1890 LIRItem index(x->argument_at(1), this);
1891 buf.load_item();
1892 index.load_item();
1893
1894 LIR_Opr result = rlock_result(x);
1895 if (GenerateRangeChecks) {
1896 CodeEmitInfo* info = state_for(x);
1897 CodeStub* stub = new RangeCheckStub(info, index.result(), true);
1898 LIR_Opr buf_obj = buf.result();
1899 #if INCLUDE_ALL_GCS
|
1848 LIR_Opr LIRGenerator::shenandoah_read_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
1849 if (UseShenandoahGC && ShenandoahReadBarrier) {
1850
1851 LabelObj* done = new LabelObj();
1852 LIR_Opr result = new_register(T_OBJECT);
1853 __ move(obj, result);
1854 if (need_null_check) {
1855 __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
1856 __ branch(lir_cond_equal, T_LONG, done->label());
1857 }
1858 LIR_Address* brooks_ptr_address = generate_address(result, BrooksPointer::byte_offset(), T_ADDRESS);
1859 __ load(brooks_ptr_address, result, info ? new CodeEmitInfo(info) : NULL, lir_patch_none);
1860
1861 __ branch_destination(done->label());
1862 return result;
1863 } else {
1864 return obj;
1865 }
1866 }
1867
1868 LIR_Opr LIRGenerator::ensure_in_register(LIR_Opr obj) {
1869 if (!obj->is_register()) {
1870 LIR_Opr obj_reg = new_register(T_OBJECT);
1871 if (obj->is_constant()) {
1872 __ move(obj, obj_reg);
1873 } else {
1874 __ leal(obj, obj_reg);
1875 }
1876 obj = obj_reg;
1877 }
1878 return obj;
1879 }
1880
1881 LIR_Opr LIRGenerator::shenandoah_write_barrier(LIR_Opr obj, CodeEmitInfo* info, bool need_null_check) {
1882 if (UseShenandoahGC && ShenandoahWriteBarrier) {
1883
1884 LIR_Opr result = new_register(T_OBJECT);
1885 obj = ensure_in_register(obj);
1886 assert(obj->is_register(), "must be a register at this point");
1887
1888 __ shenandoah_wb(obj, result, info ? new CodeEmitInfo(info) : NULL, need_null_check);
1889 return result;
1890
1891 } else {
1892 return obj;
1893 }
1894 }
1895 #endif
1896
1897
1898 //------------------------java.nio.Buffer.checkIndex------------------------
1899
1900 // int java.nio.Buffer.checkIndex(int)
1901 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
1902 // NOTE: by the time we are in checkIndex() we are guaranteed that
1903 // the buffer is non-null (because checkIndex is package-private and
1904 // only called from within other methods in the buffer).
1905 assert(x->number_of_arguments() == 2, "wrong type");
1906 LIRItem buf (x->argument_at(0), this);
1907 LIRItem index(x->argument_at(1), this);
1908 buf.load_item();
1909 index.load_item();
1910
1911 LIR_Opr result = rlock_result(x);
1912 if (GenerateRangeChecks) {
1913 CodeEmitInfo* info = state_for(x);
1914 CodeStub* stub = new RangeCheckStub(info, index.result(), true);
1915 LIR_Opr buf_obj = buf.result();
1916 #if INCLUDE_ALL_GCS
|