730 }
731
732 void TemplateTable::index_check(Register array, Register index)
733 {
734 // destroys r1, rscratch1
735 // check array
736 __ null_check(array, arrayOopDesc::length_offset_in_bytes());
737 // sign extend index for use by indexed load
738 // __ movl2ptr(index, index);
739 // check index
740 Register length = rscratch1;
741 __ ldrw(length, Address(array, arrayOopDesc::length_offset_in_bytes()));
742 __ cmpw(index, length);
743 if (index != r1) {
744 // ??? convention: move aberrant index into r1 for exception message
745 assert(r1 != array, "different registers");
746 __ mov(r1, index);
747 }
748 Label ok;
749 __ br(Assembler::LO, ok);
750 __ mov(rscratch1, Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
751 __ br(rscratch1);
752 __ bind(ok);
753 }
754
755 void TemplateTable::iaload()
756 {
757 transition(itos, itos);
758 __ mov(r1, r0);
759 __ pop_ptr(r0);
760 // r0: array
761 // r1: index
762 index_check(r0, r1); // leaves index in r1, kills rscratch1
763 __ lea(r1, Address(r0, r1, Address::uxtw(2)));
764 __ ldrw(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_INT)));
765 }
766
767 void TemplateTable::laload()
768 {
769 transition(itos, ltos);
|
730 }
731
732 void TemplateTable::index_check(Register array, Register index)
733 {
734 // destroys r1, rscratch1
735 // check array
736 __ null_check(array, arrayOopDesc::length_offset_in_bytes());
737 // sign extend index for use by indexed load
738 // __ movl2ptr(index, index);
739 // check index
740 Register length = rscratch1;
741 __ ldrw(length, Address(array, arrayOopDesc::length_offset_in_bytes()));
742 __ cmpw(index, length);
743 if (index != r1) {
744 // ??? convention: move aberrant index into r1 for exception message
745 assert(r1 != array, "different registers");
746 __ mov(r1, index);
747 }
748 Label ok;
749 __ br(Assembler::LO, ok);
750 // ??? convention: move array into r3 for exception message
751 __ mov(r3, array);
752 __ mov(rscratch1, Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
753 __ br(rscratch1);
754 __ bind(ok);
755 }
756
757 void TemplateTable::iaload()
758 {
759 transition(itos, itos);
760 __ mov(r1, r0);
761 __ pop_ptr(r0);
762 // r0: array
763 // r1: index
764 index_check(r0, r1); // leaves index in r1, kills rscratch1
765 __ lea(r1, Address(r0, r1, Address::uxtw(2)));
766 __ ldrw(r0, Address(r1, arrayOopDesc::base_offset_in_bytes(T_INT)));
767 }
768
769 void TemplateTable::laload()
770 {
771 transition(itos, ltos);
|