Revert "Revert "Have JIT execution take ownership of the LLVMContextRef""

This reverts commit 19adece68b.
This commit is contained in:
Alex Crichton
2013-06-13 21:25:18 -07:00
parent 1a3edecbf2
commit a90fffe367
8 changed files with 89 additions and 61 deletions

View File

@@ -329,12 +329,12 @@ LLVMRustLoadCrate(void* mem, const char* crate) {
return true;
}
extern "C" void*
LLVMRustExecuteJIT(void* mem,
LLVMPassManagerRef PMR,
LLVMModuleRef M,
CodeGenOpt::Level OptLevel,
bool EnableSegmentedStacks) {
extern "C" LLVMExecutionEngineRef
LLVMRustBuildJIT(void* mem,
LLVMPassManagerRef PMR,
LLVMModuleRef M,
CodeGenOpt::Level OptLevel,
bool EnableSegmentedStacks) {
InitializeNativeTarget();
InitializeNativeTargetAsmPrinter();
@@ -371,21 +371,15 @@ LLVMRustExecuteJIT(void* mem,
if(!EE || Err != "") {
LLVMRustError = Err.c_str();
return 0;
// The EngineBuilder only takes ownership of these two structures if the
// create() call is successful, but here it wasn't successful.
LLVMDisposeModule(M);
delete MM;
return NULL;
}
MM->invalidateInstructionCache();
Function* func = EE->FindFunctionNamed("_rust_main");
if(!func || Err != "") {
LLVMRustError = Err.c_str();
return 0;
}
void* entry = EE->getPointerToFunction(func);
assert(entry);
return entry;
return wrap(EE);
}
extern "C" bool

View File

@@ -6,13 +6,14 @@ LLVMRustConstSmallInt
LLVMRustConstInt
LLVMRustLoadCrate
LLVMRustPrepareJIT
LLVMRustExecuteJIT
LLVMRustBuildJIT
LLVMRustParseBitcode
LLVMRustParseAssemblyFile
LLVMRustPrintPassTimings
LLVMRustStartMultithreading
LLVMCreateObjectFile
LLVMDisposeObjectFile
LLVMDisposeExecutionEngine
LLVMGetSections
LLVMDisposeSectionIterator
LLVMIsSectionIteratorAtEnd
@@ -356,6 +357,7 @@ LLVMGetParamParent
LLVMGetParamTypes
LLVMGetParams
LLVMGetPointerAddressSpace
LLVMGetPointerToGlobal
LLVMGetPreviousBasicBlock
LLVMGetPreviousFunction
LLVMGetPreviousGlobal

View File

@@ -45,6 +45,7 @@
#include "llvm/Transforms/Vectorize.h"
#include "llvm-c/Core.h"
#include "llvm-c/BitReader.h"
#include "llvm-c/ExecutionEngine.h"
#include "llvm-c/Object.h"
// Used by RustMCJITMemoryManager::getPointerToNamedFunction()