diff options
author | Brian Robbins <brianrob@microsoft.com> | 2018-08-10 10:22:40 -0700 |
---|---|---|
committer | Hyungju Lee <leee.lee@samsung.com> | 2019-07-15 12:52:53 +0900 |
commit | 38798cf1b663c45046fa58df9bf25a016e80d4a0 (patch) | |
tree | 2b782cfcf5db0a560b1a2daf71f4d4661f686618 /src/vm/eventpipebuffer.cpp | |
parent | 6dca04a8e7afc711221a3dc499d696a192ffb540 (diff) | |
download | coreclr-38798cf1b663c45046fa58df9bf25a016e80d4a0.tar.gz coreclr-38798cf1b663c45046fa58df9bf25a016e80d4a0.tar.bz2 coreclr-38798cf1b663c45046fa58df9bf25a016e80d4a0.zip |
Align the Contents of EventPipeBuffers (#19375)submit/tizen_5.0_base/20190715.050501submit/tizen_5.0_base/20190715.035802accepted/tizen/5.0/base/20190717.015232
Diffstat (limited to 'src/vm/eventpipebuffer.cpp')
-rw-r--r-- | src/vm/eventpipebuffer.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/vm/eventpipebuffer.cpp b/src/vm/eventpipebuffer.cpp index 16398714cd..e7489cd0cd 100644 --- a/src/vm/eventpipebuffer.cpp +++ b/src/vm/eventpipebuffer.cpp @@ -22,8 +22,8 @@ EventPipeBuffer::EventPipeBuffer(unsigned int bufferSize) m_pBuffer = new BYTE[bufferSize]; memset(m_pBuffer, 0, bufferSize); - m_pCurrent = m_pBuffer; m_pLimit = m_pBuffer + bufferSize; + m_pCurrent = GetNextAlignedAddress(m_pBuffer); m_mostRecentTimeStamp.QuadPart = 0; m_pLastPoppedEvent = NULL; @@ -55,6 +55,7 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve GC_NOTRIGGER; MODE_ANY; PRECONDITION(pThread != NULL); + PRECONDITION(((size_t)m_pCurrent % AlignmentSize) == 0); } CONTRACTL_END; @@ -110,7 +111,7 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve if(success) { // Advance the current pointer past the event. - m_pCurrent += eventSize; + m_pCurrent = GetNextAlignedAddress(m_pCurrent + eventSize); } return success; @@ -134,7 +135,7 @@ void EventPipeBuffer::Clear() CONTRACTL_END; memset(m_pBuffer, 0, (size_t)(m_pLimit - m_pBuffer)); - m_pCurrent = m_pBuffer; + m_pCurrent = GetNextAlignedAddress(m_pBuffer); m_mostRecentTimeStamp.QuadPart = 0; m_pLastPoppedEvent = NULL; } @@ -154,9 +155,10 @@ EventPipeEventInstance* EventPipeBuffer::GetNext(EventPipeEventInstance *pEvent, if(pEvent == NULL) { // If this buffer contains an event, select it. - if(m_pCurrent > m_pBuffer) + BYTE *pFirstAlignedInstance = GetNextAlignedAddress(m_pBuffer); + if(m_pCurrent > pFirstAlignedInstance) { - pNextInstance = (EventPipeEventInstance*)m_pBuffer; + pNextInstance = (EventPipeEventInstance*)pFirstAlignedInstance; } else { @@ -174,7 +176,7 @@ EventPipeEventInstance* EventPipeBuffer::GetNext(EventPipeEventInstance *pEvent, // We have a pointer within the bounds of the buffer. // Find the next event by skipping the current event with it's data payload immediately after the instance. - pNextInstance = (EventPipeEventInstance *)(pEvent->GetData() + pEvent->GetDataLength()); + pNextInstance = (EventPipeEventInstance *)GetNextAlignedAddress(const_cast<BYTE *>(pEvent->GetData() + pEvent->GetDataLength())); // Check to see if we've reached the end of the written portion of the buffer. if((BYTE*)pNextInstance >= m_pCurrent) @@ -245,14 +247,14 @@ bool EventPipeBuffer::EnsureConsistency() CONTRACTL_END; // Check to see if the buffer is empty. - if(m_pBuffer == m_pCurrent) + if(GetNextAlignedAddress(m_pBuffer) == m_pCurrent) { // Make sure that the buffer size is greater than zero. _ASSERTE(m_pBuffer != m_pLimit); } // Validate the contents of the filled portion of the buffer. - BYTE *ptr = m_pBuffer; + BYTE *ptr = GetNextAlignedAddress(m_pBuffer); while(ptr < m_pCurrent) { // Validate the event. @@ -263,7 +265,7 @@ bool EventPipeBuffer::EnsureConsistency() _ASSERTE((pInstance->GetData() != NULL && pInstance->GetDataLength() > 0) || (pInstance->GetData() == NULL && pInstance->GetDataLength() == 0)); // Skip the event. - ptr += sizeof(*pInstance) + pInstance->GetDataLength(); + ptr = GetNextAlignedAddress(ptr + sizeof(*pInstance) + pInstance->GetDataLength()); } // When we're done walking the filled portion of the buffer, |