diff options
author | Brian Robbins <brianrob@microsoft.com> | 2018-08-10 10:22:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-10 10:22:40 -0700 |
commit | d6850f7830da3ced9e80948263fe821a3c7a3960 (patch) | |
tree | da5d6ed1836bf4238f2f6c95397b96056d36c9b5 /src/vm/eventpipebuffer.h | |
parent | 88690582f2e310c0277d6bd5a349bfac8858e46f (diff) | |
download | coreclr-d6850f7830da3ced9e80948263fe821a3c7a3960.tar.gz coreclr-d6850f7830da3ced9e80948263fe821a3c7a3960.tar.bz2 coreclr-d6850f7830da3ced9e80948263fe821a3c7a3960.zip |
Align the Contents of EventPipeBuffers (#19375)
Diffstat (limited to 'src/vm/eventpipebuffer.h')
-rw-r--r-- | src/vm/eventpipebuffer.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vm/eventpipebuffer.h b/src/vm/eventpipebuffer.h index 7d6287d93d..7b20883f73 100644 --- a/src/vm/eventpipebuffer.h +++ b/src/vm/eventpipebuffer.h @@ -20,6 +20,10 @@ class EventPipeBuffer private: + // Instances of EventPipeEventInstance in the buffer must be 8-byte aligned. + // It is OK for the data payloads to be unaligned because they are opaque blobs that are copied via memcpy. + const size_t AlignmentSize = 8; + // A pointer to the actual buffer. BYTE *m_pBuffer; @@ -72,6 +76,17 @@ private: m_pNextBuffer = pBuffer; } + FORCEINLINE BYTE* GetNextAlignedAddress(BYTE *pAddress) + { + LIMITED_METHOD_CONTRACT; + _ASSERTE(m_pBuffer <= pAddress && m_pLimit > pAddress); + + pAddress = (BYTE*)ALIGN_UP(pAddress, AlignmentSize); + + _ASSERTE((size_t)pAddress % AlignmentSize == 0); + return pAddress; + } + public: EventPipeBuffer(unsigned int bufferSize); |