< prev index next >

src/hotspot/cpu/sparc/interp_masm_sparc.cpp

Print this page
rev 50030 : 8201593: Print array length in ArrayIndexOutOfBoundsException.
Reviewed-by: dholmes, mdoerr, smonteith, shade


 864   throw_if_not_2( throw_entry_point, Rscratch, ok);
 865 }
 866 void InterpreterMacroAssembler::throw_if_not_x( Condition ok_condition,
 867                                                 address   throw_entry_point,
 868                                                 Register  Rscratch ) {
 869   Label ok;
 870   if (ok_condition != never) {
 871     throw_if_not_1_x( ok_condition, ok);
 872     delayed()->nop();
 873   }
 874   throw_if_not_2( throw_entry_point, Rscratch, ok);
 875 }
 876 
 877 // Check that index is in range for array, then shift index by index_shift, and put arrayOop + shifted_index into res
 878 // Note: res is still shy of address by array offset into object.
 879 
 880 void InterpreterMacroAssembler::index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res) {
 881   assert_not_delayed();
 882 
 883   verify_oop(array);
 884   // sign extend since tos (index) can be a 32bit value
 885   sra(index, G0, index);
 886 
 887   // check array
 888   Label ptr_ok;
 889   tst(array);
 890   throw_if_not_1_x( notZero, ptr_ok );
 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);
 893 
 894   Label index_ok;
 895   cmp(index, tmp);
 896   throw_if_not_1_icc( lessUnsigned, index_ok );
 897   if (index_shift > 0)  delayed()->sll(index, index_shift, index);
 898   else                  delayed()->add(array, index, res); // addr - const offset in index
 899   // convention: move aberrant index into G3_scratch for exception message
 900   mov(index, G3_scratch);
 901   throw_if_not_2( Interpreter::_throw_ArrayIndexOutOfBoundsException_entry, G4_scratch, index_ok);





 902 
 903   // add offset if didn't do it in delay slot
 904   if (index_shift > 0)   add(array, index, res); // addr - const offset in index
 905 }
 906 
 907 
 908 void InterpreterMacroAssembler::index_check(Register array, Register index, int index_shift, Register tmp, Register res) {
 909   assert_not_delayed();
 910 
 911   // pop array
 912   pop_ptr(array);
 913 
 914   // check array
 915   index_check_without_pop(array, index, index_shift, tmp, res);
 916 }
 917 
 918 
 919 void InterpreterMacroAssembler::get_const(Register Rdst) {
 920   ld_ptr(Lmethod, in_bytes(Method::const_offset()), Rdst);
 921 }
 922 
 923 
 924 void InterpreterMacroAssembler::get_constant_pool(Register Rdst) {




 864   throw_if_not_2( throw_entry_point, Rscratch, ok);
 865 }
 866 void InterpreterMacroAssembler::throw_if_not_x( Condition ok_condition,
 867                                                 address   throw_entry_point,
 868                                                 Register  Rscratch ) {
 869   Label ok;
 870   if (ok_condition != never) {
 871     throw_if_not_1_x( ok_condition, ok);
 872     delayed()->nop();
 873   }
 874   throw_if_not_2( throw_entry_point, Rscratch, ok);
 875 }
 876 
 877 // Check that index is in range for array, then shift index by index_shift, and put arrayOop + shifted_index into res
 878 // Note: res is still shy of address by array offset into object.
 879 
 880 void InterpreterMacroAssembler::index_check_without_pop(Register array, Register index, int index_shift, Register tmp, Register res) {
 881   assert_not_delayed();
 882 
 883   verify_oop(array);
 884   // Sign extend since tos (index) can be a 32bit value.
 885   sra(index, G0, index);
 886 
 887   // Check array.
 888   Label ptr_ok;
 889   tst(array);
 890   throw_if_not_1_x(notZero, ptr_ok);
 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);
 893 
 894   Label index_ok;
 895   cmp(index, tmp);
 896   throw_if_not_1_icc(lessUnsigned, index_ok);
 897   if (index_shift > 0) {
 898     delayed()->sll(index, index_shift, index);
 899   } else {
 900     delayed()->add(array, index, res); // addr - const offset in index
 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);
 907 
 908   // add offset if didn't do it in delay slot
 909   if (index_shift > 0) { add(array, index, res); } // addr - const offset in index
 910 }
 911 
 912 
 913 void InterpreterMacroAssembler::index_check(Register array, Register index, int index_shift, Register tmp, Register res) {
 914   assert_not_delayed();
 915 
 916   // pop array
 917   pop_ptr(array);
 918 
 919   // check array
 920   index_check_without_pop(array, index, index_shift, tmp, res);
 921 }
 922 
 923 
 924 void InterpreterMacroAssembler::get_const(Register Rdst) {
 925   ld_ptr(Lmethod, in_bytes(Method::const_offset()), Rdst);
 926 }
 927 
 928 
 929 void InterpreterMacroAssembler::get_constant_pool(Register Rdst) {


< prev index next >