Finish compiler series
This commit is contained in:
parent
b9f508db6a
commit
fc6621b8d1
|
@ -20,7 +20,9 @@ void llvm_context::create_types() {
|
||||||
|
|
||||||
gmachine_type->setBody(
|
gmachine_type->setBody(
|
||||||
stack_ptr_type,
|
stack_ptr_type,
|
||||||
node_ptr_type
|
node_ptr_type,
|
||||||
|
IntegerType::getInt64Ty(ctx),
|
||||||
|
IntegerType::getInt64Ty(ctx)
|
||||||
);
|
);
|
||||||
struct_types.at("node_base")->setBody(
|
struct_types.at("node_base")->setBody(
|
||||||
IntegerType::getInt32Ty(ctx),
|
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 });
|
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) {
|
void llvm_context::create_unwind(Function* f) {
|
||||||
auto unwind_f = functions.at("unwind");
|
auto unwind_f = functions.at("unwind");
|
||||||
builder.CreateCall(unwind_f, { f->args().begin() });
|
builder.CreateCall(unwind_f, { f->args().begin() });
|
||||||
|
|
|
@ -55,7 +55,6 @@ struct llvm_context {
|
||||||
void create_alloc(llvm::Function*, llvm::Value*);
|
void create_alloc(llvm::Function*, llvm::Value*);
|
||||||
llvm::Value* create_track(llvm::Function*, llvm::Value*);
|
llvm::Value* create_track(llvm::Function*, llvm::Value*);
|
||||||
|
|
||||||
llvm::Value* create_eval(llvm::Value*);
|
|
||||||
void create_unwind(llvm::Function*);
|
void create_unwind(llvm::Function*);
|
||||||
|
|
||||||
llvm::Value* unwrap_gmachine_stack_ptr(llvm::Value*);
|
llvm::Value* unwrap_gmachine_stack_ptr(llvm::Value*);
|
||||||
|
|
14
09/runtime.c
14
09/runtime.c
|
@ -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) {
|
struct node_base* gmachine_track(struct gmachine* g, struct node_base* b) {
|
||||||
g->gc_node_count++;
|
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;
|
b->gc_next = g->gc_nodes;
|
||||||
g->gc_nodes = b;
|
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;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user