Commit graph

29873 commits

Author SHA1 Message Date
Jooyung Han
e30a7f5d1f Change linker config variable: VNDK_VER
With VNDK APEX, the path for VNDK libs has been changed
from /system/lib/vndk-VER to /apex/com.android.vndk.vVER/lib

Previously, VNDK_VER is replaced with prefix(e.g. "-29"). We could
still prepend prefix("v") to the vndk version, but this change uses a
raw vndk version as the value of VNKD_VER.

Bug: 141451661
Test: m && boot (tested with cuttlefish)
Change-Id: Ibf4cf5e29b7f28e733d4b3bc15171f4359e1d2f2
2019-10-11 10:09:16 +09:00
Christopher Ferris
87a10ac108 Merge "Add support for scudo." 2019-10-10 16:56:21 +00:00
Christopher Ferris
85169658e1 Add support for scudo.
As the first pass, the malloc_info for scudo doesn't return anything.
This feature is hardly ever used, so this seems fine for the first
revision.

Bug: 137795072

Test: Ran unit tests on a taimen using scudo and a taimen using jemalloc.
Change-Id: I675386ae17ba5505c27bd9da12c60242d795464a
2019-10-09 18:54:53 -07:00
Elliott Hughes
48da33389b Merge "Remove unused -D from libm build." 2019-10-09 15:09:59 +00:00
Elliott Hughes
e9ff762789 Merge "Reimplement the <ctype.h> is* functions." 2019-10-09 15:09:45 +00:00
Elliott Hughes
ee15585029 Merge "Restore __ANDROID_NDK__." 2019-10-09 15:09:35 +00:00
Elliott Hughes
2584b88469 Remove unused -D from libm build.
Test: treehugger
Change-Id: I3dd9625790f56b49fabd3fa7b58aab23bffa9dba
2019-10-08 17:53:58 -07:00
Elliott Hughes
9823c926b2 Restore __ANDROID_NDK__.
At heart a revert of "Don't #define __ANDROID_NDK__ for the platform build!",
which was commit eb61430374.

The original change was insufficiently motivated, and meant that the
NDK -- not just the platform -- no longer defines __ANDROID_NDK__. Which
then broke at least building toybox with NDK r19.

Change-Id: Ic616688e4d17d25714a9ef381269d7431deac9b0
2019-10-08 12:36:22 -07:00
Elliott Hughes
a4959aa6f8 Reimplement the <ctype.h> is* functions.
Following on from the towlower()/towupper() changes, add benchmarks for
most of <ctype.h>, rewrite the tests to cover the entire defined range
for all of these functions, and then reimplement most of the functions.

The old table-based implementation is mostly a bad idea on modern
hardware, with only ispunct() showing a significant benefit compared to
any other way I could think of writing it, and isalnum() a marginal but
still convincingly genuine benefit.

My new benchmarks make an effort to test an example from each relevant
range of characters to avoid, say, accidentally optimizing the behavior
of `isalnum('0')` at the expense of `isalnum('z')`.

Interestingly, clang is able to generate what I believe to be the
optimal implementations from the most readable code, which is
impressive. It certainly matched or beat all my attempts to be clever!

The BSD table-based implementations made a special case of EOF despite
having a `_ctype_` table that's offset by 1 to include EOF at index 0.
I'm not sure why they didn't take advantage of that, but removing the
explicit check for EOF measurably improves the generated code on arm and
arm64, so even the two functions that still use the table benefit from
this rewrite.

Here are the benchmark results:

arm64 before:
  BM_ctype_isalnum_n                 3.73 ns         3.73 ns    183727137
  BM_ctype_isalnum_y1                3.82 ns         3.81 ns    186383058
  BM_ctype_isalnum_y2                3.73 ns         3.72 ns    187809830
  BM_ctype_isalnum_y3                3.78 ns         3.77 ns    181383055
  BM_ctype_isalpha_n                 3.75 ns         3.75 ns    189453927
  BM_ctype_isalpha_y1                3.76 ns         3.75 ns    184854043
  BM_ctype_isalpha_y2                4.32 ns         3.78 ns    186326931
  BM_ctype_isascii_n                 2.49 ns         2.48 ns    275583822
  BM_ctype_isascii_y                 2.51 ns         2.51 ns    282123915
  BM_ctype_isblank_n                 3.11 ns         3.10 ns    220472044
  BM_ctype_isblank_y1                3.20 ns         3.19 ns    226088868
  BM_ctype_isblank_y2                3.11 ns         3.11 ns    220809122
  BM_ctype_iscntrl_n                 3.79 ns         3.78 ns    188719938
  BM_ctype_iscntrl_y1                3.72 ns         3.71 ns    186209237
  BM_ctype_iscntrl_y2                3.80 ns         3.80 ns    184315749
  BM_ctype_isdigit_n                 3.76 ns         3.74 ns    188334682
  BM_ctype_isdigit_y                 3.78 ns         3.77 ns    186249335
  BM_ctype_isgraph_n                 3.99 ns         3.98 ns    177814143
  BM_ctype_isgraph_y1                3.98 ns         3.95 ns    175140090
  BM_ctype_isgraph_y2                4.01 ns         4.00 ns    178320453
  BM_ctype_isgraph_y3                3.96 ns         3.95 ns    175412814
  BM_ctype_isgraph_y4                4.01 ns         4.00 ns    175711174
  BM_ctype_islower_n                 3.75 ns         3.74 ns    188604818
  BM_ctype_islower_y                 3.79 ns         3.78 ns    154738238
  BM_ctype_isprint_n                 3.96 ns         3.95 ns    177607734
  BM_ctype_isprint_y1                3.94 ns         3.93 ns    174877244
  BM_ctype_isprint_y2                4.02 ns         4.01 ns    178206135
  BM_ctype_isprint_y3                3.94 ns         3.93 ns    175959069
  BM_ctype_isprint_y4                4.03 ns         4.02 ns    176158314
  BM_ctype_isprint_y5                3.95 ns         3.94 ns    178745462
  BM_ctype_ispunct_n                 3.78 ns         3.77 ns    184727184
  BM_ctype_ispunct_y                 3.76 ns         3.75 ns    187947503
  BM_ctype_isspace_n                 3.74 ns         3.74 ns    185300285
  BM_ctype_isspace_y1                3.77 ns         3.76 ns    187202066
  BM_ctype_isspace_y2                3.73 ns         3.73 ns    184105959
  BM_ctype_isupper_n                 3.81 ns         3.80 ns    185038761
  BM_ctype_isupper_y                 3.71 ns         3.71 ns    185885793
  BM_ctype_isxdigit_n                3.79 ns         3.79 ns    184965673
  BM_ctype_isxdigit_y1               3.76 ns         3.75 ns    188251672
  BM_ctype_isxdigit_y2               3.79 ns         3.78 ns    184187481
  BM_ctype_isxdigit_y3               3.77 ns         3.76 ns    187635540

arm64 after:
  BM_ctype_isalnum_n                 3.37 ns         3.37 ns    205613810
  BM_ctype_isalnum_y1                3.40 ns         3.39 ns    204806361
  BM_ctype_isalnum_y2                3.43 ns         3.43 ns    205066077
  BM_ctype_isalnum_y3                3.50 ns         3.50 ns    200057128
  BM_ctype_isalpha_n                 2.97 ns         2.97 ns    236084076
  BM_ctype_isalpha_y1                2.97 ns         2.97 ns    236083626
  BM_ctype_isalpha_y2                2.97 ns         2.97 ns    236084246
  BM_ctype_isascii_n                 2.55 ns         2.55 ns    272879994
  BM_ctype_isascii_y                 2.46 ns         2.45 ns    286522323
  BM_ctype_isblank_n                 3.18 ns         3.18 ns    220431175
  BM_ctype_isblank_y1                3.18 ns         3.18 ns    220345602
  BM_ctype_isblank_y2                3.18 ns         3.18 ns    220308509
  BM_ctype_iscntrl_n                 3.10 ns         3.10 ns    220344270
  BM_ctype_iscntrl_y1                3.10 ns         3.07 ns    228973615
  BM_ctype_iscntrl_y2                3.07 ns         3.07 ns    229192626
  BM_ctype_isdigit_n                 3.07 ns         3.07 ns    228925676
  BM_ctype_isdigit_y                 3.07 ns         3.07 ns    229182934
  BM_ctype_isgraph_n                 2.66 ns         2.66 ns    264268737
  BM_ctype_isgraph_y1                2.66 ns         2.66 ns    264445277
  BM_ctype_isgraph_y2                2.66 ns         2.66 ns    264327427
  BM_ctype_isgraph_y3                2.66 ns         2.66 ns    264427480
  BM_ctype_isgraph_y4                2.66 ns         2.66 ns    264155250
  BM_ctype_islower_n                 2.66 ns         2.66 ns    264421600
  BM_ctype_islower_y                 2.66 ns         2.66 ns    264341148
  BM_ctype_isprint_n                 2.66 ns         2.66 ns    264415198
  BM_ctype_isprint_y1                2.66 ns         2.66 ns    264268793
  BM_ctype_isprint_y2                2.66 ns         2.66 ns    264419205
  BM_ctype_isprint_y3                2.66 ns         2.66 ns    264205886
  BM_ctype_isprint_y4                2.66 ns         2.66 ns    264440797
  BM_ctype_isprint_y5                2.72 ns         2.72 ns    264333293
  BM_ctype_ispunct_n                 3.52 ns         3.51 ns    198956572
  BM_ctype_ispunct_y                 3.38 ns         3.38 ns    201661792
  BM_ctype_isspace_n                 3.39 ns         3.39 ns    206896620
  BM_ctype_isspace_y1                3.39 ns         3.39 ns    206569020
  BM_ctype_isspace_y2                3.39 ns         3.39 ns    206564415
  BM_ctype_isupper_n                 2.76 ns         2.75 ns    254227134
  BM_ctype_isupper_y                 2.76 ns         2.75 ns    254235314
  BM_ctype_isxdigit_n                3.60 ns         3.60 ns    194418653
  BM_ctype_isxdigit_y1               2.97 ns         2.97 ns    236082424
  BM_ctype_isxdigit_y2               3.48 ns         3.48 ns    200390011
  BM_ctype_isxdigit_y3               3.48 ns         3.48 ns    202255815

arm32 before:
  BM_ctype_isalnum_n                 4.77 ns         4.76 ns    129230464
  BM_ctype_isalnum_y1                4.88 ns         4.87 ns    147939321
  BM_ctype_isalnum_y2                4.74 ns         4.73 ns    145508054
  BM_ctype_isalnum_y3                4.81 ns         4.80 ns    144968914
  BM_ctype_isalpha_n                 4.80 ns         4.79 ns    148262579
  BM_ctype_isalpha_y1                4.74 ns         4.73 ns    145061326
  BM_ctype_isalpha_y2                4.83 ns         4.82 ns    147642546
  BM_ctype_isascii_n                 3.74 ns         3.72 ns    186711139
  BM_ctype_isascii_y                 3.79 ns         3.78 ns    183654780
  BM_ctype_isblank_n                 4.20 ns         4.19 ns    169733252
  BM_ctype_isblank_y1                4.19 ns         4.18 ns    165713363
  BM_ctype_isblank_y2                4.22 ns         4.21 ns    168776265
  BM_ctype_iscntrl_n                 4.75 ns         4.74 ns    145417484
  BM_ctype_iscntrl_y1                4.82 ns         4.81 ns    146283250
  BM_ctype_iscntrl_y2                4.79 ns         4.78 ns    148662453
  BM_ctype_isdigit_n                 4.77 ns         4.76 ns    145789210
  BM_ctype_isdigit_y                 4.84 ns         4.84 ns    146909458
  BM_ctype_isgraph_n                 4.72 ns         4.71 ns    145874663
  BM_ctype_isgraph_y1                4.86 ns         4.85 ns    142037606
  BM_ctype_isgraph_y2                4.79 ns         4.78 ns    145109612
  BM_ctype_isgraph_y3                4.75 ns         4.75 ns    144829039
  BM_ctype_isgraph_y4                4.86 ns         4.85 ns    146769899
  BM_ctype_islower_n                 4.76 ns         4.75 ns    147537637
  BM_ctype_islower_y                 4.79 ns         4.78 ns    145648017
  BM_ctype_isprint_n                 4.82 ns         4.81 ns    147154780
  BM_ctype_isprint_y1                4.76 ns         4.76 ns    145117604
  BM_ctype_isprint_y2                4.87 ns         4.86 ns    145801406
  BM_ctype_isprint_y3                4.79 ns         4.78 ns    148043446
  BM_ctype_isprint_y4                4.77 ns         4.76 ns    145157619
  BM_ctype_isprint_y5                4.91 ns         4.90 ns    147810800
  BM_ctype_ispunct_n                 4.74 ns         4.73 ns    145588611
  BM_ctype_ispunct_y                 4.82 ns         4.81 ns    144065436
  BM_ctype_isspace_n                 4.78 ns         4.77 ns    147153712
  BM_ctype_isspace_y1                4.73 ns         4.72 ns    145252863
  BM_ctype_isspace_y2                4.84 ns         4.83 ns    148615797
  BM_ctype_isupper_n                 4.75 ns         4.74 ns    148276631
  BM_ctype_isupper_y                 4.80 ns         4.79 ns    145529893
  BM_ctype_isxdigit_n                4.78 ns         4.77 ns    147271646
  BM_ctype_isxdigit_y1               4.74 ns         4.74 ns    145142209
  BM_ctype_isxdigit_y2               4.83 ns         4.82 ns    146398497
  BM_ctype_isxdigit_y3               4.78 ns         4.77 ns    147617686

arm32 after:
  BM_ctype_isalnum_n                 4.35 ns         4.35 ns    161086146
  BM_ctype_isalnum_y1                4.36 ns         4.35 ns    160961111
  BM_ctype_isalnum_y2                4.36 ns         4.36 ns    160733210
  BM_ctype_isalnum_y3                4.35 ns         4.35 ns    160897524
  BM_ctype_isalpha_n                 3.67 ns         3.67 ns    189377208
  BM_ctype_isalpha_y1                3.68 ns         3.67 ns    189438146
  BM_ctype_isalpha_y2                3.75 ns         3.69 ns    190971186
  BM_ctype_isascii_n                 3.69 ns         3.68 ns    191029191
  BM_ctype_isascii_y                 3.68 ns         3.68 ns    191011817
  BM_ctype_isblank_n                 4.09 ns         4.09 ns    171887541
  BM_ctype_isblank_y1                4.09 ns         4.09 ns    171829345
  BM_ctype_isblank_y2                4.08 ns         4.07 ns    170585590
  BM_ctype_iscntrl_n                 4.08 ns         4.07 ns    170614383
  BM_ctype_iscntrl_y1                4.13 ns         4.11 ns    171495899
  BM_ctype_iscntrl_y2                4.19 ns         4.18 ns    165255578
  BM_ctype_isdigit_n                 4.25 ns         4.24 ns    165237008
  BM_ctype_isdigit_y                 4.24 ns         4.24 ns    165256149
  BM_ctype_isgraph_n                 3.82 ns         3.81 ns    183610114
  BM_ctype_isgraph_y1                3.82 ns         3.81 ns    183614131
  BM_ctype_isgraph_y2                3.82 ns         3.81 ns    183616840
  BM_ctype_isgraph_y3                3.79 ns         3.79 ns    183620182
  BM_ctype_isgraph_y4                3.82 ns         3.81 ns    185740009
  BM_ctype_islower_n                 3.75 ns         3.74 ns    183619502
  BM_ctype_islower_y                 3.68 ns         3.68 ns    190999901
  BM_ctype_isprint_n                 3.69 ns         3.68 ns    190899544
  BM_ctype_isprint_y1                3.68 ns         3.67 ns    190192384
  BM_ctype_isprint_y2                3.67 ns         3.67 ns    189351466
  BM_ctype_isprint_y3                3.67 ns         3.67 ns    189430348
  BM_ctype_isprint_y4                3.68 ns         3.68 ns    189430161
  BM_ctype_isprint_y5                3.69 ns         3.68 ns    190962419
  BM_ctype_ispunct_n                 4.14 ns         4.14 ns    171034861
  BM_ctype_ispunct_y                 4.19 ns         4.19 ns    168308152
  BM_ctype_isspace_n                 4.50 ns         4.50 ns    156250887
  BM_ctype_isspace_y1                4.48 ns         4.48 ns    155124476
  BM_ctype_isspace_y2                4.50 ns         4.50 ns    155077504
  BM_ctype_isupper_n                 3.68 ns         3.68 ns    191020583
  BM_ctype_isupper_y                 3.68 ns         3.68 ns    191015669
  BM_ctype_isxdigit_n                4.50 ns         4.50 ns    156276745
  BM_ctype_isxdigit_y1               3.28 ns         3.27 ns    214729725
  BM_ctype_isxdigit_y2               4.48 ns         4.48 ns    155265129
  BM_ctype_isxdigit_y3               4.48 ns         4.48 ns    155216846

I've also corrected a small mistake in the documentation for isxdigit().

Test: tests and benchmarks
Change-Id: I4a77859f826c3fc8f0e327e847886882f29ec4a3
2019-10-08 12:04:09 -07:00
George Burgess IV
57f01b91d7 Merge changes I13f94cdc,I2107ae65,I7dc10b56,I2037548c
* changes:
  libc: remove now-unused FORTIFY functions
  fortify: remove last uses of __bos_trivially_not*
  fortify(string): emit diagnostics regardless of API level
  fortify(fcntl): emit diagnostics regardless of API level
2019-10-08 17:12:58 +00:00
Treehugger Robot
aad91dcd1d Merge "Restrict the availability of the bionic libs" 2019-10-08 05:33:29 +00:00
George Burgess IV
23e6f0a900 libc: remove now-unused FORTIFY functions
As of I2037548cc2061e46c379931588194c21dfe234b4, these are no longer
used. Since they're new in R, we can remove them instead of keeping
backwards compat 'forever'. Take that opportunity now.

Bug: 141267932
Test: TreeHugger
Change-Id: I13f94cdcff6e75ad19b964be76445f113f79559b
2019-10-07 19:09:38 -07:00
Evgenii Stepanov
29ec2881a0 Merge "Block signals in pthread_create." 2019-10-08 00:34:49 +00:00
George Burgess IV
3aedee9828 fortify: remove last uses of __bos_trivially_not*
Since we're using the gt/ge ones a lot now, having `not` versions
probably just adds to confusion. Swap out their remaining uses and
delete them.

Bug: 141267932
Test: m checkbuild on internal-master
Change-Id: I2107ae65007a4995e4fa23371fefe4db7547f43b
2019-10-07 16:18:44 -07:00
George Burgess IV
fd1ff4b2c8 fortify(string): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I7dc10b56b667f8f2f2cd360b008d834af92a72e4
2019-10-07 16:18:44 -07:00
George Burgess IV
9349b9e51b fortify(fcntl): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I2037548cc2061e46c379931588194c21dfe234b4
2019-10-07 16:18:41 -07:00
Evgenii Stepanov
b92d1c3a26 Block signals in pthread_create.
HWASan-instrumented code needs TLS_SLOT_SANITIZER set up to run, and
that is not done until the new thread calls __hwasan_thread_enter. Block
all signals until that time to prevent hwasan-instrumented signal
handlers running (and crashing) on the new thread.

Bug: 141893397
Test: seq 0 10000000 | xargs -n 1 -P 200 adb shell am instrument \
      -w -r -e command grant-all \
      com.android.permissionutils/.PermissionInstrumentation

(cherry picked from commit d181585dd5)

Change-Id: Id65fae836edcacdf057327ccf16cf0b5e0f9474a
2019-10-07 15:37:26 -07:00
Jiyong Park
e87e0dcbae Restrict the availability of the bionic libs
The bionic libs are now restricted to be in the runtime APEX and the
platform (for bootstrapping). It can still be referenced from other
APEXes but can't be included there.

Bug: 139870423
Test: m
Change-Id: I7f99eef27ccf75844ca5c9a7ea866496841b738f
2019-10-07 13:52:32 +09:00
Ryan Prichard
67ff8b5f9c Merge "Inline soinfo::get_tls" 2019-10-04 18:25:36 +00:00
Treehugger Robot
3e565bd7ee Merge "fortify(unistd): emit diagnostics regardless of API level" 2019-10-04 06:36:54 +00:00
Treehugger Robot
cfa2e8a667 Merge "<unistd.h> __INTRODUCED_IN cleaup." 2019-10-04 06:29:43 +00:00
Elliott Hughes
0e14c5a869 <unistd.h> __INTRODUCED_IN cleaup.
The NDK doesn't support anything older than API level 16, so remove some
more clutter.

Test: builds
Change-Id: If257a27841396af001b089b7ae0fbd8c3e0128e4
2019-10-03 20:35:38 -07:00
George Burgess IV
da8d30f357 fortify(unistd): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I17ad1283cbedaec2ab070134320e1c5401d3e6a4
2019-10-03 20:30:02 -07:00
Treehugger Robot
3398552aa6 Merge "Remove __INTRODUCED_IN for obsolete API levels." 2019-10-04 01:47:03 +00:00
Ryan Prichard
c6bec07fb6 Inline soinfo::get_tls
The run-time of dl_iterate_phdr can be noticeable for exception-handling.

e.g. I tested extest on the GitHub issue by:
 - disabling the dlpi_subs/dlpi_adds-based caching in libgcc
 - adding a weaker "load base hint" caching in libgcc that doesn't need
   the dlpi_subs/dlpi_adds fields, but still has to iterate over every
   module to validate a cache hit

extest throws 10000 exceptions, and I saw a regression from ~1550ms
runtime on Q to about ~1950ms on master. This CL reduces the regression to
about ~1700ms.

Bug: https://github.com/android/ndk/issues/1062
Test: bionic unit tests
Change-Id: I099e97e1a20f5b2aa6737789e49d965170eb85a8
2019-10-03 18:01:59 -07:00
Elliott Hughes
f106a391d3 Remove __INTRODUCED_IN for obsolete API levels.
The NDK only supports >= 16, so remove anything older than that to avoid
giving the misleading impression that such old targets are still
supported.

(This change doesn't touch <unistd.h>. I'll follow up with that once the
outstanding FORTIFY changes to that file are in.)

Test: builds
Change-Id: I6cc6ecdb99fe228a4afa71f78e5fd45309ba9786
2019-10-03 16:09:04 -07:00
Christopher Ferris
bdb16cf8b8 Merge "Update to kernel headers v5.3.2." 2019-10-03 22:59:32 +00:00
Christopher Ferris
b8a95e2186 Update to kernel headers v5.3.2.
Test: Builds and run unit tests on taimen/cuttlefish.
Change-Id: I6ebd8f179d159ac974555e8edca588083e8081b3
2019-10-03 10:59:32 -07:00
Christopher Ferris
b29454794c Merge "Add support for scudo." 2019-10-03 01:06:30 +00:00
Elliott Hughes
3d6cf766be Merge "<sys/select.h>: add docs, and a warning against using select()." 2019-10-03 00:47:25 +00:00
Treehugger Robot
40ef00f039 Merge "fortify(stdio): emit diagnostics regardless of API level" 2019-10-03 00:36:22 +00:00
Elliott Hughes
cfac8d0074 <sys/select.h>: add docs, and a warning against using select().
Test: N/A
Change-Id: I596d63f2c8039434e2b8023eefb944da5c4bbb40
2019-10-02 14:13:54 -07:00
Christopher Ferris
88b2f0d8f0 Add support for scudo.
Bug: 137795072

Test: Unit tests pass on jemalloc and scudo.
Change-Id: I764cdad2507d322ff36dd5d28bd8ff9719601e6a
2019-10-02 12:48:23 -07:00
Christopher Ferris
d120b8a06c Merge "Make it easy to switch between scudo and jemalloc." 2019-10-02 19:00:12 +00:00
Christopher Ferris
e55e5eef8a Make it easy to switch between scudo and jemalloc.
Refactor some of the definitions to separate out all of the native
allocator pieces into one place that can be changed easily. This
should fix a few static libraries that appear to have accidentally
included jemalloc wrapper functions. For example, I verified that
libc_nomalloc.a no longer has references to any je_XXX functions.

Modify the bionic_libc_platform_headers to not include any libraries.
If this isn't updated, soong thinks there are cycles when used by
libscudo.

To enable scudo, change the libc_native_allocator_defaults defaults
from libc_jemalloc5_defaults to libc_scudo_defaults and comment out
the defaults: ["libc_scudo_wrapper_defaults"], line for the shared
library libc_scudo.

To do a final switch to scudo, it will be necessary to clean up
some code in other parts of the tree, but this allows a single cl
to enable or disable.

Bug: 137795072

Test: Builds with jemalloc or scudo with a small change.
Test: Ran bionic unit tests.
Change-Id: I07bb5432a0d2b2f405f92412e8d04fb9c9e51b31
Merged-In: I07bb5432a0d2b2f405f92412e8d04fb9c9e51b31
(cherry picked from commit ccff1b19ef)
2019-10-02 09:45:13 -07:00
Treehugger Robot
eb9775d36f Merge "fortify(poll): emit diagnostics regardless of API level" 2019-10-02 00:25:50 +00:00
Treehugger Robot
822beaeeac Merge "fortify(strings): emit diagnostics regardless of API level" 2019-10-01 21:36:11 +00:00
Elliott Hughes
2244f40e51 Merge "Move bionic ("runtime") apex definition into bionic/." 2019-10-01 20:42:23 +00:00
Treehugger Robot
803bd0a012 Merge "fortify(socket/stat): emit diagnostics regardless of API level" 2019-10-01 07:11:36 +00:00
Elliott Hughes
470d10cf0f Move bionic ("runtime") apex definition into bionic/.
Bug: http://b/139176024
Test: boots
Change-Id: Ifc3829e00b99c2f65ed932f0b42ab1ae59fec27c
2019-09-30 16:44:58 -07:00
George Burgess IV
113d6fa14e fortify(stdio): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I875a072c74f578d4404576c5bb42fd8ea30ff68d
2019-09-30 13:00:36 -07:00
George Burgess IV
db87607524 fortify(poll): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I5e147d28ec606c104b5905fd3d0c3fc197f0e4b8
2019-09-30 13:00:36 -07:00
George Burgess IV
bc37c5a8ce fortify(strings): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: Ief185320f93ec31f4d0a8035c450a7ab7b4e02b4
2019-09-30 13:00:35 -07:00
George Burgess IV
d0a0f72852 fortify(socket/stat): emit diagnostics regardless of API level
Bug: 141267932
Test: m checkbuild on internal-master

Change-Id: I7fe29184290e19ec080b204aa98d513ce59bc66b
2019-09-30 13:00:35 -07:00
Elliott Hughes
82ee3a08e2 Merge "Optimize tolower(3)/toupper(3) from <ctype.h>." 2019-09-30 18:49:51 +00:00
Christopher Ferris
d24c14d817 Merge "Make tls related header files platform accessible." 2019-09-30 16:15:33 +00:00
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
41488b79c4 Merge "Revert "Revert "Add benchmarks that run simple programs""" 2019-09-27 19:59:50 +00: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