ART: Switch tagging table to a map

Performance is critical. A map involves overhead for moving GC,
but has much faster lookup for the common case.

Make test 905 robust against unstable ordering.

Bug: 31385027
Test: m test-art-host
Test: m ART_USE_READ_BARRIER=true test-art-host
Change-Id: Ica3ff603fc78168759fccfe79c97860279ce9036
diff --git a/test/905-object-free/src/Main.java b/test/905-object-free/src/Main.java
index 7b52e29..16dec5d 100644
--- a/test/905-object-free/src/Main.java
+++ b/test/905-object-free/src/Main.java
@@ -15,6 +15,7 @@
  */
 
 import java.util.ArrayList;
+import java.util.Arrays;
 
 public class Main {
   public static void main(String[] args) throws Exception {
@@ -42,6 +43,7 @@
 
     Runtime.getRuntime().gc();
 
+    getAndPrintTags();
     System.out.println("---");
 
     // Note: the reporting will not depend on the heap layout (which could be unstable). Walking
@@ -53,10 +55,12 @@
 
     Runtime.getRuntime().gc();
 
+    getAndPrintTags();
     System.out.println("---");
 
     Runtime.getRuntime().gc();
 
+    getAndPrintTags();
     System.out.println("---");
   }
 
@@ -66,7 +70,14 @@
     setTag(obj, tag);
   }
 
+  private static void getAndPrintTags() {
+    long[] freedTags = getCollectedTags();
+    Arrays.sort(freedTags);
+    System.out.println(Arrays.toString(freedTags));
+  }
+
   private static native void setupObjectFreeCallback();
   private static native void enableFreeTracking(boolean enable);
   private static native void setTag(Object o, long tag);
+  private static native long[] getCollectedTags();
 }