allocate new LLVMContext per Lua global state

pull/81/head 0.9
Dibyendu Majumdar 9 years ago
parent 2da4a33e38
commit d2fbb17572

@ -374,7 +374,7 @@ class RAVI_API RaviJITStateImpl : public RaviJITState {
// map of names to functions
std::map<std::string, RaviJITFunction *> functions_;
llvm::LLVMContext &context_;
llvm::LLVMContext *context_;
// The triple represents the host target
std::string triple_;
@ -420,7 +420,7 @@ public:
void addGlobalSymbol(const std::string &name, void *address);
virtual void dump();
virtual llvm::LLVMContext &context() { return context_; }
virtual llvm::LLVMContext &context() { return *context_; }
LuaLLVMTypes *types() const { return types_; }
const std::string &triple() const { return triple_; }
bool is_auto() const { return auto_; }

@ -42,7 +42,7 @@ RaviJITState *RaviJITFunctionImpl::owner() const { return owner_; }
// lua_State - all compilation activity happens
// in the context of the JIT State
RaviJITStateImpl::RaviJITStateImpl()
: context_(llvm::getGlobalContext()), auto_(false), enabled_(true),
: auto_(false), enabled_(true),
opt_level_(2), size_level_(0), min_code_size_(150), min_exec_count_(50),
gc_step_(200) {
// LLVM needs to be initialized else
@ -64,7 +64,8 @@ RaviJITStateImpl::RaviJITStateImpl()
// format; LLVM 3.7 onwards COEFF is supported
triple_ += "-elf";
#endif
types_ = new LuaLLVMTypes(context_);
context_ = new llvm::LLVMContext();
types_ = new LuaLLVMTypes(*context_);
}
// Destroy the JIT state freeing up any
@ -79,6 +80,7 @@ RaviJITStateImpl::~RaviJITStateImpl() {
delete todelete[i];
}
delete types_;
delete context_;
}
void RaviJITStateImpl::addGlobalSymbol(const std::string &name, void *address) {

Loading…
Cancel
Save