From 42c26919532146b887b134430c4713709b7a4d75 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Tue, 29 Oct 2019 17:14:56 +0000 Subject: Box everything Everything now gets reduced to an i8*, either through placing on the heap (in the case of primitives) or just through a simple pointer cast. In the case of primitives, boxing might be avoided by casting the primitive to an i8*, however this would only work for primitives with sizes less than or equal to the size of a pointer on the system. Boxing increases the generated LLVMIR size dramatically, so it is probably worth looking into ways to reduce the frequency of boxing. One option is to keep track of whether or not a value has been boxed, and only boxing/unboxing it when necessary instead of all the time. The current implementation uses LLVMBuildMalloc, which allocates memory, but does not ever free this memory. Freeing boxes once its value is extracted may be safe, though I'm not certain. It may be worth looking into LLVM's garbage collection support at this point. --- common.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common.c') diff --git a/common.c b/common.c index 8e144d1..4830206 100644 --- a/common.c +++ b/common.c @@ -1,7 +1,8 @@ #include "debug.h" -int debug_int(int i) { - debug("%d\n", i); +char *debug_int(char *i) { + int *p = (int *) i; + debug("%d\n", *p); return i; } -- cgit v1.2.1