Implement keepGoing in asm if musttail is not available

This commit is contained in:
2024-10-10 16:52:27 -07:00
parent 0dc657bfeb
commit 1faeb220d5
2 changed files with 19 additions and 5 deletions
+19
View File
@@ -3262,10 +3262,29 @@ struct CheckContext {
ReadContext *tls;
};
#if __has_attribute(musttail)
FLATTEN PRESERVE_NONE void keepGoing(CheckJob *job, CheckContext *context) {
job = job->next;
MUSTTAIL return job->continuation(job, context);
}
#else
static_assert(offsetof(CheckJob, next) == 0x38);
static_assert(offsetof(CheckJob, continuation) == 0x28);
extern "C" void keepGoing(CheckJob *, CheckContext *);
#if defined(__x86_64__)
asm("keepGoing:\n"
" mov 0x38(%rdi),%rdi\n"
" jmp *0x28(%rdi)\n");
#elif defined(__aarch64__)
asm("keepGoing:\n"
" ldr x0, [x0, #0x38]\n"
" ldr x16, [x0, #0x28]\n"
" br x16\n");
#else
#error "Only x64 and aarch64 are supported"
#endif
#endif
FLATTEN PRESERVE_NONE void complete(CheckJob *job, CheckContext *context) {
if (context->started == context->count) {