Don't use the graph's dex file when printing HInvoke.
It's not the right dex file if the invokes come from inlined
methods.
Test: manual
Change-Id: I4e3fb35e2bddc67510c39e12075c9a5ca0498a3a
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index 7dcf244..a20ec3c 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -451,8 +451,16 @@
void VisitInvoke(HInvoke* invoke) OVERRIDE {
StartAttributeStream("dex_file_index") << invoke->GetDexMethodIndex();
- StartAttributeStream("method_name") << GetGraph()->GetDexFile().PrettyMethod(
- invoke->GetDexMethodIndex(), /* with_signature */ false);
+ ArtMethod* method = invoke->GetResolvedMethod();
+ // We don't print signatures, which conflict with c1visualizer format.
+ static constexpr bool kWithSignature = false;
+ // Note that we can only use the graph's dex file for the unresolved case. The
+ // other invokes might be coming from inlined methods.
+ ScopedObjectAccess soa(Thread::Current());
+ std::string method_name = (method == nullptr)
+ ? GetGraph()->GetDexFile().PrettyMethod(invoke->GetDexMethodIndex(), kWithSignature)
+ : method->PrettyMethod(kWithSignature);
+ StartAttributeStream("method_name") << method_name;
}
void VisitInvokeUnresolved(HInvokeUnresolved* invoke) OVERRIDE {
diff --git a/test/450-checker-types/src/Main.java b/test/450-checker-types/src/Main.java
index ea8609e..f787438 100644
--- a/test/450-checker-types/src/Main.java
+++ b/test/450-checker-types/src/Main.java
@@ -634,7 +634,7 @@
/// CHECK-DAG: <<Null:l\d+>> NullConstant
/// CHECK-DAG: <<Phi:l\d+>> Phi [<<Arg>>,<<Null>>] klass:SubclassA
/// CHECK-DAG: <<NCPhi:l\d+>> NullCheck [<<Phi>>]
- /// CHECK-DAG: InvokeVirtual [<<NCPhi>>] method_name:Super.hashCode
+ /// CHECK-DAG: InvokeVirtual [<<NCPhi>>] method_name:java.lang.Object.hashCode
public void testThisArgumentMoreSpecific(boolean cond) {
// Inlining method from Super will build it with `this` typed as Super.
@@ -655,7 +655,7 @@
/// CHECK-START: void Main.testExplicitArgumentMoreSpecific(SubclassA) inliner (after)
/// CHECK-DAG: <<Arg:l\d+>> ParameterValue klass:SubclassA
/// CHECK-DAG: <<NCArg:l\d+>> NullCheck [<<Arg>>] klass:SubclassA
- /// CHECK-DAG: InvokeVirtual [<<NCArg>>] method_name:Super.hashCode
+ /// CHECK-DAG: InvokeVirtual [<<NCArg>>] method_name:java.lang.Object.hashCode
public void testExplicitArgumentMoreSpecific(SubclassA obj) {
// Inlining a method will build it with reference types from its signature,