History log of /libcore/ojluni/src/main/java/java/lang/String.java
Revision Date Author Comments
6bf866608fbbd6aad37ba0daa288778a6f1fad41 27-May-2016 Neil Fuller <nfuller@google.com> Improve getChars() bounds checking and add a test

The dstEnd calculation could previously overflow and a negative
dstBegin wasn't being caught in one specific case.

Bug: 28998511
Change-Id: I144d92d114bab94f5a207c3e3d5f5b55c97e9838
6238c7b3995953d394629585be4d72a524003ae7 25-Apr-2016 Przemyslaw Szczepaniak <pszczepaniak@google.com> Restore fastpath of Pattern#split

Re-added lost fastpath for Pattern#split
called with single character split regex.

Removed almost identical fastpath from
String#split and made it use the one in
the Pattern class.

Before:
Trial Report (1 of 6):
Experiment {instrument=runtime, benchmarkMethod=timePatternSplitComma, vm=default, parameters={}}
Results:
runtime(ns): min=61332.97, 1st qu.=62783.21, median=63029.70, mean=63793.72, 3rd qu.=64398.73, max=69335.01
Trial Report (2 of 6):
Experiment {instrument=runtime, benchmarkMethod=timePatternSplitLiteralDot, vm=default, parameters={}}
Results:
runtime(ns): min=62285.54, 1st qu.=62801.82, median=63652.11, mean=64028.37, 3rd qu.=64508.20, max=68743.82
Trial Report (3 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitComma, vm=default, parameters={}}
Results:
runtime(ns): min=3145.06, 1st qu.=3224.04, median=3369.42, mean=3405.25, 3rd qu.=3601.02, max=3714.71
Trial Report (4 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitHard, vm=default, parameters={}}
Results:
runtime(ns): min=96497.74, 1st qu.=102259.06, median=105605.01, mean=105157.62, 3rd qu.=108752.15, max=110870.39
Trial Report (5 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitLiteralDot, vm=default, parameters={}}
Results:
runtime(ns): min=3164.36, 1st qu.=3200.15, median=3261.57, mean=3319.27, 3rd qu.=3402.46, max=3727.68
Trial Report (6 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitNewline, vm=default, parameters={}}
Results:
runtime(ns): min=3129.43, 1st qu.=3138.40, median=3161.53, mean=3197.32, 3rd qu.=3253.53, max=3359.39

After:
Trial Report (1 of 6):
Experiment {instrument=runtime, benchmarkMethod=timePatternSplitComma, vm=default, parameters={}}
Results:
runtime(ns): min=3225.99, 1st qu.=3253.19, median=3267.54, mean=3320.92, 3rd qu.=3406.82, max=3436.16
Trial Report (2 of 6):
Experiment {instrument=runtime, benchmarkMethod=timePatternSplitLiteralDot, vm=default, parameters={}}
Results:
runtime(ns): min=3277.96, 1st qu.=3295.68, median=3339.86, mean=3403.39, 3rd qu.=3539.36, max=3677.60
Trial Report (3 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitComma, vm=default, parameters={}}
Results:
runtime(ns): min=3195.46, 1st qu.=3216.71, median=3247.12, mean=3354.20, 3rd qu.=3510.25, max=3686.05
Trial Report (4 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitHard, vm=default, parameters={}}
Results:
runtime(ns): min=99889.34, 1st qu.=100793.37, median=102606.42, mean=103979.16, 3rd qu.=105644.24, max=115821.46
Trial Report (5 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitLiteralDot, vm=default, parameters={}}
Results:
runtime(ns): min=2926.79, 1st qu.=3080.29, median=3156.58, mean=3144.20, 3rd qu.=3228.23, max=3259.98
Trial Report (6 of 6):
Experiment {instrument=runtime, benchmarkMethod=timeStringSplitNewline, vm=default, parameters={}}
Results:
runtime(ns): min=3134.79, 1st qu.=3174.47, median=3221.38, mean=3250.06, 3rd qu.=3315.56, max=3492.58

Bug: 28330359
Change-Id: If302b36579cb6b6e9ce6907540e8481057455820
(cherry picked from commit b14296a6415c216acb84683a9b930f7678a5201d)
e868b9aaf0531791c7a0ad6b70b517fe903b8771 26-Apr-2016 Narayan Kamath <narayan@google.com> String: Avoid char-by-char copy during replace.

This version is roughly twice as fast after the rewrite in change
a8d952d4388d5173dedc3a80381328fd9d7c5f07. Note that the M version
suffered from the same flaw.

BEFORE
------
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.24, 1st qu.=32.36, median=32.65, mean=32.80, 3rd qu.=33.32, max=33.67
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_16}}
runtime(ns): min=49.22, 1st qu.=49.54, median=49.99, mean=50.19, 3rd qu.=50.54, max=52.23
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_64}}
runtime(ns): min=227.23, 1st qu.=229.91, median=231.68, mean=231.58, 3rd qu.=232.79, max=236.38
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_256}}
runtime(ns): min=893.41, 1st qu.=897.96, median=905.14, mean=912.62, 3rd qu.=920.15, max=966.30

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.60, 1st qu.=32.69, median=32.98, mean=33.02, 3rd qu.=33.07, max=34.12
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_16}}
runtime(ns): min=48.43, 1st qu.=48.76, median=49.08, mean=49.31, 3rd qu.=49.87, max=50.72
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_64}}
runtime(ns): min=2517.18, 1st qu.=2541.84, median=2662.98, mean=2709.11, 3rd qu.=2775.76, max=3226.40
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_256}}
runtime(ns): min=10265.82, 1st qu.=11161.48, median=12261.24, mean=12058.61, 3rd qu.=12839.44, max=13236.97

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=EMPTY}}
runtime(ns): min=31.81, 1st qu.=32.31, median=32.56, mean=32.71, 3rd qu.=33.21, max=33.82
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_16}}
runtime(ns): min=894.87, 1st qu.=910.36, median=938.87, mean=981.06, 3rd qu.=1001.98, max=1300.58
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_64}}
runtime(ns): min=2670.28, 1st qu.=2680.25, median=2732.86, mean=2806.53, 3rd qu.=2768.80, max=3514.73
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_256}}
runtime(ns): min=10099.17, 1st qu.=10323.71, median=10500.71, mean=10950.80, 3rd qu.=10913.56, max=14215.69

AFTER
-----
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.16, 1st qu.=32.27, median=32.47, mean=32.46, 3rd qu.=32.65, max=32.80
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_16}}
runtime(ns): min=48.74, 1st qu.=49.04, median=49.18, mean=49.37, 3rd qu.=49.56, max=50.81
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_64}}
runtime(ns): min=228.67, 1st qu.=229.15, median=230.99, mean=231.22, 3rd qu.=232.97, max=234.63
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_256}}
runtime(ns): min=896.83, 1st qu.=898.40, median=904.05, mean=906.79, 3rd qu.=916.44, max=919.98

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.07, 1st qu.=32.11, median=32.44, mean=32.64, 3rd qu.=32.66, max=35.07
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_16}}
runtime(ns): min=48.66, 1st qu.=48.96, median=49.39, mean=49.33, 3rd qu.=49.64, max=50.01
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_64}}
runtime(ns): min=1638.41, 1st qu.=1666.38, median=1678.58, mean=1725.19, 3rd qu.=1819.44, max=1870.15
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_256}}
runtime(ns): min=4519.89, 1st qu.=4836.48, median=5659.44, mean=5495.27, 3rd qu.=6065.99, max=6277.55

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.25, 1st qu.=32.33, median=32.49, mean=32.71, 3rd qu.=32.74, max=34.48
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_16}}
runtime(ns): min=673.04, 1st qu.=712.29, median=798.60, mean=801.31, 3rd qu.=882.12, max=960.31
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_64}}
runtime(ns): min=1113.34, 1st qu.=1426.13, median=1614.06, mean=1633.30, 3rd qu.=1880.92, max=2078.03
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_256}}
runtime(ns): min=3657.71, 1st qu.=4101.37, median=4742.67, mean=4607.25, 3rd qu.=5164.10, max=5259.11

bug: 28060800

(cherry picked from commit f65410c8f0be6102b1612ce5a2e16960f8d07547)

Change-Id: I6d83194cb5597e9161b3aedaada79016411ee015
6670b0a239dd9d184d0ac8a5eb4c90b4da921a25 18-Apr-2016 Narayan Kamath <narayan@google.com> String: Improve performance of String.getBytes.

Add special cases for UTF-8, ISO-8859-1 and US-ASCII.

Benchmarks show a 3x to 30x improvement across the board.

BEFORE :
--------------
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=EMPTY}}
runtime(ns): min=3675.38, 1st qu.=3708.42, median=3765.87, mean=3784.90, 3rd qu.=3889.08, max=3897.30
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_16}}
runtime(ns): min=11766.89, 1st qu.=11804.59, median=12039.35, mean=12016.62, 3rd qu.=12182.33, max=12421.93
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_64}}
runtime(ns): min=17947.28, 1st qu.=18181.18, median=18474.02, mean=18444.80, 3rd qu.=18733.02, max=18904.24
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_256}}
runtime(ns): min=54922.50, 1st qu.=55640.28, median=56511.91, mean=56687.14, 3rd qu.=58096.55, max=58555.82
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_512}}
runtime(ns): min=93966.35, 1st qu.=96132.46, median=96508.71, mean=96668.19, 3rd qu.=97831.84, max=98228.46

Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=EMPTY}}
runtime(ns): min=3804.60, 1st qu.=3832.21, median=3870.29, mean=3955.06, 3rd qu.=3998.85, max=4513.34
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_16}}
runtime(ns): min=12325.98, 1st qu.=12489.95, median=12592.85, mean=12617.96, 3rd qu.=12760.47, max=13013.03
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_64}}
runtime(ns): min=18154.88, 1st qu.=18353.76, median=18518.34, mean=18540.77, 3rd qu.=18748.34, max=18811.98
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_256}}
runtime(ns): min=41027.14, 1st qu.=41446.54, median=41877.28, mean=41905.38, 3rd qu.=42363.32, max=42933.43
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_512}}
runtime(ns): min=91035.64, 1st qu.=92336.02, median=94013.21, mean=93905.50, 3rd qu.=95455.29, max=96344.39

Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=EMPTY}}
runtime(ns): min=3781.58, 1st qu.=3795.26, median=3839.86, mean=3845.25, 3rd qu.=3866.07, max=3969.57
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_16}}
runtime(ns): min=12044.17, 1st qu.=12090.35, median=12179.87, mean=12195.30, 3rd qu.=12298.93, max=12376.89
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_64}}
runtime(ns): min=18972.04, 1st qu.=19136.75, median=19347.64, mean=19409.64, 3rd qu.=19709.62, max=19952.67
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_256}}
runtime(ns): min=47600.52, 1st qu.=48461.23, median=50291.26, mean=50161.80, 3rd qu.=51811.29, max=52993.30
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_512}}
runtime(ns): min=75600.36, 1st qu.=75968.53, median=78173.55, mean=78727.87, 3rd qu.=81136.79, max=84758.54

AFTER :
------------
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=EMPTY}}
runtime(ns): min=1104.34, 1st qu.=1131.09, median=1150.68, mean=1154.42, 3rd qu.=1168.01, max=1243.59
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_16}}
runtime(ns): min=1137.97, 1st qu.=1151.18, median=1177.42, mean=1172.80, 3rd qu.=1195.89, max=1199.96
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_64}}
runtime(ns): min=1522.89, 1st qu.=1544.52, median=1571.69, mean=1612.86, 3rd qu.=1690.00, max=1708.94
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_256}}
runtime(ns): min=2458.72, 1st qu.=2559.36, median=3023.47, mean=2962.93, 3rd qu.=3282.42, max=3426.12
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesAscii, vm=default, parameters={string=L_512}}
runtime(ns): min=3785.74, 1st qu.=3874.94, median=4552.37, mean=4681.23, 3rd qu.=5574.72, max=6245.85

Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=EMPTY}}
runtime(ns): min=1137.79, 1st qu.=1149.34, median=1171.17, mean=1166.55, 3rd qu.=1180.61, max=1194.83
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_16}}
runtime(ns): min=1049.41, 1st qu.=1086.79, median=1134.18, mean=1146.32, 3rd qu.=1172.61, max=1357.04
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_64}}
runtime(ns): min=1193.05, 1st qu.=1451.91, median=1542.92, mean=1527.42, 3rd qu.=1643.31, max=1695.34
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_256}}
runtime(ns): min=2515.17, 1st qu.=2940.09, median=3143.91, mean=3114.54, 3rd qu.=3321.73, max=3444.45
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesIso88591, vm=default, parameters={string=L_512}}
runtime(ns): min=3881.31, 1st qu.=3970.16, median=4328.92, mean=4291.21, 3rd qu.=4582.91, max=4885.02

Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=EMPTY}}
runtime(ns): min=955.51, 1st qu.=972.96, median=979.11, mean=977.32, 3rd qu.=983.49, max=988.33
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_16}}
runtime(ns): min=1229.63, 1st qu.=1242.28, median=1251.33, mean=1254.39, 3rd qu.=1268.16, max=1272.79
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_64}}
runtime(ns): min=1768.46, 1st qu.=1816.73, median=1854.81, mean=1883.12, 3rd qu.=1975.01, max=1996.59
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_256}}
runtime(ns): min=8710.40, 1st qu.=9348.30, median=9750.93, mean=9935.78, 3rd qu.=10569.36, max=11556.14
Experiment {instrument=runtime, benchmarkMethod=timeGetBytesUtf8, vm=default, parameters={string=L_512}}
runtime(ns): min=14126.17, 1st qu.=14228.94, median=15590.25, mean=15130.62, 3rd qu.=15826.37, max=15944.59

bug: 28189091

(cherry picked from commit f9d0b60eab4582ba161b1c73379902422dc73a9f)

Change-Id: Ie494d3351c843d6b0bc92c89159c00bb1052b522
6d562f688e350ade3c025bfb1c4c8cca9b3e2030 13-Apr-2016 Narayan Kamath <narayan@google.com> HashMap: Remove support for alt-hashing.

This approach has been abandoned in OpenJdk8 (in favour of tree-ifying
when the number of collisions for a given key is large). Given that :

(1) Alt-hashing has always been disabled on Android (the threshold
was Integer.MAX_VALUE).
(2) The OpenJdk8 changes are fairly extensive.

We revert to what's essentially the Android M implementation of HashMap;
always using a secondary hash, always ignoring the load factor and starting
with an initial size of 4.

The Hashtable implementation has been left untouched, except for the
removal of effectively dead alt-hashing code.

bug: 28082128

(cherry picked from commit bfada6f78af63fd626be6991c696cb0393289686)

Change-Id: Id0378441104659d341ffaf0b0edf42c592586fae
85287a150a9771d515319316df49ba7a17bd9c65 11-Apr-2016 Narayan Kamath <narayan@google.com> String: reimplement String.replace(char, char).

Allocates one fewer object by using String.setCharAt instead.

Android M
---------
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=EMPTY}}
runtime(ns): min=16.71, 1st qu.=17.35, median=17.59, mean=17.50, 3rd qu.=17.75, max=17.91
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=L_16}}
runtime(ns): min=52.31, 1st qu.=52.53, median=52.80, mean=53.19, 3rd qu.=53.82, max=55.04
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=L_64}}
runtime(ns): min=207.14, 1st qu.=207.76, median=208.74, mean=210.13, 3rd qu.=211.60, max=219.06
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=L_256}}
runtime(ns): min=822.15, 1st qu.=824.74, median=827.54, mean=928.81, 3rd qu.=842.17, max=1720.25

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=EMPTY}}
runtime(ns): min=17.82, 1st qu.=18.14, median=18.44, mean=18.38, 3rd qu.=18.62, max=18.78
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=L_16}}
runtime(ns): min=319.42, 1st qu.=327.69, median=346.29, mean=353.81, 3rd qu.=378.73, max=413.36
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=L_64}}
runtime(ns): min=977.09, 1st qu.=1005.63, median=1049.10, mean=1056.24, 3rd qu.=1111.03, max=1150.09
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=L_256}}
runtime(ns): min=2735.23, 1st qu.=2819.67, median=2973.69, mean=3432.62, 3rd qu.=4289.10, max=4903.52

Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=EMPTY}}
runtime(ns): min=17.32, 1st qu.=17.39, median=17.47, mean=17.54, 3rd qu.=17.76, max=17.79
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=L_16}}
runtime(ns): min=52.80, 1st qu.=53.03, median=53.59, mean=53.48, 3rd qu.=53.88, max=54.30
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=L_64}}
runtime(ns): min=1073.04, 1st qu.=1091.94, median=1136.54, mean=1193.77, 3rd qu.=1301.52, max=1463.46
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=L_256}}
runtime(ns): min=5054.41, 1st qu.=5197.68, median=5369.77, mean=5710.48, 3rd qu.=6237.26, max=6811.14

Android N
---------
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=EMPTY}}
runtime(ns): min=16.49, 1st qu.=16.50, median=16.63, mean=16.77, 3rd qu.=17.03, max=17.31
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=L_16}}
runtime(ns): min=58.85, 1st qu.=58.91, median=59.52, mean=59.46, 3rd qu.=59.67, max=60.63
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=L_64}}
runtime(ns): min=251.52, 1st qu.=252.46, median=253.68, mean=255.18, 3rd qu.=258.32, max=260.16
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharNonExistent, vm=default, parameters={s=L_256}}
runtime(ns): min=1025.60, 1st qu.=1027.28, median=1030.04, mean=1031.43, 3rd qu.=1035.53, max=1041.07

Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=EMPTY}}
runtime(ns): min=17.04, 1st qu.=17.09, median=17.14, mean=17.15, 3rd qu.=17.22, max=17.32
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=L_16}}
runtime(ns): min=58.45, 1st qu.=58.83, median=59.30, mean=59.28, 3rd qu.=59.73, max=59.97
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=L_64}}
runtime(ns): min=1157.16, 1st qu.=1210.96, median=1256.07, mean=1370.44, 3rd qu.=1510.65, max=1861.24
Experiment {instrument=runtime, benchmarkMethod=timeReplaceCharRepeated, vm=default, parameters={s=L_256}}
runtime(ns): min=4679.54, 1st qu.=4743.65, median=4822.16, mean=5298.78, 3rd qu.=5303.08, max=8488.73

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=EMPTY}}
runtime(ns): min=16.50, 1st qu.=16.53, median=16.66, mean=16.76, 3rd qu.=16.92, max=17.35
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=L_16}}
runtime(ns): min=305.28, 1st qu.=327.30, median=345.80, mean=340.93, 3rd qu.=349.71, max=370.18
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=L_64}}
runtime(ns): min=1094.23, 1st qu.=1144.18, median=1169.23, mean=1217.70, 3rd qu.=1239.01, max=1589.17
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleChar, vm=default, parameters={s=L_256}}
runtime(ns): min=3036.83, 1st qu.=4118.11, median=5428.48, mean=4855.60, 3rd qu.=5501.08, max=5512.46

bug: 28060800

(cherry picked from commit 956df7fe3324416647e2f69b376eca819cf016e7)

Change-Id: I036dad4a6f5e83fdbf7a7a430faea3955e2e6558
85f6c14a299a6102a4542b051451482b0e23c5f9 11-Apr-2016 Narayan Kamath <narayan@google.com> String: reimplement replace(CharSequence, CharSequence).

We're not using regexes any longer. Performance is now on par
with Android M.

This change also adds basic unit-tests, which we were lacking so far.

Android M
---------
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=EMPTY}}
runtime(ns): min=33.49, 1st qu.=33.85, median=34.10, mean=34.22, 3rd qu.=34.55, max=35.09
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_16}}
runtime(ns): min=48.58, 1st qu.=48.98, median=49.20, mean=49.51, 3rd qu.=49.83, max=51.75
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_64}}
runtime(ns): min=236.04, 1st qu.=236.82, median=238.75, mean=239.42, 3rd qu.=241.72, max=243.95
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_256}}
runtime(ns): min=921.01, 1st qu.=924.97, median=932.92, mean=934.84, 3rd qu.=940.41, max=964.41

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=EMPTY}}
runtime(ns): min=33.87, 1st qu.=34.10, median=34.26, mean=34.33, 3rd qu.=34.51, max=35.00
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_16}}
runtime(ns): min=695.64, 1st qu.=747.74, median=780.07, mean=792.92, 3rd qu.=860.18, max=860.55
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_64}}
runtime(ns): min=2719.39, 1st qu.=2758.88, median=2778.37, mean=2901.49, 3rd qu.=2858.23, max=3782.71
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_256}}
runtime(ns): min=12814.17, 1st qu.=12831.58, median=12938.24, mean=12973.31, 3rd qu.=13051.15, max=13359.51

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=EMPTY}}
runtime(ns): min=33.50, 1st qu.=33.65, median=34.00, mean=34.20, 3rd qu.=34.74, max=35.20
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_16}}
runtime(ns): min=48.51, 1st qu.=49.01, median=49.37, mean=49.41, 3rd qu.=49.86, max=50.25
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_64}}
runtime(ns): min=2536.89, 1st qu.=2687.66, median=2726.48, mean=2726.00, 3rd qu.=2774.11, max=2898.73
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_256}}
runtime(ns): min=9524.14, 1st qu.=9673.23, median=10163.81, mean=10062.96, 3rd qu.=10375.81, max=10594.24

Android N
---------
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.09, 1st qu.=32.33, median=32.53, mean=32.63, 3rd qu.=33.01, max=33.22
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_16}}
runtime(ns): min=48.92, 1st qu.=49.12, median=50.11, mean=50.52, 3rd qu.=52.44, max=52.98
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_64}}
runtime(ns): min=251.74, 1st qu.=253.67, median=255.06, mean=255.81, 3rd qu.=257.76, max=262.20
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceNonExistent, vm=default, parameters={s=L_256}}
runtime(ns): min=915.08, 1st qu.=923.41, median=926.69, mean=926.91, 3rd qu.=932.22, max=935.61

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=EMPTY}}
runtime(ns): min=32.09, 1st qu.=32.53, median=32.64, mean=32.73, 3rd qu.=33.03, max=33.16
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_16}}
runtime(ns): min=49.25, 1st qu.=51.35, median=51.91, mean=51.78, 3rd qu.=52.60, max=53.11
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_64}}
runtime(ns): min=2422.00, 1st qu.=2457.65, median=2536.93, mean=2534.74, 3rd qu.=2600.31, max=2662.56
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSequenceRepeated, vm=default, parameters={s=L_256}}
runtime(ns): min=9604.40, 1st qu.=9690.33, median=9935.53, mean=10176.73, 3rd qu.=10554.54, max=11774.79

Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=EMPTY}}
runtime(ns): min=31.97, 1st qu.=32.20, median=32.54, mean=32.58, 3rd qu.=32.90, max=33.40
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_16}}
runtime(ns): min=657.99, 1st qu.=673.30, median=707.95, mean=717.83, 3rd qu.=752.64, max=794.76
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_64}}
runtime(ns): min=2553.89, 1st qu.=2583.49, median=2675.01, mean=2698.93, 3rd qu.=2724.23, max=3105.93
Experiment {instrument=runtime, benchmarkMethod=timeReplaceSingleSequence, vm=default, parameters={s=L_256}}
runtime(ns): min=9669.46, 1st qu.=9958.64, median=10113.85, mean=10363.71, 3rd qu.=10331.31, max=12721.61

bug: 28060800

(cherry picked from commit ab3af282533fecfba4649e78d0a9fd8ad83bd7c7)

Change-Id: Ia175d848fd684128ab497f576fb02b3361852aaa
0513f9df1e34c10f9e1527d6d99123e726d9de17 12-Jan-2016 Narayan Kamath <narayan@google.com> String : Fix integer overflow in getChars.

bug: 26444984
Change-Id: I3f03d839591aebdd3c51aa805bbd891833e97861
2c87ad3a45cecf9e344487cad1abfdebe79f2c7c 21-Dec-2015 Narayan Kamath <narayan@google.com> Update file headers.

Change-Id: I8149f41585768a1a4b72ab7bb4a1452376c05cc2
e3577e1f385f28f48782b6bda72c99bfcb87dd93 10-Dec-2015 Narayan Kamath <narayan@google.com> Fix String.codePointAt.

Was passing the wrong indices to Character.codePointAt.

bug: 26126818
Change-Id: Id9edb51067c847bb8637bf614b21727b4a58f58a
dc56766500bc9c08f8852cbf735f991a8a8bdabf 02-Dec-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> String#split trailing separators fix

Fast path for String#split was removing trailing empty entries if limit argument was <= 0. This should only happen if the
limit is equal to 0.

Bug: 25925128
Bug: 25943996
Change-Id: I2db96b1af5ae822974edaa6a688ad12a03a9cbc3
7e9207a271a8ac4fe8a8f397a2a022798b85ebca 17-Nov-2015 Narayan Kamath <narayan@google.com> Improve String exception details.

Always include the offsets and the requested range. Fixes
201-built-in-exception-detail-messages.

Change-Id: I2a3aa7feaee3f7950272115ecd80f492a98cf5d3
8ea3f1631043cc9381b5f07220b199feeec6a02f 17-Nov-2015 Narayan Kamath <narayan@google.com> Revert "Fix build, String is different in mnc/lmp-mr1"

This reverts commit da0b7230820320936babd192b24ad85d6ce146bd.
11166afdbe991ab305ef579fb11fc41db7776e37 06-Nov-2015 Narayan Kamath <narayan@google.com> Undo merge of mr1 change.

Change-Id: I0849634fd199761d10a97e9f76288e0da2cd1efa
b282683ebf0df1a787821ceac86030383c6e18dd 03-Nov-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix build, String is different in mnc/lmp-mr1

Change-Id: Ib795dc30aca793249b4136511d8002500cd3918b
cc7b3c3cdd4d442d82c113186fecf79f81944b15 27-Oct-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> String#split fast path optimization

Instead of allocating ArrayList
and growing/shrinking it, lets count all the
separators and allocate the array of the required
size.

Change-Id: Ia70ef54efd1580903f5752e3d488b3643e5c89b7
cdd31b26176b48a321df5ea9d5e4364e7209dae9 08-Oct-2015 Narayan Kamath <narayan@google.com> String: fix bounds checks on getChars

getCharsNoChecks really does mean *no checks*. We must check that
the output array has the right size.

Change-Id: I6a0521b5da42f344927833d7b17c2b477ba05def
b90c36f25b990336a456daad69ea9db9256b86ce 28-Sep-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Track changes to the runtime representation of j.l.String.

Change-Id: I3aecd952128097258743a88f4f664024c9183ea0
da0b7230820320936babd192b24ad85d6ce146bd 03-Nov-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Fix build, String is different in mnc/lmp-mr1

Change-Id: Ib795dc30aca793249b4136511d8002500cd3918b
9c1600b3f22e33c704a9b0487806a0d990d78a88 27-Oct-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> String#split fast path optimization

Instead of allocating ArrayList
and growing/shrinking it, lets count all the
separators and allocate the array of the required
size.

Change-Id: Ia70ef54efd1580903f5752e3d488b3643e5c89b7
(cherry picked from commit f2cc57313df2fd0f84cb0550bccd3396a3029b7f)
0a15327f9568f6a8d6b296a0d5fdc0676052898b 09-Jul-2015 Przemyslaw Szczepaniak <pszczepaniak@google.com> Use CaseMapper for String.toUpper/LowerCase

Fixes libcore.java.lang.StringTest#testCaseMapping_el test.

+ bugfix for StringToReal removal.

Change-Id: I204c9bf056086ddacc70d01c89005781e208e80e
46e3649f898305d185fc40bae2542e933a16b619 06-May-2015 Piotr Jastrzebski <haaawk@google.com> Use OpenJdk implementation of java.lang.* [part 1]

- Changes to String hashing.
- Change StringCoding.isTrusted.
- For boxed primitive types, change how TYPE is derived (use the
array equivalents component type).
- System: the security manager is now always null. Also, port over
changes to make system properties read only.
- StrictMath : Use our existing fdlibm and remove references to
jdflibm.h.

Change-Id: I221692836b9320cade9074b122fbc25c8e72cf99
51b1b6997fd3f980076b8081f7f1165ccc2a4008 16-Feb-2015 Piotr Jastrzebski <haaawk@google.com> Initial import of OpenJdk files.

Create new libcore/ojluni directory with src/main/java and
src/main/native subdirectiories.

Build ojluni into core-oj jar.

Use openjdk classes from java.awt.font package.

Copy all files from jdk/src/share/classes and jdk/src/solaris/classes
directories in openjdk into libcore/ojluni/src/main/java.

Copy following native files from openjdk to
libcore/ojluni/src/main/native:
jdk/src/solaris/native/java/io/canonicalize_md.c
build/linux-amd64/include/classfile_constants.h
jdk/src/share/native/java/net/DatagramPacket.c
jdk/src/solaris/native/sun/net/spi/DefaultProxySelector.c
jdk/src/share/native/java/lang/Double.c
jdk/src/share/native/java/lang/fdlibm/include/fdlibm.h
jdk/src/solaris/native/sun/nio/ch/FileChannelImpl.c
jdk/src/solaris/native/java/io/FileDescriptor_md.c
jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c
jdk/src/share/native/java/io/FileInputStream.c
jdk/src/solaris/native/sun/nio/ch/FileKey.c
jdk/src/solaris/native/java/io/FileOutputStream_md.c
jdk/src/solaris/native/java/io/FileSystem_md.c
jdk/src/share/native/java/lang/Float.c
jdk/src/share/native/java/net/Inet4Address.c
jdk/src/solaris/native/java/net/Inet4AddressImpl.c
jdk/src/share/native/java/net/Inet6Address.c
jdk/src/solaris/native/java/net/Inet6AddressImpl.c
jdk/src/share/native/java/net/InetAddress.c
jdk/src/solaris/native/java/net/InetAddressImplFactory.c
jdk/src/share/native/java/io/io_util.c
jdk/src/solaris/native/sun/nio/ch/IOUtil.c
jdk/src/share/native/java/io/io_util.h
jdk/src/solaris/native/java/io/io_util_md.c
jdk/src/solaris/native/java/io/io_util_md.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/java_io_FileDescriptor.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileInputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileOutputStream.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_FileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_ObjectStreamClass.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_io_UnixFileSystem.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Double.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Float.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Integer.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Long.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Runtime.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Shutdown.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_StrictMath.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_String.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_System.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Thread.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/java_lang_Throwable.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_DatagramPacket.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet4AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6Address.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_Inet6AddressImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddress.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_InetAddressImplFactory.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_NetworkInterface.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainDatagramSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_PlainSocketImpl.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketInputStream.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOptions.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/java_net_SocketOutputStream.h
jdk/src/share/native/java/lang/java_props.h
jdk/src/solaris/native/java/lang/java_props_md.c
jdk/src/share/native/java/util/zip/Adler32.c as java_util_zip_Adler32.c
jdk/src/share/native/java/util/zip/CRC32.c as java_util_zip_CRC32.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_CRC32.h
jdk/src/share/native/java/util/zip/Deflater.c as java_util_zip_Deflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Deflater.h
jdk/src/share/native/java/util/zip/Inflater.c as java_util_zip_Inflater.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_Inflater.h
jdk/src/share/native/java/util/zip/ZipFile.c as java_util_zip_ZipFile.c
build/linux-amd64/tmp/sun/java.util.zip/zip/CClassHeaders/java_util_zip_ZipFile.h
jdk/src/share/native/java/lang/fdlibm/include/jfdlibm.h
jdk/src/share/native/common/jlong.h
jdk/src/solaris/native/common/jlong_md.h
jdk/src/share/native/common/jni_util.c
jdk/src/share/native/common/jni_util.h
jdk/src/solaris/native/common/jni_util_md.c
jdk/src/share/javavm/export/jvm.h
jdk/src/solaris/javavm/export/jvm_md.h
jdk/src/solaris/native/java/net/linux_close.c
jdk/src/share/native/sun/misc/NativeSignalHandler.c
jdk/src/solaris/native/sun/nio/ch/NativeThread.c
jdk/src/share/native/java/net/net_util.c
jdk/src/share/native/java/net/net_util.h
jdk/src/solaris/native/java/net/net_util_md.c
jdk/src/solaris/native/java/net/net_util_md.h
jdk/src/solaris/native/java/net/NetworkInterface.c
jdk/src/share/native/sun/nio/ch/nio.h
jdk/src/solaris/native/sun/nio/ch/nio_util.h
jdk/src/share/native/java/io/ObjectStreamClass.c
jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c
jdk/src/solaris/native/java/net/PlainSocketImpl.c
jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c
jdk/src/share/native/java/lang/Runtime.c
jdk/src/share/native/java/lang/Shutdown.c
jdk/src/share/native/sun/misc/Signal.c
jdk/src/solaris/native/java/net/SocketInputStream.c
jdk/src/solaris/native/java/net/SocketOutputStream.c
jdk/src/share/native/java/lang/StrictMath.c
jdk/src/share/native/java/lang/String.c
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_NativeSignalHandler.h
build/linux-amd64/tmp/java/java.lang/java/CClassHeaders/sun_misc_Signal.h
build/linux-amd64/tmp/sun/java.net/net/CClassHeaders/sun_net_spi_DefaultProxySelector.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileChannelImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileDispatcherImpl.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_FileKey.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOStatus.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_IOUtil.h
build/linux-amd64/tmp/java/java.nio/nio/CClassHeaders/sun_nio_ch_NativeThread.h
jdk/src/share/native/java/lang/System.c
jdk/src/share/native/java/lang/Thread.c
jdk/src/share/native/java/lang/Throwable.c
jdk/src/solaris/native/java/io/UnixFileSystem_md.c
jdk/src/solaris/native/java/lang/UNIXProcess_md.c
jdk/src/share/native/java/util/zip/zip_util.c
jdk/src/share/native/java/util/zip/zip_util.h

Change-Id: Ib237df4e1b7b5b4d9f12e74d189e6ec9eed3c31d