Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*.so
*.dylib
*.dSYM
*.h.gen
*.jl.cov
*.jl.*.cov
*.jl.mem
Expand Down
13 changes: 13 additions & 0 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,19 @@ function which(m::Module, s::Symbol)
return binding_module(m, s)
end

"""
which(tt::TupleType)
"""
function which(tt::Type{T}) where T<:Tuple
m = ccall(:jl_gf_invoke_lookup, Any, (Any, UInt), tt, typemax(UInt))
if m === nothing
error("no unique matching method found for the specified signature")
end
return m.func::Method
end



# function reflection
"""
nameof(f::Function) -> Symbol
Expand Down
5 changes: 4 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ SRCS += anticodegen
LLVM_LIBS := support
endif

uprobes.h.gen : uprobes.d
dtrace -h -s uprobes.d -o uprobes.h.gen

# headers are used for dependency tracking, while public headers will be part of the dist
UV_HEADERS :=
HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_internal.h options.h timing.h)
HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h uprobes.h.gen julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_internal.h options.h timing.h)
PUBLIC_HEADERS := $(BUILDDIR)/julia_version.h $(wildcard $(SRCDIR)/support/*.h) $(addprefix $(SRCDIR)/,julia.h julia_assert.h julia_threads.h tls.h locks.h atomics.h julia_gcext.h)
ifeq ($(USE_SYSTEM_LIBUV),0)
UV_HEADERS += uv.h
Expand Down
46 changes: 45 additions & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
#endif
#include "julia_assert.h"

#ifdef ENABLE_TRACING_PROBES
// Dtrace Timings
#include "uprobes.h.gen"
#endif
void DTRACE__COMPILE_START(void);
void DTRACE__COMPILE_END(jl_method_instance_t *mi);

// The compilation signature is not used to cache the method if the number of overlapping methods is greater than this
#define MAX_UNSPECIALIZED_CONFLICTS 32

Expand Down Expand Up @@ -1792,9 +1799,46 @@ jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t
}
}

jl_generate_fptr(codeinst);
{
// Instrument the time spent in this block for this method instance
DTRACE__COMPILE_START();
jl_generate_fptr(codeinst);
DTRACE__COMPILE_END(mi);
}
return codeinst;
}
void DTRACE__COMPILE_START(void)
{
#ifdef ENABLE_TRACING_PROBES
if (JULIA_COMPILE_START_ENABLED()) {
JULIA_COMPILE_START();
}
#endif
}
void DTRACE__COMPILE_END(jl_method_instance_t *mi)
{
#ifdef ENABLE_TRACING_PROBES
if (JULIA_COMPILE_START_ENABLED()) {
if (jl_is_method(mi->def.method)) {
ios_t str_;
ios_mem(&str_, 10000);
JL_STREAM* str = (JL_STREAM*)&str_;

//jl_printf(str, "%s.%s, ", jl_symbol_name(mi->def.method->module->name), jl_symbol_name(mi->def.method->name));

//jl_static_show_func_sig(str, mi->specTypes);
jl_static_show(str, mi->specTypes);

str_.buf[str_.size] = 0;
JULIA_COMPILE_END(str_.buf);

ios_close(&str_);
} else {
JULIA_COMPILE_END("top-level scope");
}
}
#endif
}

JL_DLLEXPORT jl_value_t *jl_fptr_const_return(jl_code_instance_t *m, jl_value_t **args, uint32_t nargs)
{
Expand Down
7 changes: 5 additions & 2 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
// be considered untrusted, but can be helpful during development
// #define SEGV_EXCEPTION

// profiling options
// profiling options ----------------------------------------------------------

// GC_FINAL_STATS prints total GC stats at exit
// #define GC_FINAL_STATS
Expand All @@ -78,7 +78,10 @@
// #define OBJPROFILE

// Automatic Instrumenting Profiler
//#define ENABLE_TIMINGS
// #define ENABLE_TIMINGS

// Automatic Instrumenting Profiler
#define ENABLE_TRACING_PROBES


// method dispatch profiling --------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/uprobes.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
provider julia {
probe compile__start();
probe compile__end(char*);
};