|
Cyclone Scheme
0.28.0
|
Go to the documentation of this file.
9 #ifndef CYCLONE_TYPES_H
10 #define CYCLONE_TYPES_H
23 #include "cyclone/bignum.h"
25 #ifdef CYC_HIGH_RES_TIMERS
30 long long hrt_get_current();
31 long long hrt_cmp_current(
long long tstamp);
32 void hrt_log_delta(
const char *label,
long long tstamp);
79 #define obj_is_not_closure(obj) \
80 ((obj == NULL) || is_value_type(obj) || (type_of(obj) > macro_tag))
92 #define type_of(obj) (((pair_type *) obj)->tag)
116 #define GROW_HEAP_BY_SIZE (2 * 1024 * 1024)
119 #define INITIAL_HEAP_SIZE (3 * 1024 * 1024)
122 #define HEAP_SIZE (8 * 1024 * 1024)
131 #define GC_COLLECTION_THRESHOLD 0.0125 //0.05
134 #define GC_COLLECT_UNDER_UNSWEPT_HEAP_COUNT 3
137 #define GC_FREE_THRESHOLD 0.40
142 #define MAX_STACK_TRACES 10
145 #define DEBUG_SHOW_DIAG 0
148 #define GC_DEBUG_SHOW_SWEEP_DIAG 0
151 #define GC_DEBUG_TRACE 0
154 #define GC_DEBUG_VERBOSE 0
161 #define GC_SAFETY_CHECKS 0
164 #define NANOSECONDS_PER_MILLISECOND 1000000
195 #if INTPTR_MAX == INT64_MAX
196 #define LAST_FIXED_SIZE_HEAP_TYPE HEAP_96
198 #define LAST_FIXED_SIZE_HEAP_TYPE HEAP_64
202 #define NUM_HEAP_TYPES (HEAP_HUGE + 1)
274 #define mark(x) (((list) x)->hdr.mark)
277 #define grayed(x) (((list) x)->hdr.grayed)
280 #define immutable(x) (((list) x)->hdr.immutable)
297 #define gc_color_red 0
300 #define gc_color_blue 2
449 #define gc_is_stack_obj(low_limit, thd, obj) \
450 (stack_overflow(((object)low_limit), ((object)obj)) && \
451 stack_overflow(((object)obj), ((object)((gc_thread_data *)thd)->stack_start)))
465 #define set_thread_blocked(d, c) \
466 gc_mutator_thread_blocked(((gc_thread_data *)d), (c))
470 #define return_thread_runnable(d, r) \
471 gc_mutator_thread_runnable(((gc_thread_data *)d), (r), NULL)
476 #define return_thread_runnable_with_obj(d, r, maybe_copied) \
477 gc_mutator_thread_runnable(((gc_thread_data *)d), (r), maybe_copied)
497 #define NUM_GC_ARGS 128
502 #define STACK_GROWTH_IS_DOWNWARD 1
508 #define STACK_SIZE 500000
513 #define MAX_STACK_OBJ (STACK_SIZE * 2)
516 #if STACK_GROWTH_IS_DOWNWARD
517 #define stack_overflow(x,y) ((x) < (y))
519 #define stack_overflow(x,y) ((x) > (y))
528 #define forward(obj) (((pair_type *) obj)->pair_car)
536 void add_mutation(
void *data,
object var,
int index,
object value);
593 #define CYC_FIXNUM_MAX 1073741823
596 #define CYC_FIXNUM_MIN -1073741824
607 #define obj_is_int(x) ((unsigned long)(x) & (unsigned long)1)
613 #define obj_obj2int(x) ((long)((uintptr_t)x)>>1)
619 #define obj_int2obj(c) ((void *)((((long)c)*2) | 1))
624 #define obj_is_char(x) (((unsigned long)(x) & (unsigned long)3) == 2)
629 #define obj_obj2char(x) (char_type)((uintptr_t)(x)>>2)
634 #define obj_char2obj(c) ((void *)((((uintptr_t)c)<<2) | 2))
639 #define is_value_type(x) ((unsigned long)(x) & (unsigned long)3)
644 #define is_object_type(x) ((x != NULL) && !is_value_type(x))
666 typedef void (*
function_type) (
void *data,
object clo,
int argc,
object *args);
688 #define make_cvar(n,v) \
690 n.hdr.mark = gc_color_red; \
692 n.hdr.immutable = 0; \
713 #define make_c_opaque(var, p) \
715 var.hdr.mark = gc_color_red; \
716 var.hdr.grayed = 0; \
717 var.hdr.immutable = 0; \
718 var.tag = c_opaque_tag; \
719 var.collect_ptr = 0; \
723 #define opaque_ptr(x) (((c_opaque)x)->ptr)
726 #define opaque_collect_ptr(x) (((c_opaque)x)->collect_ptr)
777 #define boolean_desc(x) (((boolean_type *) x)->desc)
779 #define make_boolean(x) (x ? boolean_t : boolean_f)
795 #define symbol_desc(x) (((symbol_type *) x)->desc)
797 #define defsymbol(name) \
798 static object quote_##name = NULL;
830 #define alloc_bignum(data, p) \
831 bignum_type *p = gc_alloc_bignum((gc_thread_data *)data);
834 #define BIGNUM_CALL(x) { \
836 if ((__bn_mp_rv = (x)) != MP_OKAY) { \
837 fprintf(stderr, "Error calling bignum function: %s\n", \
838 mp_error_to_string(__bn_mp_rv)); \
853 #define make_complex_num(n,r,i) \
854 complex_num_type n; \
855 n.hdr.mark = gc_color_red; \
857 n.tag = complex_num_tag; \
858 n.value = (r + (i * I));
860 #define alloca_complex_num(n,r,i) \
861 complex_num_type *n = alloca(sizeof(complex_num_type)); \
862 n->hdr.mark = gc_color_red; \
864 n->tag = complex_num_tag; \
865 n->value = (r + (i * I));
868 #define assign_complex_num(pobj,v) \
869 ((complex_num_type *)pobj)->hdr.mark = gc_color_red; \
870 ((complex_num_type *)pobj)->hdr.grayed = 0; \
871 ((complex_num_type *)pobj)->tag = complex_num_tag; \
872 complex_num_value(pobj) = v;
884 #define make_double(n,v) \
886 n.hdr.mark = gc_color_red; \
888 n.tag = double_tag; \
892 #define alloca_double(n,v) \
893 double_type *n = alloca(sizeof(double_type)); \
894 n->hdr.mark = gc_color_red; \
896 n->tag = double_tag; \
900 #define assign_double(pobj,v) \
901 ((double_type *)pobj)->hdr.mark = gc_color_red; \
902 ((double_type *)pobj)->hdr.grayed = 0; \
903 ((double_type *)pobj)->tag = double_tag; \
904 double_value(pobj) = v;
907 #define integer_value(x) (((integer_type *) x)->value)
910 #define double_value(x) (((double_type *) x)->value)
913 #define bignum_value(x) (((bignum_type *) x)->bn)
916 #define complex_num_value(x) (((complex_num_type *) x)->value)
945 #define make_string(cs, s) string_type cs; \
946 { int len = strlen(s); \
947 cs.hdr.mark = gc_color_red; \
949 cs.hdr.immutable = 0; \
950 cs.tag = string_tag; \
953 cs.str = alloca(sizeof(char) * (len + 1)); \
954 memcpy(cs.str, s, len + 1);}
960 #define make_string_with_len(cs, s, length) string_type cs; \
961 { int len = length; \
962 cs.hdr.mark = gc_color_red; \
964 cs.hdr.immutable = 0; \
965 cs.tag = string_tag; cs.len = len; \
967 cs.str = alloca(sizeof(char) * (len + 1)); \
968 memcpy(cs.str, s, len); \
975 #define make_string_noalloc(cs, s, length) string_type cs; \
976 { cs.hdr.mark = gc_color_red; cs.hdr.grayed = 0; cs.hdr.immutable = 0; \
977 cs.tag = string_tag; cs.len = length; \
978 cs.num_cp = length; \
982 #define make_utf8_string(data, cs, s) string_type cs; \
983 { int len = strlen(s); \
984 cs.hdr.mark = gc_color_red; \
986 cs.hdr.immutable = 0; \
987 cs.tag = string_tag; \
988 cs.num_cp = Cyc_utf8_count_code_points((uint8_t *)s); \
989 if (cs.num_cp < 0) { \
990 Cyc_rt_raise_msg(data, "Invalid UTF-8 characters in string"); \
993 cs.str = alloca(sizeof(char) * (len + 1)); \
994 memcpy(cs.str, s, len + 1);}
1000 #define make_utf8_string_with_len(cs, s, length, num_code_points) string_type cs; \
1001 { int len = length; \
1002 cs.hdr.mark = gc_color_red; \
1003 cs.hdr.grayed = 0; \
1004 cs.hdr.immutable = 0; \
1005 cs.tag = string_tag; cs.len = len; \
1006 cs.num_cp = num_code_points; \
1007 cs.str = alloca(sizeof(char) * (len + 1)); \
1008 memcpy(cs.str, s, len); \
1009 cs.str[len] = '\0';}
1015 #define make_utf8_string_noalloc(cs, s, length) string_type cs; \
1016 { cs.hdr.mark = gc_color_red; cs.hdr.grayed = 0; cs.hdr.immutable = 0; \
1017 cs.tag = string_tag; cs.len = length; \
1018 cs.num_cp = length; \
1024 #define alloc_string(_data, _s, _len, _num_cp) \
1025 if (_len >= MAX_STACK_OBJ) { \
1027 _s = gc_alloc(((gc_thread_data *)data)->heap, \
1028 sizeof(string_type) + _len + 1, \
1030 (gc_thread_data *)data, \
1032 ((string_type *) _s)->hdr.mark = ((gc_thread_data *)data)->gc_alloc_color; \
1033 ((string_type *) _s)->hdr.grayed = 0; \
1034 ((string_type *) _s)->hdr.immutable = 0; \
1035 ((string_type *) _s)->tag = string_tag; \
1036 ((string_type *) _s)->len = _len; \
1037 ((string_type *) _s)->num_cp = _num_cp; \
1038 ((string_type *) _s)->str = (((char *)_s) + sizeof(string_type)); \
1040 _s = alloca(sizeof(string_type)); \
1041 ((string_type *)_s)->hdr.mark = gc_color_red; \
1042 ((string_type *)_s)->hdr.grayed = 0; \
1043 ((string_type *)_s)->hdr.immutable = 0; \
1044 ((string_type *)_s)->tag = string_tag; \
1045 ((string_type *)_s)->len = _len; \
1046 ((string_type *)_s)->num_cp = _num_cp; \
1047 ((string_type *)_s)->str = alloca(sizeof(char) * (_len + 1)); \
1053 #define alloc_bytevector(_data, _bv, _len) \
1054 if (_len >= MAX_STACK_OBJ) { \
1056 _bv = gc_alloc(((gc_thread_data *)data)->heap, \
1057 sizeof(bytevector_type) + _len, \
1059 (gc_thread_data *)data, \
1061 ((bytevector) _bv)->hdr.mark = ((gc_thread_data *)data)->gc_alloc_color; \
1062 ((bytevector) _bv)->hdr.grayed = 0; \
1063 ((bytevector) _bv)->hdr.immutable = 0; \
1064 ((bytevector) _bv)->tag = bytevector_tag; \
1065 ((bytevector) _bv)->len = _len; \
1066 ((bytevector) _bv)->data = (char *)(((char *)_bv) + sizeof(bytevector_type)); \
1068 _bv = alloca(sizeof(bytevector_type)); \
1069 ((bytevector) _bv)->hdr.mark = gc_color_red; \
1070 ((bytevector) _bv)->hdr.grayed = 0; \
1071 ((bytevector) _bv)->hdr.immutable = 0; \
1072 ((bytevector) _bv)->tag = bytevector_tag; \
1073 ((bytevector) _bv)->len = _len; \
1074 ((bytevector) _bv)->data = alloca(sizeof(char) * _len); \
1078 #define string_num_cp(x) (((string_type *) x)->num_cp)
1081 #define string_len(x) (((string_type *) x)->len)
1084 #define string_str(x) (((string_type *) x)->str)
1117 #define CYC_BINARY_PORT_FLAG 0x10
1119 #define CYC_IO_BUF_LEN 1024
1122 #define make_port(p,f,m) \
1124 p.hdr.mark = gc_color_red; \
1126 p.hdr.immutable = 0; \
1137 p.tok_buf_len = 0; \
1139 p.mem_buf_len = 0; \
1140 p.str_bv_in_mem_buf = NULL; \
1141 p.str_bv_in_mem_buf_len = 0; \
1145 #define make_input_port(p,f,rl) \
1147 p.hdr.mark = gc_color_red; \
1149 p.hdr.immutable = 0; \
1159 p.tok_buf = malloc(CYC_IO_BUF_LEN); \
1160 p.tok_buf_len = CYC_IO_BUF_LEN; \
1161 p.mem_buf = malloc(CYC_IO_BUF_LEN); \
1162 p.mem_buf_len = 0; \
1163 p.str_bv_in_mem_buf = NULL; \
1164 p.str_bv_in_mem_buf_len = 0; \
1184 #define make_empty_vector(v) \
1186 v.hdr.mark = gc_color_red; \
1188 v.hdr.immutable = 0; \
1189 v.tag = vector_tag; \
1190 v.num_elements = 0; \
1194 #define alloca_empty_vector(v) \
1195 vector_type *v = alloca(sizeof(vector_type)); \
1196 v->hdr.mark = gc_color_red; \
1197 v->hdr.grayed = 0; \
1198 v->hdr.immutable = 0; \
1199 v->tag = vector_tag; \
1200 v->num_elements = 0; \
1218 #define make_empty_bytevector(v) \
1219 bytevector_type v; \
1220 v.hdr.mark = gc_color_red; \
1222 v.hdr.immutable = 0; \
1223 v.tag = bytevector_tag; \
1228 #define alloca_empty_bytevector(v) \
1229 bytevector_type *v = alloca(sizeof(bytevector_type)); \
1230 v->hdr.mark = gc_color_red; \
1231 v->hdr.grayed = 0; \
1232 v->hdr.immutable = 0; \
1233 v->tag = bytevector_tag; \
1257 #define make_pair(n,a,d) \
1259 n.hdr.mark = gc_color_red; \
1261 n.hdr.immutable = 0; \
1267 #define alloca_pair(n,a,d) \
1268 pair_type *n = alloca(sizeof(pair_type)); \
1269 n->hdr.mark = gc_color_red; \
1270 n->hdr.grayed = 0; \
1271 n->hdr.immutable = 0; \
1272 n->tag = pair_tag; \
1282 #define set_pair(n,a,d) \
1283 n->hdr.mark = gc_color_red; \
1284 n->hdr.grayed = 0; \
1285 n->hdr.immutable = 0; \
1286 n->tag = pair_tag; \
1296 #define set_pair_as_expr(n,a,d) \
1297 (((pair)(n))->hdr.mark = gc_color_red, \
1298 ((pair)(n))->hdr.grayed = 0, \
1299 ((pair)(n))->hdr.immutable = 0, \
1300 ((pair)(n))->tag = pair_tag, \
1301 ((pair)(n))->pair_car = a, \
1302 ((pair)(n))->pair_cdr = d, \
1314 #define make_cell(n,a) make_pair(n,a,NULL)
1315 #define alloca_cell(n,a) alloca_pair(n,a,NULL)
1316 #define set_cell_as_expr(n,a) set_pair_as_expr(n,a,NULL)
1325 #define car(x) (((pair_type *) x)->pair_car)
1327 #define cdr(x) (((pair_type *) x)->pair_cdr)
1328 #define caar(x) (car(car(x)))
1329 #define cadr(x) (car(cdr(x)))
1330 #define cdar(x) (cdr(car(x)))
1331 #define cddr(x) (cdr(cdr(x)))
1332 #define caaar(x) (car(car(car(x))))
1333 #define caadr(x) (car(car(cdr(x))))
1334 #define cadar(x) (car(cdr(car(x))))
1335 #define caddr(x) (car(cdr(cdr(x))))
1336 #define cdaar(x) (cdr(car(car(x))))
1337 #define cdadr(x) (cdr(car(cdr(x))))
1338 #define cddar(x) (cdr(cdr(car(x))))
1339 #define cdddr(x) (cdr(cdr(cdr(x))))
1340 #define caaaar(x) (car(car(car(car(x)))))
1341 #define caaadr(x) (car(car(car(cdr(x)))))
1342 #define caadar(x) (car(car(cdr(car(x)))))
1343 #define caaddr(x) (car(car(cdr(cdr(x)))))
1344 #define cadaar(x) (car(cdr(car(car(x)))))
1345 #define cadadr(x) (car(cdr(car(cdr(x)))))
1346 #define caddar(x) (car(cdr(cdr(car(x)))))
1347 #define cadddr(x) (car(cdr(cdr(cdr(x)))))
1348 #define cdaaar(x) (cdr(car(car(car(x)))))
1349 #define cdaadr(x) (cdr(car(car(cdr(x)))))
1350 #define cdadar(x) (cdr(car(cdr(car(x)))))
1351 #define cdaddr(x) (cdr(car(cdr(cdr(x)))))
1352 #define cddaar(x) (cdr(cdr(car(car(x)))))
1353 #define cddadr(x) (cdr(cdr(car(cdr(x)))))
1354 #define cdddar(x) (cdr(cdr(cdr(car(x)))))
1355 #define cddddr(x) (cdr(cdr(cdr(cdr(x)))))
1364 #define Cyc_caar(d, x) (Cyc_car(d, Cyc_car(d, x)))
1365 #define Cyc_cadr(d, x) (Cyc_car(d, Cyc_cdr(d, x)))
1366 #define Cyc_cdar(d, x) (Cyc_cdr(d, Cyc_car(d, x)))
1367 #define Cyc_cddr(d, x) (Cyc_cdr(d, Cyc_cdr(d, x)))
1368 #define Cyc_caaar(d, x) (Cyc_car(d, Cyc_car(d, Cyc_car(d, x))))
1369 #define Cyc_caadr(d, x) (Cyc_car(d, Cyc_car(d, Cyc_cdr(d, x))))
1370 #define Cyc_cadar(d, x) (Cyc_car(d, Cyc_cdr(d, Cyc_car(d, x))))
1371 #define Cyc_caddr(d, x) (Cyc_car(d, Cyc_cdr(d, Cyc_cdr(d, x))))
1372 #define Cyc_cdaar(d, x) (Cyc_cdr(d, Cyc_car(d, Cyc_car(d, x))))
1373 #define Cyc_cdadr(d, x) (Cyc_cdr(d, Cyc_car(d, Cyc_cdr(d, x))))
1374 #define Cyc_cddar(d, x) (Cyc_cdr(d, Cyc_cdr(d, Cyc_car(d, x))))
1375 #define Cyc_cdddr(d, x) (Cyc_cdr(d, Cyc_cdr(d, Cyc_cdr(d, x))))
1376 #define Cyc_caaaar(d, x) (Cyc_car(d, Cyc_car(d, Cyc_car(d, Cyc_car(d, x)))))
1377 #define Cyc_caaadr(d, x) (Cyc_car(d, Cyc_car(d, Cyc_car(d, Cyc_cdr(d, x)))))
1378 #define Cyc_caadar(d, x) (Cyc_car(d, Cyc_car(d, Cyc_cdr(d, Cyc_car(d, x)))))
1379 #define Cyc_caaddr(d, x) (Cyc_car(d, Cyc_car(d, Cyc_cdr(d, Cyc_cdr(d, x)))))
1380 #define Cyc_cadaar(d, x) (Cyc_car(d, Cyc_cdr(d, Cyc_car(d, Cyc_car(d, x)))))
1381 #define Cyc_cadadr(d, x) (Cyc_car(d, Cyc_cdr(d, Cyc_car(d, Cyc_cdr(d, x)))))
1382 #define Cyc_caddar(d, x) (Cyc_car(d, Cyc_cdr(d, Cyc_cdr(d, Cyc_car(d, x)))))
1383 #define Cyc_cadddr(d, x) (Cyc_car(d, Cyc_cdr(d, Cyc_cdr(d, Cyc_cdr(d, x)))))
1384 #define Cyc_cdaaar(d, x) (Cyc_cdr(d, Cyc_car(d, Cyc_car(d, Cyc_car(d, x)))))
1385 #define Cyc_cdaadr(d, x) (Cyc_cdr(d, Cyc_car(d, Cyc_car(d, Cyc_cdr(d, x)))))
1386 #define Cyc_cdadar(d, x) (Cyc_cdr(d, Cyc_car(d, Cyc_cdr(d, Cyc_car(d, x)))))
1387 #define Cyc_cdaddr(d, x) (Cyc_cdr(d, Cyc_car(d, Cyc_cdr(d, Cyc_cdr(d, x)))))
1388 #define Cyc_cddaar(d, x) (Cyc_cdr(d, Cyc_cdr(d, Cyc_car(d, Cyc_car(d, x)))))
1389 #define Cyc_cddadr(d, x) (Cyc_cdr(d, Cyc_cdr(d, Cyc_car(d, Cyc_cdr(d, x)))))
1390 #define Cyc_cdddar(d, x) (Cyc_cdr(d, Cyc_cdr(d, Cyc_cdr(d, Cyc_car(d, x)))))
1391 #define Cyc_cddddr(d, x) (Cyc_cdr(d, Cyc_cdr(d, Cyc_cdr(d, Cyc_cdr(d, x)))))
1435 #define mmacro(c,f) \
1437 c.hdr.mark = gc_color_red; \
1439 c.tag = macro_tag; \
1447 #define mclosure0(c, f) \
1448 static closure0_type c = { .hdr.mark = gc_color_red, .hdr.grayed = 0, .tag = closure0_tag, .fn = f, .num_args = -1 };
1450 #define maclosure0(c,f,na) \
1452 c.hdr.mark = gc_color_red; \
1454 c.tag = closure0_tag; \
1461 #define mclosure1(c,f,a) \
1463 c.hdr.mark = gc_color_red; \
1465 c.tag = closure1_tag; \
1481 #define defprimitive(name, desc, fnc) \
1482 static primitive_type name##_primitive = {primitive_tag, #desc, fnc}; \
1483 static const object primitive_##name = &name##_primitive
1486 #define prim(x) (x && ((primitive)x)->tag == primitive_tag)
1489 #define prim_name(x) (((primitive_type *) x)->desc)
1508 #define return_copy(ptr, o) \
1512 if (!is_object_type(obj)) \
1515 if (t == double_tag) { \
1516 ((common_type *)ptr)->double_t.hdr.mark = gc_color_red; \
1517 ((common_type *)ptr)->double_t.hdr.grayed = 0; \
1518 ((common_type *)ptr)->double_t.tag = double_tag; \
1519 ((common_type *)ptr)->double_t.value = double_value(obj); \
1541 void **
vpbuffer_add(
void **buf,
int *len,
int i,
void *obj);
1555 int gc_minor(
void *data,
object low_limit,
object high_limit,
closure cont,
1556 object * args,
int num_args);
tag_type tag
Definition: types.h:1475
gc_status_type
Definition: types.h:283
@ forward_tag
Definition: types.h:60
void(* primitive_function_type)(void *data, object cont, object args)
Definition: types.h:669
void * gc_alloc(gc_heap_root *h, size_t size, char *obj, gc_thread_data *thd, int *heap_grown)
Allocate memory on the heap for an object.
Definition: gc.c:1360
unsigned short read_len
Definition: types.h:1112
bytevector_type * bytevector
Definition: types.h:1215
tag_type tag
Definition: types.h:747
tag_type tag
Definition: types.h:935
const tag_type tag
Definition: types.h:772
tag_type tag
Definition: types.h:825
@ vector_tag
Definition: types.h:69
int num_args
Definition: types.h:1416
void gc_mutator_thread_runnable(gc_thread_data *thd, object result, object maybe_copied)
Called explicitly from a mutator thread to let the collector know that it has finished blocking.
Definition: gc.c:2880
void * ptr
Definition: types.h:708
@ CYC_BN_GTE
Definition: types.h:927
tag_type tag
Definition: types.h:1414
complex_num_type complex_num_t
Definition: types.h:1505
A closed-over function with no variables.
Definition: types.h:1405
int num_elements
Definition: types.h:1173
Complex number.
Definition: types.h:846
@ integer_tag
Definition: types.h:61
function_type fn
Definition: types.h:1423
void * gc_try_alloc_rest(gc_heap *h, size_t size, char *obj, gc_thread_data *thd)
gc_header_type hdr
Definition: types.h:1413
int last_write
Definition: types.h:356
void ** moveBuf
Definition: types.h:344
unsigned int tok_end
Definition: types.h:1107
function_type fn
Definition: types.h:1415
char * mem_buf
Definition: types.h:1110
unsigned char is_unswept
Definition: types.h:238
void gc_post_handshake(gc_status_type s)
Change GC status to the given type.
Definition: gc.c:2415
int stack_trace_idx
Definition: types.h:326
tag_type tag
Definition: types.h:848
gc_heap_type
Definition: types.h:186
void gc_mut_cooperate(gc_thread_data *thd, int buf_len)
Called by a mutator to cooperate with the collector thread.
Definition: gc.c:1914
void Cyc_int2bignum(int n, mp_int *bn)
Definition: runtime.c:1723
@ primitive_tag
Definition: types.h:66
pthread_mutex_t lock
Definition: types.h:371
pthread_mutex_t lock
Definition: types.h:736
gc_header_type hdr
Definition: types.h:1474
int num_cp
Definition: types.h:936
cyc_thread_state_type
Definition: types.h:311
cond_var_type * cond_var
Definition: types.h:750
object element
Definition: types.h:1417
gc_header_type hdr
Definition: types.h:1398
@ record_tag
Definition: types.h:73
vector_type v
Definition: types.h:1179
pair_type * list
Definition: types.h:1253
The condition variable thread synchronization type.
Definition: types.h:745
unsigned char globals_changed
Definition: types.h:342
void gc_collector_trace()
The collector's tracing algorithm.
Definition: gc.c:2328
tag_type tag
Definition: types.h:735
unsigned char is_full
Definition: types.h:236
void gc_start_collector()
Spawn the collector thread.
Definition: gc.c:2618
cvar_type * cvar
Definition: types.h:683
A closed-over function with one variable.
Definition: types.h:1412
pair_type d
Definition: types.h:1308
bn_cmp_type
Definition: types.h:922
void gc_initialize(void)
Perform one-time initialization before mutators can be executed.
Definition: gc.c:213
@ void_tag
Definition: types.h:72
uint8_t gc_done_tracing
Definition: types.h:352
bignum_type bignum_t
Definition: types.h:1504
A function built into the runtime.
Definition: types.h:1473
The port object type.
Definition: types.h:1096
C Opaque type - a wrapper around a pointer of any type.
Definition: types.h:702
object pair_car
Definition: types.h:1250
int num_minor_gcs
Definition: types.h:383
tag_type tag
Definition: types.h:879
@ CYC_THREAD_STATE_BLOCKED_COOPERATING
Definition: types.h:312
primitive_type * primitive
Definition: types.h:1479
Vector type.
Definition: types.h:1170
@ HEAP_REST
Definition: types.h:190
boolean_type boolean_t
Definition: types.h:1498
gc_stage_type
Definition: types.h:287
void ** buf
Definition: types.h:305
int num_args
Definition: types.h:1409
double_type double_t
Definition: types.h:1503
unsigned char flags
Definition: types.h:1102
void * gc_try_alloc_slow(gc_heap *h_passed, gc_heap *h, size_t size, char *obj, gc_thread_data *thd)
Definition: gc.c:1139
The boolean type: True or False.
Definition: types.h:770
void gc_heap_merge(gc_heap *hdest, gc_heap *hsrc)
Merge one heap into another.
Definition: gc.c:2789
@ CYC_THREAD_STATE_NEW
Definition: types.h:311
void gc_thr_grow_move_buffer(gc_thread_data *d)
Increase the size of the mutator's move buffer.
Definition: gc.c:1769
int len
Definition: types.h:937
gc_header_type hdr
Definition: types.h:824
object * elements
Definition: types.h:1426
char * str
Definition: types.h:938
closure0_type * macro
Definition: types.h:1433
@ STAGE_TRACING
Definition: types.h:287
The pair (cons) type.
Definition: types.h:1247
pair_type pair_t
Definition: types.h:1499
boolean_type * boolean
Definition: types.h:775
@ atomic_tag
Definition: types.h:71
The atomic thread synchronization type.
Definition: types.h:757
short gc_num_args
Definition: types.h:395
int num_elements
Definition: types.h:1425
int len
Definition: types.h:1212
gc_header_type hdr
Definition: types.h:878
@ cond_var_tag
Definition: types.h:56
int padding
Definition: types.h:812
void gc_mark_globals(object globals, object global_table)
Mark globals as part of the tracing collector.
Definition: gc.c:2634
int mutation_buflen
Definition: types.h:338
char * stack_limit
Definition: types.h:334
closure1_type * closure1
Definition: types.h:1430
size_t str_bv_in_mem_buf_len
Definition: types.h:1114
@ HEAP_96
Definition: types.h:189
void vp_add(vpbuffer *v, void *obj)
Definition: runtime.c:6902
gc_header_type hdr
Definition: types.h:703
c_opaque_type * c_opaque
Definition: types.h:710
int mutation_count
Definition: types.h:340
object transport_stack_value(gc_thread_data *data, object var, object value, int *run_gc)
Definition: runtime.c:566
void ** vpbuffer_add(void **buf, int *len, int i, void *obj)
Definition: runtime.c:6877
void Cyc_make_shared_object(void *data, object k, object obj)
Definition: runtime.c:6204
void gc_mark_gray2(gc_thread_data *thd, object obj)
Add a pending write to the mark buffer.
Definition: gc.c:2170
int Cyc_bignum_cmp(bn_cmp_type type, object x, int tx, object y, int ty)
Definition: runtime.c:1731
FILE * fp
Definition: types.h:1100
char * stack_prev_frame
Definition: types.h:328
mutex_type * mutex
Definition: types.h:738
void gc_mark_gray(gc_thread_data *thd, object obj)
Mark the given object gray if it is on the heap.
Definition: gc.c:2137
vector_type * vector
Definition: types.h:1176
gc_header_type hdr
Definition: types.h:678
unsigned int size
Definition: types.h:226
gc_heap * next
Definition: types.h:248
tag_type tag
Definition: types.h:810
void gc_thread_data_free(gc_thread_data *thd)
Free all data for the given mutator.
Definition: gc.c:2739
C-variable integration type - wrapper around a Cyclone object pointer.
Definition: types.h:677
char ** stack_traces
Definition: types.h:324
gc_header_type hdr
Definition: types.h:1421
Bytevector type.
Definition: types.h:1209
primitive_type primitive_t
Definition: types.h:1501
Deprecated - boxed integers.
Definition: types.h:808
@ closureN_tag
Definition: types.h:51
void gc_print_stats(gc_heap *h)
Print heap usage information. Before calling this function the current thread must have the heap lock...
Definition: gc.c:776
primitive_function_type fn
Definition: types.h:1477
void clear_mutations(void *data)
Definition: runtime.c:660
gc_header_type hdr
Definition: types.h:847
gc_heap * gc_heap_free(gc_heap *page, gc_heap *prev_page)
Free a page of the heap.
Definition: gc.c:733
int num_args
Definition: types.h:1424
void * gc_alloc_bignum(gc_thread_data *data)
A convenience function for allocating bignums.
Definition: gc.c:1315
gc_header_type hdr
Definition: types.h:758
@ HEAP_SM
Definition: types.h:187
function_type fn
Definition: types.h:1400
Closure for a macro.
Definition: types.h:1397
int moveBufLen
Definition: types.h:346
unsigned block_size
Definition: types.h:232
tag_type tag
Definition: types.h:1422
int mode
Definition: types.h:1101
@ double_tag
Definition: types.h:58
const char * desc
Definition: types.h:773
object gc_cont
Definition: types.h:391
@ HEAP_64
Definition: types.h:188
object Cyc_scm_call_no_gc(gc_thread_data *parent_thd, object fnc, object arg)
Definition: ffi.c:137
closure0_type * closure0
Definition: types.h:1429
function_type fn
Definition: types.h:1408
gc_heap * gc_heap_create(int heap_type, size_t size, gc_thread_data *thd)
Create a new heap page. The caller must hold the necessary locks.
Definition: gc.c:394
object pair_cdr
Definition: types.h:1251
unsigned char gc_trace_color
Definition: types.h:350
int heap_num_huge_allocations
Definition: types.h:381
@ port_tag
Definition: types.h:65
mark_buffer * mark_buffer
Definition: types.h:367
unsigned int ttl
Definition: types.h:228
object * pvar
Definition: types.h:681
integer_type integer_t
Definition: types.h:1502
tag_type tag
Definition: types.h:1407
object exception_handler_stack
Definition: types.h:385
object Cyc_scm_call(gc_thread_data *parent_thd, object fnc, int argc, object *args)
Definition: ffi.c:61
void gc_mut_update(gc_thread_data *thd, object old_obj, object value)
Write barrier for updates to heap-allocated objects.
Definition: gc.c:1879
gc_header_type hdr
Definition: types.h:934
object param_objs
Definition: types.h:387
double complex value
Definition: types.h:849
void add_mutation(void *data, object var, int index, object value)
Definition: runtime.c:625
object obj
Definition: types.h:760
void gc_merge_all_heaps(gc_thread_data *dest, gc_thread_data *src)
Merge all thread heaps into another.
Definition: gc.c:2802
@ STAGE_CLEAR_OR_MARKING
Definition: types.h:287
@ CYC_THREAD_STATE_TERMINATED
Definition: types.h:313
@ STAGE_RESTING
Definition: types.h:289
gc_free_list * next
Definition: types.h:210
gc_header_type hdr
Definition: types.h:734
void gc_sleep_ms(int ms)
A high-resolution sleep function.
Definition: gc.c:2605
void * gc_try_alloc(gc_heap *h, size_t size, char *obj, gc_thread_data *thd)
Attempt to allocate a new heap slot for the given object.
Definition: gc.c:1076
Symbols are similar to strings, but only one instance of each unique symbol is created,...
Definition: types.h:788
A closed-over function with zero or more closed-over variables.
Definition: types.h:1420
void gc_request_mark_globals(void)
A helper function for calling gc_mark_globals.
Definition: runtime.c:5854
uintptr_t * cached_heap_free_sizes
Definition: types.h:377
void * unused
Definition: types.h:1099
unsigned buf_len
Definition: types.h:306
pair_type * pair
Definition: types.h:1254
@ STATUS_ASYNC
Definition: types.h:283
The string type.
Definition: types.h:933
unsigned int remaining
Definition: types.h:230
object scm_thread_obj
Definition: types.h:397
size_t tok_buf_len
Definition: types.h:1109
gc_heap_type type
Definition: types.h:224
@ CYC_BN_GT
Definition: types.h:926
pthread_t thread_id
Definition: types.h:373
gc_header_type hdr
Definition: types.h:746
pair_type c
Definition: types.h:1307
object(* inline_function_type)()
Definition: types.h:672
unsigned char collect_ptr
Definition: types.h:705
mp_int bn
Definition: types.h:826
@ STATUS_SYNC1
Definition: types.h:283
void Cyc_import_shared_object(void *data, object cont, object filename, object entry_pt_fnc)
Definition: runtime.c:6994
unsigned int buf_idx
Definition: types.h:1105
gc_heap_root * heap
Definition: types.h:375
@ c_opaque_tag
Definition: types.h:55
object_tag
Definition: types.h:48
@ boolean_tag
Definition: types.h:53
@ CYC_BN_LTE
Definition: types.h:923
char * stack_start
Definition: types.h:332
symbol_type * symbol
Definition: types.h:793
void gc_add_mutator(gc_thread_data *thd)
Add data for a new mutator that is starting to run.
Definition: gc.c:261
gc_header_type hdr
Definition: types.h:1406
@ cvar_tag
Definition: types.h:57
int count
Definition: types.h:1533
closure0_type * closure
Definition: types.h:1432
@ bignum_tag
Definition: types.h:62
int gc_status
Definition: types.h:354
gc_heap * next_free
Definition: types.h:244
uintptr_t * cached_heap_total_sizes
Definition: types.h:379
atomic_type * atomic
Definition: types.h:762
int gc_is_mutator_new(gc_thread_data *thd)
Determine if the given mutator is in the list of new threads.
Definition: gc.c:329
@ string_tag
Definition: types.h:67
pair_type b
Definition: types.h:1306
Exact integer of unlimited precision.
Definition: types.h:823
gc_heap * gc_grow_heap(gc_heap *h, size_t size, gc_thread_data *thd)
Grow a heap by allocating a new page.
Definition: gc.c:1012
const tag_type tag
Definition: types.h:790
gc_header_type hdr
Definition: types.h:1210
tag_type tag
Definition: types.h:1249
vpbuffer * vp_create(void)
Definition: runtime.c:6892
cyc_thread_state_type thread_state
Definition: types.h:330
char * data
Definition: types.h:1213
A union of all the constant-size objects.
Definition: types.h:1497
gc_header_type hdr
Definition: types.h:1097
char * gc_copy_obj(object hp, char *obj, gc_thread_data *thd)
Copy given object into given heap object.
Definition: gc.c:814
size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r)
Get the number of bytes that will be allocated for obj.
Definition: gc.c:1485
@ eof_tag
Definition: types.h:59
unsigned int free_size
Definition: types.h:234
@ CYC_THREAD_STATE_RUNNABLE
Definition: types.h:311
const char * desc
Definition: types.h:1476
char * data
Definition: types.h:250
vector_type v
Definition: types.h:1181
void ** buf
Definition: types.h:1531
object * elements
Definition: types.h:1174
const char * desc
Definition: types.h:791
char * tok_buf
Definition: types.h:1108
void * gc_alloc_rest(gc_heap_root *hrt, size_t size, char *obj, gc_thread_data *thd, int *heap_grown)
gc_header_type hdr
Definition: types.h:1248
void gc_wait_handshake()
Wait for all mutators to handshake.
Definition: gc.c:2430
@ symbol_tag
Definition: types.h:68
void gc_remove_mutator(gc_thread_data *thd)
Remove selected mutator from the mutator list. This is done for terminated threads....
Definition: gc.c:290
unsigned char tag_type
Definition: types.h:86
void gc_init_fixed_size_free_list(gc_heap *h)
Initialize free lists within a single heap page. Assumes that there is no data currently on the heap ...
Definition: gc.c:458
void gc_heap_create_rest(gc_heap *h, gc_thread_data *thd)
unsigned int col_num
Definition: types.h:1104
void gc_add_new_unrunning_mutator(gc_thread_data *thd)
Add data for a new mutator that is not yet scheduled to run. This is done so there is a record in the...
Definition: gc.c:246
closureN_type * closureN
Definition: types.h:1431
mark_buffer * next
Definition: types.h:307
int gc_is_mutator_active(gc_thread_data *thd)
Determine if the given mutator is in the list of active threads.
Definition: gc.c:312
void gc_mutator_thread_blocked(gc_thread_data *thd, object cont)
Called explicitly from a mutator thread to let the collector know it (may) block for an unknown perio...
Definition: gc.c:2831
gc_heap * gc_heap_last(gc_heap *h)
Get the heap's last page.
Definition: gc.c:1554
void gc_thread_data_init(gc_thread_data *thd, int mut_num, char *stack_base, long stack_size)
Initialize runtime data structures for a thread.
Definition: gc.c:2673
unsigned char gc_alloc_color
Definition: types.h:348
@ CYC_BN_LT
Definition: types.h:924
unsigned int line_num
Definition: types.h:1103
void ** vpbuffer_realloc(void **buf, int *len)
Definition: runtime.c:6872
@ HEAP_HUGE
Definition: types.h:191
int mark_buffer_len
Definition: types.h:369
double value
Definition: types.h:880
tag_type tag
Definition: types.h:1098
int last_read
Definition: types.h:358
unsigned int tok_start
Definition: types.h:1106
tag_type tag
Definition: types.h:704
The mutex thread synchronization type.
Definition: types.h:733
tag_type tag
Definition: types.h:1172
void vpbuffer_free(void **buf)
Definition: runtime.c:6887
@ macro_tag
Definition: types.h:52
void ** mutations
Definition: types.h:336
void * object
Definition: types.h:40
pthread_cond_t cond
Definition: types.h:748
Double-precision floating point type, also known as a flonum.
Definition: types.h:877
int pending_writes
Definition: types.h:365
@ STATUS_SYNC2
Definition: types.h:283
char * data_end
Definition: types.h:252
int value
Definition: types.h:811
gc_header_type hdr
Definition: types.h:809
void(* function_type)(void *data, object clo, int argc, object *args)
Definition: types.h:666
list global_table
Definition: runtime.c:519
tag_type tag
Definition: types.h:679
@ closure1_tag
Definition: types.h:50
gc_header_type hdr
Definition: types.h:771
object * gc_args
Definition: types.h:393
int gc_minor(void *data, object low_limit, object high_limit, closure cont, object *args, int num_args)
Definition: runtime.c:6031
gc_heap * gc_sweep(gc_heap *h, gc_thread_data *thd)
Sweep portion of the GC algorithm.
Definition: gc.c:1589
gc_header_type hdr
Definition: types.h:1171
@ STAGE_SWEEPING
Definition: types.h:289
@ mutex_tag
Definition: types.h:63
gc_header_type hdr
Definition: types.h:789
size_t mem_buf_len
Definition: types.h:1111
void gc_empty_collector_stack()
Empty the collector's mark stack.
Definition: gc.c:2385
@ pair_tag
Definition: types.h:64
void gc_handshake(gc_status_type s)
Called by the collector thread to perform a handshake with all of the mutators.
Definition: gc.c:2405
unsigned int last_alloc_size
Definition: types.h:242
vector_type v
Definition: types.h:1180
symbol_type symbol_t
Definition: types.h:1500
vector_type v
Definition: types.h:1178
jmp_buf * jmp_start
Definition: types.h:389
tag_type tag
Definition: types.h:759
int len
Definition: types.h:1532
tag_type tag
Definition: types.h:1211
@ CYC_BN_EQ
Definition: types.h:925
void * gc_alloc_from_bignum(gc_thread_data *data, bignum_type *src)
A helper function to create a heap-allocated copy of a bignum.
Definition: gc.c:1340
int num_unswept_children
Definition: types.h:240
char * str_bv_in_mem_buf
Definition: types.h:1113
gc_heap ** heap
Definition: types.h:260
tag_type tag
Definition: types.h:1399
gc_free_list * free_list
Definition: types.h:246
@ CYC_THREAD_STATE_BLOCKED
Definition: types.h:312
@ closure0_tag
Definition: types.h:49
int num_args
Definition: types.h:1401
@ bytevector_tag
Definition: types.h:54
unsigned int size
Definition: types.h:209
@ complex_num_tag
Definition: types.h:70