Skip to content

Commit

Permalink
finish reworking closure allocations (oops)
Browse files Browse the repository at this point in the history
  • Loading branch information
StavromulaBeta committed Sep 24, 2024
1 parent 285c188 commit 0f5cc1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/cognac.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ void to_c(module_t* mod)
}
else
{
fprintf(c_source, "uint8_t* env");
fprintf(c_source, "ANY* env");
if (func->func->argc) fprintf(c_source, ", ");
}
//reg_dequeue_t* ar = make_register_dequeue();
Expand Down Expand Up @@ -954,7 +954,7 @@ void to_c(module_t* mod)
}
else
{
fprintf(c_source, "uint8_t* env");
fprintf(c_source, "ANY* env");
if (func->func->argc) fprintf(c_source, ", ");
}
reg_dequeue_t* ar = make_register_dequeue();
Expand All @@ -976,7 +976,7 @@ void to_c(module_t* mod)
fprintf(c_source, "\tBOX %s = *(BOX*)env;\n",
c_word_name(w->word));
if (w->next)
fprintf(c_source, "\tenv += sizeof(BOX);\n");
fprintf(c_source, "\tenv++;\n");
}
else
{
Expand All @@ -985,7 +985,7 @@ void to_c(module_t* mod)
c_word_name(w->word),
c_val_type(w->word->val->type));
if (w->next)
fprintf(c_source, "\tenv += sizeof(%s);\n", c_val_type(w->word->val->type));
fprintf(c_source, "\tenv++;\n");
}
}

Expand Down Expand Up @@ -1242,7 +1242,7 @@ void to_c(module_t* mod)
reg_t* reg = make_register(block, NULL);
push_register_front(reg, registers);
if (!op->op->func->captures)
fprintf(c_source, "\tBLOCK _%zu = gc_malloc(sizeof(void*));", reg->id);
fprintf(c_source, "\tBLOCK _%zu = gc_malloc(sizeof(void*));\n", reg->id);
else
{
size_t sz = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ typedef struct cognate_table* TABLE;

typedef struct cognate_block
{
void (*fn)(uint8_t*);
uint8_t env[0];
void (*fn)(ANY*);
ANY env[0];
} cognate_block;

#define NUMBER_TYPE ( NIL | 0x0000000000000008 ) // Use NaN boxing, so the value here is irrelevant.
Expand Down Expand Up @@ -835,7 +835,7 @@ static char* show_symbol(SYMBOL s, char* buffer)

static char* show_block(BLOCK b, char* buffer)
{
void (*fn)(uint8_t*) = b->fn;
void (*fn)(ANY*) = b->fn;
return buffer + sprintf(buffer, "<block %p>", *(void**)&fn);
}

Expand Down Expand Up @@ -1032,7 +1032,7 @@ static ptrdiff_t compare_objects(ANY ob1, ANY ob2)

static void call_block(BLOCK b)
{
b->fn((uint8_t*)&b->env);
b->fn((ANY*)&b->env);
}


Expand Down Expand Up @@ -2355,12 +2355,12 @@ static void ___seek(SYMBOL ref, NUMBER n, IO io)
throw_error_fmt("Can't seek to position %.14g relative to %s", n, ref);
}

static void invalid_jump(uint8_t* env)
static void invalid_jump(ANY* env)
{
throw_error("Cannot resume expired continuation");
}

static void oh_no(uint8_t* env)
static void oh_no(ANY* env)
{
#ifdef DEBUG
// Remove all the now-invalid backtraces.
Expand Down

0 comments on commit 0f5cc1c

Please sign in to comment.