我正在制作一个解释器,它以鸡计划的风格进行内存分配。基本思想是:
int main() {
instruction instructions[] = { zero_root, print_root, hello_world,
hello_world, stop };
top_ip.go = &instructions[0];
setjmp(top);
(*top_ip.go)(top_ip);
return 0;
}
89,10-17 Bot
和
/* The following function is machine dependent */
static bool is_time_to_gc(){
/* Is allocated on the stack */
char stack_top;
/* It's address is therefore the stack's top */
return &stack_top >= STACK_LIMIT;
}
static void goto_next_instruction(struct instruction_pointer ip) {
++ip.go;
if (is_time_to_gc()) {
/*
* Some complicated garbage collection stuff which I haven't
* completed yet.
*/
top_ip.go = ip.go;
longjmp(top, 0);
}
(*ip.go)(ip);
}
示例指令是:
static void hello_world(struct instruction_pointer ip) {
printf("Hello World!\n");
goto_next_instruction(ip);
}
我需要知道的是 STACK_LIMIT 的值应该是什么(我还需要知道堆栈是向上还是向下增长。)如何获取有关堆栈限制的平台特定信息?