summaryrefslogtreecommitdiffstats
path: root/runtime/quick/inline_method_analyser.cc
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2014-04-02 15:24:05 +0100
committerVladimir Marko <vmarko@google.com>2014-04-04 17:25:17 +0100
commit505ebb0e7b42e7facc8354515b06333ee8b84b10 (patch)
tree6f7adb2333b5a3b8b903097cf80f8b7896ed7d2e /runtime/quick/inline_method_analyser.cc
parent8e40c3e662d852da87b6bcfe79355f96ab9e91c7 (diff)
downloadandroid_art-505ebb0e7b42e7facc8354515b06333ee8b84b10.tar.gz
android_art-505ebb0e7b42e7facc8354515b06333ee8b84b10.tar.bz2
android_art-505ebb0e7b42e7facc8354515b06333ee8b84b10.zip
Inlining synthetic accessors.
Bug: 11549140 Change-Id: Ie0034a6840b1beaa3df92f26bf9d315119c81e34
Diffstat (limited to 'runtime/quick/inline_method_analyser.cc')
-rw-r--r--runtime/quick/inline_method_analyser.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/runtime/quick/inline_method_analyser.cc b/runtime/quick/inline_method_analyser.cc
index 0a1b72e6b4..8bd8dbab73 100644
--- a/runtime/quick/inline_method_analyser.cc
+++ b/runtime/quick/inline_method_analyser.cc
@@ -135,6 +135,12 @@ bool InlineMethodAnalyser::AnalyseMethodCode(verifier::MethodVerifier* verifier,
}
}
+bool InlineMethodAnalyser::IsSyntheticAccessor(MethodReference ref) {
+ const DexFile::MethodId& method_id = ref.dex_file->GetMethodId(ref.dex_method_index);
+ const char* method_name = ref.dex_file->GetMethodName(method_id);
+ return strncmp(method_name, "access$", strlen("access$")) == 0;
+}
+
bool InlineMethodAnalyser::AnalyseReturnMethod(const DexFile::CodeItem* code_item,
InlineMethod* result) {
const Instruction* return_instruction = Instruction::At(code_item->insns_);
@@ -226,8 +232,11 @@ bool InlineMethodAnalyser::AnalyseIGetMethod(verifier::MethodVerifier* verifier,
}
if ((verifier->GetAccessFlags() & kAccStatic) != 0u || object_arg != 0u) {
- // TODO: Support inlining IGET on other register than "this".
- return false;
+ // TODO: Implement inlining of IGET on non-"this" registers (needs correct stack trace for NPE).
+ // Allow synthetic accessors. We don't care about losing their stack frame in NPE.
+ if (!IsSyntheticAccessor(verifier->GetMethodReference())) {
+ return false;
+ }
}
// InlineIGetIPutData::object_arg is only 4 bits wide.
@@ -244,9 +253,9 @@ bool InlineMethodAnalyser::AnalyseIGetMethod(verifier::MethodVerifier* verifier,
result->opcode = kInlineOpIGet;
result->flags = kInlineSpecial;
data->op_variant = IGetVariant(opcode);
- data->method_is_static = (verifier->GetAccessFlags() & kAccStatic) != 0 ? 1u : 0u;
+ data->method_is_static = (verifier->GetAccessFlags() & kAccStatic) != 0u ? 1u : 0u;
data->object_arg = object_arg; // Allow IGET on any register, not just "this".
- data->src_arg = 0;
+ data->src_arg = 0u;
data->return_arg_plus1 = 0u;
}
return true;
@@ -287,9 +296,12 @@ bool InlineMethodAnalyser::AnalyseIPutMethod(verifier::MethodVerifier* verifier,
uint32_t object_arg = object_reg - arg_start;
uint32_t src_arg = src_reg - arg_start;
- if ((verifier->GetAccessFlags() & kAccStatic) != 0 || object_arg != 0) {
- // TODO: Support inlining IPUT on other register than "this".
- return false;
+ if ((verifier->GetAccessFlags() & kAccStatic) != 0u || object_arg != 0u) {
+ // TODO: Implement inlining of IPUT on non-"this" registers (needs correct stack trace for NPE).
+ // Allow synthetic accessors. We don't care about losing their stack frame in NPE.
+ if (!IsSyntheticAccessor(verifier->GetMethodReference())) {
+ return false;
+ }
}
// InlineIGetIPutData::object_arg/src_arg/return_arg_plus1 are each only 4 bits wide.
@@ -308,7 +320,7 @@ bool InlineMethodAnalyser::AnalyseIPutMethod(verifier::MethodVerifier* verifier,
result->opcode = kInlineOpIPut;
result->flags = kInlineSpecial;
data->op_variant = IPutVariant(opcode);
- data->method_is_static = (verifier->GetAccessFlags() & kAccStatic) != 0 ? 1u : 0u;
+ data->method_is_static = (verifier->GetAccessFlags() & kAccStatic) != 0u ? 1u : 0u;
data->object_arg = object_arg; // Allow IPUT on any register, not just "this".
data->src_arg = src_arg;
data->return_arg_plus1 = return_arg_plus1;