Skip to content

Commit

Permalink
Try to fix windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jun 6, 2016
1 parent 878d665 commit 7159938
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
29 changes: 29 additions & 0 deletions src/cgmemmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,28 @@ class RTDyldMemoryManagerJL : public SectionMemoryManager {
mapAddresses(Dyld, ro_alloc);
mapAddresses(Dyld, exe_alloc);
}
#ifdef _OS_WINDOWS_
template <typename Alloc>
void *lookupWriteAddressFor(void *rt_addr, Alloc *allocator)
{
for (auto &alloc: allocator->allocations) {
if (alloc.rt_addr == rt_addr) {
return alloc.wr_addr;
}
}
return nullptr;
}
void *lookupWriteAddressFor(void *rt_addr)
{
if (!ro_alloc)
return rt_addr;
if (void *ptr = lookupWriteAddressFor(rt_addr, ro_alloc))
return ptr;
if (void *ptr = lookupWriteAddressFor(rt_addr, exe_alloc))
return ptr;
return rt_addr;
}
#endif
};

uint8_t *RTDyldMemoryManagerJL::allocateCodeSection(uintptr_t Size,
Expand Down Expand Up @@ -883,6 +905,13 @@ void notifyObjectLoaded(RTDyldMemoryManager *memmgr,
}
#endif

#ifdef _OS_WINDOWS_
void *lookupWriteAddressFor(RTDyldMemoryManager *memmgr, void *rt_addr)
{
return ((RTDyldMemoryManagerJL*)memmgr)->lookupWriteAddressFor(rt_addr);
}
#endif

#else
typedef SectionMemoryManager RTDyldMemoryManagerJL;
#endif
Expand Down
12 changes: 8 additions & 4 deletions src/codegen_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ extern bool jl_dylib_DI_for_fptr(size_t pointer, const object::ObjectFile **obje
bool onlySysImg, bool *isSysImg, void **saddr, char **name, char **filename);

#ifdef USE_ORCJIT
extern JL_DLLEXPORT void ORCNotifyObjectEmitted(JITEventListener *Listener,
const object::ObjectFile &obj,
const object::ObjectFile &debugObj,
const RuntimeDyld::LoadedObjectInfo &L);
JL_DLLEXPORT void ORCNotifyObjectEmitted(JITEventListener *Listener,
const object::ObjectFile &obj,
const object::ObjectFile &debugObj,
const RuntimeDyld::LoadedObjectInfo &L,
RTDyldMemoryManager *memmgr);
#ifdef _OS_WINDOWS_
void *lookupWriteAddressFor(RTDyldMemoryManager *memmgr, void *rt_addr);
#endif
#endif
26 changes: 17 additions & 9 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,13 @@ class JuliaJITEventListener: public JITEventListener
virtual void NotifyObjectEmitted(const object::ObjectFile &obj,
const RuntimeDyld::LoadedObjectInfo &L)
{
return _NotifyObjectEmitted(obj,obj,L);
return _NotifyObjectEmitted(obj,obj,L,nullptr);
}

virtual void _NotifyObjectEmitted(const object::ObjectFile &obj,
const object::ObjectFile &debugObj,
const RuntimeDyld::LoadedObjectInfo &L)
const object::ObjectFile &debugObj,
const RuntimeDyld::LoadedObjectInfo &L,
RTDyldMemoryManager *memmgr)
#else
virtual void NotifyObjectEmitted(const ObjectImage &obj)
#endif
Expand Down Expand Up @@ -397,14 +398,20 @@ class JuliaJITEventListener: public JITEventListener
#endif
Addr -= SectionAddr - SectionLoadAddr;
*pAddr = (uint8_t*)Addr;
if (SectionLoadOffset != 1)
assert(SectionLoadOffset == SectionAddr - SectionLoadAddr);
else
SectionLoadOffset = SectionAddr - SectionLoadAddr;
if (SectionAddrCheck)
assert(SectionAddrCheck == SectionLoadAddr);
else
SectionAddrCheck = SectionLoadAddr;
#ifdef USE_ORCJIT
if (memmgr)
SectionAddr =
(uintptr_t)lookupWriteAddressFor(memmgr,
(void*)SectionLoadAddr);
#endif
if (SectionLoadOffset != 1)
assert(SectionLoadOffset == SectionAddr - SectionLoadAddr);
else
SectionLoadOffset = SectionAddr - SectionLoadAddr;
}
}
assert(catchjmp);
Expand Down Expand Up @@ -613,9 +620,10 @@ class JuliaJITEventListener: public JITEventListener
JL_DLLEXPORT void ORCNotifyObjectEmitted(JITEventListener *Listener,
const object::ObjectFile &obj,
const object::ObjectFile &debugObj,
const RuntimeDyld::LoadedObjectInfo &L)
const RuntimeDyld::LoadedObjectInfo &L,
RTDyldMemoryManager *memmgr)
{
((JuliaJITEventListener*)Listener)->_NotifyObjectEmitted(obj,debugObj,L);
((JuliaJITEventListener*)Listener)->_NotifyObjectEmitted(obj,debugObj,L,memmgr);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class JuliaOJIT {
ORCNotifyObjectEmitted(JuliaListener.get(),
*Object,
*SavedObjects.back().getBinary(),
*LO);
*LO, JIT.MemMgr);

// record all of the exported symbols defined in this object
// in the primary hash table for the enclosing JIT
Expand Down

0 comments on commit 7159938

Please sign in to comment.