Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
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{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 : uprobes.d
dtrace -h -s uprobes.d

# 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 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
15 changes: 15 additions & 0 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ using namespace llvm;
#include "jitlayers.h"
#include "julia_assert.h"

// Dtrace Timings
#include "uprobes.h"

RTDyldMemoryManager* createRTDyldMemoryManager(void);

static IntegerType *T_uint32;
Expand Down Expand Up @@ -336,9 +339,21 @@ void JuliaOJIT::DebugObjectRegistrar::operator()(RTDyldObjHandleT H,
static_cast<const RuntimeDyld::LoadedObjectInfo*>(&LOS));
}

struct CompileTiming {
CompileTiming(std::string name) :name(name) {
JULIA_COMPILE_START();
}
~CompileTiming() {
JULIA_COMPILE_END(name.c_str());
}
std::string name;
};

object::OwningBinary<object::ObjectFile> JuliaOJIT::CompilerT::operator()(Module &M)
{
// Instrument the time spent in this block for this method instance
CompileTiming _c(M.getName().str());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeffBezanson do you know where I can find the caller of this function in a context that would have the name of the method instance?

Copy link
Member Author

@NHDaly NHDaly Apr 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay, i put a breakpoint and got a stacktrace, and it gives me:

    frame #2: 0x00000001001b5f45 libjulia.1.2.dylib`JuliaOJIT::CompilerT::operator(this=0x0000000105039938, M=0x000000011131b280)(llvm::Module&) at jitlayers.cpp:355 [opt]
    frame #3: 0x00000001001b6c06 libjulia.1.2.dylib`llvm::orc::IRCompileLayer<llvm::orc::RTDyldObjectLinkingLayer, JuliaOJIT::CompilerT>::addModule(this=0x0000000105039930, M=<unavailable>, Resolver=std::__1::shared_ptr<llvm::JITSymbolResolver>::element_type @ 0x000000011131c810 strong=1 weak=1) at IRCompileLayer.h:57:48 [opt]
    frame #4: 0x00000001001b6ab7 libjulia.1.2.dylib`JuliaOJIT::addModule(this=<unavailable>, M=unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > @ 0x00007ffeefbfe630) at jitlayers.cpp:477:41 [opt]
    frame #5: 0x00000001001b73a3 libjulia.1.2.dylib`jl_finalize_function(llvm::StringRef) [inlined] jl_add_to_ee(m=unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> > @ scalar) at jitlayers.cpp:702:25 [opt]
    frame #6: 0x00000001001b738f libjulia.1.2.dylib`jl_finalize_function(F=<unavailable>) at jitlayers.cpp:710 [opt]
    frame #7: 0x00000001001596e9 libjulia.1.2.dylib`getAddressForFunction(fname=<unavailable>) at codegen.cpp:1338:5 [opt]
    frame #8: 0x0000000100159a77 libjulia.1.2.dylib`::jl_generate_fptr(output=0x000000010c443c10) at codegen.cpp:1432:39 [opt]
    frame #9: 0x00000001000ddb01 libjulia.1.2.dylib`jl_compile_method_internal(mi=0x000000010c524350, world=25987) at gf.c:1795:5 [opt]
    frame #10: 0x00000001000e02ab libjulia.1.2.dylib`jl_apply_generic(args=0x00007ffeefbfe790, nargs=2) at gf.c:2196:16 [opt]

But i'm surprised; isn't finalize happening after the optimization passes have finished? Why is the JL_TIMING(LLVM_OPT); block there?


JL_TIMING(LLVM_OPT);
jit.PM.run(M);
std::unique_ptr<MemoryBuffer> ObjBuffer(
Expand Down
2 changes: 1 addition & 1 deletion src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
// #define OBJPROFILE

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


// 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*);
};