diff options
author | 2018-07-03 09:18:32 +0100 | |
---|---|---|
committer | 2018-07-03 09:18:32 +0100 | |
commit | 35d5b8a2c5d2fce03be59aa003c3bf3c1b481be0 (patch) | |
tree | 7665f6d1527be61af13c8ef53f10833dd4200cfd | |
parent | b28683f43231e65860ecf91c96a8c0234542c019 (diff) |
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
-rw-r--r-- | compiler/utils/arm/jni_macro_assembler_arm_vixl.cc | 5 | ||||
-rw-r--r-- | compiler/utils/arm64/jni_macro_assembler_arm64.cc | 5 | ||||
-rw-r--r-- | compiler/utils/managed_register.h | 4 | ||||
-rw-r--r-- | compiler/utils/mips/assembler_mips.cc | 5 | ||||
-rw-r--r-- | compiler/utils/mips64/assembler_mips64.cc | 5 | ||||
-rw-r--r-- | compiler/utils/x86/jni_macro_assembler_x86.cc | 3 | ||||
-rw-r--r-- | compiler/utils/x86_64/jni_macro_assembler_x86_64.cc | 3 | ||||
-rw-r--r-- | dexdump/dexdump_cfg.cc | 2 | ||||
-rw-r--r-- | dexlayout/dex_visualize.cc | 2 | ||||
-rw-r--r-- | dexlayout/dexdiag.cc | 4 | ||||
-rw-r--r-- | patchoat/patchoat.cc | 2 | ||||
-rw-r--r-- | runtime/entrypoints/entrypoint_utils.cc | 4 | ||||
-rw-r--r-- | runtime/instrumentation.cc | 4 | ||||
-rw-r--r-- | runtime/oat_file.cc | 2 | ||||
-rw-r--r-- | runtime/quick_exception_handler.cc | 2 | ||||
-rw-r--r-- | runtime/stack.cc | 2 | ||||
-rw-r--r-- | tools/veridex/flow_analysis.cc | 5 | ||||
-rw-r--r-- | tools/wrapagentproperties/wrapagentproperties.cc | 10 |
18 files changed, 34 insertions, 35 deletions
diff --git a/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc b/compiler/utils/arm/jni_macro_assembler_arm_vixl.cc index 2c428fac7e..c6c764e3a9 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 @@ void ArmVIXLJNIMacroAssembler::BuildFrame(size_t frame_size, // 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 a5aa1c12b3..d6ce03387c 100644 --- a/compiler/utils/arm64/jni_macro_assembler_arm64.cc +++ b/compiler/utils/arm64/jni_macro_assembler_arm64.cc @@ -719,11 +719,10 @@ void Arm64JNIMacroAssembler::BuildFrame(size_t frame_size, // 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 2b7b2aa7ce..db9c36cc75 100644 --- a/compiler/utils/managed_register.h +++ b/compiler/utils/managed_register.h @@ -101,11 +101,11 @@ class ManagedRegisterSpill : public ManagedRegister { 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 dce5b95fec..c0b6f988d4 100644 --- a/compiler/utils/mips/assembler_mips.cc +++ b/compiler/utils/mips/assembler_mips.cc @@ -4801,10 +4801,9 @@ void MipsAssembler::BuildFrame(size_t frame_size, // 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 bb1bb82fa5..5b1c5d9e01 100644 --- a/compiler/utils/mips64/assembler_mips64.cc +++ b/compiler/utils/mips64/assembler_mips64.cc @@ -3633,9 +3633,8 @@ void Mips64Assembler::BuildFrame(size_t frame_size, // 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 7e29c4aa26..dd99f03aa7 100644 --- a/compiler/utils/x86/jni_macro_assembler_x86.cc +++ b/compiler/utils/x86/jni_macro_assembler_x86.cc @@ -67,8 +67,7 @@ void X86JNIMacroAssembler::BuildFrame(size_t frame_size, 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 9486cb44c5..f6b2f9df34 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 @@ void X86_64JNIMacroAssembler::BuildFrame(size_t frame_size, __ 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 69ee0682a3..7e534ed359 100644 --- a/dexdump/dexdump_cfg.cc +++ b/dexdump/dexdump_cfg.cc @@ -120,7 +120,7 @@ static void dumpMethodCFGImpl(const DexFile* dex_file, 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 abcaffc434..4a36744e97 100644 --- a/dexlayout/dex_visualize.cc +++ b/dexlayout/dex_visualize.cc @@ -305,7 +305,7 @@ static uint32_t FindNextByteAfterSection(dex_ir::Header* header, 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 aa4e6d031e..493a8a2793 100644 --- a/dexlayout/dexdiag.cc +++ b/dexlayout/dexdiag.cc @@ -90,7 +90,9 @@ class PageCount { 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 0beca1f4ce..97b315e85c 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -539,7 +539,7 @@ bool PatchOat::Patch(const std::string& image_location, 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 e71d1fa38a..d902455c00 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -74,11 +74,11 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa, cons } 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 d752805d02..e5cdef749e 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -252,7 +252,7 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) 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 @@ static void InstrumentationInstallStack(Thread* thread, void* arg) 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 8842942e7a..58e16ed1b7 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -686,7 +686,7 @@ bool OatFileBase::Setup(int zip_fd, const char* abs_dex_location, std::string* e 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 8b99b9f9c8..2dbde6f510 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -472,7 +472,7 @@ class DeoptimizeStackVisitor FINAL : public StackVisitor { } 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 a181bfe091..2fb8c413e9 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -856,7 +856,7 @@ void StackVisitor::WalkStack(bool include_transitions) { 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 154c60f6ac..d4f7e5f91d 100644 --- a/tools/veridex/flow_analysis.cc +++ b/tools/veridex/flow_analysis.cc @@ -739,14 +739,15 @@ RegisterValue FlowAnalysisSubstitutor::AnalyzeInvoke(const Instruction& instruct 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 77e19e691a..39cb20acf2 100644 --- a/tools/wrapagentproperties/wrapagentproperties.cc +++ b/tools/wrapagentproperties/wrapagentproperties.cc @@ -139,9 +139,10 @@ struct ExtraJvmtiInterface : public jvmtiInterface_1_ { 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 @@ struct ExtraJvmtiInterface : public jvmtiInterface_1_ { 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; } |