< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page




 487   }
 488 }
 489 
 490 
 491 void LIRGenerator::array_range_check(LIR_Opr array, LIR_Opr index,
 492                                     CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info) {
 493   CodeStub* stub = new RangeCheckStub(range_check_info, index, array);
 494   if (index->is_constant()) {
 495     cmp_mem_int(lir_cond_belowEqual, array, arrayOopDesc::length_offset_in_bytes(),
 496                 index->as_jint(), null_check_info);
 497     __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
 498   } else {
 499     cmp_reg_mem(lir_cond_aboveEqual, index, array,
 500                 arrayOopDesc::length_offset_in_bytes(), T_INT, null_check_info);
 501     __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
 502   }
 503 }
 504 
 505 
 506 void LIRGenerator::nio_range_check(LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
 507   CodeStub* stub = new RangeCheckStub(info, index, NULL);
 508   if (index->is_constant()) {
 509     cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info);
 510     __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
 511   } else {
 512     cmp_reg_mem(lir_cond_aboveEqual, index, buffer,
 513                 java_nio_Buffer::limit_offset(), T_INT, info);
 514     __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
 515   }
 516   __ move(index, result);
 517 }
 518 
 519 
 520 
 521 void LIRGenerator::arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp_op, CodeEmitInfo* info) {
 522   LIR_Opr result_op = result;
 523   LIR_Opr left_op   = left;
 524   LIR_Opr right_op  = right;
 525 
 526   if (TwoOperandLIRForm && left_op != result_op) {
 527     assert(right_op != result_op, "malformed");


1872   }
1873 }
1874 
1875 
1876 //------------------------java.nio.Buffer.checkIndex------------------------
1877 
1878 // int java.nio.Buffer.checkIndex(int)
1879 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
1880   // NOTE: by the time we are in checkIndex() we are guaranteed that
1881   // the buffer is non-null (because checkIndex is package-private and
1882   // only called from within other methods in the buffer).
1883   assert(x->number_of_arguments() == 2, "wrong type");
1884   LIRItem buf  (x->argument_at(0), this);
1885   LIRItem index(x->argument_at(1), this);
1886   buf.load_item();
1887   index.load_item();
1888 
1889   LIR_Opr result = rlock_result(x);
1890   if (GenerateRangeChecks) {
1891     CodeEmitInfo* info = state_for(x);
1892     CodeStub* stub = new RangeCheckStub(info, index.result(), NULL);
1893     if (index.result()->is_constant()) {
1894       cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info);
1895       __ branch(lir_cond_belowEqual, T_INT, stub);
1896     } else {
1897       cmp_reg_mem(lir_cond_aboveEqual, index.result(), buf.result(),
1898                   java_nio_Buffer::limit_offset(), T_INT, info);
1899       __ branch(lir_cond_aboveEqual, T_INT, stub);
1900     }
1901     __ move(index.result(), result);
1902   } else {
1903     // Just load the index into the result register
1904     __ move(index.result(), result);
1905   }
1906 }
1907 
1908 
1909 //------------------------array access--------------------------------------
1910 
1911 
1912 void LIRGenerator::do_ArrayLength(ArrayLength* x) {




 487   }
 488 }
 489 
 490 
 491 void LIRGenerator::array_range_check(LIR_Opr array, LIR_Opr index,
 492                                     CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info) {
 493   CodeStub* stub = new RangeCheckStub(range_check_info, index, array);
 494   if (index->is_constant()) {
 495     cmp_mem_int(lir_cond_belowEqual, array, arrayOopDesc::length_offset_in_bytes(),
 496                 index->as_jint(), null_check_info);
 497     __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
 498   } else {
 499     cmp_reg_mem(lir_cond_aboveEqual, index, array,
 500                 arrayOopDesc::length_offset_in_bytes(), T_INT, null_check_info);
 501     __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
 502   }
 503 }
 504 
 505 
 506 void LIRGenerator::nio_range_check(LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
 507   CodeStub* stub = new RangeCheckStub(info, index);
 508   if (index->is_constant()) {
 509     cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info);
 510     __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
 511   } else {
 512     cmp_reg_mem(lir_cond_aboveEqual, index, buffer,
 513                 java_nio_Buffer::limit_offset(), T_INT, info);
 514     __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
 515   }
 516   __ move(index, result);
 517 }
 518 
 519 
 520 
 521 void LIRGenerator::arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp_op, CodeEmitInfo* info) {
 522   LIR_Opr result_op = result;
 523   LIR_Opr left_op   = left;
 524   LIR_Opr right_op  = right;
 525 
 526   if (TwoOperandLIRForm && left_op != result_op) {
 527     assert(right_op != result_op, "malformed");


1872   }
1873 }
1874 
1875 
1876 //------------------------java.nio.Buffer.checkIndex------------------------
1877 
1878 // int java.nio.Buffer.checkIndex(int)
1879 void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
1880   // NOTE: by the time we are in checkIndex() we are guaranteed that
1881   // the buffer is non-null (because checkIndex is package-private and
1882   // only called from within other methods in the buffer).
1883   assert(x->number_of_arguments() == 2, "wrong type");
1884   LIRItem buf  (x->argument_at(0), this);
1885   LIRItem index(x->argument_at(1), this);
1886   buf.load_item();
1887   index.load_item();
1888 
1889   LIR_Opr result = rlock_result(x);
1890   if (GenerateRangeChecks) {
1891     CodeEmitInfo* info = state_for(x);
1892     CodeStub* stub = new RangeCheckStub(info, index.result());
1893     if (index.result()->is_constant()) {
1894       cmp_mem_int(lir_cond_belowEqual, buf.result(), java_nio_Buffer::limit_offset(), index.result()->as_jint(), info);
1895       __ branch(lir_cond_belowEqual, T_INT, stub);
1896     } else {
1897       cmp_reg_mem(lir_cond_aboveEqual, index.result(), buf.result(),
1898                   java_nio_Buffer::limit_offset(), T_INT, info);
1899       __ branch(lir_cond_aboveEqual, T_INT, stub);
1900     }
1901     __ move(index.result(), result);
1902   } else {
1903     // Just load the index into the result register
1904     __ move(index.result(), result);
1905   }
1906 }
1907 
1908 
1909 //------------------------array access--------------------------------------
1910 
1911 
1912 void LIRGenerator::do_ArrayLength(ArrayLength* x) {


< prev index next >