summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2020-09-16 09:46:58 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2020-10-07 08:32:52 +0000
commit8d34a182fea1b24f7b8361b55e930cb953cf3fb2 (patch)
tree4f5ed9d9ac417dfd69fd18f64412b2272c448e05 /compiler/optimizing/nodes.h
parent8ecbc4e844fc3b73e6a5c5151eda914d53297180 (diff)
Change interface conflict stub to take the interface method.
To avoid doing dex cache lookup, pass the interface method instead. This costs a few hundred KBs on speed compiled APKs (< 0.5% code size), but improves performance when hitting a conflict (as seen on dogfood data). For nterp, we currently pass the conflict method instead of the interface method. We need to handle default methods before optimizing it. This removes our last use of dex cache in compiled code. A follow-up CL will remove the NeedsDexCacheOfDeclaringClass from HInvokeInterface. Test: test.py Change-Id: I3cdd4543ad7d904b3e81950af46a48a48af6991a
Diffstat (limited to 'compiler/optimizing/nodes.h')
-rw-r--r--compiler/optimizing/nodes.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index b674937ee3..9200689f27 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -4417,6 +4417,12 @@ enum class CodePtrLocation {
kCallArtMethod,
};
+static inline bool IsPcRelativeMethodLoadKind(MethodLoadKind load_kind) {
+ return load_kind == MethodLoadKind::kBootImageLinkTimePcRelative ||
+ load_kind == MethodLoadKind::kBootImageRelRo ||
+ load_kind == MethodLoadKind::kBssEntry;
+}
+
class HInvoke : public HVariableInputSizeInstruction {
public:
bool NeedsEnvironment() const override;
@@ -4738,9 +4744,7 @@ class HInvokeStaticOrDirect final : public HInvoke {
bool IsStringInit() const { return GetMethodLoadKind() == MethodLoadKind::kStringInit; }
bool HasMethodAddress() const { return GetMethodLoadKind() == MethodLoadKind::kJitDirectAddress; }
bool HasPcRelativeMethodLoadKind() const {
- return GetMethodLoadKind() == MethodLoadKind::kBootImageLinkTimePcRelative ||
- GetMethodLoadKind() == MethodLoadKind::kBootImageRelRo ||
- GetMethodLoadKind() == MethodLoadKind::kBssEntry;
+ return IsPcRelativeMethodLoadKind(GetMethodLoadKind());
}
QuickEntrypointEnum GetStringInitEntryPoint() const {
@@ -4941,10 +4945,11 @@ class HInvokeInterface final : public HInvoke {
MethodReference method_reference,
ArtMethod* resolved_method,
MethodReference resolved_method_reference,
- uint32_t imt_index)
+ uint32_t imt_index,
+ MethodLoadKind load_kind)
: HInvoke(kInvokeInterface,
allocator,
- number_of_arguments,
+ number_of_arguments + (NeedsCurrentMethod(load_kind) ? 1 : 0),
0u,
return_type,
dex_pc,
@@ -4952,7 +4957,12 @@ class HInvokeInterface final : public HInvoke {
resolved_method,
resolved_method_reference,
kInterface),
- imt_index_(imt_index) {
+ imt_index_(imt_index),
+ hidden_argument_load_kind_(load_kind) {
+ }
+
+ static bool NeedsCurrentMethod(MethodLoadKind load_kind) {
+ return load_kind == MethodLoadKind::kRecursive;
}
bool IsClonable() const override { return true; }
@@ -4967,7 +4977,16 @@ class HInvokeInterface final : public HInvoke {
return true;
}
+ size_t GetSpecialInputIndex() const {
+ return GetNumberOfArguments();
+ }
+
+ void AddSpecialInput(HInstruction* input) {
+ InsertInputAt(GetSpecialInputIndex(), input);
+ }
+
uint32_t GetImtIndex() const { return imt_index_; }
+ MethodLoadKind GetHiddenArgumentLoadKind() const { return hidden_argument_load_kind_; }
DECLARE_INSTRUCTION(InvokeInterface);
@@ -4977,6 +4996,9 @@ class HInvokeInterface final : public HInvoke {
private:
// Cached value of the resolved method, to avoid needing the mutator lock.
const uint32_t imt_index_;
+
+ // How the hidden argument (the interface method) is being loaded.
+ const MethodLoadKind hidden_argument_load_kind_;
};
class HNeg final : public HUnaryOperation {