From f6516bae63f6f031b91c8309aea3e7d03ff2c093 Mon Sep 17 00:00:00 2001 From: Egor Sheremetov Date: Sun, 4 Feb 2024 11:58:57 +0100 Subject: [PATCH] Added stack alignment check, fixed Makefile to build target in x86-64 mode --- runtime/Makefile | 10 +++++----- runtime/runtime.c | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/runtime/Makefile b/runtime/Makefile index 679cc5ec4..d70affdc9 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -5,13 +5,13 @@ TEST_FLAGS=$(COMMON_FLAGS) -DDEBUG_VERSION UNIT_TESTS_FLAGS=$(TEST_FLAGS) INVARIANTS_CHECK_FLAGS=$(TEST_FLAGS) -DFULL_INVARIANT_CHECKS -# this target is the most important one, its' artefacts should be used as a runtime of Lama -all: gc.o runtime.o - ar rc runtime.a runtime.o gc.o - -all64: gc64.o runtime64.o +all: gc64.o runtime64.o ar rc runtime.a runtime64.o gc64.o +# this target is the most important one, its' artefacts should be used as a runtime of Lama +all32: gc.o runtime.o + ar rc runtime.a runtime.o gc.o + NEGATIVE_TESTS=$(sort $(basename $(notdir $(wildcard negative_scenarios/*_neg.c)))) $(NEGATIVE_TESTS): %: negative_scenarios/%.c diff --git a/runtime/runtime.c b/runtime/runtime.c index 9c0940bdb..a11fd1763 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -14,6 +14,7 @@ extern size_t __gc_stack_top, __gc_stack_bottom; flag = __gc_stack_top == 0; \ if (flag) { __gc_stack_top = (size_t)__builtin_frame_address(0); } \ assert(__gc_stack_top != 0); \ + assert(__gc_stack_top & 0xF == 0); \ assert(__builtin_frame_address(0) <= (void *)__gc_stack_top); #define POST_GC() \ @@ -238,15 +239,15 @@ extern aint LtagHash (char *s) { p++; } - if (strncmp(s, de_hash(h), 5) != 0) { failure("%s <-> %s\n", s, de_hash(h)); } + if (strncmp(s, de_hash(h), MAX_SEXP_TAG_LEN) != 0) { failure("%s <-> %s\n", s, de_hash(h)); } return BOX(h); } char *de_hash (aint n) { - static char buf[6] = {0, 0, 0, 0, 0, 0}; + static char buf[MAX_SEXP_TAG_LEN + 1] = {0, 0, 0, 0, 0, 0}; char *p = (char *)BOX(NULL); - p = &buf[5]; + p = &buf[MAX_SEXP_TAG_LEN]; *p-- = 0;