Skip to content

Commit b9114ea

Browse files
committed
12MB stack size only applicable to windows and macos
1 parent 0ae1a94 commit b9114ea

5 files changed

Lines changed: 20 additions & 16 deletions

File tree

jsrc/j.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,11 @@ struct jtimespec jmtclk(void); //monotonic clock. Intended rel->abs conversions
532532
// NEW WAY
533533
// The named-call stack is used only when there is a locative, EXCEPT that after a call to 18!:4 it is used until the function calling 18!:4 returns.
534534
// Since startup calls 18!:4 without a name, we have to allow for the possibility of deep recursion in the name stack. Normally only a little of the stack is used
535+
#if defined(__APPLE__) || defined(_WIN32)
535536
#define CSTACKSIZE (SY_64?12009472:1015808) // size we allocate in the calling function, aligned to 16k system page size
537+
#else
538+
#define CSTACKSIZE (SY_64?7946240:1015808) // OS default stack size 8MB, aligned to 16k system page size
539+
#endif
536540
#define CSTACKRESERVE 100000 // amount we allow for slop before we sample the stackpointer, and after the last check
537541
#else
538542
// OBSOLETE OLD WAY (with USECSTACK off)
@@ -2147,7 +2151,7 @@ extern JS gjt; // global for JPF (procs without jt)
21472151
/* strchr fails for CE MIPS - neg chars - spellit fails in ws.c for f=.+. */
21482152
#define strchr(a,b) (C*)strchr((unsigned char*)(a), (unsigned char)(b))
21492153
#endif
2150-
#if (defined(__arm__)||defined(__aarch64__)||defined(_M_ARM64)) && !defined(__MACH__)
2154+
#if (defined(__arm__)||defined(__aarch64__)||defined(_M_ARM64)) && !defined(__APPLE__)
21512155
// option -fsigned-char in android and raspberry
21522156
#ifdef strchr
21532157
#undef strchr

jsrc/jconsole.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
#include <signal.h>
1818
#include <stdint.h>
1919
#include <locale.h>
20-
#ifdef __MACH__
20+
#ifdef __APPLE__
2121
#include <xlocale.h>
2222
#endif
2323

2424
#include "j.h"
2525
#include "jeload.h"
2626

27-
#define J_STACK 0x1000000uL // 16mb
27+
#define J_STACK 0xc00000uL // 12mb
2828

2929
static int forceprmpt=0; /* emit prompt even if isatty is false */
3030
static int breadline=0; /* 0: none 1: libedit 2: linenoise */
@@ -68,7 +68,7 @@ char histfile[512];
6868
static int readlineinit()
6969
{
7070
if(hreadline)return 0; // already run
71-
#ifndef __MACH__
71+
#ifndef __APPLE__
7272
if(!(hreadline=dlopen("libedit.so.3",RTLD_LAZY)))
7373
if(!(hreadline=dlopen("libedit.so.2",RTLD_LAZY)))
7474
if(!(hreadline=dlopen("libedit.so.1",RTLD_LAZY)))
@@ -243,7 +243,7 @@ int main(int argc, char* argv[])
243243
free(argvv);
244244
}
245245

246-
#if !defined(WIN32)
246+
#if 0
247247
// set stack size to get limit error instead of crash
248248
struct rlimit lim;
249249
if(!getrlimit(RLIMIT_STACK,&lim)){

make2/build_jconsole.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,33 @@ LDFLAGS=" -ldl $LDTHREAD -m32 $macmin "
161161
#-mmacosx-version-min=10.5
162162
darwin_j64)
163163
CFLAGS="$common $macmin"
164-
LDFLAGS=" -ldl $LDTHREAD $macmin "
164+
LDFLAGS=" -Wl,-stack_size -Wl,0xc00000 -ldl $LDTHREAD $macmin "
165165
;;
166166
darwin_j64avx)
167167
CFLAGS="$common $macmin"
168-
LDFLAGS=" -ldl $LDTHREAD $macmin "
168+
LDFLAGS=" -Wl,-stack_size -Wl,0xc00000 -ldl $LDTHREAD $macmin "
169169
;;
170170
darwin_j64avx2)
171171
CFLAGS="$common $macmin"
172-
LDFLAGS=" -ldl $LDTHREAD $macmin "
172+
LDFLAGS=" -Wl,-stack_size -Wl,0xc00000 -ldl $LDTHREAD $macmin "
173173
;;
174174
darwin_j64avx512)
175175
CFLAGS="$common $macmin"
176-
LDFLAGS=" -ldl $LDTHREAD $macmin "
176+
LDFLAGS=" -Wl,-stack_size -Wl,0xc00000 -ldl $LDTHREAD $macmin "
177177
;;
178178
darwin_j64arm) # darwin arm
179179
CFLAGS="$common $macmin -march=armv8-a+crc "
180-
LDFLAGS=" -ldl $LDTHREAD $macmin "
180+
LDFLAGS=" -Wl,-stack_size -Wl,0xc00000 -ldl $LDTHREAD $macmin "
181181
;;
182182
windows_j32)
183183
TARGET=jconsole.exe
184184
CFLAGS="$common -m32 "
185-
LDFLAGS=" -m32 -Wl,--stack=0x1000000,--subsystem,console -static-libgcc $LDTHREAD"
185+
LDFLAGS=" -m32 -Wl,--stack=0xc00000,--subsystem,console -static-libgcc $LDTHREAD"
186186
;;
187187
windows_j6*)
188188
TARGET=jconsole.exe
189189
CFLAGS="$common"
190-
LDFLAGS=" -Wl,--stack=0x1000000,--subsystem,console -static-libgcc $LDTHREAD"
190+
LDFLAGS=" -Wl,--stack=0xc00000,--subsystem,console -static-libgcc $LDTHREAD"
191191
;;
192192
*)
193193
echo no case for those parameters

makemsvc/jconsole/makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ endif
1010
ifeq (1,${x64})
1111
CF1= -maes -msse3 -fno-strict-aliasing -Wno-parentheses -Wno-unused-variable -Wno-pointer-sign -Wno-missing-braces -Wno-char-subscripts -Wno-unused-value -Wno-unused-function -Wno-empty-body -Wno-sometimes-uninitialized -Wno-string-plus-int -Wno-unknown-pragmas -Wno-delete-non-abstract-non-virtual-dtor
1212
CFLAGS= ${PTHREADINC} ${FDEBUG} /DEMU_AVX=1 /WX /W3 /O2 /GS /D_USING_V110_SDK71_ /D_CRT_SECURE_NO_WARNINGS /MT ${CF1}
13-
FLAGS= ${LDEBUG} /STACK:0x10000000 /MACHINE:X64 /SUBSYSTEM:CONSOLE,5.02
13+
FLAGS= ${LDEBUG} /STACK:0xc00000 /MACHINE:X64 /SUBSYSTEM:CONSOLE,5.02
1414
else
1515
CF1= -m32 -msse2 -fno-strict-aliasing -Wno-parentheses -Wno-unused-variable -Wno-pointer-sign -Wno-missing-braces -Wno-char-subscripts -Wno-unused-value -Wno-unused-function -Wno-empty-body -Wno-sometimes-uninitialized -Wno-string-plus-int -Wno-unknown-pragmas -Wno-delete-non-abstract-non-virtual-dtor
1616
CFLAGS= ${PTHREADINC} ${FDEBUG} /WX /W3 /O2 /GS /D_USING_V110_SDK71_ /D_CRT_SECURE_NO_WARNINGS /MT ${CF1}
17-
FLAGS= ${LDEBUG} /STACK:0x10000000 /MACHINE:X86 /SUBSYSTEM:CONSOLE,5.01
17+
FLAGS= ${LDEBUG} /STACK:0xc00000 /MACHINE:X86 /SUBSYSTEM:CONSOLE,5.01
1818
endif
1919

2020
.SUFFIXES: .o

makemsvc/jconsole/makefile.win

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ LDEBUG = /DEBUG
1010
!if "1"=="$(x64)"
1111
CF1= -maes -msse3 -fno-strict-aliasing -Wno-parentheses -Wno-unused-variable -Wno-pointer-sign -Wno-missing-braces -Wno-char-subscripts -Wno-unused-value -Wno-unused-function -Wno-empty-body -Wno-sometimes-uninitialized -Wno-string-plus-int -Wno-unknown-pragmas -Wno-delete-non-abstract-non-virtual-dtor
1212
CFLAGS= $(PTHREADINC) $(FDEBUG) /DEMU_AVX=1 /WX /W3 /O2 /GS /D_USING_V110_SDK71_ /D_CRT_SECURE_NO_WARNINGS /MT $(CF1)
13-
FLAGS= $(LDEBUG) /STACK:0x10000000 /MACHINE:X64 /SUBSYSTEM:CONSOLE,5.02
13+
FLAGS= $(LDEBUG) /STACK:0xc00000 /MACHINE:X64 /SUBSYSTEM:CONSOLE,5.02
1414
!else
1515
CF1= -m32 -msse2 -fno-strict-aliasing -Wno-parentheses -Wno-unused-variable -Wno-pointer-sign -Wno-missing-braces -Wno-char-subscripts -Wno-unused-value -Wno-unused-function -Wno-empty-body -Wno-sometimes-uninitialized -Wno-string-plus-int -Wno-unknown-pragmas -Wno-delete-non-abstract-non-virtual-dtor
1616
CFLAGS= $(PTHREADINC) $(FDEBUG) /WX /W3 /O2 /GS /D_USING_V110_SDK71_ /D_CRT_SECURE_NO_WARNINGS /MT $(CF1)
17-
FLAGS= $(LDEBUG) /STACK:0x10000000 /MACHINE:X86 /SUBSYSTEM:CONSOLE,5.01
17+
FLAGS= $(LDEBUG) /STACK:0xc00000 /MACHINE:X86 /SUBSYSTEM:CONSOLE,5.01
1818
!endif
1919

2020
.SUFFIXES: .o

0 commit comments

Comments
 (0)