diff --git a/base/inference.jl b/base/inference.jl index 55a1199ff1228..8c0e2e099da41 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -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: 0defs, type, jl_gf_name(gf), lim); } +DLLEXPORT int can_inline(void) +{ + return jl_compileropts.can_inline; +} + #ifdef __cplusplus } #endif diff --git a/src/init.c b/src/init.c index ff11e346e5b46..693f4e7f54b37 100644 --- a/src/init.c +++ b/src/init.c @@ -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; diff --git a/src/julia.expmap b/src/julia.expmap index 40edbbba6a1dc..a1ad9f40712f0 100644 --- a/src/julia.expmap +++ b/src/julia.expmap @@ -33,6 +33,7 @@ uv_*; add_library_mapping; utf8proc_*; + can_inline; /* freebsd */ environ; diff --git a/src/julia.h b/src/julia.h index 86b122fab6081..387a094b03259 100644 --- a/src/julia.h +++ b/src/julia.h @@ -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; diff --git a/ui/repl.c b/ui/repl.c index 37d4f88bd0ab4..eda5d1011ee06 100644 --- a/ui/repl.c +++ b/ui/repl.c @@ -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"; @@ -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; @@ -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");