diff options
author | Sebastien Hertz <shertz@google.com> | 2014-01-27 18:01:39 +0100 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2014-01-28 18:18:14 +0100 |
commit | abff6439db28fbbed95490bfff7e24d1fdf5b771 (patch) | |
tree | 6ed749056b1d2e29f2bdf81c13e80e15849e9836 /runtime/interpreter/interpreter_goto_table_impl.cc | |
parent | 7ea5dafc81b2bba7cabad26130bb75dc8f709803 (diff) | |
download | art-abff6439db28fbbed95490bfff7e24d1fdf5b771.zip art-abff6439db28fbbed95490bfff7e24d1fdf5b771.tar.gz art-abff6439db28fbbed95490bfff7e24d1fdf5b771.tar.bz2 |
Refactor array access for the interpreter.
Adds GetWithoutChecks and SetWithoutChecks methods in PrimitiveArray and use
them in the interpreter. Updates Get and Set methods to rely on them and adds
some DCHECK to control exception flow.
Renames IsValidIndex into CheckIsValidIndex to reflect it can throw an
exception. It's also more consistent with ObjectArray::CheckIsAssignable.
Make ThrowArrayIndexOutOfBoundsException private in Array since it's only used
by Array::CheckIsValidIndex.
Updates DoFilledNewArray to use SetWithoutChecks rather than Set.
Change-Id: I2fd314d77a67cf969843d499b86d04ca7b7a43e6
Diffstat (limited to 'runtime/interpreter/interpreter_goto_table_impl.cc')
-rw-r--r-- | runtime/interpreter/interpreter_goto_table_impl.cc | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/runtime/interpreter/interpreter_goto_table_impl.cc b/runtime/interpreter/interpreter_goto_table_impl.cc index 942c275..ca03885 100644 --- a/runtime/interpreter/interpreter_goto_table_impl.cc +++ b/runtime/interpreter/interpreter_goto_table_impl.cc @@ -932,8 +932,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); BooleanArray* array = a->AsBooleanArray(); - if (LIKELY(array->IsValidIndex(index))) { - shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetData()[index]); + if (LIKELY(array->CheckIsValidIndex(index))) { + shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -950,8 +950,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); ByteArray* array = a->AsByteArray(); - if (LIKELY(array->IsValidIndex(index))) { - shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetData()[index]); + if (LIKELY(array->CheckIsValidIndex(index))) { + shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -968,8 +968,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); CharArray* array = a->AsCharArray(); - if (LIKELY(array->IsValidIndex(index))) { - shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetData()[index]); + if (LIKELY(array->CheckIsValidIndex(index))) { + shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -986,8 +986,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); ShortArray* array = a->AsShortArray(); - if (LIKELY(array->IsValidIndex(index))) { - shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetData()[index]); + if (LIKELY(array->CheckIsValidIndex(index))) { + shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1004,8 +1004,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); IntArray* array = a->AsIntArray(); - if (LIKELY(array->IsValidIndex(index))) { - shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetData()[index]); + if (LIKELY(array->CheckIsValidIndex(index))) { + shadow_frame.SetVReg(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1022,8 +1022,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); LongArray* array = a->AsLongArray(); - if (LIKELY(array->IsValidIndex(index))) { - shadow_frame.SetVRegLong(inst->VRegA_23x(inst_data), array->GetData()[index]); + if (LIKELY(array->CheckIsValidIndex(index))) { + shadow_frame.SetVRegLong(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1040,7 +1040,7 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* } else { int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); ObjectArray<Object>* array = a->AsObjectArray<Object>(); - if (LIKELY(array->IsValidIndex(index))) { + if (LIKELY(array->CheckIsValidIndex(index))) { shadow_frame.SetVRegReference(inst->VRegA_23x(inst_data), array->GetWithoutChecks(index)); ADVANCE(2); } else { @@ -1059,8 +1059,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* uint8_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data)); int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); BooleanArray* array = a->AsBooleanArray(); - if (LIKELY(array->IsValidIndex(index))) { - array->GetData()[index] = val; + if (LIKELY(array->CheckIsValidIndex(index))) { + array->SetWithoutChecks(index, val); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1078,8 +1078,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* int8_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data)); int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); ByteArray* array = a->AsByteArray(); - if (LIKELY(array->IsValidIndex(index))) { - array->GetData()[index] = val; + if (LIKELY(array->CheckIsValidIndex(index))) { + array->SetWithoutChecks(index, val); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1097,8 +1097,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* uint16_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data)); int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); CharArray* array = a->AsCharArray(); - if (LIKELY(array->IsValidIndex(index))) { - array->GetData()[index] = val; + if (LIKELY(array->CheckIsValidIndex(index))) { + array->SetWithoutChecks(index, val); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1116,8 +1116,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* int16_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data)); int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); ShortArray* array = a->AsShortArray(); - if (LIKELY(array->IsValidIndex(index))) { - array->GetData()[index] = val; + if (LIKELY(array->CheckIsValidIndex(index))) { + array->SetWithoutChecks(index, val); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1135,8 +1135,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* int32_t val = shadow_frame.GetVReg(inst->VRegA_23x(inst_data)); int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); IntArray* array = a->AsIntArray(); - if (LIKELY(array->IsValidIndex(index))) { - array->GetData()[index] = val; + if (LIKELY(array->CheckIsValidIndex(index))) { + array->SetWithoutChecks(index, val); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1154,8 +1154,8 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* int64_t val = shadow_frame.GetVRegLong(inst->VRegA_23x(inst_data)); int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); LongArray* array = a->AsLongArray(); - if (LIKELY(array->IsValidIndex(index))) { - array->GetData()[index] = val; + if (LIKELY(array->CheckIsValidIndex(index))) { + array->SetWithoutChecks(index, val); ADVANCE(2); } else { HANDLE_PENDING_EXCEPTION(); @@ -1173,7 +1173,7 @@ JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* int32_t index = shadow_frame.GetVReg(inst->VRegC_23x()); Object* val = shadow_frame.GetVRegReference(inst->VRegA_23x(inst_data)); ObjectArray<Object>* array = a->AsObjectArray<Object>(); - if (LIKELY(array->IsValidIndex(index) && array->CheckAssignable(val))) { + if (LIKELY(array->CheckIsValidIndex(index) && array->CheckAssignable(val))) { array->SetWithoutChecks(index, val); ADVANCE(2); } else { |