From fc6621b8d1f856d9e9fa7e40e810a1c523e7aece Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 10 Feb 2020 19:18:55 -0800 Subject: [PATCH] Finish compiler series --- 09/llvm_context.cpp | 9 +++------ 09/llvm_context.hpp | 1 - 09/runtime.c | 14 ++++++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/09/llvm_context.cpp b/09/llvm_context.cpp index 99ab480..45dcb50 100644 --- a/09/llvm_context.cpp +++ b/09/llvm_context.cpp @@ -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() }); diff --git a/09/llvm_context.hpp b/09/llvm_context.hpp index 89e145e..fbe4cc1 100644 --- a/09/llvm_context.hpp +++ b/09/llvm_context.hpp @@ -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*); diff --git a/09/runtime.c b/09/runtime.c index 52a74c8..7b8a7c3 100644 --- a/09/runtime.c +++ b/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) { 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; }