OSDN Git Service

ART: String DexCache asm fast path for ARM64
authorChristina Wadsworth <cwadsworth@google.com>
Mon, 8 Aug 2016 20:08:05 +0000 (13:08 -0700)
committerChristina Wadsworth <cwadsworth@google.com>
Mon, 22 Aug 2016 20:30:22 +0000 (13:30 -0700)
In the entrypoints, before a string is looked up in the slow path (in
the intern table), I added assembly to check the dex cache and return a
string pointer if the string is already in the dex cache.

Test: test-art-host

Change-Id: Ic9a724848c61e4fa66e82334e2c7b20b13bf8e6c

runtime/arch/arm64/quick_entrypoints_arm64.S

index 3e6fbaf..7b71983 100644 (file)
@@ -1786,11 +1786,40 @@ ENTRY art_quick_set64_static
 END art_quick_set64_static
 
     /*
-     * Entry from managed code to resolve a string, this stub will allocate a String and deliver an
-     * exception on error. On success the String is returned. w0 holds the string index. The fast
-     * path check for hit in strings cache has already been performed.
+     * Entry from managed code to resolve a string, this stub will
+     * check the dex cache for a matching string (the fast path), and if not found,
+     * it will allocate a String and deliver an exception on error.
+     * On success the String is returned. R0 holds the string index.
      */
-ONE_ARG_DOWNCALL art_quick_resolve_string, artResolveStringFromCode, RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
+
+ENTRY art_quick_resolve_string
+    ldr   x1, [sp]                                               // load referrer
+    ldr   w2, [x1, #ART_METHOD_DECLARING_CLASS_OFFSET]           // load declaring class
+    ldr   x1, [x2, #DECLARING_CLASS_DEX_CACHE_STRINGS_OFFSET]    // load string dex cache
+    mov   x2, #STRING_DEX_CACHE_SIZE_MINUS_ONE
+    and   x2, x0, x2
+    lsl   x2, x2, #STRING_DEX_CACHE_ELEMENT_SIZE_SHIFT
+    add   x1, x2, x1
+    ldr   x2, [x1]                                               // load index and pointer into x2
+    lsr   x3, x2, #32                                            // get upper 32 bits
+    ubfx  x2, x2, #0, #32                                        // get lower 32 bits
+    cmp   x0, x3
+    bne   .Lart_quick_resolve_string_slow_path
+#ifdef USE_READ_BARRIER
+    ldr   x3, [x2, #MIRROR_OBJECT_LOCK_WORD_OFFSET]
+    tbz   x3, #LOCK_WORD_MARK_BIT_SHIFT, .Lart_quick_resolve_string_slow_path
+#endif
+    mov   x0, x2
+    ret
+
+.Lart_quick_resolve_string_slow_path:
+    SETUP_SAVE_REFS_ONLY_FRAME                      // save callee saves in case of GC
+    mov   x1, xSELF                                 // pass Thread::Current
+    bl    artResolveStringFromCode                  // (uint32_t type_idx, Method* method, Thread*)
+    RESTORE_SAVE_REFS_ONLY_FRAME
+    RETURN_IF_RESULT_IS_NON_ZERO_OR_DELIVER
+
+END art_quick_resolve_string
 
 // Generate the allocation entrypoints for each allocator.
 GENERATE_ALLOC_ENTRYPOINTS_FOR_NON_REGION_TLAB_ALLOCATORS