mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
using boehm gc by default
This commit is contained in:
parent
b3a0c52889
commit
d609e52e5f
3 changed files with 14 additions and 11 deletions
4
Makefile
4
Makefile
|
@ -8,10 +8,10 @@ GC_OBJ=./gc/gc.a
|
|||
$GC_OBJ: ./gc/alloc.c
|
||||
cd gc && make test
|
||||
|
||||
sexp.o: sexp.c sexp.h
|
||||
sexp.o: sexp.c sexp.h config.h
|
||||
gcc -c -g -Os -o $@ $<
|
||||
|
||||
eval.o: eval.c eval.h sexp.h
|
||||
eval.o: eval.c debug.c eval.h sexp.h config.h
|
||||
gcc -c -g -Os -o $@ $<
|
||||
|
||||
chibi-scheme: sexp.o eval.o $(GC_OBJ)
|
||||
|
|
18
eval.c
18
eval.c
|
@ -79,7 +79,7 @@ void env_define(env e, sexp key, sexp value) {
|
|||
|
||||
env extend_env_closure (env e, sexp fv) {
|
||||
int i;
|
||||
env e2 = (env) malloc(sizeof(struct env));
|
||||
env e2 = (env) SEXP_ALLOC(sizeof(struct env));
|
||||
e2->tag = SEXP_ENV;
|
||||
e2->parent = e;
|
||||
e2->bindings = SEXP_NULL;
|
||||
|
@ -91,7 +91,7 @@ env extend_env_closure (env e, sexp fv) {
|
|||
|
||||
env make_standard_env() {
|
||||
int i;
|
||||
env e = (env) malloc(sizeof(struct env));
|
||||
env e = (env) SEXP_ALLOC(sizeof(struct env));
|
||||
e->tag = SEXP_ENV;
|
||||
e->parent = NULL;
|
||||
e->bindings = SEXP_NULL;
|
||||
|
@ -110,7 +110,7 @@ void shrink_bcode(bytecode *bc, unsigned int i) {
|
|||
bytecode tmp;
|
||||
if ((*bc)->len != i) {
|
||||
fprintf(stderr, "shrinking to %d\n", i);
|
||||
tmp = (bytecode) malloc(sizeof(struct bytecode) + i);
|
||||
tmp = (bytecode) SEXP_ALLOC(sizeof(struct bytecode) + i);
|
||||
tmp->tag = SEXP_BYTECODE;
|
||||
tmp->len = i;
|
||||
memcpy(tmp->data, (*bc)->data, i);
|
||||
|
@ -123,7 +123,7 @@ void emit(bytecode *bc, unsigned int *i, char c) {
|
|||
bytecode tmp;
|
||||
if ((*bc)->len < (*i)+1) {
|
||||
fprintf(stderr, "expanding (%d < %d)\n", (*bc)->len, (*i)+1);
|
||||
tmp = (bytecode) malloc(sizeof(unsigned int) + (*bc)->len*2);
|
||||
tmp = (bytecode) SEXP_ALLOC(sizeof(unsigned int) + (*bc)->len*2);
|
||||
tmp->len = (*bc)->len*2;
|
||||
memcpy(tmp->data, (*bc)->data, (*bc)->len);
|
||||
SEXP_FREE(*bc);
|
||||
|
@ -135,7 +135,7 @@ void emit(bytecode *bc, unsigned int *i, char c) {
|
|||
void emit_word(bytecode *bc, unsigned int *i, unsigned long val) {
|
||||
bytecode tmp;
|
||||
if ((*bc)->len < (*i)+4) {
|
||||
tmp = (bytecode) malloc(sizeof(unsigned int) + (*bc)->len*2);
|
||||
tmp = (bytecode) SEXP_ALLOC(sizeof(unsigned int) + (*bc)->len*2);
|
||||
tmp->len = (*bc)->len*2;
|
||||
memcpy(tmp->data, (*bc)->data, (*bc)->len);
|
||||
SEXP_FREE(*bc);
|
||||
|
@ -440,7 +440,7 @@ void analyze_lambda (sexp name, sexp formals, sexp body,
|
|||
|
||||
bytecode compile(sexp params, sexp obj, env e, sexp fv, sexp sv, int done_p) {
|
||||
unsigned int i = 0, j, d = 0;
|
||||
bytecode bc = (bytecode) malloc(sizeof(struct bytecode)+INIT_BCODE_SIZE);
|
||||
bytecode bc = (bytecode) SEXP_ALLOC(sizeof(struct bytecode)+INIT_BCODE_SIZE);
|
||||
sexp sv2 = set_vars(e, params, obj, SEXP_NULL), ls;
|
||||
fprintf(stderr, "set-vars: "); write_sexp(stderr, sv2); fprintf(stderr, "\n");
|
||||
bc->tag = SEXP_BYTECODE;
|
||||
|
@ -689,9 +689,9 @@ sexp eval_in_stack(sexp obj, env e, sexp* stack, unsigned int top) {
|
|||
}
|
||||
|
||||
sexp eval(sexp obj, env e) {
|
||||
sexp* stack = (sexp*) malloc(sizeof(sexp) * INIT_STACK_SIZE);
|
||||
sexp* stack = (sexp*) SEXP_ALLOC(sizeof(sexp) * INIT_STACK_SIZE);
|
||||
sexp res = eval_in_stack(obj, e, stack, 0);
|
||||
free(stack);
|
||||
SEXP_FREE(stack);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -701,7 +701,7 @@ int main (int argc, char **argv) {
|
|||
|
||||
sexp_init();
|
||||
e = make_standard_env();
|
||||
stack = (sexp*) malloc(sizeof(sexp) * INIT_STACK_SIZE);
|
||||
stack = (sexp*) SEXP_ALLOC(sizeof(sexp) * INIT_STACK_SIZE);
|
||||
|
||||
/* repl */
|
||||
fprintf(stdout, "> ");
|
||||
|
|
3
sexp.c
3
sexp.c
|
@ -672,6 +672,9 @@ sexp read_sexp (FILE *in) {
|
|||
void sexp_init() {
|
||||
if (! initialized_p) {
|
||||
initialized_p = 1;
|
||||
#ifdef USE_BOEHM
|
||||
GC_init();
|
||||
#endif
|
||||
symbol_table = SEXP_ALLOC(symbol_table_primes[0]*sizeof(sexp));
|
||||
the_dot_symbol = intern(".");
|
||||
the_quote_symbol = intern("quote");
|
||||
|
|
Loading…
Add table
Reference in a new issue