ART: Do not use std::<container>::at().
These functions are specified as throwing std::out_of_range
and we do not use exceptions.
Test: m
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I67c365ed6d779c101a18b9f386c751c48ca76e16
diff --git a/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc b/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc
index 2c428fa..c6c764e 100644
--- a/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc
+++ b/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc
@@ -120,11 +120,10 @@
// Write out entry spills.
int32_t offset = frame_size + kFramePointerSize;
- for (size_t i = 0; i < entry_spills.size(); ++i) {
- ArmManagedRegister reg = entry_spills.at(i).AsArm();
+ for (const ManagedRegisterSpill& spill : entry_spills) {
+ ArmManagedRegister reg = spill.AsArm();
if (reg.IsNoRegister()) {
// only increment stack offset.
- ManagedRegisterSpill spill = entry_spills.at(i);
offset += spill.getSize();
} else if (reg.IsCoreRegister()) {
asm_.StoreToOffset(kStoreWord, AsVIXLRegister(reg), sp, offset);
diff --git a/compiler/utils/arm64/jni_macro_assembler_arm64.cc b/compiler/utils/arm64/jni_macro_assembler_arm64.cc
index a5aa1c1..d6ce033 100644
--- a/compiler/utils/arm64/jni_macro_assembler_arm64.cc
+++ b/compiler/utils/arm64/jni_macro_assembler_arm64.cc
@@ -719,11 +719,10 @@
// Write out entry spills
int32_t offset = frame_size + static_cast<size_t>(kArm64PointerSize);
- for (size_t i = 0; i < entry_spills.size(); ++i) {
- Arm64ManagedRegister reg = entry_spills.at(i).AsArm64();
+ for (const ManagedRegisterSpill& spill : entry_spills) {
+ Arm64ManagedRegister reg = spill.AsArm64();
if (reg.IsNoRegister()) {
// only increment stack offset.
- ManagedRegisterSpill spill = entry_spills.at(i);
offset += spill.getSize();
} else if (reg.IsXRegister()) {
StoreToOffset(reg.AsXRegister(), SP, offset);
diff --git a/compiler/utils/managed_register.h b/compiler/utils/managed_register.h
index 2b7b2aa..db9c36c 100644
--- a/compiler/utils/managed_register.h
+++ b/compiler/utils/managed_register.h
@@ -101,11 +101,11 @@
ManagedRegisterSpill(const ManagedRegister& other, int32_t size)
: ManagedRegister(other), size_(size), spill_offset_(-1) { }
- int32_t getSpillOffset() {
+ int32_t getSpillOffset() const {
return spill_offset_;
}
- int32_t getSize() {
+ int32_t getSize() const {
return size_;
}
diff --git a/compiler/utils/mips/assembler_mips.cc b/compiler/utils/mips/assembler_mips.cc
index dce5b95..c0b6f98 100644
--- a/compiler/utils/mips/assembler_mips.cc
+++ b/compiler/utils/mips/assembler_mips.cc
@@ -4801,10 +4801,9 @@
// Write out entry spills.
int32_t offset = frame_size + kFramePointerSize;
- for (size_t i = 0; i < entry_spills.size(); ++i) {
- MipsManagedRegister reg = entry_spills.at(i).AsMips();
+ for (const ManagedRegisterSpill& spill : entry_spills) {
+ MipsManagedRegister reg = spill.AsMips();
if (reg.IsNoRegister()) {
- ManagedRegisterSpill spill = entry_spills.at(i);
offset += spill.getSize();
} else if (reg.IsCoreRegister()) {
StoreToOffset(kStoreWord, reg.AsCoreRegister(), SP, offset);
diff --git a/compiler/utils/mips64/assembler_mips64.cc b/compiler/utils/mips64/assembler_mips64.cc
index bb1bb82..5b1c5d9 100644
--- a/compiler/utils/mips64/assembler_mips64.cc
+++ b/compiler/utils/mips64/assembler_mips64.cc
@@ -3633,9 +3633,8 @@
// Write out entry spills.
int32_t offset = frame_size + kFramePointerSize;
- for (size_t i = 0; i < entry_spills.size(); ++i) {
- Mips64ManagedRegister reg = entry_spills[i].AsMips64();
- ManagedRegisterSpill spill = entry_spills.at(i);
+ for (const ManagedRegisterSpill& spill : entry_spills) {
+ Mips64ManagedRegister reg = spill.AsMips64();
int32_t size = spill.getSize();
if (reg.IsNoRegister()) {
// only increment stack offset.
diff --git a/compiler/utils/x86/jni_macro_assembler_x86.cc b/compiler/utils/x86/jni_macro_assembler_x86.cc
index 7e29c4a..dd99f03 100644
--- a/compiler/utils/x86/jni_macro_assembler_x86.cc
+++ b/compiler/utils/x86/jni_macro_assembler_x86.cc
@@ -67,8 +67,7 @@
cfi().AdjustCFAOffset(kFramePointerSize);
DCHECK_EQ(static_cast<size_t>(cfi().GetCurrentCFAOffset()), frame_size);
- for (size_t i = 0; i < entry_spills.size(); ++i) {
- ManagedRegisterSpill spill = entry_spills.at(i);
+ for (const ManagedRegisterSpill& spill : entry_spills) {
if (spill.AsX86().IsCpuRegister()) {
int offset = frame_size + spill.getSpillOffset();
__ movl(Address(ESP, offset), spill.AsX86().AsCpuRegister());
diff --git a/compiler/utils/x86_64/jni_macro_assembler_x86_64.cc b/compiler/utils/x86_64/jni_macro_assembler_x86_64.cc
index 9486cb4..f6b2f9d 100644
--- a/compiler/utils/x86_64/jni_macro_assembler_x86_64.cc
+++ b/compiler/utils/x86_64/jni_macro_assembler_x86_64.cc
@@ -75,8 +75,7 @@
__ movq(Address(CpuRegister(RSP), 0), method_reg.AsX86_64().AsCpuRegister());
- for (size_t i = 0; i < entry_spills.size(); ++i) {
- ManagedRegisterSpill spill = entry_spills.at(i);
+ for (const ManagedRegisterSpill& spill : entry_spills) {
if (spill.AsX86_64().IsCpuRegister()) {
if (spill.getSize() == 8) {
__ movq(Address(CpuRegister(RSP), frame_size + spill.getSpillOffset()),
diff --git a/dexdump/dexdump_cfg.cc b/dexdump/dexdump_cfg.cc
index 69ee068..7e534ed 100644
--- a/dexdump/dexdump_cfg.cc
+++ b/dexdump/dexdump_cfg.cc
@@ -120,7 +120,7 @@
os << inst_str.substr(cur_start, next_escape - cur_start);
// Escape all necessary characters.
while (next_escape < inst_str.size()) {
- char c = inst_str.at(next_escape);
+ char c = inst_str[next_escape];
if (c == '"' || c == '{' || c == '}' || c == '<' || c == '>') {
os << '\\' << c;
} else {
diff --git a/dexlayout/dex_visualize.cc b/dexlayout/dex_visualize.cc
index abcaffc..4a36744 100644
--- a/dexlayout/dex_visualize.cc
+++ b/dexlayout/dex_visualize.cc
@@ -305,7 +305,7 @@
const std::vector<dex_ir::DexFileSection>& sorted_sections,
size_t section_index) {
for (size_t i = section_index + 1; i < sorted_sections.size(); ++i) {
- const dex_ir::DexFileSection& section = sorted_sections.at(i);
+ const dex_ir::DexFileSection& section = sorted_sections[i];
if (section.size != 0) {
return section.offset;
}
diff --git a/dexlayout/dexdiag.cc b/dexlayout/dexdiag.cc
index aa4e6d0..493a8a2 100644
--- a/dexlayout/dexdiag.cc
+++ b/dexlayout/dexdiag.cc
@@ -90,7 +90,9 @@
map_[type]++;
}
size_t Get(uint16_t type) const {
- return map_.at(type);
+ auto it = map_.find(type);
+ DCHECK(it != map_.end());
+ return it->second;
}
private:
std::map<uint16_t, size_t> map_;
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 0beca1f..97b315e 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -539,7 +539,7 @@
space_to_memmap_map.emplace(space, std::move(image));
PatchOat p = PatchOat(isa,
- space_to_memmap_map.at(space).get(),
+ space_to_memmap_map[space].get(),
space->GetLiveBitmap(),
space->GetMemMap(),
delta,
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index e71d1fa..d902455 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -74,11 +74,11 @@
}
for (size_t i = 0; i < args.size(); ++i) {
if (shorty[i + 1] == 'L') {
- jobject val = args.at(i).l;
+ jobject val = args[i].l;
soa.Env()->SetObjectArrayElement(args_jobj, i, val);
} else {
JValue jv;
- jv.SetJ(args.at(i).j);
+ jv.SetJ(args[i].j);
mirror::Object* val = BoxPrimitive(Primitive::GetType(shorty[i + 1]), jv).Ptr();
if (val == nullptr) {
CHECK(soa.Self()->IsExceptionPending());
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index d752805..e5cdef7 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -252,7 +252,7 @@
if (m->IsRuntimeMethod()) {
const InstrumentationStackFrame& frame =
- instrumentation_stack_->at(instrumentation_stack_depth_);
+ (*instrumentation_stack_)[instrumentation_stack_depth_];
if (frame.interpreter_entry_) {
// This instrumentation frame is for an interpreter bridge and is
// pushed when executing the instrumented interpreter bridge. So method
@@ -271,7 +271,7 @@
reached_existing_instrumentation_frames_ = true;
const InstrumentationStackFrame& frame =
- instrumentation_stack_->at(instrumentation_stack_depth_);
+ (*instrumentation_stack_)[instrumentation_stack_depth_];
CHECK_EQ(m, frame.method_) << "Expected " << ArtMethod::PrettyMethod(m)
<< ", Found " << ArtMethod::PrettyMethod(frame.method_);
return_pc = frame.return_pc_;
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 8842942..58e16ed 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -686,7 +686,7 @@
return false;
}
}
- dex_file_pointer = uncompressed_dex_files_.get()->at(i)->Begin();
+ dex_file_pointer = (*uncompressed_dex_files_)[i]->Begin();
} else {
// Do not support mixed-mode oat files.
if (uncompressed_dex_files_ != nullptr) {
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index 8b99b9f..2dbde6f 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -472,7 +472,7 @@
}
static VRegKind GetVRegKind(uint16_t reg, const std::vector<int32_t>& kinds) {
- return static_cast<VRegKind>(kinds.at(reg * 2));
+ return static_cast<VRegKind>(kinds[reg * 2]);
}
QuickExceptionHandler* const exception_handler_;
diff --git a/runtime/stack.cc b/runtime/stack.cc
index a181bfe..2fb8c41 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -856,7 +856,7 @@
if (reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()) == return_pc) {
CHECK_LT(instrumentation_stack_depth, thread_->GetInstrumentationStack()->size());
const instrumentation::InstrumentationStackFrame& instrumentation_frame =
- thread_->GetInstrumentationStack()->at(instrumentation_stack_depth);
+ (*thread_->GetInstrumentationStack())[instrumentation_stack_depth];
instrumentation_stack_depth++;
if (GetMethod() ==
Runtime::Current()->GetCalleeSaveMethod(CalleeSaveType::kSaveAllCalleeSaves)) {
diff --git a/tools/veridex/flow_analysis.cc b/tools/veridex/flow_analysis.cc
index 154c60f..d4f7e5f 100644
--- a/tools/veridex/flow_analysis.cc
+++ b/tools/veridex/flow_analysis.cc
@@ -739,14 +739,15 @@
MethodReference method(&resolver_->GetDexFile(), id);
// TODO: doesn't work for multidex
// TODO: doesn't work for overriding (but maybe should be done at a higher level);
- if (accesses_.find(method) == accesses_.end()) {
+ auto method_accesses_it = accesses_.find(method);
+ if (method_accesses_it == accesses_.end()) {
return GetReturnType(id);
}
uint32_t args[5];
if (!is_range) {
instruction.GetVarArgs(args);
}
- for (const ReflectAccessInfo& info : accesses_.at(method)) {
+ for (const ReflectAccessInfo& info : method_accesses_it->second) {
if (info.cls.IsParameter() || info.name.IsParameter()) {
RegisterValue cls = info.cls.IsParameter()
? GetRegister(GetParameterAt(instruction, is_range, args, info.cls.GetParameterIndex()))
diff --git a/tools/wrapagentproperties/wrapagentproperties.cc b/tools/wrapagentproperties/wrapagentproperties.cc
index 77e19e6..39cb20a 100644
--- a/tools/wrapagentproperties/wrapagentproperties.cc
+++ b/tools/wrapagentproperties/wrapagentproperties.cc
@@ -139,9 +139,10 @@
static jvmtiError WrapGetSystemProperty(jvmtiEnv* env, const char* prop, char** out) {
ExtraJvmtiInterface* funcs = reinterpret_cast<ExtraJvmtiInterface*>(
const_cast<jvmtiInterface_1_*>(env->functions));
- if (funcs->proxy_vm->map->find(prop) != funcs->proxy_vm->map->end()) {
+ auto it = funcs->proxy_vm->map->find(prop);
+ if (it != funcs->proxy_vm->map->end()) {
+ const std::string& val = it->second;
std::string str_prop(prop);
- const std::string& val = funcs->proxy_vm->map->at(str_prop);
jvmtiError res = env->Allocate(val.size() + 1, reinterpret_cast<unsigned char**>(out));
if (res != JVMTI_ERROR_NONE) {
return res;
@@ -198,8 +199,9 @@
if (res != JVMTI_ERROR_NONE) {
return res;
}
- if (funcs->proxy_vm->map->find(prop) != funcs->proxy_vm->map->end()) {
- funcs->proxy_vm->map->at(prop) = val;
+ auto it = funcs->proxy_vm->map->find(prop);
+ if (it != funcs->proxy_vm->map->end()) {
+ it->second = val;
}
return JVMTI_ERROR_NONE;
}