Commit graph

30216 commits

Author SHA1 Message Date
Elliott Hughes
1c8a2a99a7 Optimize tolower(3)/toupper(3) from <ctype.h>.
The tables in the BSD tolower/toupper are slower for ASCII than just
doing the bit twiddling.

We can't actually remove the tables on LP32, so move them into the
"cruft" we keep around for backwards compatibility (but remove them for
LP64 where they were never exposed).

I noticed that the new bit-twiddling tolower(3) was performing better
on arm64 than toupper(3). The 0xdf constant was requiring an extra MOV,
and there isn't a BIC that takes an immediate value. Since we've already
done the comparison to check that we're in the right range (where the
bit is always set), though, we can EOR 0x20 to get the same result as
the missing BIC 0x20 in just one instruction.

I've applied that same optimization to towupper(3) too.

Before:

  BM_ctype_tolower_n                 3.30 ns         3.30 ns    212353035
  BM_ctype_tolower_y                 3.31 ns         3.30 ns    211234204
  BM_ctype_toupper_n                 3.30 ns         3.29 ns    214161246
  BM_ctype_toupper_y                 3.29 ns         3.28 ns    207643473

  BM_wctype_towupper_ascii_n         3.53 ns         3.53 ns    195944444
  BM_wctype_towupper_ascii_y         3.48 ns         3.48 ns    199233248

After:

  BM_ctype_tolower_n                 2.93 ns         2.92 ns    242373703
  BM_ctype_tolower_y                 2.88 ns         2.87 ns    245365309
  BM_ctype_toupper_n                 2.93 ns         2.93 ns    243049353
  BM_ctype_toupper_y                 2.89 ns         2.89 ns    245072521

  BM_wctype_towupper_ascii_n         3.34 ns         3.33 ns    212951912
  BM_wctype_towupper_ascii_y         3.29 ns         3.29 ns    214651254

(Why do both the "y" and "n" variants speed up with the EOR
change? Because the compiler transforms the code so that we
unconditionally do the bit twiddling and then use CSEL to decide whether
or not to actually use the result.)

We also save 1028 bytes of data in the LP64 libc.so.

Test: ran the bionic benchmarks and tests
Change-Id: I7829339f8cb89a58efe539c2a01c51807413aa2d
2019-09-27 14:42:39 -07:00
Ryan Prichard
280888571a Merge "Revert "Revert "Add benchmarks that run simple programs"""
am: 41488b79c4

Change-Id: Ie71f6c294ae39d19e94b4c0115471ebf1b20a0b5
2019-09-27 13:21:49 -07:00
Ryan Prichard
41488b79c4 Merge "Revert "Revert "Add benchmarks that run simple programs""" 2019-09-27 19:59:50 +00:00
Peter Collingbourne
16abcaed04 Merge "Disable sanitization of crt objects."
am: 4096cba7f8

Change-Id: I59413472e4c5101e2a2956ddb46ea18f2aeba193
2019-09-27 12:58:09 -07:00
Peter Collingbourne
4096cba7f8 Merge "Disable sanitization of crt objects." 2019-09-27 19:31:13 +00:00
Christopher Ferris
c5d3a4348a Make tls related header files platform accessible.
There are places in frameworks and art code that directly included
private bionic header files. Move these files to the new platform
include files.

This change also moves the __get_tls.h header file to tls.h and includes
the tls defines header so that there is a single header that platform
code can use to get __get_tls and the defines.

Also, simplify the visibility rules for platform includes.

Bug: 141560639

Test: Builds and bionic unit tests pass.
Change-Id: I9e5e9c33fe8a85260f69823468bc9d340ab7a1f9
Merged-In: I9e5e9c33fe8a85260f69823468bc9d340ab7a1f9
(cherry picked from commit 44631c919a)
2019-09-27 12:14:24 -07:00
Elliott Hughes
3355fdc3fc Merge "ASCII fastpath for towupper and towlower."
am: 57a64a7172

Change-Id: Iaee20d1c71f6f87d2f44d185ed85a15783326067
2019-09-27 10:42:43 -07:00
Elliott Hughes
57a64a7172 Merge "ASCII fastpath for towupper and towlower." 2019-09-27 17:14:53 +00:00
Elliott Hughes
c4697aac26 Merge "Add trivial <ctype.h> benchmarks."
am: dc2599d16c

Change-Id: Id698705ed8160a5e3bfabfc6245e4f9f90a8c569
2019-09-27 10:14:46 -07:00
Elliott Hughes
dc2599d16c Merge "Add trivial <ctype.h> benchmarks." 2019-09-27 16:45:26 +00:00
Balaram Makam
0e670e26a2 ASCII fastpath for towupper and towlower.
This change elides unnecessary calls to __find_icu_symbol
for ASCII chars and improves PUBG mobile game loading time by 7% on
hikey620(Cortex-A53):

name                old time/op  new time/op  delta
PUBG_0.13.0_Launch   41.5s ± 2%   37.7s ± 3%  -9.24%  (p=0.008 n=5+5)

Below are the bionic benchmark results on a Pixel 2 XL for 64-bit,
showing a large speedup for ASCII and only a small slowdown for non-ASCII.

Before:

  BM_wctype_towlower_ascii_n         10.5 ns         10.4 ns     61973065
  BM_wctype_towlower_ascii_y         10.2 ns         10.2 ns     70158659
  BM_wctype_towlower_unicode_n       10.3 ns         10.3 ns     67719478
  BM_wctype_towlower_unicode_y       10.6 ns         10.5 ns     67841545
  BM_wctype_towupper_ascii_n         10.8 ns         10.8 ns     63456778
  BM_wctype_towupper_ascii_y         10.9 ns         10.9 ns     65116910
  BM_wctype_towupper_unicode_n       10.7 ns         10.7 ns     67463276
  BM_wctype_towupper_unicode_y       10.4 ns         10.4 ns     66467890

After:

  BM_wctype_towlower_ascii_n         3.35 ns         3.34 ns    205567652
  BM_wctype_towlower_ascii_y         3.30 ns         3.29 ns    214108746
  BM_wctype_towlower_unicode_n       10.9 ns         10.8 ns     65007743
  BM_wctype_towlower_unicode_y       10.6 ns         10.6 ns     63819060
  BM_wctype_towupper_ascii_n         3.53 ns         3.53 ns    195944444
  BM_wctype_towupper_ascii_y         3.48 ns         3.48 ns    199233248
  BM_wctype_towupper_unicode_n       11.1 ns         11.1 ns     62760216
  BM_wctype_towupper_unicode_y       11.0 ns         11.0 ns     61608872

Test: bionic unit tests on device
Test: bionic benchmarks on device
Signed-off-by: Balaram Makam <b.makam@samsung.com>
Change-Id: I77ab7efb66d7bcb35d00467663607535e5c1992f
2019-09-27 16:41:03 +00:00
Elliott Hughes
9ff7d09643 Add trivial <ctype.h> benchmarks.
Just to sanity check that toupper/tolower and towupper/towlower are in
the same ballpark for the ASCII range.

Test: ran benchmarks
Change-Id: I1ddc3f4f4478b4075107831f27bf4d4b4a3bc5e8
2019-09-26 21:47:01 -07:00
Ryan Prichard
2c236bc506 Revert "Revert "Add benchmarks that run simple programs""
This reverts commit 3bf27c86d1.

Disable the 32-bit glibc target. We're not interested in benchmarking that
target, and the bench_noop_nostl executable doesn't build when ASAN is
turned on, because the libclang_rt.asan_cxx-i386.a lib contains
ubsan_type_hash_itanium.cc.o, which needs __dynamic_cast and various
STL typeinfo variables. The equivalent libclang_rt.asan_cxx-x86_64.a
lib doesn't have ubsan_type_hash_itanium.cc.o in it.

Bug: http://b/141693636
Test: m bench_noop_nostl bench_noop bench_noop_static ASAN_OPTIONS=detect_leaks=0 SANITIZE_HOST=address
Change-Id: Id6de17e622682f3a166367ad670cba5bfa6aee47
2019-09-26 16:18:37 -07:00
Elliott Hughes
6d4deb3454 Merge "benchmarks: remove more boilerplate."
am: f5b44a5ea6

Change-Id: I06e55c29deca1b3af5b60b3a746686a5432bb5a1
2019-09-26 14:54:03 -07:00
Elliott Hughes
f5b44a5ea6 Merge "benchmarks: remove more boilerplate." 2019-09-26 21:38:52 +00:00
John Cater
8719712e03 Merge "Fix gensyscalls.py to actually use the input argument provided in bionic/libc/Android.bp."
am: 6595551e28

Change-Id: Id0d953692482ddaa1c83a38024e56b4751b14c0b
2019-09-26 14:13:37 -07:00
John Cater
6595551e28 Merge "Fix gensyscalls.py to actually use the input argument provided in bionic/libc/Android.bp." 2019-09-26 20:55:06 +00:00
Peter Collingbourne
7eb851c7da Disable sanitization of crt objects.
The accompanying soong change causes sanitize attributes to be allowed on
cc_object targets and propagates sanitize attributes into dependencies. This
is problematic for the crt objects in sanitizer builds because everything
depends on them including the sanitizer runtime, so a circular dependency
would otherwise be created. Furthermore, some of the code in these objects
runs before sanitizer initialization so it is unlikely that sanitizing them
would work anyway. Therefore, disable sanitization on these objects.

Change-Id: I25380dfc8eed5db34b034ba127a9d6b5674032fa
2019-09-26 12:16:06 -07:00
John Cater
e86e505b85 Fix gensyscalls.py to actually use the input argument provided in
bionic/libc/Android.bp.

Test: Built and tested bionic.
Change-Id: Ibb25990b2b1b5c18edfdaaab4f1593fa8d95f338
2019-09-26 15:02:04 -04:00
Raman Tenneti
93d9329cbf Merge "Revert "Add benchmarks that run simple programs""
am: 0878ac991a

Change-Id: I7462a2870711af912cdb4733fc6d7e19692691f1
2019-09-26 11:33:35 -07:00
Raman Tenneti
0878ac991a Merge "Revert "Add benchmarks that run simple programs"" 2019-09-26 17:54:33 +00:00
Raman Tenneti
3bf27c86d1 Revert "Add benchmarks that run simple programs"
This reverts commit aa85ac2b08.

Reason for revert: builds are broken - Bug: 141693636

Change-Id: I7502813ae519719c578a05676a0adf9537019bd3
2019-09-26 17:52:48 +00:00
Elliott Hughes
d92250741b Merge "Add trivial towlower/towupper benchmarks."
am: 6ebeaac69d

Change-Id: I369653e0951ba4dc9d6801a5bbea60bf7530b69c
2019-09-26 07:53:31 -07:00
Elliott Hughes
96705e3712 benchmarks: remove more boilerplate.
Many of our benchmarks are basically just "call one function with a
fixed argument". We don't need to keep repeating all the boilerplate for
that.

This also ensures we don't forget the benchmark::DoNotOptimize, which --
in addition to being a good idea in general -- specifically solves the
problem with gettid benchmark and provides a more accurate result by
removing the indirection through a function pointer.

Test: ran benchmarks
Change-Id: Id67535243678cd0d48f51cf25141e2040da9af03
2019-09-26 07:42:23 -07:00
Elliott Hughes
6ebeaac69d Merge "Add trivial towlower/towupper benchmarks." 2019-09-26 14:25:21 +00:00
Elliott Hughes
bab9cfd99a Add trivial towlower/towupper benchmarks.
Currently 11ns for both ascii and unicode in 64-bit, 15ns for 32-bit.

Test: ran benchmarks
Change-Id: Ie810b324c855b52b66a96889a194bc5b5b55653f
2019-09-25 22:13:32 -07:00
Kiyoung Kim
2ba6a1eb4e Merge "Use generated linker config by default"
am: 34c0043fd8

Change-Id: I240b5d9356435705df574fa5f6c7beda31454f97
2019-09-25 21:14:49 -07:00
Kiyoung Kim
34c0043fd8 Merge "Use generated linker config by default" 2019-09-26 00:58:15 +00:00
Ryan Prichard
51fe8ac1d7 Merge "run-on-host fixes"
am: ef0adb1275

Change-Id: Ie4bb92b12050ae868521a30ff9b6bc8e52175235
2019-09-25 13:08:58 -07:00
Ryan Prichard
8cf02d08f0 Merge "Add benchmarks that run simple programs"
am: b10ac9e661

Change-Id: Ib191a5a7ca8341e00a5726a660c9ec8ad0930f7e
2019-09-25 13:08:00 -07:00
Ryan Prichard
ef0adb1275 Merge "run-on-host fixes" 2019-09-25 19:48:35 +00:00
Ryan Prichard
b10ac9e661 Merge "Add benchmarks that run simple programs" 2019-09-25 19:48:21 +00:00
Dongwon Kang
d13749216f Merge "Remove libvorbisdec from greylist."
am: 45d2a09c95

Change-Id: I75a188353e716ce20df73a016281c76ecc554601
2019-09-25 12:00:27 -07:00
Dongwon Kang
45d2a09c95 Merge "Remove libvorbisdec from greylist." 2019-09-25 18:50:11 +00:00
Evgeny Eltsin
ab93b21b66 Merge "Make more pthread functions weak for native bridge"
am: d481848e4d

Change-Id: I7cf572ab1ea38829788d8676e332dae21d4007de
2019-09-25 10:57:52 -07:00
Treehugger Robot
d481848e4d Merge "Make more pthread functions weak for native bridge" 2019-09-25 17:44:22 +00:00
Evgeny Eltsin
8a18af52d9 Make more pthread functions weak for native bridge
These are using __pthread_internal_*.

Test: run bionic-unit-tests on cuttlefish
Change-Id: Idbb2503f03bd9f1f2a20fced34b734f573c1c0ad
2019-09-25 16:55:47 +02:00
Ryan Prichard
aa85ac2b08 Add benchmarks that run simple programs
Specifically, test the wall-clock time for running:
 * a C program that does nothing (i.e. no STL)
 * a C++ program that does nothing
 * a statically-linked C++ program
 * toybox true (in /system/bin and /vendor/bin)
 * mksh -c true (in /system/bin and /vendor/bin)

Test: bionic-spawn-benchmarks
Change-Id: I961850ec90004cac83088feab5783f4f27768be1
2019-09-25 09:35:43 +00:00
Dongwon Kang
b2a1c11c77 Remove libvorbisdec from greylist.
Test: build and boot. Checked libvorbisdec.so is not in /system/lib[64]
Bug: 141257741
Change-Id: Id9d9f691d5e5fa089a9d98a1be49754c8355202f
2019-09-24 18:55:44 -07:00
Ryan Prichard
3cfb89d451 run-on-host fixes
* Fix the path to bionic-benchmarks-glibc

 * Add symlinks for the toybox symlink commands. Each symlink bypasses the
   intermediate symlink in ${OUT}/system/bin and points to the final
   toybox binary. Suppress a bunch of warnings by skipping symlinks for
   non-existent files.

   The new spawn benchmarks try to run /system/bin/true. (They also try to
   run /vendor/bin/true and print an error.)

 * Quote "$@"

 * Use soong_ui.bash --dumpvars-mode to set a bunch of variables, rather
   than get_build_var, which invokes Soong once per variable. This reduces
   the "build/run-on-host.sh" runtime from 4s to 1.3s.

 * build/run-on-host.sh isn't executable and is only useful when it's
   sourced into another shell, so remove its shebang to reduce confusion.

Bug: none
Test: \
  . build/envsetup.sh
  lunch aosp_x86_64-userdebug
  . bionic/build/run-on-host.sh
  prepare MODULES-IN-bionic MODULES-IN-external-toybox
  /system/bin/true

Change-Id: I59e9a6aca77d35b16bdf51759c5fc7e725bfc67c
2019-09-24 15:36:31 -07:00
Christopher Ferris
4bd1f74f8b Merge "Revert "Temporarily disable some clock_getres tests.""
am: f97dcc15e8

Change-Id: I91655acf2bde0b3e3eab1e0d2ee291084efcfe61
2019-09-24 12:45:45 -07:00
Christopher Ferris
f97dcc15e8 Merge "Revert "Temporarily disable some clock_getres tests."" 2019-09-24 19:19:28 +00:00
Christopher Ferris
a9dfe1c352 Revert "Temporarily disable some clock_getres tests."
This reverts commit 8eba2a59ac.

Reason for revert: The kernel update has been reverted.

Change-Id: I21d9ac3c319b8c6e8546a0b40c5646c5610cc8c5
2019-09-24 16:20:17 +00:00
Christopher Ferris
a4f5db67ab Merge "Temporarily disable some clock_getres tests."
am: 849f0db7ca

Change-Id: Ia002ff900640f0ff6fde67829eac77cfa2221fc0
2019-09-24 07:23:57 -07:00
Christopher Ferris
849f0db7ca Merge "Temporarily disable some clock_getres tests." 2019-09-24 14:12:13 +00:00
Christopher Ferris
387e8bf4e3 Merge "Stop executing if skip occurs."
am: 7c852064bb

Change-Id: Ida6b9d6211619203fc8c9a3f79a88d18e033e74a
2019-09-23 21:26:41 -07:00
Christopher Ferris
8eba2a59ac Temporarily disable some clock_getres tests.
A kernel update broke three clock_getres tests, so disable
them while the kernel is fixed.

Bug: 141515847

Test: All tests pass on cuttlefish.
Change-Id: I7db789b2b8ba0bc5f8b13bb06e85711031735925
2019-09-23 18:44:22 -07:00
Christopher Ferris
7c852064bb Merge "Stop executing if skip occurs." 2019-09-24 01:14:15 +00:00
Christopher Ferris
103b998a52 Stop executing if skip occurs.
Bug: 141358530

Test: Forced a skip and verified it registers as a skip.
Change-Id: I9915c67ebae4389a26f28e16375ad4a41f3e4837
2019-09-23 09:41:13 -07:00
Kiyoung Kim
89b9528445 Use generated linker config by default
Use generated linker config by default, but with some back up plan
(sys.linker.use_generated_config property). Linker config generator
still does not support non-treblelized devices and vndk-lite, so these
cases should be handled later.

Bug: 138920271
Test: m -j && atest passed
Test: Tested from cuttlefish
Change-Id: I39e9d089a82f9409eccdcaa4fb26660caf3f5779
2019-09-23 14:25:40 +09:00