OSDN Git Service

am 3d30b073: Merge "ART: Do not emit load when inlining unused Thread.currentThread()"
authorAndreas Gampe <agampe@google.com>
Sat, 12 Jul 2014 01:41:57 +0000 (01:41 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Sat, 12 Jul 2014 01:41:57 +0000 (01:41 +0000)
* commit '3d30b073541f19470e8b5dddef9377411fa587c3':
  ART: Do not emit load when inlining unused Thread.currentThread()

compiler/dex/quick/gen_invoke.cc
test/082-inline-execute/src/Main.java

index 02f39ac..6c0dfe8 100755 (executable)
@@ -1638,6 +1638,12 @@ bool Mir2Lir::GenInlinedStringCompareTo(CallInfo* info) {
 
 bool Mir2Lir::GenInlinedCurrentThread(CallInfo* info) {
   RegLocation rl_dest = InlineTarget(info);
+
+  // Early exit if the result is unused.
+  if (rl_dest.orig_sreg < 0) {
+    return true;
+  }
+
   RegLocation rl_result = EvalLoc(rl_dest, kRefReg, true);
 
   switch (cu_->instruction_set) {
index 5b8134d..3b11879 100644 (file)
@@ -49,6 +49,7 @@ public class Main {
     test_String_indexOf();
     test_String_isEmpty();
     test_String_length();
+    test_Thread_currentThread();
   }
 
   /*
@@ -70,6 +71,17 @@ public class Main {
       return (b - a) < maxDelta;
   }
 
+  /**
+   * Will test inlining Thread.currentThread().
+   */
+  public static void test_Thread_currentThread() {
+    // 1. Do not use result.
+    Thread.currentThread();
+
+    // 2. Result should not be null.
+    Assert.assertNotNull(Thread.currentThread());
+  }
+
   public static void test_String_length() {
     String str0 = "";
     String str1 = "x";