Skip to content

Commit

Permalink
xrCPU_Pipe: __asm pause replaced by _mm_pause.
Browse files Browse the repository at this point in the history
bugtrap: added __asm code replacement for x64.
  • Loading branch information
imdex committed Apr 16, 2017
1 parent 7b9b838 commit e5e71c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions code/3rd-party/bugtrap/SymEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ BOOL CSymEngine::InitStackTrace(LPSTACKFRAME64 pStackFrame)
if (! GetThreadContext(hThread, &m_StartExceptionContext))
return FALSE;
*/
#ifdef _M_IX86
__asm
{
push eax
Expand Down Expand Up @@ -1222,6 +1223,11 @@ BOOL CSymEngine::InitStackTrace(LPSTACKFRAME64 pStackFrame)
pop edi
pop eax
}
#elif defined(_M_IX64)
RtlCaptureContext(&m_StartExceptionContext);
#else
# error "Unsupported architecture"
#endif
}

ZeroMemory(pStackFrame, sizeof(*pStackFrame));
Expand Down Expand Up @@ -2715,10 +2721,16 @@ BOOL CSymEngine::GetNextStackTraceEntry(CStackTraceEntry& rEntry)
if (hModule != NULL)
GetModuleFileName(hModule, rEntry.m_szModule, countof(rEntry.m_szModule));
DWORD64 dwExceptionAddress = m_swContext.m_stFrame.AddrPC.Offset;
WORD wExceptionSegment; // wExceptionSegment = m_swContext.m_stFrame.AddrPC.Segment;
__asm { mov word ptr [wExceptionSegment], cs }
WORD wExceptionSegment = m_swContext.m_stFrame.AddrPC.Segment;
#ifdef _M_IX86
_stprintf_s(rEntry.m_szAddress, countof(rEntry.m_szAddress),
_T("%04lX:%08llu"), wExceptionSegment, dwExceptionAddress);
_T("%04lX:%08I64X"), wExceptionSegment, dwExceptionAddress);
#elif defined(_M_IX64)
_stprintf_s(rEntry.m_szAddress, countof(rEntry.m_szAddress),
_T("%04lX:%016lX"), wExceptionSegment, dwExceptionAddress);
#else
# error "Unsupported architecture"
#endif

BYTE arrSymBuffer[512];
ZeroMemory(arrSymBuffer, sizeof(arrSymBuffer));
Expand Down
4 changes: 2 additions & 2 deletions code/engine/xrCPU_Pipe/ttapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DWORD ttapi_Init( processor_info* ID )
for ( i = 0 ; i < dwNumIter ; ++i ) {
if ( dwDummy == 0 )
goto process1;
__asm pause;
_mm_pause();
}
process1:
QueryPerformanceCounter( &liEnd );
Expand Down Expand Up @@ -244,7 +244,7 @@ VOID ttapi_RunAllWorkers()
// Waiting task queue to become empty
//Start = __rdtsc();
while( ttapi_queue_size.size )
__asm pause;
_mm_pause();
//Stop = __rdtsc();
//Msg( "Wait: %u ticks" , Stop - Start );

Expand Down

0 comments on commit e5e71c9

Please sign in to comment.