Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --noinline startup option #9354

Merged
merged 1 commit into from
Dec 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ end

inference_stack = EmptyCallStack()

# Julia compiler options struct (see jl_compileropts_t in src/julia.h)
immutable JLCompilerOpts
julia_home::Ptr{Cchar}
julia_bin::Ptr{Cchar}
build_path::Ptr{Cchar}
image_file::Ptr{Cchar}
cpu_target::Ptr{Cchar}
code_coverage::Int8
malloc_log::Int8
check_bounds::Int8
dumpbitcode::Int8
int_literals::Cint
compile_enabled::Int8
opt_level::Int8
depwarn::Int8
can_inline::Int8
end

compileropts() = unsafe_load(cglobal(:jl_compileropts, JLCompilerOpts))

function is_static_parameter(sv::StaticVarInfo, s::Symbol)
sp = sv.sp
for i=1:2:length(sp)
Expand Down Expand Up @@ -1554,9 +1574,11 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)

if !rec
@assert fulltree.args[3].head === :body
fulltree.args[3] = inlining_pass(fulltree.args[3], sv, fulltree)[1]
# inlining can add variables
sv.vars = append_any(f_argnames(fulltree), fulltree.args[2][1])
if compileropts().can_inline == 1
fulltree.args[3] = inlining_pass(fulltree.args[3], sv, fulltree)[1]
# inlining can add variables
sv.vars = append_any(f_argnames(fulltree), fulltree.args[2][1])
end
tuple_elim_pass(fulltree)
tupleref_elim_pass(fulltree.args[3], sv)
linfo.inferred = true
Expand Down
19 changes: 0 additions & 19 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,25 +242,6 @@ end
warn(err::Exception; prefix="ERROR: ", kw...) =
warn(sprint(io->showerror(io,err)), prefix=prefix; kw...)

# Julia compiler options struct (see jl_compileropts_t in src/julia.h)
immutable JLCompilerOpts
julia_home::Ptr{Cchar}
julia_bin::Ptr{Cchar}
build_path::Ptr{Cchar}
image_file::Ptr{Cchar}
cpu_target::Ptr{Cchar}
code_coverage::Int8
malloc_log::Int8
check_bounds::Int8
dumpbitcode::Int8
int_literals::Cint
compile_enabled::Int8
opt_level::Int8
depwarn::Int8
end

compileropts() = unsafe_load(cglobal(:jl_compileropts, JLCompilerOpts))

function julia_cmd(julia=joinpath(JULIA_HOME, "julia"))
opts = compileropts()
cpu_target = bytestring(opts.cpu_target)
Expand Down
1 change: 1 addition & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jl_compileropts_t jl_compileropts = { NULL, // julia_home
JL_COMPILEROPT_COMPILE_DEFAULT,
0, // opt_level
1, // depwarn
1 // can_inline
};

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

extern DLLEXPORT jl_compileropts_t jl_compileropts;
Expand Down
12 changes: 12 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"
" --inline={yes|no} Control whether inlining is permitted (even for functions 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 @@ -95,6 +96,7 @@ void parse_opts(int *argcp, char ***argvp)
{ "dump-bitcode", required_argument, 0, 302 },
{ "compile", required_argument, 0, 303 },
{ "depwarn", required_argument, 0, 304 },
{ "inline", required_argument, 0, 305 },
{ 0, 0, 0, 0 }
};
int c;
Expand Down Expand Up @@ -198,6 +200,16 @@ void parse_opts(int *argcp, char ***argvp)
exit(1);
}
break;
case 305: /* inline */
if (!strcmp(optarg,"yes"))
jl_compileropts.can_inline = 1;
else if (!strcmp(optarg,"no"))
jl_compileropts.can_inline = 0;
else {
ios_printf(ios_stderr, "julia: invalid argument to --inline (%s)\n", optarg);
exit(1);
}
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