Skip to content

Commit c300327

Browse files
authored
add spill_additional_fp_simd_regs() (alibaba#1556)
1 parent f2d69e3 commit c300327

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

net/security-context/tls-stream.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,12 @@ class TLSSocketStream : public ForwardSocketStream {
467467
}
468468

469469
static int ssbio_bwrite(BIO* b, const char* buf, int cnt) {
470+
spill_additional_fp_simd_regs();
470471
return get_bio_sockstream(b)->write(buf, cnt);
471472
}
472473

473474
static int ssbio_bread(BIO* b, char* buf, int cnt) {
475+
spill_additional_fp_simd_regs();
474476
return get_bio_sockstream(b)->recv(buf, cnt);
475477
}
476478

thread/thread.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,21 @@ namespace photon
733733
// helps allocating when using hybrid C++20 style coroutine
734734
void* stackful_malloc(size_t size);
735735
void stackful_free(void* ptr);
736+
737+
// Some additional registers are defined as callee-saved ones, such as
738+
// d8 ~ d15 fp/simd registers in AARCH64, or xmm6 ~ xmm15 simd registers
739+
// in Windows x64.
740+
// But in fact, it is likely in reality that they do not actually need
741+
// spilling, so we leave them here for the users to manually do spilling
742+
// if needed.
743+
inline void spill_additional_fp_simd_regs() {
744+
#ifdef __aarch64__
745+
asm volatile("" ::: "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15");
746+
#elif defined(_WIN32)
747+
asm volatile("" ::: "xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11",
748+
"xmm12", "xmm13", "xmm14", "xmm15");
749+
#endif
750+
}
736751
};
737752

738753
/*

0 commit comments

Comments
 (0)