Make atomics faster on aarch64

This change implements the compiler runtime for ARM v8.1 ISE atomics and
gets rid of the mandatory -mno-outline-atomics flag. It can dramatically
speed things up, on newer ARM CPUs, as indicated by the changed lines in
test/libc/thread/footek_test.c. In llamafile dispatching on hwcap atomic
also shaved microseconds off synchronization barriers.
This commit is contained in:
Justine Tunney 2024-08-16 11:05:37 -07:00
parent de0cde8def
commit 11d9fb521d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
12 changed files with 2053 additions and 71 deletions

View file

@ -245,7 +245,7 @@ static void CheckPrivilegedCrossReferences(void) {
if (~shdr->sh_flags & SHF_EXECINSTR)
continue; // data reference
if ((secname = GetElfString(elf, esize, secstrs, shdr->sh_name)) &&
strcmp(".privileged", secname)) {
!startswith(secname, ".privileged")) {
tinyprint(2, epath,
": code in .privileged section "
"references symbol '",

View file

@ -343,7 +343,7 @@ LDLIBS_X86_64="-lcosmo"
CRT_AARCH64="$LIB_AARCH64/crt.o"
CPPFLAGS_AARCH64="$CPPFLAGS -fsigned-char"
CFLAGS_AARCH64="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
CFLAGS_AARCH64="$CFLAGS -ffixed-x18 -ffixed-x28"
LDFLAGS_AARCH64="$LDFLAGS -L$LIB_AARCH64 -L$BIN/../aarch64-linux-cosmo/lib -Wl,-T,$LIB_AARCH64/aarch64.lds -Wl,-z,common-page-size=16384 -Wl,-z,max-page-size=16384"
LDLIBS_AARCH64="-lcosmo"

View file

@ -131,7 +131,7 @@ elif [ x"$ARCH" = x"aarch64" ]; then
OBJCOPYFLAGS="-S"
PAGESZ=16384
CPPFLAGS="$CPPFLAGS -fsigned-char"
CFLAGS="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
CFLAGS="$CFLAGS -ffixed-x18 -ffixed-x28"
LDFLAGS="$LDFLAGS -Wl,-T,$LIB/aarch64.lds"
else
fatal_error "$ARCH: unsupported architecture"

View file

@ -79,7 +79,7 @@ o/$(MODE)/tool/hello/hello-pe.ape: \
# elf2pe can generate binaries that don't have dll imports
o/$(MODE)/tool/hello/life-pe.dbg: \
o/$(MODE)/tool/hello/life-pe.o
@$(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION) -q -e WinMain #-Ttext-segment=0x140000000
@$(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION) -q -e WinMain -Ttext-segment=0x140000000
o/$(MODE)/tool/hello/life-pe.ape: \
o/$(MODE)/tool/hello/life-pe.dbg \
o/$(MODE)/tool/build/elf2pe