Currently, these services are very simples or noop.
However, alternatives GC can provide more complex ones.
Signed-off-by: Jean Privat <jean@pryen.org>
#define VAL_ISA(e, c, i) (VAL2VFT((e))[(c)].cid == (cid_t)(i))
-void * alloc(size_t);
+/* GC and memory management */
+void *alloc(size_t); /* allocate memory to store an object with an object header */
+void *raw_alloc(size_t); /* allocate raw memory to store a raw stram of byte */
+void register_static_object(val_t*); /* mark that something is a global or once object */
+
extern val_t G_args;
extern val_t G_stdin;
extern val_t G_stdout;
#include <gc/gc.h>
#endif
+void *raw_alloc(size_t s0)
+{
+ return alloc(s0);
+}
+
+void register_static_object(val_t *o)
+{
+ return;
+}
+
void *large_alloc(size_t s0)
{
static char * alloc_pos = NULL;
else
var mainm = sys.select_method(name)
v.add_instr("G_sys = NEW_Sys();")
+ v.add_instr("register_static_object(&G_sys);")
v.add_instr("{mainm.cname}(G_sys);")
end
end
body.compile_to_c(v)
var e = v.register(result.as(not null))
v.add_instr("once_value_{i} = {e};")
+ v.add_instr("register_static_object(&once_value_{i});")
if res.stype.is_nullable then v.add_instr("once_bool_{i} = true;")
v.unindent
v.add_instr("} else {e} = once_value_{i};")
s = "NEW_NativeArray(UNTAG_Int(@@@), sizeof(val_t))"
else if n == once "calloc_string".to_symbol then
p[0] = p[1]
- s = "BOX_NativeString((char*)malloc((UNTAG_Int(@@@) * sizeof(char))))"
+ s = "BOX_NativeString((char*)raw_alloc((UNTAG_Int(@@@) * sizeof(char))))"
end
if s == null then
v.visitor.error(self, "Fatal error: unknown intern method {method.full_name}.")