summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter_common.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-01-27 18:01:39 +0100
committerSebastien Hertz <shertz@google.com>2014-01-28 18:18:14 +0100
commitabff6439db28fbbed95490bfff7e24d1fdf5b771 (patch)
tree6ed749056b1d2e29f2bdf81c13e80e15849e9836 /runtime/interpreter/interpreter_common.cc
parent7ea5dafc81b2bba7cabad26130bb75dc8f709803 (diff)
downloadart-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_common.cc')
-rw-r--r--runtime/interpreter/interpreter_common.cc28
1 files changed, 11 insertions, 17 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index be358e3..0f94ccd 100644
--- a/runtime/interpreter/interpreter_common.cc
+++ b/runtime/interpreter/interpreter_common.cc
@@ -200,26 +200,20 @@ bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame,
DCHECK(self->IsExceptionPending());
return false;
}
+ uint32_t arg[5]; // only used in filled-new-array.
+ uint32_t vregC; // only used in filled-new-array-range.
if (is_range) {
- uint32_t vregC = inst->VRegC_3rc();
- const bool is_primitive_int_component = componentClass->IsPrimitiveInt();
- for (int32_t i = 0; i < length; ++i) {
- if (is_primitive_int_component) {
- newArray->AsIntArray()->Set(i, shadow_frame.GetVReg(vregC + i));
- } else {
- newArray->AsObjectArray<Object>()->Set(i, shadow_frame.GetVRegReference(vregC + i));
- }
- }
+ vregC = inst->VRegC_3rc();
} else {
- uint32_t arg[5];
inst->GetArgs(arg);
- const bool is_primitive_int_component = componentClass->IsPrimitiveInt();
- for (int32_t i = 0; i < length; ++i) {
- if (is_primitive_int_component) {
- newArray->AsIntArray()->Set(i, shadow_frame.GetVReg(arg[i]));
- } else {
- newArray->AsObjectArray<Object>()->Set(i, shadow_frame.GetVRegReference(arg[i]));
- }
+ }
+ const bool is_primitive_int_component = componentClass->IsPrimitiveInt();
+ for (int32_t i = 0; i < length; ++i) {
+ size_t src_reg = is_range ? vregC + i : arg[i];
+ if (is_primitive_int_component) {
+ newArray->AsIntArray()->SetWithoutChecks(i, shadow_frame.GetVReg(src_reg));
+ } else {
+ newArray->AsObjectArray<Object>()->SetWithoutChecks(i, shadow_frame.GetVRegReference(src_reg));
}
}