this repo has no description

Make handle stack size configurable like memory (#257)

This PR resolves #156

authored by

Sodgerel Mandakhnaran and committed by
GitHub
986e0fbb acffc29a

+9 -4
+6 -4
runtime.c
··· 680 680 as_variant(variant)->value = value; 681 681 } 682 682 683 - #define MAX_HANDLES 4096 684 - 685 683 struct handle_scope { 686 684 struct object*** base; 687 685 }; 688 686 689 - static struct object** handle_stack[MAX_HANDLES]; 687 + #ifndef HANDLE_STACK_SIZE 688 + #define HANDLE_STACK_SIZE 4096 689 + #endif 690 + 691 + static struct object** handle_stack[HANDLE_STACK_SIZE]; 690 692 static struct object*** handles = handle_stack; 691 693 #ifndef NDEBUG 692 694 // Only used to check for handle stack overflow. 693 - static struct object*** handles_end = &handle_stack[MAX_HANDLES]; 695 + static struct object*** handles_end = &handle_stack[HANDLE_STACK_SIZE]; 694 696 #endif 695 697 696 698 void pop_handles(void* local_handles) {
+3
scrapscript.py
··· 2478 2478 cflags = discover_cflags(cc, args.debug) 2479 2479 if args.memory: 2480 2480 cflags += [f"-DMEMORY_SIZE={args.memory}"] 2481 + if args.handle_stack_size: 2482 + cflags += [f"-DHANDLE_STACK_SIZE={args.handle_stack_size}"] 2481 2483 ldflags = env_get_split("LDFLAGS") 2482 2484 subprocess.run([*cc, "-o", "a.out", *cflags, args.output, *ldflags], check=True) 2483 2485 ··· 2590 2592 comp.add_argument("--format", action="store_true") 2591 2593 comp.add_argument("--compile", action="store_true") 2592 2594 comp.add_argument("--memory", type=int) 2595 + comp.add_argument("--handle-stack-size", type=int) 2593 2596 comp.add_argument("--run", action="store_true") 2594 2597 comp.add_argument("--debug", action="store_true", default=False) 2595 2598 comp.add_argument("--check", action="store_true", default=False)