OSDN Git Service

Fix class loader interning following a String.intern.
authorCarl Shapiro <cshapiro@google.com>
Wed, 20 Oct 2010 00:27:13 +0000 (17:27 -0700)
committerCarl Shapiro <cshapiro@google.com>
Wed, 20 Oct 2010 02:29:23 +0000 (19:29 -0700)
commitf527f1a7868d5a878d5bea3495e1db8ea039428a
treed6bc5d688c98c46fee2cc71743148b02197b3cc5
parent3844c2bf9e37343621d0deddf57fe26a53259cd9
Fix class loader interning following a String.intern.

Strings can be intered by the class loader, in the case of string
literals, or by the user, through String.intern.  Literal strings
exist for the life of their referencing classes.  User strings are
weak and may be garbage collected when unreferenced.  These two
classes of strings are kept in seprate tables for the conveniance of
the garbage collector during root traversal.

When a class loader interns a string that was already interned by the
user the runtime must move the string from the intern table to the
literal table to increase the reference strength.  Previously, this
was implemented by inserting the incoming string into the literal
table and removing any matching strings in the intern table.  This
transition lost pointer equality.  With this change we first insert
the exact string from the intern table into the literal table and
secondly remove its reference from the intern table.  By moving the
string between tables pointer equality is preserved.

At this point lookupInternedString should be split into two functions,
possibly by pulled up the relevant bits into the public interface
functions.  Since this change will be merged to gingerbread I will
leave the clean up to a separate change.

Bug: 3098960
Change-Id: I11d24d0afa9b7ca2e53fefb1b5e6364795e14d44
vm/Intern.c