Make more threading improvements

- ASAN memory morgue is now lockless
- Make C11 atomics header more portable
- Rewrote pthread keys support to be lockless
- Simplify Python's unicode table unpacking code
- Make crash report write(2) closer to being atomic
- Make it possible to strace/ftrace a single thread
- ASAN now checks nul-terminated strings fast and properly
- Windows fork() now restores TLS memory of calling thread
This commit is contained in:
Justine Tunney 2022-11-01 22:36:03 -07:00
parent d7b88734cd
commit e522aa3a07
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
189 changed files with 1363 additions and 1217 deletions

View file

@ -179,28 +179,28 @@ STATIC_YOINK("ShowCrashReportsEarly");
#define HeaderEqualCase(H, S) \
SlicesEqualCase(S, strlen(S), HeaderData(H), HeaderLength(H))
#define TRACE_BEGIN \
do { \
if (!IsTiny()) { \
if (funtrace) { \
atomic_fetch_add_explicit(&__ftrace, 1, memory_order_relaxed); \
} \
if (systrace) { \
atomic_fetch_add_explicit(&__strace, 1, memory_order_relaxed); \
} \
} \
#define TRACE_BEGIN \
do { \
if (!IsTiny()) { \
if (funtrace) { \
ftrace_enabled(+1); \
} \
if (systrace) { \
strace_enabled(+1); \
} \
} \
} while (0)
#define TRACE_END \
do { \
if (!IsTiny()) { \
if (funtrace) { \
atomic_fetch_sub_explicit(&__ftrace, 1, memory_order_relaxed); \
} \
if (systrace) { \
atomic_fetch_sub_explicit(&__strace, 1, memory_order_relaxed); \
} \
} \
#define TRACE_END \
do { \
if (!IsTiny()) { \
if (funtrace) { \
ftrace_enabled(-1); \
} \
if (systrace) { \
strace_enabled(-1); \
} \
} \
} while (0)
// letters not used: INOQYnoqwxy
@ -5385,16 +5385,16 @@ static void LuaPrint(lua_State *L) {
static void EnableRawMode(void) {
if (lua_repl_isterminal) {
--__strace;
strace_enabled(-1);
linenoiseEnableRawMode(0);
++__strace;
strace_enabled(+1);
}
}
static void DisableRawMode(void) {
--__strace;
strace_enabled(-1);
linenoiseDisableRawMode();
++__strace;
strace_enabled(+1);
}
static int LuaInterpreter(lua_State *L) {
@ -6893,14 +6893,14 @@ static void MakeExecutableModifiable(void) {
if (IsNetbsd()) return; // TODO
if (_endswith(zpath, ".com.dbg")) return;
close(zfd);
ft = __ftrace;
ft = ftrace_enabled(0);
if ((zfd = OpenExecutable()) == -1) {
WARNF("(srvr) can't open executable for modification: %m");
}
if (ft > 0) {
__ftrace = 0;
ftrace_install();
__ftrace = ft;
ftrace_enabled(ft);
}
}
@ -6980,9 +6980,9 @@ static int HandlePoll(int ms) {
rc = HandleReadline();
if (rc < 0) return rc;
} else {
--__strace;
strace_enabled(-1);
linenoiseRefreshLine(lua_repl_linenoise);
++__strace;
strace_enabled(+1);
}
#endif
}