Skip to content

Commit f3b0882

Browse files
committed
Add --noinline startup option
1 parent ebdaed7 commit f3b0882

File tree

6 files changed

+17
-1
lines changed

6 files changed

+17
-1
lines changed

base/inference.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,9 @@ const inline_incompletematch_allowed = false
25112511

25122512
inline_worthy(body, cost::Real) = true
25132513
function inline_worthy(body::Expr, cost::Real=1.0) # precondition: 0<cost
2514+
if ccall(:can_inline, Cint, ()) == 0
2515+
return false
2516+
end
25142517
if popmeta!(body, :inline)[1]
25152518
return true
25162519
end

src/gf.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,11 @@ jl_value_t *jl_matching_methods(jl_function_t *gf, jl_value_t *type, int lim)
19311931
return ml_matches(mt->defs, type, jl_gf_name(gf), lim);
19321932
}
19331933

1934+
DLLEXPORT int can_inline(void)
1935+
{
1936+
return jl_compileropts.can_inline;
1937+
}
1938+
19341939
#ifdef __cplusplus
19351940
}
19361941
#endif

src/init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ jl_compileropts_t jl_compileropts = { NULL, // build_path
8888
JL_COMPILEROPT_DUMPBITCODE_OFF,
8989
0, // int_literals
9090
JL_COMPILEROPT_COMPILE_DEFAULT,
91-
0 // opt_level
91+
0, // opt_level
92+
1 // inline
9293
};
9394

9495
int jl_boot_file_loaded = 0;

src/julia.expmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
uv_*;
3333
add_library_mapping;
3434
utf8proc_*;
35+
can_inline;
3536

3637
/* freebsd */
3738
environ;

src/julia.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,7 @@ typedef struct {
13361336
int int_literals;
13371337
int8_t compile_enabled;
13381338
int8_t opt_level;
1339+
int8_t can_inline;
13391340
} jl_compileropts_t;
13401341

13411342
extern DLLEXPORT jl_compileropts_t jl_compileropts;

ui/repl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static const char *opts =
8585
" --track-allocation={none|user|all}\n"
8686
" Count bytes allocated by each source line\n"
8787
" --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)\n"
88+
" --noinline Do not inline compiled functions (even those declared as @inline)\n"
8889
" -O, --optimize Run time-intensive code optimizations\n"
8990
" --int-literals={32|64} Select integer literal size independent of platform\n"
9091
" --dump-bitcode={yes|no} Dump bitcode for the system image (used with --build)\n";
@@ -106,6 +107,7 @@ void parse_opts(int *argcp, char ***argvp)
106107
{ "int-literals", required_argument, 0, 301 },
107108
{ "dump-bitcode", required_argument, 0, 302 },
108109
{ "compile", required_argument, 0, 303 },
110+
{ "noinline", no_argument, 0, 304 },
109111
{ 0, 0, 0, 0 }
110112
};
111113
int c;
@@ -198,6 +200,9 @@ void parse_opts(int *argcp, char ***argvp)
198200
exit(1);
199201
}
200202
break;
203+
case 304: /* noinline */
204+
jl_compileropts.can_inline = 0;
205+
break;
201206
default:
202207
ios_printf(ios_stderr, "julia: unhandled option -- %c\n", c);
203208
ios_printf(ios_stderr, "This is a bug, please report it.\n");

0 commit comments

Comments
 (0)