Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
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
10 changes: 10 additions & 0 deletions src/Native/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ if(WIN32)
list(APPEND COMMON_RUNTIME_SOURCES
windows/PalRedhawkCommon.cpp
windows/PalRedhawkMinWin.cpp
../gc/windows/gcenv.windows.cpp
eventtrace.cpp
rheventtrace.cpp
)
Expand All @@ -149,6 +150,12 @@ if(WIN32)
else()

include_directories(unix)

include(CheckIncludeFiles)
include(CheckLibraryExists)

include(../gc/unix/configure.cmake)

if(NOT CLR_CMAKE_PLATFORM_ARCH_WASM)
include_directories(../libunwind/include)
else()
Expand All @@ -166,6 +173,9 @@ else()

list(APPEND COMMON_RUNTIME_SOURCES
unix/PalRedhawkUnix.cpp
../gc/unix/gcenv.unix.cpp
Copy link
Member

Choose a reason for hiding this comment

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

I have noticed that gcenv.unix.cpp has several TODOs.

In particular, GCToOSInterface::GetCacheSizePerLogicalCpu is important for a good GC performance. It was not implemented for CoreRT before your change either, so it is not a regression. I would be nice to get it fixed in future change.

../gc/unix/events.cpp
../gc/unix/cgroup.cpp
)

list(APPEND FULL_RUNTIME_SOURCES
Expand Down
2 changes: 1 addition & 1 deletion src/Native/Runtime/PalRedhawk.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ EventDataDescCreate(_Out_ EVENT_DATA_DESCRIPTOR * EventDataDescriptor, _In_opt_
}
#endif // _EVNTPROV_H_

extern GCSystemInfo g_SystemInfo;
extern GCSystemInfo g_RhSystemInfo;

#ifdef PLATFORM_UNIX
#define REDHAWK_PALIMPORT extern "C"
Expand Down
4 changes: 2 additions & 2 deletions src/Native/Runtime/RWLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void ReaderWriterLock::AcquireReadLockWorker()
if (TryAcquireReadLock())
return;

if (g_SystemInfo.dwNumberOfProcessors <= 1)
if (g_RhSystemInfo.dwNumberOfProcessors <= 1)
break;

// Delay by approximately 2*i clock cycles (Pentium III).
Expand Down Expand Up @@ -242,7 +242,7 @@ void ReaderWriterLock::AcquireWriteLock()
RedhawkGCInterface::WaitForGCCompletion();
}

if (g_SystemInfo.dwNumberOfProcessors <= 1)
if (g_RhSystemInfo.dwNumberOfProcessors <= 1)
{
break;
}
Expand Down
206 changes: 0 additions & 206 deletions src/Native/Runtime/gcrhenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1630,209 +1630,3 @@ ProfilingScanContext::ProfilingScanContext(BOOL fProfilerPinnedParam)
#endif
}
#endif // defined(FEATURE_EVENT_TRACE) && !defined(DACCESS_COMPILE)

#if !defined(DACCESS_COMPILE)
// An implementatino of GCEvent that delegates to
// a CLREvent, which in turn delegates to the PAL. This event
// is also host-aware.
class GCEvent::Impl
{
private:
CLREventStatic m_event;

public:
Impl() = default;

bool IsValid()
{
WRAPPER_NO_CONTRACT;

return !!m_event.IsValid();
}

void CloseEvent()
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
m_event.CloseEvent();
}

void Set()
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
m_event.Set();
}

void Reset()
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
m_event.Reset();
}

uint32_t Wait(uint32_t timeout, bool alertable)
{
WRAPPER_NO_CONTRACT;

assert(m_event.IsValid());
return m_event.Wait(timeout, alertable);
}

bool CreateAutoEvent(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

return !!m_event.CreateAutoEventNoThrow(initialState);
}

bool CreateManualEvent(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

return !!m_event.CreateManualEventNoThrow(initialState);
}

bool CreateOSAutoEvent(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

return !!m_event.CreateOSAutoEventNoThrow(initialState);
}

bool CreateOSManualEvent(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

return !!m_event.CreateOSManualEventNoThrow(initialState);
}
};

GCEvent::GCEvent()
: m_impl(nullptr)
{
}

void GCEvent::CloseEvent()
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
m_impl->CloseEvent();
}

void GCEvent::Set()
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
m_impl->Set();
}

void GCEvent::Reset()
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
m_impl->Reset();
}

uint32_t GCEvent::Wait(uint32_t timeout, bool alertable)
{
WRAPPER_NO_CONTRACT;

assert(m_impl != nullptr);
return m_impl->Wait(timeout, alertable);
}

bool GCEvent::CreateManualEventNoThrow(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
return false;
}

event->CreateManualEvent(initialState);
m_impl = event.Extract();
return true;
}

bool GCEvent::CreateAutoEventNoThrow(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
return false;
}

event->CreateAutoEvent(initialState);
m_impl = event.Extract();
return IsValid();
}

bool GCEvent::CreateOSAutoEventNoThrow(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
return false;
}

event->CreateOSAutoEvent(initialState);
m_impl = event.Extract();
return IsValid();
}

bool GCEvent::CreateOSManualEventNoThrow(bool initialState)
{
CONTRACTL{
NOTHROW;
GC_NOTRIGGER;
} CONTRACTL_END;

assert(m_impl == nullptr);
NewHolder<GCEvent::Impl> event = new (nothrow) GCEvent::Impl();
if (!event)
{
return false;
}

event->CreateOSManualEvent(initialState);
m_impl = event.Extract();
return IsValid();
}
#endif // !defined(DACCESS_COMPILE)
2 changes: 1 addition & 1 deletion src/Native/Runtime/threadstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void ThreadStore::SuspendAllThreads(bool waitForGCEvent, bool fireDebugEvent)

if (keepWaiting)
{
if (PalSwitchToThread() == 0 && g_SystemInfo.dwNumberOfProcessors > 1)
if (PalSwitchToThread() == 0 && g_RhSystemInfo.dwNumberOfProcessors > 1)
{
// No threads are scheduled on this processor. Perhaps we're waiting for a thread
// that's scheduled on another processor. If so, let's give it a little time
Expand Down
Loading