879 |
879 |
880 void InterpreterMacroAssembler::index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res) { |
880 void InterpreterMacroAssembler::index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res) { |
881 assert_not_delayed(); |
881 assert_not_delayed(); |
882 |
882 |
883 verify_oop(array); |
883 verify_oop(array); |
884 // sign extend since tos (index) can be a 32bit value |
884 // Sign extend since tos (index) can be a 32bit value. |
885 sra(index, G0, index); |
885 sra(index, G0, index); |
886 |
886 |
887 // check array |
887 // Check array. |
888 Label ptr_ok; |
888 Label ptr_ok; |
889 tst(array); |
889 tst(array); |
890 throw_if_not_1_x( notZero, ptr_ok ); |
890 throw_if_not_1_x(notZero, ptr_ok); |
891 delayed()->ld( array, arrayOopDesc::length_offset_in_bytes(), tmp ); // check index |
891 delayed()->ld(array, arrayOopDesc::length_offset_in_bytes(), tmp); // Check index. |
892 throw_if_not_2( Interpreter::_throw_NullPointerException_entry, G3_scratch, ptr_ok); |
892 throw_if_not_2(Interpreter::_throw_NullPointerException_entry, G3_scratch, ptr_ok); |
893 |
893 |
894 Label index_ok; |
894 Label index_ok; |
895 cmp(index, tmp); |
895 cmp(index, tmp); |
896 throw_if_not_1_icc( lessUnsigned, index_ok ); |
896 throw_if_not_1_icc(lessUnsigned, index_ok); |
897 if (index_shift > 0) delayed()->sll(index, index_shift, index); |
897 if (index_shift > 0) { |
898 else delayed()->add(array, index, res); // addr - const offset in index |
898 delayed()->sll(index, index_shift, index); |
899 // convention: move aberrant index into G3_scratch for exception message |
899 } else { |
900 mov(index, G3_scratch); |
900 delayed()->add(array, index, res); // addr - const offset in index |
901 throw_if_not_2( Interpreter::_throw_ArrayIndexOutOfBoundsException_entry, G4_scratch, index_ok); |
901 } |
|
902 // Pass the array to create more detailed exceptions. |
|
903 // Convention: move aberrant index into Otos_i for exception message. |
|
904 mov(index, Otos_i); |
|
905 mov(array, G3_scratch); |
|
906 throw_if_not_2(Interpreter::_throw_ArrayIndexOutOfBoundsException_entry, G4_scratch, index_ok); |
902 |
907 |
903 // add offset if didn't do it in delay slot |
908 // add offset if didn't do it in delay slot |
904 if (index_shift > 0) add(array, index, res); // addr - const offset in index |
909 if (index_shift > 0) { add(array, index, res); } // addr - const offset in index |
905 } |
910 } |
906 |
911 |
907 |
912 |
908 void InterpreterMacroAssembler::index_check(Register array, Register index, int index_shift, Register tmp, Register res) { |
913 void InterpreterMacroAssembler::index_check(Register array, Register index, int index_shift, Register tmp, Register res) { |
909 assert_not_delayed(); |
914 assert_not_delayed(); |