Skip to content
Merged
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
22 changes: 22 additions & 0 deletions src/coreclr/vm/interpexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ extern "C" void SamplingProfiler_OnSamplepoint();
// for numeric_limits
#include <limits>
#include <functional>
#include <atomic>

// Compiler reordering barrier. Prevents the compiler from moving memory accesses across this
// point. It emits no instructions and provides no CPU or cross-thread ordering; use it only to
// order accesses with respect to asynchronous interruption on the SAME thread, such as a stack
// overflow or other hardware-exception handler.
Comment thread
BrzVlad marked this conversation as resolved.
static inline void CompilerBarrier()
{
std::atomic_signal_fence(std::memory_order_acq_rel);
}

struct InterpDispatchCacheEntry
{
Expand Down Expand Up @@ -3360,7 +3370,11 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
if (!pChildFrame)
{
pChildFrame = (InterpMethodContextFrame*)alloca(sizeof(InterpMethodContextFrame));
// We make sure that a new frame can't be seen with invalid ip/next when a stack
// overflow is triggered at a location outside of our control.
pChildFrame->ip = NULL;
pChildFrame->pNext = NULL;
CompilerBarrier();
pFrame->pNext = pChildFrame;
}
pChildFrame->ReInit(pFrame, targetIp, returnValueAddress, LOCAL_VAR_ADDR(callArgsOffset, int8_t));
Expand Down Expand Up @@ -3463,7 +3477,11 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
if (!pChildFrame)
{
pChildFrame = (InterpMethodContextFrame*)alloca(sizeof(InterpMethodContextFrame));
// We make sure that a new frame can't be seen with invalid ip/next when a stack
// overflow is triggered at a location outside of our control.
pChildFrame->ip = NULL;
pChildFrame->pNext = NULL;
CompilerBarrier();
pFrame->pNext = pChildFrame;
}
pChildFrame->ReInit(pFrame, targetIp, returnValueAddress, callArgsAddress);
Expand Down Expand Up @@ -4296,7 +4314,11 @@ do \
if (!pChildFrame)
{
pChildFrame = (InterpMethodContextFrame*)alloca(sizeof(InterpMethodContextFrame));
// We make sure that a new frame can't be seen with invalid ip/next when a stack
// overflow is triggered at a location outside of our control.
pChildFrame->ip = NULL;
pChildFrame->pNext = NULL;
CompilerBarrier();
pFrame->pNext = pChildFrame;
}
// Set the frame to the same values as the caller frame.
Expand Down
Loading