buffer fixes

This commit is contained in:
ProgramSnail 2024-11-12 02:12:28 +03:00
parent 959c06cc65
commit f5c7843942
3 changed files with 24 additions and 15 deletions

View file

@ -7,6 +7,8 @@
#include "stdlib.h"
extern size_t __gc_stack_top, __gc_stack_bottom;
static inline void **s_top(struct State *s) {
return s->stack + STACK_SIZE - s->bf->global_area_size;
}
@ -54,7 +56,8 @@ static inline void s_push(struct State *s, void *val) {
#endif
--s->sp;
*s->sp = val;
// __gc_stack_top= (size_t)(s->sp - 1);
__gc_stack_top = (size_t)(s->sp);
__gc_stack_top -= __gc_stack_top & 0xF;
}
static inline void s_push_i(struct State *s, aint val) {
@ -82,7 +85,8 @@ static inline void *s_pop(struct State *s) {
void *value = *s->sp;
*s->sp = NULL;
++s->sp;
// __gc_stack_top = (size_t)(s->sp - 1);
__gc_stack_top = (size_t)(s->sp);
__gc_stack_top -= __gc_stack_top & 0xF;
return value;
}
@ -226,7 +230,7 @@ static inline void **var_by_category(struct State *s, enum VarCategory category,
if (s->fp->closure == NULL) {
s_failure(s, "can't read closure parameter not in closure");
}
if (!UNBOXED(s->fp->closure)) { // TODO: check ??
if (UNBOXED(s->fp->closure)) {
s_failure(s, "not boxed value expected in closure index");
}
data *d = TO_DATA(s->fp->closure);

View file

@ -15,7 +15,7 @@
// CLOJURE_T = CLOSURE_TAG,
// };
#define STACK_SIZE 100000
#define STACK_SIZE 128 * 1024
static const size_t MAX_ARRAY_SIZE = 0x11111110;