Skip to content

Commit

Permalink
try to save a few seconds on building the sysimg
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Aug 16, 2014
1 parent 1a81a47 commit 003169b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
60 changes: 33 additions & 27 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3958,42 +3958,48 @@ static Function *jlcall_func_to_llvm(const std::string &cname, void *addr, Modul

extern "C" void jl_fptr_to_llvm(void *fptr, jl_lambda_info_t *lam, int specsig)
{
// this assigns a function pointer (from loading the system image), to the function object
std::string funcName = lam->name->name;
funcName = "julia_" + funcName;
if (specsig) {
jl_value_t *jlrettype = jl_ast_rettype(lam, (jl_value_t*)lam->ast);
std::vector<Type*> fsig(0);
for(size_t i=0; i < jl_tuple_len(lam->specTypes); i++) {
Type *ty = julia_type_to_llvm(jl_tupleref(lam->specTypes,i));
if (ty != T_void && !ty->isEmptyTy())
fsig.push_back(ty);
if (imaging_mode) {
if (!specsig) {
lam->fptr = (jl_fptr_t)fptr; // in imaging mode, it's fine to use the fptr, but we don't want it in the shadow_module
}
Type *rt = (jlrettype == (jl_value_t*)jl_nothing->type ? T_void : julia_type_to_llvm(jlrettype));
Function *f = Function::Create(FunctionType::get(rt, fsig, false),
} else {
// this assigns a function pointer (from loading the system image), to the function object
std::string funcName = lam->name->name;
funcName = "julia_" + funcName;
if (specsig) {
jl_value_t *jlrettype = jl_ast_rettype(lam, (jl_value_t*)lam->ast);
std::vector<Type*> fsig(0);
for(size_t i=0; i < jl_tuple_len(lam->specTypes); i++) {
Type *ty = julia_type_to_llvm(jl_tupleref(lam->specTypes,i));
if (ty != T_void && !ty->isEmptyTy())
fsig.push_back(ty);
}
Type *rt = (jlrettype == (jl_value_t*)jl_nothing->type ? T_void : julia_type_to_llvm(jlrettype));
Function *f = Function::Create(FunctionType::get(rt, fsig, false),
#ifdef USE_MCJIT
Function::ExternalLinkage, funcName, shadow_module);
Function::ExternalLinkage, funcName, shadow_module);
#else
Function::ExternalLinkage, funcName, jl_Module);
Function::ExternalLinkage, funcName, jl_Module);
#endif

if (lam->cFunctionObject == NULL) {
lam->cFunctionObject = (void*)f;
lam->cFunctionID = jl_assign_functionID(f);
if (lam->cFunctionObject == NULL) {
lam->cFunctionObject = (void*)f;
lam->cFunctionID = jl_assign_functionID(f);
}
add_named_global(f, (void*)fptr);
}
add_named_global(f, (void*)fptr);
}
else {
else {
#ifdef USE_MCJIT
Function *f = jlcall_func_to_llvm(funcName, fptr, shadow_module);
Function *f = jlcall_func_to_llvm(funcName, fptr, shadow_module);
#else
Function *f = jlcall_func_to_llvm(funcName, fptr, jl_Module);
Function *f = jlcall_func_to_llvm(funcName, fptr, jl_Module);
#endif
if (lam->functionObject == NULL) {
lam->functionObject = (void*)f;
lam->functionID = jl_assign_functionID(f);
assert(lam->fptr == &jl_trampoline);
lam->fptr = (jl_fptr_t)fptr;
if (lam->functionObject == NULL) {
lam->functionObject = (void*)f;
lam->functionID = jl_assign_functionID(f);
assert(lam->fptr == &jl_trampoline);
lam->fptr = (jl_fptr_t)fptr;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ void jl_restore_system_image(char *fname)
JL_PRINTF(JL_STDERR, "System image file \"%s\" not found\n", fname);
exit(1);
}
int build_mode = (jl_compileropts.build_path != NULL);
int build_mode = 0;
#ifdef _OS_WINDOWS_
//XXX: the windows linker forces our system image to be
// linked against only one dll, I picked libjulia-release
Expand Down

0 comments on commit 003169b

Please sign in to comment.