Skip to content

Commit

Permalink
Merge f3b0882 into f17595d
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Dec 15, 2014
2 parents f17595d + f3b0882 commit 5a677d5
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,9 @@ const inline_incompletematch_allowed = false

inline_worthy(body, cost::Real) = true
function inline_worthy(body::Expr, cost::Real=1.0) # precondition: 0<cost
if ccall(:can_inline, Cint, ()) == 0
return false
end
if popmeta!(body, :inline)[1]
return true
end
Expand Down
5 changes: 5 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,11 @@ jl_value_t *jl_matching_methods(jl_function_t *gf, jl_value_t *type, int lim)
return ml_matches(mt->defs, type, jl_gf_name(gf), lim);
}

DLLEXPORT int can_inline(void)
{
return jl_compileropts.can_inline;
}

#ifdef __cplusplus
}
#endif
3 changes: 2 additions & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ jl_compileropts_t jl_compileropts = { NULL, // julia_home
JL_COMPILEROPT_DUMPBITCODE_OFF,
0, // int_literals
JL_COMPILEROPT_COMPILE_DEFAULT,
0 // opt_level
0, // opt_level
1 // inline
};

int jl_boot_file_loaded = 0;
Expand Down
1 change: 1 addition & 0 deletions src/julia.expmap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
uv_*;
add_library_mapping;
utf8proc_*;
can_inline;

/* freebsd */
environ;
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,7 @@ typedef struct {
int int_literals;
int8_t compile_enabled;
int8_t opt_level;
int8_t can_inline;
} jl_compileropts_t;

extern DLLEXPORT jl_compileropts_t jl_compileropts;
Expand Down
5 changes: 5 additions & 0 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static const char *opts =
" --track-allocation={none|user|all}\n"
" Count bytes allocated by each source line\n"
" --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)\n"
" --noinline Do not inline compiled functions (even those declared as @inline)\n"
" -O, --optimize Run time-intensive code optimizations\n"
" --int-literals={32|64} Select integer literal size independent of platform\n"
" --dump-bitcode={yes|no} Dump bitcode for the system image (used with --build)\n";
Expand All @@ -93,6 +94,7 @@ void parse_opts(int *argcp, char ***argvp)
{ "int-literals", required_argument, 0, 301 },
{ "dump-bitcode", required_argument, 0, 302 },
{ "compile", required_argument, 0, 303 },
{ "noinline", no_argument, 0, 304 },
{ 0, 0, 0, 0 }
};
int c;
Expand Down Expand Up @@ -186,6 +188,9 @@ void parse_opts(int *argcp, char ***argvp)
exit(1);
}
break;
case 304: /* noinline */
jl_compileropts.can_inline = 0;
break;
default:
ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c);
ios_printf(ios_stderr, "This is a bug, please report it.\n");
Expand Down

0 comments on commit 5a677d5

Please sign in to comment.