History log of /art/runtime/mirror/string-inl.h
Revision Date Author Comments
92907f3f7af106a9eeb341caba17f3770203f7fb 20-Feb-2017 Vladimir Marko <vmarko@google.com> Remove String.setCharAt().

The internal API String.setCharAt() breaks the assumption
that strings are really immutable. That in turn breaks
string compression invariants - compressible strings must
be compressed. This CL removes the String.setCharAt() API.

The method was used only in String.replace(char, char)
when we found a match, copying the string on first match.
Instead, introduce a new native method that does the whole
replacement with a single call when we find the first match.

StringReplaceBenchmark results on Nexus 6P, lower is better:
timeReplaceCharNonExistent/EMPTY 41.93 -> 38.25 (-9%)
timeReplaceCharNonExistent/L_16 114.90 -> 95.09 (-17%)
timeReplaceCharNonExistent/L_64 419.97 -> 320.65 (-24%)
timeReplaceCharNonExistent/L_256 1667.01 -> 1091.25 (-35%)
timeReplaceCharNonExistent/L_512 3253.50 -> 2075.62 (-36%)
timeReplaceCharRepeated/EMPTY 41.93 -> 39.58 (-6%)
timeReplaceCharRepeated/L_16 114.87 -> 95.40 (-17%)
timeReplaceCharRepeated/L_64 1267.29 -> 704.32 (-44%)
timeReplaceCharRepeated/L_256 5139.14 -> 1361.80 (-74%)
timeReplaceCharRepeated/L_512 10787.81 -> 2338.41 (-78%)
timeReplaceSingleChar/EMPTY 41.78 -> 37.16 (-11%)
timeReplaceSingleChar/L_16 449.54 -> 497.51 (+11%)
timeReplaceSingleChar/L_64 942.08 -> 891.35 (-5%)
timeReplaceSingleChar/L_256 2756.18 -> 2174.64 (-21%)
timeReplaceSingleChar/L_512 5489.91 -> 3983.32 (-27%)

Test: testrunner.py --host
Test: run-libcore-tests.sh --mode=host
Test: testrunner.py --host with string compression enabled.
Test: run-libcore-tests.sh --mode=host with string compression enabled.
Bug: 31040547
Change-Id: I9cf0d5457182f0a33ca8251c29931d3eb624ae07
e39f14ff4e0d7c70016874cff24863b912d40bf1 10-Feb-2017 Vladimir Marko <vmarko@google.com> ARM64: Improve String.equals() intrinsic for const strings.

And add additional tests to 021-string2.

aosp_angler-userdebug:
before:
arm64 boot*.oat: 43324664
arm64 boot*.oat/string compression: 43411112
after:
arm64 boot*.oat: 43300136 (-24528)
arm64 boot*.oat/string compression: 43345464 (-65648)

The string compression code size difference drops from
86448 to 45328.

Test: m test-art-target on Nexus 6P
Test: m test-art-target on Nexus 6P with string compression enabled.
Bug: 31040547
Change-Id: I99a3777b91b248da2b0ac25abd260f9e5abb2c09
46ee31b67d7ee1bd085fbc240502053caa3cf8fa 14-Dec-2016 Andreas Gampe <agampe@google.com> ART: Move to libbase StringPrintf

Remove ART's StringPrintf implementation. Fix up clients. Add
missing includes where necessary.

Test: m test-art-host
Change-Id: I564038d5868595ac3bb88d641af1000cea940e5a
16850aecd661375533404099cbc679aba7377ba4 09-Dec-2016 Vladimir Marko <vmarko@google.com> Fix string compression for embedded zero chars.

Treat embedded zero character as non-ASCII.

Test: m test-art-host
Test: m test-art-host with string compression enabled.
Bug: 31040547
Change-Id: Iea6e92f89d424953814953ba27f1c7a991589c65
fdaf0f45510374d3a122fdc85d68793e2431175e 13-Oct-2016 Vladimir Marko <vmarko@google.com> Change string compression encoding.

Encode the string compression flag as the least significant
bit of the "count" field, with 0 meaning compressed and 1
meaning uncompressed.

The main vdex file is a tiny bit larger (+28B for prebuilt
boot images, +32 for on-device built images) and the oat
file sizes change. Measured on Nexus 9, AOSP ToT, these
changes are insignificant when string compression is
disabled (-200B for the 32-bit boot*.oat for prebuilt boot
image, -4KiB when built on the device attributable to
rounding, -16B for 64-bit boot*.oat for prebuilt boot image,
no change when built on device) but with string compression
enabled we get significant differences:
prebuilt multi-part boot image:
- 32-bit boot*.oat: -28KiB
- 64-bit boot*.oat: -24KiB
on-device built single boot image:
- 32-bit boot.oat: -32KiB
- 64-bit boot.oat: -28KiB
The boot image oat file overhead for string compression:
prebuilt multi-part boot image:
- 32-bit boot*.oat: before: ~80KiB after: ~52KiB
- 64-bit boot*.oat: before: ~116KiB after: ~92KiB
on-device built single boot image:
- 32-bit boot.oat: before: 92KiB after: 60KiB
- 64-bit boot.oat: before: 116KiB after: 92KiB

The differences in the SplitStringBenchmark seem to be lost
in the noise.

Test: Run ART test suite on host and Nexus 9 with Optimizing.
Test: Run ART test suite on host and Nexus 9 with interpreter.
Test: All of the above with string compression enabled.
Bug: 31040547

Change-Id: I7570c2b700f1a31004a2d3c18b1cc30046d35a74
9e868098b4a5d666570e3924518978d7abd3542e 31-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move intern table to ObjPtr

Also moved StringLog to use a GcRoot.

Also removed read barriers from lookup to prevent making weak strings
strongly live more often than necessary.

Bug: 31113334

Test: clean-oat-host && test-art-host CC baker

Change-Id: I05586e125d5dfed8d184890468fd398c79f32619
709b070044354d9f47641f273edacaeeb0240ab7 13-Oct-2016 David Sehr <sehr@google.com> Remove mirror:: and ArtMethod deps in utils.{h,cc}

The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.

One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.

Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
9d156d500801accee919b6d51e22d6ddcdcd4a05 07-Oct-2016 Mathieu Chartier <mathieuc@google.com> Move Heap parameters to ObjPtr

Deleted some unused object dumping code.

Test: test-art-host

Bug: 31113334

Change-Id: I747220caafe6679591fd4b361d7f50383a046164
7908c8e778487116a55739791d45a717560b336f 10-Sep-2016 jessicahandojo <jessicahandojo@google.com> String Compression (interpreter only) bug fix

String with length 0 considered to be compressible,
so the length should be -2147483648 or -(1 << 31).

Change-Id: Ie71f17a0e66efe9a65a8a76d4cee776db636550f
bdf7f1c3ab65ccb70f62db5ab31dba060632d458 31-Aug-2016 Andreas Gampe <agampe@google.com> ART: SHARED_REQUIRES to REQUIRES_SHARED

This coincides with the actual attribute name and upstream usage.
Preparation for deferring to libbase.

Test: m
Test: m test-art-host
Change-Id: Ia8986b5dfd926ba772bf00b0a35eaf83596d8518
3aaa37bba53d6df0265793de48b4b0b57327e57a 29-Jul-2016 jessicahandojo <jessicahandojo@google.com> creating workflow for mirror::String compression

All-ASCII String characters are stored in 8-bit blocks
instead of 16-bit. The compression has not taken place, but all
workflow are in the code already (changing kUseStringCompression in
string.h file to TRUE will enable the feature)

Notes: Feature works on interpreter only without optimizing

Test art: m ART_TEST_INTERPRETER=true ART_TEST_OPTIMIZING=false
test-art-host

Also tested with String tests from libcore/:
1. libcore.java.lang.StringTest
2. libcore.java.lang.StringBufferTest
3. libcore.java.lang.StringBuilderTest
4. libcore.java.lang.OldStringTest
5. libcore.java.lang.OldStringBufferTest

Memory improvement is 33% (from 6.03% to 4.03%, total String memory
from all apps per total memory of all apps) measured on Angler
with Hprof tools

Bug: 31040547
Change-Id: I9cc92c265ebf1305fc06b5fc33efd83797660cce
542451cc546779f5c67840e105c51205a1b0a8fd 26-Jul-2016 Andreas Gampe <agampe@google.com> ART: Convert pointer size to enum

Move away from size_t to dedicated enum (class).

Bug: 30373134
Bug: 30419309
Test: m test-art-host
Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
a4fa2e7000a97133f2f0773bc3413e4f0b79318e 22-Jun-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Track libcore change 694e617f54a7bfbdad24913ce96f5d56f1a1960a

Added new method to string class, resized the mirror object.

Bug: 28666126
Change-Id: Ibed4e134c16512bde5183e73e130534f08256888
87f3fcbd0db352157fc59148e94647ef21b73bce 28-Apr-2016 Vladimir Marko <vmarko@google.com> Replace String.charAt() with HIR.

Replace String.charAt() with HArrayLength, HBoundsCheck and
HArrayGet. This allows GVN on the HArrayLength and BCE on
the HBoundsCheck as well as using the infrastructure for
HArrayGet, i.e. better handling of constant indexes than
the old intrinsic and using the HArm64IntermediateAddress.

Bug: 28330359
Change-Id: I32bf1da7eeafe82537a60416abf6ac412baa80dc
c4c1de17b363ad1d89325303e6d95f27c144dc86 12-Apr-2016 Yi Kong <yikong@google.com> Increase vtable size for String class

Tracks libcore change 5458546631c65f6d375b6a1780d36d0abb5b95af which
increases vtable size for String by four.

Bug: 28108421
Change-Id: I3f7b373ffc08a0f5351f04b5045866ea040f8e6e
(cherry picked from commit 478078a8f9375ec53a3c77c19c0cdb82a9917c88)
617209c00dae14fd179ed1926166a691140c1912 13-Apr-2016 Narayan Kamath <narayan@google.com> Track removal of String hash functions.

The number of virtual methods dropped by one. The change to the
field counting merits some explanation, with the change to OpenJDK
we got rid of two 16 bit fields and added a 32 bit field (which the
companion change removed), so things continued to work happily.
This change brings the number of 16 bit fields down to zero.

Also fixes 100-reflect2, which iterates over all methods in j.l.String.

bug: 28082128

(cherry picked from commit 5d8fa8bbcb9411015c92d687cb1f3cb785146bf7)

Change-Id: I4e5454547e08b072768bbc466e2f5c027b8dab86
478078a8f9375ec53a3c77c19c0cdb82a9917c88 12-Apr-2016 Yi Kong <yikong@google.com> Increase vtable size for String class

Tracks libcore change 5458546631c65f6d375b6a1780d36d0abb5b95af which
increases vtable size for String by four.

Bug: 28108421
Change-Id: I3f7b373ffc08a0f5351f04b5045866ea040f8e6e
5d8fa8bbcb9411015c92d687cb1f3cb785146bf7 13-Apr-2016 Narayan Kamath <narayan@google.com> Track removal of String hash functions.

The number of virtual methods dropped by one. The change to the
field counting merits some explanation, with the change to OpenJDK
we got rid of two 16 bit fields and added a 32 bit field (which the
companion change removed), so things continued to work happily.
This change brings the number of 16 bit fields down to zero.

Also fixes 100-reflect2, which iterates over all methods in j.l.String.

bug: 28082128
Change-Id: If402a372c010b673ef54949e13815b4ae9d3fb99
29f33e6bdb6188f55de909f01c23d6bea7fd000e 19-May-2015 Piotr Jastrzebski <haaawk@google.com> A few more string related changes.

- Remove implementation of String::SetOffset (always zero).
- Update the class layout : one less static reference field.

Change-Id: I16e9c560659c6c5c608d14e31880ba27fec1b929
8a89433aafe6dbb88fa1659b4364d733e5af739b 07-May-2015 Piotr Jastrzebski <haaawk@google.com> Update runtime to work with the OpenJdk String.

The key difference here is that the OpenJdk String class
does not maintain an offset or a count field into its backing
char[] array. The offset is assumed to be zero, and the count
is always array.length.

Change-Id: I8b0518642f440cd38d24d9b90c575b7110233cc5
44095a15349445e87942a728a825bd32ea11be1d 27-Apr-2015 Piotr Jastrzebski <haaawk@google.com> String: account for the hash32 field.

Also temporarily disable intrinsics for now.

Change-Id: I8158962efeba6e4ccb39cc147bff782aace3ffbc
c2b35d2501243332bf5423707e871bae532ddc52 27-Aug-2015 Vladimir Marko <vmarko@google.com> ART: Add zero-padding to allocation request for String.

Also make the signed-to-unsigned conversion of utf16_length
in String::Alloc() explicit and make the overflow check take
into account the oveflow in the multiplication by
sizeof(uint16_t), i.e. being passed a negative utf16_length.

Bug: 23528461
Change-Id: Ia5844ea79f8f12e897f52fa27b0984358e3dea0b
4ef5226864717a48717a328167f6fd3e90900072 26-Aug-2015 Vladimir Marko <vmarko@google.com> ART: Include zero-padding in String::SizeOf().

String.equals() intrinsics depend on the zero-padding
but the zygote compaction didn't preserve it.

Bug: 23528461
Change-Id: I57286a31ea2491c7365045d6c69d7ed2e7a5773a
90443477f9a0061581c420775ce3b7eeae7468bc 17-Jul-2015 Mathieu Chartier <mathieuc@google.com> Move to newer clang annotations

Also enable -Wthread-safety-negative.

Changes:
Switch to capabilities and negative capabilities.

Future work:
Use capabilities to implement uninterruptible annotations to work
with AssertNoThreadSuspension.

Bug: 20072211

Change-Id: I42fcbe0300d98a831c89d1eff3ecd5a7e99ebf33
b7c8c1a6cc84173d2d6826ea3a228708730570d1 22-Jun-2015 Jeff Hao <jeffhao@google.com> Make large string use large object space.

Bug: 21209641

(cherry-picked from commit 38fafa18f0fcf610f6314a0fc4165e04e6e5d017)

Change-Id: If6d708307ba1ecdde6bf856d31dceac9ee782fb7
38fafa18f0fcf610f6314a0fc4165e04e6e5d017 22-Jun-2015 Jeff Hao <jeffhao@google.com> Make large string use large object space.

Bug: 21209641
Change-Id: I731a920c02f29f0321f2077093516aaa0f8d782f
c449e8b79aaaf156ce055524c41474cc1200ed5a 11-Jun-2015 Igor Murashkin <iam@google.com> runtime: Minor cleanup and extra comments around interpreter

Change-Id: I24c0b261de8cf737babd9d01bf679482d48c8bc9
3d21bdf8894e780d349c481e5c9e29fe1556051c 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.

Bug: 19264997

(cherry picked from commit e401d146407d61eeb99f8d6176b2ac13c4df1e33)

Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d

Fix some ArtMethod related bugs

Added root visiting for runtime methods, not currently required
since the GcRoots in these methods are null.

Added missing GetInterfaceMethodIfProxy in GetMethodLine, fixes
--trace run-tests 005, 044.

Fixed optimizing compiler bug where we used a normal stack location
instead of double on ARM64, this fixes the debuggable tests.

TODO: Fix JDWP tests.

Bug: 19264997

Change-Id: I7c55f69c61d1b45351fd0dc7185ffe5efad82bd3

ART: Fix casts for 64-bit pointers on 32-bit compiler.

Bug: 19264997
Change-Id: Ief45cdd4bae5a43fc8bfdfa7cf744e2c57529457

Fix JDWP tests after ArtMethod change

Fixes Throwable::GetStackDepth for exception event detection after
internal stack trace representation change.

Adds missing ArtMethod::GetInterfaceMethodIfProxy call in case of
proxy method.

Bug: 19264997
Change-Id: I363e293796848c3ec491c963813f62d868da44d2

Fix accidental IMT and root marking regression

Was always using the conflict trampoline. Also included fix for
regression in GC time caused by extra roots. Most of the regression
was IMT.

Fixed bug in DumpGcPerformanceInfo where we would get SIGABRT due to
detached thread.

EvaluateAndApplyChanges:
From ~2500 -> ~1980
GC time: 8.2s -> 7.2s due to 1s less of MarkConcurrentRoots

Bug: 19264997
Change-Id: I4333e80a8268c2ed1284f87f25b9f113d4f2c7e0

Fix bogus image test assert

Previously we were comparing the size of the non moving space to
size of the image file.

Now we properly compare the size of the image space against the size
of the image file.

Bug: 19264997
Change-Id: I7359f1f73ae3df60c5147245935a24431c04808a

[MIPS64] Fix art_quick_invoke_stub argument offsets.

ArtMethod reference's size got bigger, so we need to move other args
and leave enough space for ArtMethod* and 'this' pointer.

This fixes mips64 boot.

Bug: 19264997
Change-Id: I47198d5f39a4caab30b3b77479d5eedaad5006ab
e401d146407d61eeb99f8d6176b2ac13c4df1e33 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Move mirror::ArtMethod to native

Optimizing + quick tests are passing, devices boot.

TODO: Test and fix bugs in mips64.

Saves 16 bytes per most ArtMethod, 7.5MB reduction in system PSS.
Some of the savings are from removal of virtual methods and direct
methods object arrays.

Bug: 19264997
Change-Id: I622469a0cfa0e7082a2119f3d6a9491eb61e3f3d
41b175aba41c9365a1c53b8a1afbd17129c87c14 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192

(cherry picked from commit 80afd02024d20e60b197d3adfbb43cc303cf29e0)

Change-Id: I905257a21de90b5860ebe1e39563758f721eab82
80afd02024d20e60b197d3adfbb43cc303cf29e0 19-May-2015 Vladimir Marko <vmarko@google.com> ART: Clean up arm64 kNumberOfXRegisters usage.

Avoid undefined behavior for arm64 stemming from 1u << 32 in
loops with upper bound kNumberOfXRegisters.

Create iterators for enumerating bits in an integer either
from high to low or from low to high and use them for
<arch>Context::FillCalleeSaves() on all architectures.

Refactor runtime/utils.{h,cc} by moving all bit-fiddling
functions to runtime/base/bit_utils.{h,cc} (together with
the new bit iterators) and all time-related functions to
runtime/base/time_utils.{h,cc}. Improve test coverage and
fix some corner cases for the bit-fiddling functions.

Bug: 13925192
Change-Id: I704884dab15b41ecf7a1c47d397ab1c3fc7ee0f7
81aa012f4ed23957cc6321ec460bd804004504c6 28-Apr-2015 Mathieu Chartier <mathieuc@google.com> Fix some compaction bugs in string allocation

Change-Id: I2b8499c60de7690e1012d71bccba4ecd589da9af
848f70a3d73833fc1bf3032a9ff6812e429661d9 15-Jan-2014 Jeff Hao <jeffhao@google.com> Replace String CharArray with internal uint16_t array.

Summary of high level changes:
- Adds compiler inliner support to identify string init methods
- Adds compiler support (quick & optimizing) with new invoke code path
that calls method off the thread pointer
- Adds thread entrypoints for all string init methods
- Adds map to verifier to log when receiver of string init has been
copied to other registers. used by compiler and interpreter

Change-Id: I797b992a8feb566f9ad73060011ab6f51eb7ce01
2cebb24bfc3247d3e9be138a3350106737455918 22-Apr-2015 Mathieu Chartier <mathieuc@google.com> Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
a5afcfc73141e5e378d79a326d02c5c2039fb025 29-Jan-2015 Narayan Kamath <narayan@google.com> Be more lenient with 4 byte UTF-8 sequences.

Accept 4 byte sequences and convert them into surrogate
pairs instead of expecting 2 separate 3 byte sequences
each encoding one half of a surrogate pair.

Note that in addition to supporting 4 byte sequences in
strings from JNI, we also tolerate them in dex files. This
is mainly for consistency, and there's no need to claim any
sort of official support.

bug: 18848397
bug: https://code.google.com/p/android/issues/detail?id=81341
Change-Id: Ibc98d29e59d98803e640f2489ea4c56912a59b29
cdfd39f579574a75b98e7ad48c69826b00361b27 30-Aug-2014 Mathieu Chartier <mathieuc@google.com> Change intern table to unordered set.

Intern table active used bytes goes from 430k to 317k on system
server. Similar %wise savings on other apps.

Bug: 16238192

(cherry picked from commit d910fcef539e12ab181e56ec80684f39c4e95733)

Change-Id: Ic70395124435c6f420a77e6d8639404a160f395a
d910fcef539e12ab181e56ec80684f39c4e95733 30-Aug-2014 Mathieu Chartier <mathieuc@google.com> Change intern table to unordered set.

Intern table active used bytes goes from 430k to 317k on system
server. Similar %wise savings on other apps.

Bug: 16238192

Change-Id: I92de72de3eae0b76629e9da83db2c2d0fa613052
37f05ef45e0393de812d51261dc293240c17294d 17-Jul-2014 Fred Shih <ffred@google.com> Reduced memory usage of primitive fields smaller than 4-bytes

Reduced memory used by byte and boolean fields from 4 bytes down to a
single byte and shorts and chars down to two bytes. Fields are now
arranged as Reference followed by decreasing component sizes, with
fields shuffled forward as needed.

Bug: 8135266
Change-Id: I65eaf31ed27e5bd5ba0c7d4606454b720b074752
98d1cc8033251c93786e2fa8c59a2e555a9493be 16-May-2014 Mingyao Yang <mingyao@google.com> Improve performance of invokevirtual/invokeinterface with embedded imt/vtable

Add an embedded version of imt/vtable into class object. Both tables start at
fixed offset within class object so method/entry point can be loaded directly
from class object for invokeinterface/invokevirtual.

Bug: 8142917
Change-Id: I4240d58cfbe9250107c95c0708c036854c455968
b0fa5dc7769c1e054032f39de0a3f6d6dd06f8cf 29-Apr-2014 Ian Rogers <irogers@google.com> Force inlining on trivial accessors.

Make volatility for GetFieldObject a template parameter.
Move some trivial mirror::String routines to a -inl.h.

Bug: 14285442

Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92