Avoid inliner spam wrt String.length.
Also, remove a use of std::map for our preferred SafeMap and be more explicit
with types.
Change-Id: I7b9a4bb1f73c22490fe416503e050671e7c99fe0
diff --git a/compiler/dex/quick/dex_file_method_inliner.cc b/compiler/dex/quick/dex_file_method_inliner.cc
index c21ddcc..0937be3 100644
--- a/compiler/dex/quick/dex_file_method_inliner.cc
+++ b/compiler/dex/quick/dex_file_method_inliner.cc
@@ -499,25 +499,25 @@
uint32_t method_idx = FindMethodIndex(dex_file, &cache, def.method_def);
if (method_idx != kIndexNotFound) {
DCHECK(inline_methods_.find(method_idx) == inline_methods_.end());
- inline_methods_[method_idx] = def.intrinsic;
+ inline_methods_.Put(method_idx, def.intrinsic);
}
}
dex_file_ = dex_file;
}
bool DexFileMethodInliner::AddInlineMethod(int32_t method_idx, InlineMethodOpcode opcode,
- uint16_t flags, uint32_t data) {
+ InlineMethodFlags flags, uint32_t data) {
WriterMutexLock mu(Thread::Current(), lock_);
- InlineMethod* im = &inline_methods_[method_idx];
- if (im->flags == 0) {
- im->opcode = opcode;
- im->flags = flags;
- im->data = data;
+ if (LIKELY(inline_methods_.find(method_idx) == inline_methods_.end())) {
+ InlineMethod im = {opcode, flags, data};
+ inline_methods_.Put(method_idx, im);
return true;
} else {
- // TODO: Warning about a method being already inlined?
- LOG(WARNING) << "Inliner: " << PrettyMethod(method_idx, *dex_file_) << " already inline, "
- << im->flags;
+ if (PrettyMethod(method_idx, *dex_file_) == "int java.lang.String.length()") {
+ // TODO: String.length is both kIntrinsicIsEmptyOrLength and kInlineOpIGet.
+ } else {
+ LOG(ERROR) << "Inliner: " << PrettyMethod(method_idx, *dex_file_) << " already inline";
+ }
return false;
}
}
diff --git a/compiler/dex/quick/dex_file_method_inliner.h b/compiler/dex/quick/dex_file_method_inliner.h
index 1d99731..6e81303 100644
--- a/compiler/dex/quick/dex_file_method_inliner.h
+++ b/compiler/dex/quick/dex_file_method_inliner.h
@@ -18,9 +18,9 @@
#define ART_COMPILER_DEX_QUICK_DEX_FILE_METHOD_INLINER_H_
#include <stdint.h>
-#include <map>
#include "base/mutex.h"
#include "base/macros.h"
+#include "safe_map.h"
#include "dex/compiler_enums.h"
#include "dex_file.h"
#include "locks.h"
@@ -56,14 +56,15 @@
kInlineOpIPut,
};
-enum InlineMethodFlags {
- kInlineIntrinsic = 0x0001,
- kInlineSpecial = 0x0002,
+enum InlineMethodFlags : uint16_t {
+ kNoInlineMethodFlags = 0x0000,
+ kInlineIntrinsic = 0x0001,
+ kInlineSpecial = 0x0002,
};
struct InlineMethod {
- uint16_t opcode;
- uint16_t flags;
+ InlineMethodOpcode opcode;
+ InlineMethodFlags flags;
uint32_t data;
};
@@ -369,7 +370,7 @@
friend class DexFileToMethodInlinerMap;
bool AddInlineMethod(int32_t method_idx, InlineMethodOpcode opcode,
- uint16_t flags, uint32_t data) LOCKS_EXCLUDED(lock_);
+ InlineMethodFlags flags, uint32_t data) LOCKS_EXCLUDED(lock_);
bool AnalyseReturnMethod(int32_t method_idx, const DexFile::CodeItem* code_item,
OpSize size) LOCKS_EXCLUDED(lock_);
@@ -384,7 +385,7 @@
/*
* Maps method indexes (for the particular DexFile) to Intrinsic defintions.
*/
- std::map<uint32_t, InlineMethod> inline_methods_ GUARDED_BY(lock_);
+ SafeMap<uint32_t, InlineMethod> inline_methods_ GUARDED_BY(lock_);
const DexFile* dex_file_;
DISALLOW_COPY_AND_ASSIGN(DexFileMethodInliner);