diff --git a/compiler+runtime/include/cpp/jank/jit/processor.hpp b/compiler+runtime/include/cpp/jank/jit/processor.hpp index 17cc759d1..281f03390 100644 --- a/compiler+runtime/include/cpp/jank/jit/processor.hpp +++ b/compiler+runtime/include/cpp/jank/jit/processor.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -45,7 +46,7 @@ namespace jank::jit return symbol.get().toPtr(); } - return err("Failed to find symbol"); + return err(fmt::format("Failed to find the symbol: '{}'", name.c_str())); } result diff --git a/compiler+runtime/src/cpp/jank/codegen/llvm_processor.cpp b/compiler+runtime/src/cpp/jank/codegen/llvm_processor.cpp index 77ed57270..dcbe1d064 100644 --- a/compiler+runtime/src/cpp/jank/codegen/llvm_processor.cpp +++ b/compiler+runtime/src/cpp/jank/codegen/llvm_processor.cpp @@ -136,6 +136,17 @@ namespace jank::codegen auto const global_ctor_fn(ctx->global_ctor_block->getParent()); ctx->builder->CreateCall(global_ctor_fn, {}); + /* This dance is performed to keep symbol names unique across all the modules. + * Considering LLVM JIT symbols to be global, we need to define them with + * unique names to avoid conflicts during JIT recompilation/reloading. + * + * The approach, right now, is for each namespace, we will keep a counter + * and will increase it every time we define a new symbol. When we JIT reload + * the same namespace again, we will define new symbols. + * + * This IR codegen for calling `jank_ns_set_symbol_counter`, is to set the counter + * on intial load. + */ auto const current_ns{ __rt_ctx->current_ns() }; auto const fn_type( llvm::FunctionType::get(ctx->builder->getVoidTy(), diff --git a/compiler+runtime/src/cpp/jank/jit/processor.cpp b/compiler+runtime/src/cpp/jank/jit/processor.cpp index e79a107dc..ac05ca7d4 100644 --- a/compiler+runtime/src/cpp/jank/jit/processor.cpp +++ b/compiler+runtime/src/cpp/jank/jit/processor.cpp @@ -195,7 +195,7 @@ namespace jank::jit if(error.isA()) { - return err(fmt::format("Failed to remove the symbol: {}", name)); + return err(fmt::format("Failed to remove the symbol: '{}'", name)); } return ok(); }