Increase stack size to 128k and guard size to 16k

This improves our compatibility with Apple M1.
This commit is contained in:
Justine Tunney 2022-12-18 22:58:29 -08:00
parent 57c0dcdc29
commit dd04aeba1c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
36 changed files with 109 additions and 125 deletions

View file

@ -153,6 +153,7 @@
(defconst cosmo-cpp-constants-cosmopolitan
'("__SAUCE__"
"PAGESIZE"
"GUARDSIZE"
"FRAMESIZE"
"BIGPAGESIZE"
"STACKSIZE"

View file

@ -98,7 +98,7 @@ static struct DecodeJson Parse(struct lua_State *L, const char *p,
if (UNLIKELY(!depth)) {
return (struct DecodeJson){-1, "maximum depth exceeded"};
}
if (UNLIKELY(!HaveStackMemory(PAGESIZE))) {
if (UNLIKELY(!HaveStackMemory(GUARDSIZE))) {
return (struct DecodeJson){-1, "out of stack"};
}
for (a = p, d = +1; p < e;) {

View file

@ -481,17 +481,17 @@ static void *NewBoard(size_t *out_size) {
char *p;
size_t s, n, k;
s = (byn * bxn) >> 3;
k = PAGESIZE + ROUNDUP(s, PAGESIZE);
n = ROUNDUP(k + PAGESIZE, FRAMESIZE);
k = GUARDSIZE + ROUNDUP(s, GUARDSIZE);
n = ROUNDUP(k + GUARDSIZE, FRAMESIZE);
p = _mapanon(n);
mprotect(p, PAGESIZE, 0);
mprotect(p, GUARDSIZE, 0);
mprotect(p + k, n - k, 0);
if (out_size) *out_size = n;
return p + PAGESIZE;
return p + GUARDSIZE;
}
static void FreeBoard(void *p, size_t n) {
munmap((char *)p - PAGESIZE, n);
munmap((char *)p - GUARDSIZE, n);
}
static void AllocateBoardsWithHardwareAcceleratedMemorySafety(void) {