From 3d38e8203d344acc9acd63c377b6a53683e1df67 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 25 Nov 2014 10:39:12 -0800 Subject: Move dexCacheStrings from ArtMethod to ArtClass Saves ram. Bug: 17643507 (cherry picked from commit b9a5206b91a656c091e7055ff70e4eed2c76b8b1) Change-Id: Ic446a8466eb877ddf680e1d312ae94df028f9e73 --- libart/src/main/java/java/lang/Class.java | 4 +++- libart/src/main/java/java/lang/reflect/ArtMethod.java | 10 +--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/libart/src/main/java/java/lang/Class.java b/libart/src/main/java/java/lang/Class.java index a833f6c..d766385 100644 --- a/libart/src/main/java/java/lang/Class.java +++ b/libart/src/main/java/java/lang/Class.java @@ -138,6 +138,9 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe */ private transient DexCache dexCache; + /** Short-cut to dexCache.strings */ + private transient String[] dexCacheStrings; + /** static, private, and <init> methods. */ private transient ArtMethod[] directMethods; @@ -453,7 +456,6 @@ public final class Class implements Serializable, AnnotatedElement, GenericDe * @hide */ public String getDexCacheString(Dex dex, int dexStringIndex) { - String[] dexCacheStrings = dexCache.strings; String s = dexCacheStrings[dexStringIndex]; if (s == null) { s = dex.strings().get(dexStringIndex).intern(); diff --git a/libart/src/main/java/java/lang/reflect/ArtMethod.java b/libart/src/main/java/java/lang/reflect/ArtMethod.java index 07cc30c..95e03c6 100644 --- a/libart/src/main/java/java/lang/reflect/ArtMethod.java +++ b/libart/src/main/java/java/lang/reflect/ArtMethod.java @@ -53,9 +53,6 @@ public final class ArtMethod { /** Short-cut to declaringClass.dexCache.resolvedTypes */ /* package */ Class[] dexCacheResolvedTypes; - /** Short-cut to declaringClass.dexCache.strings */ - private String[] dexCacheStrings; - /** Bits encoding access (e.g. public, private) as well as other runtime specific flags */ private int accessFlags; @@ -180,12 +177,7 @@ public final class ArtMethod { * Method we can avoid one indirection. */ private String getDexCacheString(Dex dex, int dexStringIndex) { - String s = (String) dexCacheStrings[dexStringIndex]; - if (s == null) { - s = dex.strings().get(dexStringIndex).intern(); - dexCacheStrings[dexStringIndex] = s; - } - return s; + return declaringClass.getDexCacheString(dex, dexStringIndex); } /** -- cgit v1.1