mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-25 08:08:47 +00:00
byterun gc integration fix: move __gc_stack_top by 1
This commit is contained in:
parent
c5dfe649e0
commit
956dde00a3
5 changed files with 57 additions and 52 deletions
|
|
@ -327,7 +327,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
s_enter_f(s.call_ip /*ip from call*/,
|
||||
s.is_closure_call, args_sz, locals_sz);
|
||||
#ifndef WITH_CHECK
|
||||
if ((void **)__gc_stack_top + (aint)max_additional_stack_sz - 1 <= s.stack) {
|
||||
if (s_peek_unsafe() + (aint)max_additional_stack_sz - 1 <= s.stack) {
|
||||
s_failure(&s, "stack overflow");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -351,7 +351,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
s_enter_f(s.call_ip /*ip from call*/,
|
||||
s.is_closure_call, args_sz, locals_sz);
|
||||
#ifndef WITH_CHECK
|
||||
if ((void **)__gc_stack_top + (aint)max_additional_stack_sz - 1 <= s.stack) {
|
||||
if (s_peek_unsafe() + (aint)max_additional_stack_sz - 1 <= s.stack) {
|
||||
s_failure(&s, "stack overflow");
|
||||
}
|
||||
#endif
|
||||
|
|
@ -383,7 +383,7 @@ void run_main(Bytefile* bf, int argc, char **argv) {
|
|||
s_rotate_n(args_count);
|
||||
s_push_i(BOX(call_offset));
|
||||
|
||||
void *closure = Bclosure((aint *)__gc_stack_top, BOX(args_count));
|
||||
void *closure = Bclosure((aint *)s_peek(), BOX(args_count));
|
||||
// printf("args is %li, count is %li\n", args_count, get_len(TO_DATA(closure)));
|
||||
|
||||
s_popn(args_count + 1);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include <cstring>
|
||||
extern "C" {
|
||||
#include "interpreter.h"
|
||||
#include "module_manager.h"
|
||||
#include "interpreter.h"
|
||||
#include "runtime_externs.h"
|
||||
#include "stack.h"
|
||||
#include "utils.h"
|
||||
|
|
@ -10,7 +9,9 @@ extern "C" {
|
|||
#include "analyzer.hpp"
|
||||
#include "parser.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ extern size_t __gc_stack_top, __gc_stack_bottom;
|
|||
// --- State ---
|
||||
|
||||
void init_state(struct State* s, void** stack) {
|
||||
__init(); // FIXME, disable gc
|
||||
__init();
|
||||
|
||||
s->stack = stack;
|
||||
s->fp = NULL;
|
||||
|
|
@ -28,7 +28,7 @@ void init_state(struct State* s, void** stack) {
|
|||
}
|
||||
|
||||
__gc_stack_bottom = (size_t)(s->stack + STACK_SIZE);
|
||||
__gc_stack_top = __gc_stack_bottom;
|
||||
__gc_stack_top = __gc_stack_bottom - sizeof(void*);
|
||||
|
||||
#ifdef DEBUG_VERSION
|
||||
printf("- state init done\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue