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

Turn @inbounds into a no-op for debug builds #5926

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ macro boundscheck(yesno,blk)
end

macro inbounds(blk)
if ccall(:jl_is_debugbuild, Any, ())::Bool
return :($(esc(blk)))
end
:(@boundscheck false $(esc(blk)))
end

Expand Down
2 changes: 1 addition & 1 deletion base/multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ end
# to be mutually reachable without a tunnel, as is often the case in a cluster.
function addprocs_internal(np::Integer;
tunnel=false, dir=JULIA_HOME,
exename=(ccall(:jl_is_debugbuild,Cint,())==0?"./julia-basic":"./julia-debug-basic"),
exename=(ccall(:jl_is_debugbuild,Any,())::Bool?"./julia-basic":"./julia-debug-basic"),
sshflags::Cmd=``, cman=LocalManager(), exeflags=``)

config={:dir=>dir, :exename=>exename, :exeflags=>`$exeflags --worker`, :tunnel=>tunnel, :sshflags=>sshflags}
Expand Down
2 changes: 1 addition & 1 deletion base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function versioninfo(io::IO=STDOUT, verbose::Bool=false)
if !isempty(GIT_VERSION_INFO.commit_short)
println(io, "Commit $(GIT_VERSION_INFO.commit_short) ($(GIT_VERSION_INFO.date_string))")
end
if ccall(:jl_is_debugbuild, Bool, ())
if ccall(:jl_is_debugbuild, Any, ())::Bool
println(io, "DEBUG build")
end
println(io, "Platform Info:")
Expand Down
2 changes: 1 addition & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ void jl_restore_system_image(char *fname)
#ifdef _OS_WINDOWS_
//XXX: the windows linker forces our system image to be
// linked against only one dll, I picked libjulia-release
if (jl_is_debugbuild()) build_mode = 1;
if (jl_is_debugbuild() == jl_true) build_mode = 1;
#endif
if (!build_mode) {
char *fname_shlib = (char*)alloca(strlen(fname));
Expand Down
6 changes: 3 additions & 3 deletions src/jlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ DLLEXPORT void jl_sigatomic_end(void)
JL_SIGATOMIC_END();
}

DLLEXPORT int jl_is_debugbuild(void) {
DLLEXPORT jl_value_t *jl_is_debugbuild(void) {
#ifdef DEBUG
return 1;
return jl_true;
#else
return 0;
return jl_false;
#endif
}

2 changes: 1 addition & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ DLLEXPORT int32_t jl_stat(const char *path, char *statbuf);
DLLEXPORT void NORETURN jl_exit(int status);
DLLEXPORT int jl_cpu_cores(void);
DLLEXPORT long jl_getpagesize(void);
DLLEXPORT int jl_is_debugbuild(void);
DLLEXPORT jl_value_t* jl_is_debugbuild(void);

// environment entries
DLLEXPORT jl_value_t *jl_environ(int i);
Expand Down