mirror of
git://repo.or.cz/tinycc.git
synced 2026-11-04 21:26:36 +08:00
Make bound checking faster.
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-arm64-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
build and test / test-i386-linux (push) Has been cancelled
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-arm64-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
build and test / test-i386-linux (push) Has been cancelled
With this commit bound checking will be about 20% .. 25% faster. (Tested with running testsuites with bound checking. About 1000 files.) The speedup is made possible because of TLS implementation. TLS is not possible with -run so create a new bcheck_run.o Makefile:lib/Makefile:win32/build-tcc.bat - Compile new bcheck_run.o tccelf.c:tccpe.c - Use bcheck_run.o lib/bcheck.c - Use TLS code
This commit is contained in:
parent
1bcec040d0
commit
0fb54300b5
2
Makefile
2
Makefile
@ -372,7 +372,7 @@ IR = $(IM) mkdir -p $2 && cp -r $1/. $2
|
|||||||
IM = @echo "-> $2 : $1" ;
|
IM = @echo "-> $2 : $1" ;
|
||||||
BINCHECK = $(if $(wildcard $(PROGS) *-tcc$(EXESUF)),,@echo "Makefile: nothing found to install" && exit 1)
|
BINCHECK = $(if $(wildcard $(PROGS) *-tcc$(EXESUF)),,@echo "Makefile: nothing found to install" && exit 1)
|
||||||
|
|
||||||
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o
|
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o bcheck_run.o
|
||||||
|
|
||||||
# install progs & libs
|
# install progs & libs
|
||||||
install-unx:
|
install-unx:
|
||||||
|
|||||||
@ -53,10 +53,10 @@ Cbc = $(Cbt)$(subst yes,,$(CONFIG_bcheck))
|
|||||||
$(Nat)COMMON_O += runmain.o tcov.o
|
$(Nat)COMMON_O += runmain.o tcov.o
|
||||||
$(Cbt)COMMON_O += bt-exe.o bt-log.o
|
$(Cbt)COMMON_O += bt-exe.o bt-log.o
|
||||||
$(Cbt)WIN_O += bt-dll.o
|
$(Cbt)WIN_O += bt-dll.o
|
||||||
$(Cbc)COMMON_O += bcheck.o
|
$(Cbc)COMMON_O += bcheck.o bcheck_run.o
|
||||||
|
|
||||||
# not in libtcc1.a
|
# not in libtcc1.a
|
||||||
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o
|
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o bcheck_run.o
|
||||||
|
|
||||||
OBJ-i386 = $(I386_O) pic86.o $(LIN_O)
|
OBJ-i386 = $(I386_O) pic86.o $(LIN_O)
|
||||||
OBJ-x86_64 = $(X86_64_O) va_list.o $(LIN_O)
|
OBJ-x86_64 = $(X86_64_O) va_list.o $(LIN_O)
|
||||||
@ -95,6 +95,8 @@ $(TOP)/%.o : %.c $(TCC)
|
|||||||
$S$(XCC) -c $< -o $@ $(XFLAGS)
|
$S$(XCC) -c $< -o $@ $(XFLAGS)
|
||||||
|
|
||||||
$(TOP)/bcheck.o : XFLAGS += $(BFLAGS)
|
$(TOP)/bcheck.o : XFLAGS += $(BFLAGS)
|
||||||
|
$(TOP)/bcheck_run.o : bcheck.c $(TCC)
|
||||||
|
$S$(XCC) -c bcheck.c -o $@ $(XFLAGS) $(BFLAGS) -DBCHECK_RUN
|
||||||
|
|
||||||
$(X)crt1w.o : crt1.c
|
$(X)crt1w.o : crt1.c
|
||||||
$(X)wincrt1w.o : wincrt1.c
|
$(X)wincrt1w.o : wincrt1.c
|
||||||
|
|||||||
12
lib/bcheck.c
12
lib/bcheck.c
@ -53,7 +53,11 @@
|
|||||||
/* an __attribute__ macro is defined in the system headers */
|
/* an __attribute__ macro is defined in the system headers */
|
||||||
#undef __attribute__
|
#undef __attribute__
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __i386__
|
||||||
#define FASTCALL __attribute__((regparm(3)))
|
#define FASTCALL __attribute__((regparm(3)))
|
||||||
|
#else
|
||||||
|
#define FASTCALL
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define DLL_EXPORT __declspec(dllexport)
|
# define DLL_EXPORT __declspec(dllexport)
|
||||||
@ -157,12 +161,12 @@ static pthread_spinlock_t bounds_spin;
|
|||||||
#define HAVE_SIGNAL (1)
|
#define HAVE_SIGNAL (1)
|
||||||
#define HAVE_SIGACTION (1)
|
#define HAVE_SIGACTION (1)
|
||||||
#define HAVE_FORK (1)
|
#define HAVE_FORK (1)
|
||||||
#if !defined(__APPLE__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
#if defined(__APPLE__) || defined(__arm__) || defined(__GNUC__) || defined(BCHECK_RUN)
|
||||||
#define HAVE_TLS_FUNC (0)
|
|
||||||
#define HAVE_TLS_VAR (1)
|
|
||||||
#else
|
|
||||||
#define HAVE_TLS_FUNC (1)
|
#define HAVE_TLS_FUNC (1)
|
||||||
#define HAVE_TLS_VAR (0)
|
#define HAVE_TLS_VAR (0)
|
||||||
|
#else
|
||||||
|
#define HAVE_TLS_FUNC (0)
|
||||||
|
#define HAVE_TLS_VAR (1)
|
||||||
#endif
|
#endif
|
||||||
#if defined CONFIG_TCC_MUSL || defined __ANDROID__
|
#if defined CONFIG_TCC_MUSL || defined __ANDROID__
|
||||||
# undef HAVE_CTYPE
|
# undef HAVE_CTYPE
|
||||||
|
|||||||
5
tccelf.c
5
tccelf.c
@ -1839,7 +1839,10 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
|
|||||||
|
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {
|
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {
|
||||||
tcc_add_support(s1, "bcheck.o");
|
if (s1->output_type == TCC_OUTPUT_MEMORY)
|
||||||
|
tcc_add_support(s1, "bcheck_run.o");
|
||||||
|
else
|
||||||
|
tcc_add_support(s1, "bcheck.o");
|
||||||
# if !(TARGETOS_OpenBSD || TARGETOS_NetBSD)
|
# if !(TARGETOS_OpenBSD || TARGETOS_NetBSD)
|
||||||
tcc_add_library(s1, "dl");
|
tcc_add_library(s1, "dl");
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
8
tccpe.c
8
tccpe.c
@ -2131,8 +2131,12 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
|
|||||||
#ifdef CONFIG_TCC_BACKTRACE
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
if (s1->do_backtrace) {
|
if (s1->do_backtrace) {
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL)
|
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {
|
||||||
tcc_add_support(s1, "bcheck.o");
|
if (s1->output_type == TCC_OUTPUT_MEMORY)
|
||||||
|
tcc_add_support(s1, "bcheck_run.o");
|
||||||
|
else
|
||||||
|
tcc_add_support(s1, "bcheck.o");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (s1->output_type == TCC_OUTPUT_EXE)
|
if (s1->output_type == TCC_OUTPUT_EXE)
|
||||||
tcc_add_support(s1, "bt-exe.o");
|
tcc_add_support(s1, "bt-exe.o");
|
||||||
|
|||||||
@ -201,6 +201,7 @@ exit /B %ERRORLEVEL%
|
|||||||
.\%1tcc -B. -c ../lib/builtin.c
|
.\%1tcc -B. -c ../lib/builtin.c
|
||||||
.\%1tcc -ar lib/%1libtcc1.a %LIBTCC1%.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o winex.o chkstk.o alloca.o alloca-bt.o stdatomic.o atomic.o builtin.o
|
.\%1tcc -ar lib/%1libtcc1.a %LIBTCC1%.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o winex.o chkstk.o alloca.o alloca-bt.o stdatomic.o atomic.o builtin.o
|
||||||
.\%1tcc -B. -c ../lib/bcheck.c -o lib/%1bcheck.o -bt -I..
|
.\%1tcc -B. -c ../lib/bcheck.c -o lib/%1bcheck.o -bt -I..
|
||||||
|
.\%1tcc -B. -c ../lib/bcheck.c -o lib/%1bcheck_run.o -bt -I.. -DBCHECK_RUN
|
||||||
.\%1tcc -B. -c ../lib/bt-exe.c -o lib/%1bt-exe.o
|
.\%1tcc -B. -c ../lib/bt-exe.c -o lib/%1bt-exe.o
|
||||||
.\%1tcc -B. -c ../lib/bt-log.c -o lib/%1bt-log.o
|
.\%1tcc -B. -c ../lib/bt-log.c -o lib/%1bt-log.o
|
||||||
.\%1tcc -B. -c ../lib/bt-dll.c -o lib/%1bt-dll.o
|
.\%1tcc -B. -c ../lib/bt-dll.c -o lib/%1bt-dll.o
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user