Finish compiler series

This commit is contained in:
Danila Fedorin 2020-02-10 19:18:55 -08:00
parent b9f508db6a
commit fc6621b8d1
3 changed files with 11 additions and 13 deletions

View File

@ -20,7 +20,9 @@ void llvm_context::create_types() {
gmachine_type->setBody(
stack_ptr_type,
node_ptr_type
node_ptr_type,
IntegerType::getInt64Ty(ctx),
IntegerType::getInt64Ty(ctx)
);
struct_types.at("node_base")->setBody(
IntegerType::getInt32Ty(ctx),
@ -212,11 +214,6 @@ Value* llvm_context::create_track(Function* f, Value* v) {
return builder.CreateCall(track_f, { f->arg_begin(), v });
}
Value* llvm_context::create_eval(Value* e) {
auto eval_f = functions.at("eval");
return builder.CreateCall(eval_f, { e });
}
void llvm_context::create_unwind(Function* f) {
auto unwind_f = functions.at("unwind");
builder.CreateCall(unwind_f, { f->args().begin() });

View File

@ -55,7 +55,6 @@ struct llvm_context {
void create_alloc(llvm::Function*, llvm::Value*);
llvm::Value* create_track(llvm::Function*, llvm::Value*);
llvm::Value* create_eval(llvm::Value*);
void create_unwind(llvm::Function*);
llvm::Value* unwrap_gmachine_stack_ptr(llvm::Value*);

View File

@ -170,14 +170,16 @@ void gmachine_split(struct gmachine* g, size_t n) {
struct node_base* gmachine_track(struct gmachine* g, struct node_base* b) {
g->gc_node_count++;
if(g->gc_node_count >= g->gc_node_threshold) {
gc_visit_node(b);
gmachine_gc(g);
g->gc_node_threshold *= 2;
}
b->gc_next = g->gc_nodes;
g->gc_nodes = b;
if(g->gc_node_count >= g->gc_node_threshold) {
uint64_t nodes_before = g->gc_node_count;
gc_visit_node(b);
gmachine_gc(g);
g->gc_node_threshold = g->gc_node_count * 2;
}
return b;
}