Procházet zdrojové kódy

Fix __declspec(guard(overflow)) for linux build

It is only available in VC compiler
Curtis Man před 9 roky
rodič
revize
ea02779aab

+ 3 - 3
lib/Backend/EmitBuffer.h

@@ -37,7 +37,7 @@ public:
     void Decommit();
     void Clear();
 
-    EmitBufferAllocation* AllocateBuffer(__declspec(guard(overflow)) __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, ushort pdataCount = 0, ushort xdataSize = 0, bool canAllocInPreReservedHeapPageSegment = false, bool isAnyJittedCode = false);
+    EmitBufferAllocation* AllocateBuffer(DECLSPEC_GUARD_OVERFLOW __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, ushort pdataCount = 0, ushort xdataSize = 0, bool canAllocInPreReservedHeapPageSegment = false, bool isAnyJittedCode = false);
     bool CommitBuffer(EmitBufferAllocation* allocation, __out_bcount(bytes) BYTE* destBuffer, __in size_t bytes, __in_bcount(bytes) const BYTE* sourceBuffer, __in DWORD alignPad = 0);
     bool ProtectBufferWithExecuteReadWriteForInterpreter(EmitBufferAllocation* allocation);
     bool CommitReadWriteBufferForInterpreter(EmitBufferAllocation* allocation, _In_reads_bytes_(bufferSize) BYTE* pBuffer, _In_ size_t bufferSize);
@@ -72,8 +72,8 @@ private:
     ArenaAllocator * allocator;
     Js::ScriptContext * scriptContext;
 
-    EmitBufferAllocation * NewAllocation(__declspec(guard(overflow)) size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode);
-    EmitBufferAllocation* GetBuffer(EmitBufferAllocation *allocation, __declspec(guard(overflow)) __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer);
+    EmitBufferAllocation * NewAllocation(DECLSPEC_GUARD_OVERFLOW size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode);
+    EmitBufferAllocation* GetBuffer(EmitBufferAllocation *allocation, DECLSPEC_GUARD_OVERFLOW __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer);
 
     bool FinalizeAllocation(EmitBufferAllocation *allocation);
     CustomHeap::Heap allocationHeap;

+ 1 - 1
lib/Backend/GlobHashTable.h

@@ -55,7 +55,7 @@ public:
     SListBase<HashBucket> * table;
 
 public:
-    static ValueHashTable * New(JitArenaAllocator *allocator, __declspec(guard(overflow)) uint tableSize)
+    static ValueHashTable * New(JitArenaAllocator *allocator, DECLSPEC_GUARD_OVERFLOW uint tableSize)
     {
         return AllocatorNewPlus(JitArenaAllocator, allocator, (tableSize*sizeof(SListBase<HashBucket>)), ValueHashTable, allocator, tableSize);
     }

+ 2 - 2
lib/Backend/NativeCodeData.h

@@ -36,8 +36,8 @@ public:
         Allocator();
         ~Allocator();
 
-        char * Alloc(__declspec(guard(overflow)) size_t requestedBytes);
-        char * AllocZero(__declspec(guard(overflow)) size_t requestedBytes);
+        char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
+        char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
         NativeCodeData * Finalize();
         void Free(void * buffer, size_t byteSize);
 

+ 7 - 0
lib/Common/CommonPal.h

@@ -27,6 +27,13 @@
     #define __forceinline inline
 #endif
 
+// Only VC compiler support overflow guard
+#if defined(__GNUC__) || defined(__clang__)
+#define DECLSPEC_GUARD_OVERFLOW
+#else // Windows
+#define DECLSPEC_GUARD_OVERFLOW __declspec(guard(overflow))
+#endif
+
 #ifdef __clang__
 #define CLANG_WNO_BEGIN_(x) \
     _Pragma("clang diagnostic push")\

+ 2 - 2
lib/Common/Core/AllocSizeMath.h

@@ -10,7 +10,7 @@ public:
     // Works for both 32bit and 64bit size_t arithmetic. It's also pretty
     // optimal in the cases where either left or right or both are small, compile-
     // time constants.
-    static size_t Add(__declspec(guard(overflow)) size_t left, __declspec(guard(overflow)) size_t right)
+    static size_t Add(DECLSPEC_GUARD_OVERFLOW size_t left, DECLSPEC_GUARD_OVERFLOW size_t right)
     {
         size_t allocSize = left + right;
         if (allocSize < left)
@@ -28,7 +28,7 @@ public:
     }
 
     // Optimized for right being a constant power of 2...
-    static size_t Mul(__declspec(guard(overflow)) size_t left, __declspec(guard(overflow)) size_t right)
+    static size_t Mul(DECLSPEC_GUARD_OVERFLOW size_t left, DECLSPEC_GUARD_OVERFLOW size_t right)
     {
         size_t allocSize = left * right;
         if (left != (allocSize / right))

+ 3 - 3
lib/Common/DataStructures/BaseDictionary.h

@@ -1043,7 +1043,7 @@ namespace JsUtil
             entries = newEntries;
         }
 
-        __ecount(bucketCount) int *AllocateBuckets(__declspec(guard(overflow)) const uint bucketCount)
+        __ecount(bucketCount) int *AllocateBuckets(DECLSPEC_GUARD_OVERFLOW const uint bucketCount)
         {
             return
                 AllocateArray<AllocatorType, int, false>(
@@ -1052,7 +1052,7 @@ namespace JsUtil
                     bucketCount);
         }
 
-        __ecount(size) EntryType * AllocateEntries(__declspec(guard(overflow)) int size, const bool zeroAllocate = true)
+        __ecount(size) EntryType * AllocateEntries(DECLSPEC_GUARD_OVERFLOW int size, const bool zeroAllocate = true)
         {
             // Note that the choice of leaf/non-leaf node is decided for the EntryType on the basis of TValue. By default, if
             // TValue is a pointer, a non-leaf allocation is done. This behavior can be overridden by specializing
@@ -1080,7 +1080,7 @@ namespace JsUtil
             AllocatorFree(alloc, EntryAllocatorFuncType::GetFreeFunc(), entries, size * sizeof(EntryType));
         }
 
-        void Allocate(__deref_out_ecount(bucketCount) int** ppBuckets, __deref_out_ecount(size) EntryType** ppEntries, __declspec(guard(overflow)) uint bucketCount, __declspec(guard(overflow)) int size)
+        void Allocate(__deref_out_ecount(bucketCount) int** ppBuckets, __deref_out_ecount(size) EntryType** ppEntries, DECLSPEC_GUARD_OVERFLOW uint bucketCount, DECLSPEC_GUARD_OVERFLOW int size)
         {
             int *const buckets = AllocateBuckets(bucketCount);
             Assert(buckets); // no-throw allocators are currently not supported

+ 4 - 4
lib/Common/DataStructures/FixedBitVector.h

@@ -35,10 +35,10 @@ public:
     static  BVFixed *       New(TAllocator* alloc, BVFixed * initBv);
 
     template <typename TAllocator>
-    static  BVFixed *       New(__declspec(guard(overflow)) BVIndex length, TAllocator* alloc, bool initialSet = false);
+    static  BVFixed *       New(DECLSPEC_GUARD_OVERFLOW BVIndex length, TAllocator* alloc, bool initialSet = false);
 
     template <typename TAllocator>
-    static  BVFixed *       NewNoThrow(__declspec(guard(overflow)) BVIndex length, TAllocator* alloc, bool initialSet = false);
+    static  BVFixed *       NewNoThrow(DECLSPEC_GUARD_OVERFLOW BVIndex length, TAllocator* alloc, bool initialSet = false);
 
     template <typename TAllocator>
     void                    Delete(TAllocator * alloc);
@@ -152,14 +152,14 @@ BVFixed * BVFixed::New(TAllocator * alloc, BVFixed * initBv)
 }
 
 template <typename TAllocator>
-BVFixed * BVFixed::New(__declspec(guard(overflow)) BVIndex length, TAllocator * alloc, bool initialSet)
+BVFixed * BVFixed::New(DECLSPEC_GUARD_OVERFLOW BVIndex length, TAllocator * alloc, bool initialSet)
 {
     BVFixed *result = AllocatorNewPlus(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, length, initialSet);
     return result;
 }
 
 template <typename TAllocator>
-BVFixed * BVFixed::NewNoThrow(__declspec(guard(overflow)) BVIndex length, TAllocator * alloc, bool initialSet)
+BVFixed * BVFixed::NewNoThrow(DECLSPEC_GUARD_OVERFLOW BVIndex length, TAllocator * alloc, bool initialSet)
 {
     BVFixed *result = AllocatorNewNoThrowPlus(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, length, initialSet);
     return result;

+ 2 - 2
lib/Common/DataStructures/HashTable.h

@@ -33,7 +33,7 @@ public:
     SListBase<Bucket<T>> *  table;
 
 public:
-    static HashTable<T, TAllocator> * New(TAllocator *allocator, __declspec(guard(overflow)) uint tableSize)
+    static HashTable<T, TAllocator> * New(TAllocator *allocator, DECLSPEC_GUARD_OVERFLOW uint tableSize)
     {
         return AllocatorNewPlus(TAllocator, allocator, (tableSize*sizeof(SListBase<Bucket<T>>)), HashTable, allocator, tableSize);
     }
@@ -382,7 +382,7 @@ public:
 #endif
 
 protected:
-    HashTable(TAllocator * allocator, __declspec(guard(overflow)) uint tableSize) : alloc(allocator), tableSize(tableSize)
+    HashTable(TAllocator * allocator, DECLSPEC_GUARD_OVERFLOW uint tableSize) : alloc(allocator), tableSize(tableSize)
     {
         Init();
 #if PROFILE_DICTIONARY

+ 4 - 4
lib/Common/DataStructures/InternalString.h

@@ -14,10 +14,10 @@ namespace Js
 
     public:
         InternalString() : m_charLength(0), m_content(NULL), m_offset(0) { };
-        InternalString(const char16* content, __declspec(guard(overflow)) charcount_t charLength, unsigned char offset = 0);
-        static InternalString* New(ArenaAllocator* alloc, const char16* content, __declspec(guard(overflow)) charcount_t length);
-        static InternalString* New(Recycler* recycler, const char16* content, __declspec(guard(overflow)) charcount_t length);
-        static InternalString* NewNoCopy(ArenaAllocator* alloc, const char16* content, __declspec(guard(overflow)) charcount_t length);
+        InternalString(const char16* content, DECLSPEC_GUARD_OVERFLOW charcount_t charLength, unsigned char offset = 0);
+        static InternalString* New(ArenaAllocator* alloc, const char16* content, DECLSPEC_GUARD_OVERFLOW charcount_t length);
+        static InternalString* New(Recycler* recycler, const char16* content, DECLSPEC_GUARD_OVERFLOW charcount_t length);
+        static InternalString* NewNoCopy(ArenaAllocator* alloc, const char16* content, DECLSPEC_GUARD_OVERFLOW charcount_t length);
 
         inline charcount_t GetLength() const
         {

+ 3 - 3
lib/Common/DataStructures/List.h

@@ -64,7 +64,7 @@ namespace JsUtil
         }
 
         template<class TAllocator>
-        static ReadOnlyList * New(TAllocator* alloc, __in_ecount(count) T* buffer, __declspec(guard(overflow)) int count)
+        static ReadOnlyList * New(TAllocator* alloc, __in_ecount(count) T* buffer, DECLSPEC_GUARD_OVERFLOW int count)
         {
             return AllocatorNew(TAllocator, alloc, ReadOnlyList, buffer, count, alloc);
         }
@@ -213,7 +213,7 @@ namespace JsUtil
         int increment;
         TRemovePolicyType removePolicy;
 
-        T * AllocArray(__declspec(guard(overflow)) int size) { return AllocatorNewArrayBaseFuncPtr(TAllocator, this->alloc, AllocatorInfo::GetAllocFunc(), T, size); }
+        T * AllocArray(DECLSPEC_GUARD_OVERFLOW int size) { return AllocatorNewArrayBaseFuncPtr(TAllocator, this->alloc, AllocatorInfo::GetAllocFunc(), T, size); }
         void FreeArray(T * oldBuffer, int oldBufferSize) { AllocatorFree(this->alloc, AllocatorInfo::GetFreeFunc(), oldBuffer, oldBufferSize);  }
 
         PREVENT_COPY(List); // Disable copy constructor and operator=
@@ -234,7 +234,7 @@ namespace JsUtil
             EnsureArray(0);
         }
 
-        void EnsureArray(__declspec(guard(overflow)) int32 requiredCapacity)
+        void EnsureArray(DECLSPEC_GUARD_OVERFLOW int32 requiredCapacity)
         {
             if (this->buffer == nullptr)
             {

+ 1 - 1
lib/Common/DataStructures/MruDictionary.h

@@ -111,7 +111,7 @@ namespace JsUtil
             Assert(mruListCapacity > 0);
         }
 
-        static MruDictionary *New(TAllocator *const allocator, __declspec(guard(overflow)) const int mruListCapacity)
+        static MruDictionary *New(TAllocator *const allocator, DECLSPEC_GUARD_OVERFLOW const int mruListCapacity)
         {
             return AllocatorNew(TAllocator, allocator, MruDictionary, allocator, mruListCapacity);
         }

+ 1 - 1
lib/Common/Memory/AllocationPolicyManager.h

@@ -63,7 +63,7 @@ public:
         memoryLimit = newLimit;
     }
 
-    bool RequestAlloc(__declspec(guard(overflow)) size_t byteCount)
+    bool RequestAlloc(DECLSPEC_GUARD_OVERFLOW size_t byteCount)
     {
         if (supportConcurrency)
         {

+ 9 - 9
lib/Common/Memory/Allocator.h

@@ -270,7 +270,7 @@ void DeleteObject(typename AllocatorInfo<TAllocator, T>::AllocatorType * allocat
 #define ZERO_LENGTH_ARRAY (void *)sizeof(void *)
 template <typename TAllocator, typename T, bool nothrow>
 _When_(nothrow, _Ret_writes_to_maybenull_(count, 0)) _When_(!nothrow, _Ret_writes_to_(count, 0))
-inline T * AllocateArray(TAllocator * allocator, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t count)
+inline T * AllocateArray(TAllocator * allocator, char * (TAllocator::*AllocFunc)(size_t), DECLSPEC_GUARD_OVERFLOW size_t count)
 {
     if (count == 0 && TAllocator::FakeZeroLengthArray)
     {
@@ -349,7 +349,7 @@ void AssertValue(void * mem, T value, uint byteCount)
 _Ret_notnull_
 inline void * __cdecl
 operator new(
-__declspec(guard(overflow)) size_t byteSize,
+DECLSPEC_GUARD_OVERFLOW size_t byteSize,
 _In_ void * previousAllocation) throw()
 {
     return previousAllocation;
@@ -372,7 +372,7 @@ void * previousAllocation               // Previously allocated memory
 //----------------------------------------
 template <typename TAllocator>
 _Ret_notnull_ void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
 {
     AssertCanHandleOutOfMemory();
     Assert(byteSize != 0);
@@ -383,7 +383,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, ch
 
 template <typename TAllocator>
 _Ret_notnull_ inline void * __cdecl
-operator new[](__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
+operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
 {
     AssertCanHandleOutOfMemory();
     Assert(byteSize != 0 || !TAllocator::FakeZeroLengthArray);
@@ -394,7 +394,7 @@ operator new[](__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc,
 
 template <typename TAllocator>
 _Ret_notnull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t), DECLSPEC_GUARD_OVERFLOW size_t plusSize)
 {
     AssertCanHandleOutOfMemory();
     Assert(byteSize != 0);
@@ -411,7 +411,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, ch
 //----------------------------------------
 template <typename TAllocator>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
 {
     Assert(nothrow);
     Assert(byteSize != 0);
@@ -422,7 +422,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bo
 
 template <typename TAllocator>
 _Ret_maybenull_ inline void * __cdecl
-operator new[](__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
+operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
 {
     Assert(nothrow);
     Assert(byteSize != 0 || !TAllocator::FakeZeroLengthArray);
@@ -433,7 +433,7 @@ operator new[](__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc,
 
 template <typename TAllocator>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), DECLSPEC_GUARD_OVERFLOW size_t plusSize)
 {
     Assert(nothrow);
     Assert(byteSize != 0);
@@ -447,7 +447,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bo
 
 template <typename TAllocator>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize, bool prefix)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), DECLSPEC_GUARD_OVERFLOW size_t plusSize, bool prefix)
 {
     Assert(nothrow);
     Assert(prefix);

+ 27 - 27
lib/Common/Memory/ArenaAllocator.h

@@ -224,9 +224,9 @@ public:
 
     static size_t GetAlignedSize(size_t size) { return AllocSizeMath::Align(size, ArenaAllocatorBase::ObjectAlignment); }
 
-    char * AllocInternal(__declspec(guard(overflow)) size_t requestedBytes);
+    char * AllocInternal(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
 
-    char* Realloc(void* buffer, __declspec(guard(overflow)) size_t existingBytes, __declspec(guard(overflow)) size_t requestedBytes);
+    char* Realloc(void* buffer, DECLSPEC_GUARD_OVERFLOW size_t existingBytes, DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
     void Free(void * buffer, size_t byteSize);
 #ifdef TRACK_ALLOC
     // Doesn't support tracking information, dummy implementation
@@ -235,8 +235,8 @@ public:
 #endif
 
 protected:
-    char * RealAlloc(__declspec(guard(overflow)) size_t nbytes);
-    __forceinline char * RealAllocInlined(__declspec(guard(overflow)) size_t nbytes);
+    char * RealAlloc(DECLSPEC_GUARD_OVERFLOW size_t nbytes);
+    __forceinline char * RealAllocInlined(DECLSPEC_GUARD_OVERFLOW size_t nbytes);
 private:
 #ifdef PROFILE_MEM
     void LogBegin();
@@ -250,11 +250,11 @@ private:
     static size_t Size(BigBlock * blockList);
     void FullReset();
     void SetCacheBlock(BigBlock * cacheBlock);
-    template <bool DoRecoverMemory> char * AllocFromHeap(__declspec(guard(overflow)) size_t nbytes);
+    template <bool DoRecoverMemory> char * AllocFromHeap(DECLSPEC_GUARD_OVERFLOW size_t nbytes);
     void ReleaseMemory();
     void ReleasePageMemory();
     void ReleaseHeapMemory();
-    char * SnailAlloc(__declspec(guard(overflow)) size_t nbytes);
+    char * SnailAlloc(DECLSPEC_GUARD_OVERFLOW size_t nbytes);
     BigBlock * AddBigBlock(size_t pages);
 
 #ifdef ARENA_ALLOCATOR_FREE_LIST_SIZE
@@ -289,7 +289,7 @@ public:
     static const unsigned char DbgFreeMemFill = DbgMemFill;
 #endif
     static void * New(ArenaAllocatorBase<InPlaceFreeListPolicy> * allocator);
-    static void * Allocate(void * policy, __declspec(guard(overflow)) size_t size);
+    static void * Allocate(void * policy, DECLSPEC_GUARD_OVERFLOW size_t size);
     static void * Free(void * policy, void * object, size_t size);
     static void * Reset(void * policy);
     static void PrepareFreeObject(__out_bcount(size) void * object, _In_ size_t size)
@@ -341,7 +341,7 @@ public:
     static const char DbgFreeMemFill = 0x0;
 #endif
     static void * New(ArenaAllocatorBase<StandAloneFreeListPolicy> * allocator);
-    static void * Allocate(void * policy, __declspec(guard(overflow)) size_t size);
+    static void * Allocate(void * policy, DECLSPEC_GUARD_OVERFLOW size_t size);
     static void * Free(void * policy, void * object, size_t size);
     static void * Reset(void * policy);
     static void PrepareFreeObject(_Out_writes_bytes_all_(size) void * object, _In_ size_t size)
@@ -377,12 +377,12 @@ public:
     }
 
     __forceinline
-    char * Alloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return AllocInternal(requestedBytes);
     }
 
-    char * AllocZero(__declspec(guard(overflow)) size_t nbytes)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t nbytes)
     {
         char * buffer = Alloc(nbytes);
         memset(buffer, 0, nbytes);
@@ -393,13 +393,13 @@ public:
         return buffer;
     }
 
-    char * AllocLeaf(__declspec(guard(overflow)) size_t requestedBytes)
+    char * AllocLeaf(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         // Leaf allocation is not meaningful here, but needed by Allocator-templatized classes that may call one of the Leaf versions of AllocatorNew
         return Alloc(requestedBytes);
     }
 
-    char * NoThrowAlloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * NoThrowAlloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         void (*tempOutOfMemoryFunc)() = outOfMemoryFunc;
         outOfMemoryFunc = nullptr;
@@ -408,7 +408,7 @@ public:
         return buffer;
     }
 
-    char * NoThrowAllocZero(__declspec(guard(overflow)) size_t requestedBytes)
+    char * NoThrowAllocZero(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         char * buffer = NoThrowAlloc(requestedBytes);
         if (buffer != nullptr)
@@ -418,7 +418,7 @@ public:
         return buffer;
     }
 
-    char * NoThrowNoRecoveryAlloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * NoThrowNoRecoveryAlloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         void (*tempRecoverMemoryFunc)() = recoverMemoryFunc;
         recoverMemoryFunc = nullptr;
@@ -427,7 +427,7 @@ public:
         return buffer;
     }
 
-    char * NoThrowNoRecoveryAllocZero(__declspec(guard(overflow)) size_t requestedBytes)
+    char * NoThrowNoRecoveryAllocZero(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         char * buffer = NoThrowNoRecoveryAlloc(requestedBytes);
         if (buffer != nullptr)
@@ -453,7 +453,7 @@ public:
     {
     }
 
-    char * Alloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         // Fast path
         if (sizeof(BVSparseNode) == requestedBytes)
@@ -492,22 +492,22 @@ public:
         return ArenaAllocator::Free(buffer, byteSize);
     }
 
-    char * AllocZero(__declspec(guard(overflow)) size_t nbytes)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t nbytes)
     {
         return ArenaAllocator::AllocZero(nbytes);
     }
 
-    char * AllocLeaf(__declspec(guard(overflow)) size_t requestedBytes)
+    char * AllocLeaf(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return ArenaAllocator::AllocLeaf(requestedBytes);
     }
 
-    char * NoThrowAlloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * NoThrowAlloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return ArenaAllocator::NoThrowAlloc(requestedBytes);
     }
 
-    char * NoThrowAllocZero(__declspec(guard(overflow)) size_t requestedBytes)
+    char * NoThrowAllocZero(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return ArenaAllocator::NoThrowAllocZero(requestedBytes);
     }
@@ -593,7 +593,7 @@ public:
     static const unsigned char DbgFreeMemFill = DbgMemFill;
 #endif
     static void * New(ArenaAllocatorBase<InlineCacheAllocatorTraits> * allocator);
-    static void * Allocate(void * policy, __declspec(guard(overflow)) size_t size);
+    static void * Allocate(void * policy, DECLSPEC_GUARD_OVERFLOW size_t size);
     static void * Free(void * policy, void * object, size_t size);
     static void * Reset(void * policy);
     static void Release(void * policy);
@@ -649,12 +649,12 @@ public:
 #endif
     {}
 
-    char * Alloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return AllocInternal(requestedBytes);
     }
 
-    char * AllocZero(__declspec(guard(overflow)) size_t nbytes)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t nbytes)
     {
         char * buffer = Alloc(nbytes);
         memset(buffer, 0, nbytes);
@@ -705,12 +705,12 @@ public:
     InlineCacheAllocator(__in LPCWSTR name, PageAllocator * pageAllocator, void(*outOfMemoryFunc)()) :
         ArenaAllocatorBase<InlineCacheAllocatorTraits>(name, pageAllocator, outOfMemoryFunc) {}
 
-    char * Alloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return AllocInternal(requestedBytes);
     }
 
-    char * AllocZero(__declspec(guard(overflow)) size_t nbytes)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t nbytes)
     {
         char * buffer = Alloc(nbytes);
         memset(buffer, 0, nbytes);
@@ -770,12 +770,12 @@ public:
     IsInstInlineCacheAllocator(__in LPCWSTR name, PageAllocator * pageAllocator, void(*outOfMemoryFunc)()) :
         ArenaAllocatorBase<IsInstInlineCacheAllocatorTraits>(name, pageAllocator, outOfMemoryFunc) {}
 
-    char * Alloc(__declspec(guard(overflow)) size_t requestedBytes)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes)
     {
         return AllocInternal(requestedBytes);
     }
 
-    char * AllocZero(__declspec(guard(overflow)) size_t nbytes)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t nbytes)
     {
         char * buffer = Alloc(nbytes);
         memset(buffer, 0, nbytes);

+ 9 - 9
lib/Common/Memory/CustomHeap.h

@@ -32,7 +32,7 @@ enum BucketId
     NumBuckets
 };
 
-BucketId GetBucketForSize(__declspec(guard(overflow)) size_t bytes);
+BucketId GetBucketForSize(DECLSPEC_GUARD_OVERFLOW size_t bytes);
 
 struct Page
 {
@@ -189,7 +189,7 @@ public:
         }
         return address;
     }
-    char * AllocPages(__declspec(guard(overflow)) uint pages, void ** pageSegment, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, bool * isAllJITCodeInPreReservedRegion)
+    char * AllocPages(DECLSPEC_GUARD_OVERFLOW uint pages, void ** pageSegment, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, bool * isAllJITCodeInPreReservedRegion)
     {
         Assert(this->cs.IsLocked());
         char * address = nullptr;
@@ -401,7 +401,7 @@ class Heap
 public:
     Heap(ArenaAllocator * alloc, CodePageAllocators * codePageAllocators);
 
-    Allocation* Alloc(__declspec(guard(overflow)) size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, _Inout_ bool* isAllJITCodeInPreReservedRegion);
+    Allocation* Alloc(DECLSPEC_GUARD_OVERFLOW size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, _Inout_ bool* isAllJITCodeInPreReservedRegion);
     void Free(__in Allocation* allocation);
     void DecommitAll();
     void FreeAll();
@@ -429,12 +429,12 @@ private:
     /**
      * Inline methods
      */
-    inline unsigned int GetChunkSizeForBytes(__declspec(guard(overflow)) size_t bytes)
+    inline unsigned int GetChunkSizeForBytes(DECLSPEC_GUARD_OVERFLOW size_t bytes)
     {
         return (bytes > Page::Alignment ? static_cast<unsigned int>(bytes) / Page::Alignment : 1);
     }
 
-    inline size_t GetNumPagesForSize(__declspec(guard(overflow)) size_t bytes)
+    inline size_t GetNumPagesForSize(DECLSPEC_GUARD_OVERFLOW size_t bytes)
     {
         size_t allocSize = AllocSizeMath::Add(bytes, AutoSystemInfo::PageSize);
 
@@ -446,7 +446,7 @@ private:
         return ((allocSize - 1)/ AutoSystemInfo::PageSize);
     }
 
-    inline BVIndex GetFreeIndexForPage(Page* page, __declspec(guard(overflow)) size_t bytes)
+    inline BVIndex GetFreeIndexForPage(Page* page, DECLSPEC_GUARD_OVERFLOW size_t bytes)
     {
         unsigned int length = GetChunkSizeForBytes(bytes);
         BVIndex index = page->freeBitVector.FirstStringOfOnes(length);
@@ -457,7 +457,7 @@ private:
     /**
      * Large object methods
      */
-    Allocation* AllocLargeObject(__declspec(guard(overflow)) size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, _Inout_ bool* isAllJITCodeInPreReservedRegion);
+    Allocation* AllocLargeObject(DECLSPEC_GUARD_OVERFLOW size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, _Inout_ bool* isAllJITCodeInPreReservedRegion);
 
     void FreeLargeObject(Allocation* header);
 
@@ -516,7 +516,7 @@ private:
      * Page methods
      */
     Page*       AddPageToBucket(Page* page, BucketId bucket, bool wasFull = false);
-    bool        AllocInPage(Page* page, __declspec(guard(overflow)) size_t bytes, ushort pdataCount, ushort xdataSize, Allocation ** allocation);
+    bool        AllocInPage(Page* page, DECLSPEC_GUARD_OVERFLOW size_t bytes, ushort pdataCount, ushort xdataSize, Allocation ** allocation);
     Page*       AllocNewPage(BucketId bucket, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode, _Inout_ bool* isAllJITCodeInPreReservedRegion);
     Page*       FindPageToSplit(BucketId targetBucket, bool findPreReservedHeapPages = false);
 
@@ -562,7 +562,7 @@ private:
 
 // Helpers
 unsigned int log2(size_t number);
-BucketId GetBucketForSize(__declspec(guard(overflow)) size_t bytes);
+BucketId GetBucketForSize(DECLSPEC_GUARD_OVERFLOW size_t bytes);
 void FillDebugBreak(__out_bcount_full(byteCount) BYTE* buffer, __in size_t byteCount);
 };
 }

+ 23 - 23
lib/Common/Memory/HeapAllocator.h

@@ -91,32 +91,32 @@ struct HeapAllocator
 {
     static const bool FakeZeroLengthArray = false;
 
-    char * Alloc(__declspec(guard(overflow)) size_t byteSize)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         return AllocT<false>(byteSize);
     }
     template <bool noThrow>
-    char * AllocT(__declspec(guard(overflow)) size_t byteSize);
+    char * AllocT(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
 
     // This exists solely to make the AllocateXXX macros more polymorphic
-    char * AllocLeaf(__declspec(guard(overflow)) size_t byteSize)
+    char * AllocLeaf(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         return Alloc(byteSize);
     }
 
-    char * NoThrowAlloc(__declspec(guard(overflow)) size_t byteSize)
+    char * NoThrowAlloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         return AllocT<true>(byteSize);
     }
 
-    char * AllocZero(__declspec(guard(overflow)) size_t byteSize)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         char * buffer = Alloc(byteSize);
         memset(buffer, 0, byteSize);
         return buffer;
     }
 
-    char * NoThrowAllocZero(__declspec(guard(overflow)) size_t byteSize)
+    char * NoThrowAllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         char * buffer = NoThrowAlloc(byteSize);
         if (buffer != nullptr)
@@ -182,8 +182,8 @@ class NoThrowHeapAllocator
 {
 public:
     static const bool FakeZeroLengthArray = false;
-    char * Alloc(__declspec(guard(overflow)) size_t byteSize);
-    char * AllocZero(__declspec(guard(overflow)) size_t byteSize);
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
     void Free(void * buffer, size_t byteSize);
     static NoThrowHeapAllocator Instance;
 
@@ -201,8 +201,8 @@ class NoThrowNoMemProtectHeapAllocator
 {
 public:
     static const bool FakeZeroLengthArray = false;
-    char * Alloc(__declspec(guard(overflow)) size_t byteSize);
-    char * AllocZero(__declspec(guard(overflow)) size_t byteSize);
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
     void Free(void * buffer, size_t byteSize);
     static NoThrowNoMemProtectHeapAllocator Instance;
 
@@ -218,7 +218,7 @@ class NoCheckHeapAllocator
 {
 public:
     static const bool FakeZeroLengthArray = false;
-    char * Alloc(__declspec(guard(overflow)) size_t byteSize)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         if (processHeap == NULL)
         {
@@ -233,7 +233,7 @@ public:
         }
         return buffer;
     }
-    char * AllocZero(__declspec(guard(overflow)) size_t byteSize)
+    char * AllocZero(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
     {
         if (processHeap == NULL)
         {
@@ -298,21 +298,21 @@ private:
 //----------------------------------------
 template <>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, NoThrowNoMemProtectHeapAllocator * alloc, char * (NoThrowNoMemProtectHeapAllocator::*AllocFunc)(size_t))
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoThrowNoMemProtectHeapAllocator * alloc, char * (NoThrowNoMemProtectHeapAllocator::*AllocFunc)(size_t))
 {
     return ::operator new(byteSize, alloc, true, AllocFunc);
 }
 
 template <>
 _Ret_maybenull_ inline void * __cdecl
-operator new[](__declspec(guard(overflow)) size_t byteSize, NoThrowNoMemProtectHeapAllocator * alloc, char * (NoThrowNoMemProtectHeapAllocator::*AllocFunc)(size_t))
+operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoThrowNoMemProtectHeapAllocator * alloc, char * (NoThrowNoMemProtectHeapAllocator::*AllocFunc)(size_t))
 {
     return ::operator new[](byteSize, alloc, true, AllocFunc);
 }
 
 template <>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, NoThrowNoMemProtectHeapAllocator * alloc, char * (NoThrowNoMemProtectHeapAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoThrowNoMemProtectHeapAllocator * alloc, char * (NoThrowNoMemProtectHeapAllocator::*AllocFunc)(size_t), DECLSPEC_GUARD_OVERFLOW size_t plusSize)
 {
     return ::operator new(byteSize, alloc, true, AllocFunc, plusSize);
 }
@@ -336,8 +336,8 @@ typedef NoThrowHeapAllocator NoThrowNoMemProtectHeapAllocator;
 // Default operator new/delete overrides
 //----------------------------------------
 #if !defined(USED_IN_STATIC_LIB)
-_Ret_maybenull_ void * __cdecl operator new(__declspec(guard(overflow)) size_t byteSize);
-_Ret_maybenull_ void * __cdecl operator new[](__declspec(guard(overflow)) size_t byteSize);
+_Ret_maybenull_ void * __cdecl operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize);
+_Ret_maybenull_ void * __cdecl operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize);
 #endif
 
 //----------------------------------------
@@ -360,21 +360,21 @@ operator delete(void * obj, HeapAllocator * alloc, char * (HeapAllocator::*Alloc
 //----------------------------------------
 template <>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAllocator::*AllocFunc)(size_t))
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAllocator::*AllocFunc)(size_t))
 {
     return ::operator new(byteSize, alloc, true, AllocFunc);
 }
 
 template <>
 _Ret_maybenull_ inline void * __cdecl
-operator new[](__declspec(guard(overflow)) size_t byteSize, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAllocator::*AllocFunc)(size_t))
+operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAllocator::*AllocFunc)(size_t))
 {
     return ::operator new[](byteSize, alloc, true, AllocFunc);
 }
 
 template <>
 _Ret_maybenull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAllocator::*AllocFunc)(size_t), size_t plusSize)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAllocator::*AllocFunc)(size_t), size_t plusSize)
 {
     return ::operator new(byteSize, alloc, true, AllocFunc, plusSize);
 }
@@ -394,7 +394,7 @@ operator delete(void * obj, NoThrowHeapAllocator * alloc, char * (NoThrowHeapAll
 
 template <>
 _Ret_notnull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, NoCheckHeapAllocator * alloc, char * (NoCheckHeapAllocator::*AllocFunc)(size_t))
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoCheckHeapAllocator * alloc, char * (NoCheckHeapAllocator::*AllocFunc)(size_t))
 {
     Assert(byteSize != 0);
     void * buffer = (alloc->*AllocFunc)(byteSize);
@@ -404,7 +404,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, NoCheckHeapAllocator *
 
 template <>
 _Ret_notnull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, NoCheckHeapAllocator * alloc, char * (NoCheckHeapAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoCheckHeapAllocator * alloc, char * (NoCheckHeapAllocator::*AllocFunc)(size_t), DECLSPEC_GUARD_OVERFLOW size_t plusSize)
 {
     Assert(byteSize != 0);
     Assert(plusSize != 0);
@@ -414,7 +414,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, NoCheckHeapAllocator *
 
 
 _Ret_notnull_ inline void * __cdecl
-operator new[](__declspec(guard(overflow)) size_t byteSize, NoCheckHeapAllocator * alloc, char * (NoCheckHeapAllocator::*AllocFunc)(size_t))
+operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize, NoCheckHeapAllocator * alloc, char * (NoCheckHeapAllocator::*AllocFunc)(size_t))
 {
     void * buffer = (alloc->*AllocFunc)(byteSize);
     return buffer;

+ 2 - 2
lib/Common/Memory/HeapAllocatorOperators.cpp

@@ -9,13 +9,13 @@
 //----------------------------------------
 
 _Ret_maybenull_ void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize)
 {
     return HeapNewNoThrowArray(char, byteSize);
 }
 
 _Ret_maybenull_ void * __cdecl
-operator new[](__declspec(guard(overflow)) size_t byteSize)
+operator new[](DECLSPEC_GUARD_OVERFLOW size_t byteSize)
 {
     return HeapNewNoThrowArray(char, byteSize);
 }

+ 5 - 5
lib/Common/Memory/HeapBucket.h

@@ -128,12 +128,12 @@ public:
     inline char * RealAlloc(Recycler * recycler, size_t sizeCat, size_t size);
 
 #ifdef RECYCLER_PAGE_HEAP
-    char * PageHeapAlloc(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, size_t size, ObjectInfoBits attributes, PageHeapMode mode, bool nothrow);
+    char * PageHeapAlloc(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size, ObjectInfoBits attributes, PageHeapMode mode, bool nothrow);
 #endif
 
     void ExplicitFree(void* object, size_t sizeCat);
 
-    char * SnailAlloc(Recycler * recycler, TBlockAllocatorType * allocator, __declspec(guard(overflow)) size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow);
+    char * SnailAlloc(Recycler * recycler, TBlockAllocatorType * allocator, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow);
 
     void ResetMarks(ResetMarkFlags flags);
     void ScanNewImplicitRoots(Recycler * recycler);
@@ -162,7 +162,7 @@ protected:
     static bool const IsFinalizableWriteBarrierBucket = TBlockType::RequiredAttributes == FinalizableWithBarrierBit;
 #endif
 
-    void Initialize(HeapInfo * heapInfo, __declspec(guard(overflow)) uint sizeCat);
+    void Initialize(HeapInfo * heapInfo, DECLSPEC_GUARD_OVERFLOW uint sizeCat);
     void AppendAllocableHeapBlockList(TBlockType * list);
     void DeleteHeapBlockList(TBlockType * list);
     static void DeleteEmptyHeapBlockList(TBlockType * list);
@@ -177,8 +177,8 @@ protected:
     template <class Fn> void ForEachAllocator(Fn fn);
 
     // Allocations
-    char * TryAllocFromNewHeapBlock(Recycler * recycler, TBlockAllocatorType * allocator, __declspec(guard(overflow)) size_t sizeCat, size_t size, ObjectInfoBits attributes);
-    char * TryAlloc(Recycler * recycler, TBlockAllocatorType * allocator, __declspec(guard(overflow)) size_t sizeCat, ObjectInfoBits attributes);
+    char * TryAllocFromNewHeapBlock(Recycler * recycler, TBlockAllocatorType * allocator, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size, ObjectInfoBits attributes);
+    char * TryAlloc(Recycler * recycler, TBlockAllocatorType * allocator, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, ObjectInfoBits attributes);
     TBlockType * CreateHeapBlock(Recycler * recycler);
     TBlockType * GetUnusedHeapBlock();
 

+ 7 - 7
lib/Common/Memory/LargeHeapBlock.h

@@ -110,7 +110,7 @@ public:
     LargeHeapBlock * GetNextBlock() { return next; }
     void SetNextBlock(LargeHeapBlock * next) { this->next = next; }
     size_t GetFreeSize() const { return addressEnd - allocAddressEnd; }
-    static LargeHeapBlock * New(__in char * address, __declspec(guard(overflow)) size_t pageCount, Segment * segment, __declspec(guard(overflow)) uint objectCount, LargeHeapBucket* bucket);
+    static LargeHeapBlock * New(__in char * address, DECLSPEC_GUARD_OVERFLOW size_t pageCount, Segment * segment, DECLSPEC_GUARD_OVERFLOW uint objectCount, LargeHeapBucket* bucket);
     static void Delete(LargeHeapBlock * heapBlock);
     bool IsInPendingDisposeList() { return isInPendingDisposeList; }
     void SetIsInPendingDisposeList(bool isInPendingDisposeList) { this->isInPendingDisposeList = isInPendingDisposeList; }
@@ -148,10 +148,10 @@ public:
     char* GetBeginAddress() const { return address; }
     char* GetEndAddress() const { return addressEnd; }
 
-    char * Alloc(__declspec(guard(overflow)) size_t size, ObjectInfoBits attributes);
-    char * TryAllocFromFreeList(__declspec(guard(overflow)) size_t size, ObjectInfoBits attributes);
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t size, ObjectInfoBits attributes);
+    char * TryAllocFromFreeList(DECLSPEC_GUARD_OVERFLOW size_t size, ObjectInfoBits attributes);
 
-    static size_t GetPagesNeeded(__declspec(guard(overflow)) size_t size, bool multiplyRequest);
+    static size_t GetPagesNeeded(DECLSPEC_GUARD_OVERFLOW size_t size, bool multiplyRequest);
     static uint GetMaxLargeObjectCount(size_t pageCount, size_t firstAllocationSize);
 
     void EnumerateObjects(ObjectInfoBits infoBits, void (*CallBackFunction)(void * address, size_t size));
@@ -179,7 +179,7 @@ private:
     friend class Recycler;
 #endif
 
-    LargeHeapBlock(__in char * address, __declspec(guard(overflow)) size_t pageCount, Segment * segment, __declspec(guard(overflow)) uint objectCount, LargeHeapBucket* bucket);
+    LargeHeapBlock(__in char * address, DECLSPEC_GUARD_OVERFLOW size_t pageCount, Segment * segment, DECLSPEC_GUARD_OVERFLOW uint objectCount, LargeHeapBucket* bucket);
     static LargeObjectHeader * GetHeaderFromAddress(void * address);
     LargeObjectHeader * GetHeader(void * address);
     LargeObjectHeader ** HeaderList();
@@ -199,8 +199,8 @@ private:
     uint GetMarkCount();
     bool GetObjectHeader(void* objectAddress, LargeObjectHeader** ppHeader);
     BOOL IsNewHeapBlock() const { return lastCollectAllocCount == 0; }
-    static size_t GetAllocPlusSize(__declspec(guard(overflow)) uint objectCount);
-    char * AllocFreeListEntry(__declspec(guard(overflow)) size_t size, ObjectInfoBits attributes, LargeHeapBlockFreeListEntry* entry);
+    static size_t GetAllocPlusSize(DECLSPEC_GUARD_OVERFLOW uint objectCount);
+    char * AllocFreeListEntry(DECLSPEC_GUARD_OVERFLOW size_t size, ObjectInfoBits attributes, LargeHeapBlockFreeListEntry* entry);
 
 #if ENABLE_CONCURRENT_GC
     bool RescanOnePage(Recycler * recycler, DWORD const writeWatchFlags);

+ 8 - 8
lib/Common/Memory/LargeHeapBucket.h

@@ -36,14 +36,14 @@ public:
 
     ~LargeHeapBucket();
 
-    void Initialize(HeapInfo * heapInfo, __declspec(guard(overflow)) uint sizeCat, bool supportFreeList = false);
+    void Initialize(HeapInfo * heapInfo, DECLSPEC_GUARD_OVERFLOW uint sizeCat, bool supportFreeList = false);
 
-    LargeHeapBlock* AddLargeHeapBlock(__declspec(guard(overflow)) size_t size, bool nothrow);
+    LargeHeapBlock* AddLargeHeapBlock(DECLSPEC_GUARD_OVERFLOW size_t size, bool nothrow);
 
     template <ObjectInfoBits attributes, bool nothrow>
     char* Alloc(Recycler * recycler, size_t sizeCat);
 #ifdef RECYCLER_PAGE_HEAP
-    char *PageHeapAlloc(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, size_t size, ObjectInfoBits attributes, PageHeapMode mode, bool nothrow);
+    char *PageHeapAlloc(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size, ObjectInfoBits attributes, PageHeapMode mode, bool nothrow);
 #endif
     void ExplicitFree(void * object, size_t sizeCat);
 
@@ -93,11 +93,11 @@ public:
 #endif
 
 private:
-    char * SnailAlloc(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow);
-    char * TryAlloc(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, ObjectInfoBits attributes);
-    char * TryAllocFromNewHeapBlock(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow);
-    char * TryAllocFromFreeList(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, ObjectInfoBits attributes);
-    char * TryAllocFromExplicitFreeList(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, ObjectInfoBits attributes);
+    char * SnailAlloc(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow);
+    char * TryAlloc(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, ObjectInfoBits attributes);
+    char * TryAllocFromNewHeapBlock(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size, ObjectInfoBits attributes, bool nothrow);
+    char * TryAllocFromFreeList(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, ObjectInfoBits attributes);
+    char * TryAllocFromExplicitFreeList(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, ObjectInfoBits attributes);
 
     template <class Fn> void ForEachLargeHeapBlock(Fn fn);
     template <class Fn> void ForEachEditingLargeHeapBlock(Fn fn);

+ 18 - 18
lib/Common/Memory/PageAllocator.h

@@ -91,7 +91,7 @@ struct SecondaryAllocation
 class SecondaryAllocator
 {
 public:
-    virtual bool Alloc(ULONG_PTR functionStart, DWORD functionSize, __declspec(guard(overflow)) ushort pdataCount, __declspec(guard(overflow)) ushort xdataSize, SecondaryAllocation* xdata) = 0;
+    virtual bool Alloc(ULONG_PTR functionStart, DWORD functionSize, DECLSPEC_GUARD_OVERFLOW ushort pdataCount, DECLSPEC_GUARD_OVERFLOW ushort xdataSize, SecondaryAllocation* xdata) = 0;
     virtual void Release(const SecondaryAllocation& allocation) = 0;
     virtual void Delete() = 0;
     virtual bool CanAllocate() = 0;
@@ -108,7 +108,7 @@ template<typename TVirtualAlloc>
 class SegmentBase
 {
 public:
-    SegmentBase(PageAllocatorBase<TVirtualAlloc> * allocator, __declspec(guard(overflow)) size_t pageCount);
+    SegmentBase(PageAllocatorBase<TVirtualAlloc> * allocator, DECLSPEC_GUARD_OVERFLOW size_t pageCount);
     virtual ~SegmentBase();
 
     size_t GetPageCount() const { return segmentPageCount; }
@@ -221,10 +221,10 @@ public:
     static bool IsAllocationPageAligned(__in char* address, size_t pageCount);
 
     template <typename T, bool notPageAligned>
-    char * AllocDecommitPages(__declspec(guard(overflow)) uint pageCount, T freePages, T decommitPages);
+    char * AllocDecommitPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, T freePages, T decommitPages);
 
     template <bool notPageAligned>
-    char * AllocPages(__declspec(guard(overflow)) uint pageCount);
+    char * AllocPages(DECLSPEC_GUARD_OVERFLOW uint pageCount);
 
     void ReleasePages(__in void * address, uint pageCount);
     template <bool onlyUpdateState>
@@ -247,7 +247,7 @@ public:
     void ClearRangeInDecommitPagesBitVector(uint index, uint pageCount);
 
     template <bool notPageAligned>
-    char * DoAllocDecommitPages(__declspec(guard(overflow)) uint pageCount);
+    char * DoAllocDecommitPages(DECLSPEC_GUARD_OVERFLOW uint pageCount);
     uint GetMaxPageCount();
 
     size_t DecommitFreePages(size_t pageToDecommit);
@@ -428,8 +428,8 @@ public:
     bool IsPreReservedPageAllocator() { return virtualAllocator != nullptr; }
 
 
-    PageAllocation * AllocPagesForBytes(__declspec(guard(overflow)) size_t requestedBytes);
-    PageAllocation * AllocAllocation(__declspec(guard(overflow)) size_t pageCount);
+    PageAllocation * AllocPagesForBytes(DECLSPEC_GUARD_OVERFLOW size_t requestedBytes);
+    PageAllocation * AllocAllocation(DECLSPEC_GUARD_OVERFLOW size_t pageCount);
 
     void ReleaseAllocation(PageAllocation * allocation);
     void ReleaseAllocationNoSuspend(PageAllocation * allocation);
@@ -438,8 +438,8 @@ public:
 
     void Release(void * address, size_t pageCount, void * segment);
 
-    char * AllocPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
-    char * AllocPagesPageAligned(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    char * AllocPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    char * AllocPagesPageAligned(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
 
     void ReleasePages(__in void * address, uint pageCount, __in void * pageSegment);
 #if ENABLE_BACKGROUND_PAGE_FREEING
@@ -499,23 +499,23 @@ public:
     char16 const * debugName;
 #endif
 protected:
-    SegmentBase<TVirtualAlloc> * AllocSegment(__declspec(guard(overflow)) size_t pageCount);
+    SegmentBase<TVirtualAlloc> * AllocSegment(DECLSPEC_GUARD_OVERFLOW size_t pageCount);
     void ReleaseSegment(SegmentBase<TVirtualAlloc> * segment);
 
     template <bool doPageAlign>
     char * AllocInternal(size_t * pageCount, SegmentBase<TVirtualAlloc> ** segment);
 
     template <bool notPageAligned>
-    char * SnailAllocPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
-    void OnAllocFromNewSegment(__declspec(guard(overflow)) uint pageCount, __in void* pages, SegmentBase<TVirtualAlloc>* segment);
+    char * SnailAllocPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    void OnAllocFromNewSegment(DECLSPEC_GUARD_OVERFLOW uint pageCount, __in void* pages, SegmentBase<TVirtualAlloc>* segment);
 
     template <bool notPageAligned>
-    char * TryAllocFreePages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
-    char * TryAllocFromZeroPagesList(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment, SLIST_HEADER& zeroPagesList, bool isPendingZeroList);
-    char * TryAllocFromZeroPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    char * TryAllocFreePages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    char * TryAllocFromZeroPagesList(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment, SLIST_HEADER& zeroPagesList, bool isPendingZeroList);
+    char * TryAllocFromZeroPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
 
     template <bool notPageAligned>
-    char * TryAllocDecommittedPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    char * TryAllocDecommittedPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
 
     DListBase<PageSegmentBase<TVirtualAlloc>> * GetSegmentList(PageSegmentBase<TVirtualAlloc> * segment);
     void TransferSegment(PageSegmentBase<TVirtualAlloc> * segment, DListBase<PageSegmentBase<TVirtualAlloc>> * fromSegmentList);
@@ -642,7 +642,7 @@ private:
 #endif
 
     template <bool notPageAligned>
-    char* AllocPagesInternal(__declspec(guard(overflow)) uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
+    char* AllocPagesInternal(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase<TVirtualAlloc> ** pageSegment);
 
 #ifdef PROFILE_MEM
     PageMemoryData * memoryData;
@@ -756,7 +756,7 @@ public:
     HeapPageAllocator(AllocationPolicyManager * policyManager, bool allocXdata, bool excludeGuardPages, TVirtualAlloc * virtualAllocator);
 
     BOOL ProtectPages(__in char* address, size_t pageCount, __in void* segment, DWORD dwVirtualProtectFlags, DWORD desiredOldProtectFlag);
-    bool AllocSecondary(void* segment, ULONG_PTR functionStart, DWORD functionSize, __declspec(guard(overflow)) ushort pdataCount, __declspec(guard(overflow)) ushort xdataSize, SecondaryAllocation* allocation);
+    bool AllocSecondary(void* segment, ULONG_PTR functionStart, DWORD functionSize, DECLSPEC_GUARD_OVERFLOW ushort pdataCount, DECLSPEC_GUARD_OVERFLOW ushort xdataSize, SecondaryAllocation* allocation);
     bool ReleaseSecondary(const SecondaryAllocation& allocation, void* segment);
     void TrackDecommittedPages(void * address, uint pageCount, __in void* segment);
     void DecommitPages(__in char* address, size_t pageCount = 1);

+ 21 - 21
lib/Common/Memory/Recycler.h

@@ -1073,7 +1073,7 @@ public:
 
     void LogMemProtectHeapSize(bool fromGC);
 
-    char* Realloc(void* buffer, __declspec(guard(overflow)) size_t existingBytes, __declspec(guard(overflow)) size_t requestedBytes, bool truncate = true);
+    char* Realloc(void* buffer, DECLSPEC_GUARD_OVERFLOW size_t existingBytes, DECLSPEC_GUARD_OVERFLOW size_t requestedBytes, bool truncate = true);
     void SetTelemetryBlock(RecyclerWatsonTelemetryBlock * telemetryBlock) { this->telemetryBlock = telemetryBlock; }
 
     void Prime();
@@ -1275,22 +1275,22 @@ public:
 #define DEFINE_RECYCLER_ALLOC_TRACE(AllocFunc, AllocWithAttributeFunc, attributes)
 #endif
 #define DEFINE_RECYCLER_ALLOC_BASE(AllocFunc, AllocWithAttributesFunc, attributes) \
-    inline char * AllocFunc(__declspec(guard(overflow)) size_t size) \
+    inline char * AllocFunc(DECLSPEC_GUARD_OVERFLOW size_t size) \
     { \
         return AllocWithAttributesFunc<attributes, /* nothrow = */ false>(size); \
     } \
-    __forceinline char * AllocFunc##Inlined(__declspec(guard(overflow)) size_t size) \
+    __forceinline char * AllocFunc##Inlined(DECLSPEC_GUARD_OVERFLOW size_t size) \
     { \
         return AllocWithAttributesFunc##Inlined<attributes, /* nothrow = */ false>(size);  \
     } \
     DEFINE_RECYCLER_ALLOC_TRACE(AllocFunc, AllocWithAttributesFunc, attributes);
 
 #define DEFINE_RECYCLER_NOTHROW_ALLOC_BASE(AllocFunc, AllocWithAttributesFunc, attributes) \
-    inline char * NoThrow##AllocFunc(__declspec(guard(overflow)) size_t size) \
+    inline char * NoThrow##AllocFunc(DECLSPEC_GUARD_OVERFLOW size_t size) \
     { \
         return AllocWithAttributesFunc<attributes, /* nothrow = */ true>(size); \
     } \
-    inline char * NoThrow##AllocFunc##Inlined(__declspec(guard(overflow)) size_t size) \
+    inline char * NoThrow##AllocFunc##Inlined(DECLSPEC_GUARD_OVERFLOW size_t size) \
     { \
         return AllocWithAttributesFunc##Inlined<attributes, /* nothrow = */ true>(size);  \
     } \
@@ -1326,7 +1326,7 @@ public:
     DEFINE_RECYCLER_NOTHROW_ALLOC_ZERO(AllocImplicitRoot, ImplicitRootBit);
 
     template <ObjectInfoBits enumClass>
-    char * AllocEnumClass(__declspec(guard(overflow)) size_t size)
+    char * AllocEnumClass(DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         Assert((enumClass & EnumClassMask) != 0);
         Assert((enumClass & ~EnumClassMask) == 0);
@@ -1334,7 +1334,7 @@ public:
     }
 
     template <ObjectInfoBits infoBits>
-    char * AllocWithInfoBits(__declspec(guard(overflow)) size_t size)
+    char * AllocWithInfoBits(DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         return AllocWithAttributes<infoBits, /* nothrow = */ false>(size);
     }
@@ -1393,7 +1393,7 @@ public:
     template <typename TBlockAttributes>
     void SetExplicitFreeBitOnSmallBlock(HeapBlock* heapBlock, size_t sizeCat, void* buffer, ObjectInfoBits attributes);
 
-    char* HeapAllocR(HeapInfo* eHeap, __declspec(guard(overflow)) size_t size)
+    char* HeapAllocR(HeapInfo* eHeap, DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         return RealAlloc<LeafBit, /* nothrow = */ false>(eHeap, size);
     }
@@ -1406,10 +1406,10 @@ public:
     void RootRelease(void* obj, uint *count = nullptr);
 
     template <ObjectInfoBits attributes, bool nothrow>
-    inline char* RealAlloc(HeapInfo* heap, __declspec(guard(overflow)) size_t size);
+    inline char* RealAlloc(HeapInfo* heap, DECLSPEC_GUARD_OVERFLOW size_t size);
 
     template <ObjectInfoBits attributes, bool isSmallAlloc, bool nothrow>
-    inline char* RealAllocFromBucket(HeapInfo* heap, __declspec(guard(overflow)) size_t size);
+    inline char* RealAllocFromBucket(HeapInfo* heap, DECLSPEC_GUARD_OVERFLOW size_t size);
 
     void EnterIdleDecommit();
     void LeaveIdleDecommit();
@@ -1525,23 +1525,23 @@ private:
 
     // Allocation
     template <ObjectInfoBits attributes, bool nothrow>
-    inline char * AllocWithAttributesInlined(__declspec(guard(overflow)) size_t size);
+    inline char * AllocWithAttributesInlined(DECLSPEC_GUARD_OVERFLOW size_t size);
     template <ObjectInfoBits attributes, bool nothrow>
-    char * AllocWithAttributes(__declspec(guard(overflow)) size_t size)
+    char * AllocWithAttributes(DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         return AllocWithAttributesInlined<attributes, nothrow>(size);
     }
 
     template <ObjectInfoBits attributes, bool nothrow>
-    inline char* AllocZeroWithAttributesInlined(__declspec(guard(overflow)) size_t size);
+    inline char* AllocZeroWithAttributesInlined(DECLSPEC_GUARD_OVERFLOW size_t size);
 
     template <ObjectInfoBits attributes, bool nothrow>
-    char* AllocZeroWithAttributes(__declspec(guard(overflow)) size_t size)
+    char* AllocZeroWithAttributes(DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         return AllocZeroWithAttributesInlined<attributes, nothrow>(size);
     }
 
-    char* AllocWeakReferenceEntry(__declspec(guard(overflow)) size_t size)
+    char* AllocWeakReferenceEntry(DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         return AllocWithAttributes<WeakReferenceEntryBits, /* nothrow = */ false>(size);
     }
@@ -1556,10 +1556,10 @@ private:
         return (ticks > tickCountNextDispose && this->hasDisposableObject);
     }
 
-    char* TryLargeAlloc(HeapInfo* heap, __declspec(guard(overflow)) size_t size, ObjectInfoBits attributes, bool nothrow);
+    char* TryLargeAlloc(HeapInfo* heap, DECLSPEC_GUARD_OVERFLOW size_t size, ObjectInfoBits attributes, bool nothrow);
 
     template <bool nothrow>
-    char* LargeAlloc(HeapInfo* heap, __declspec(guard(overflow)) size_t size, ObjectInfoBits attributes);
+    char* LargeAlloc(HeapInfo* heap, DECLSPEC_GUARD_OVERFLOW size_t size, ObjectInfoBits attributes);
     void OutOfMemory();
 
     // Collection
@@ -2241,7 +2241,7 @@ Recycler::RemoveSmallAllocator(SmallHeapBlockAllocatorType * allocator, size_t s
 
 template <ObjectInfoBits attributes, typename SmallHeapBlockAllocatorType>
 char *
-Recycler::SmallAllocatorAlloc(SmallHeapBlockAllocatorType * allocator, __declspec(guard(overflow)) size_t sizeCat, size_t size)
+Recycler::SmallAllocatorAlloc(SmallHeapBlockAllocatorType * allocator, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, size_t size)
 {
     return autoHeap.SmallAllocatorAlloc<attributes>(this, allocator, sizeCat, size);
 }
@@ -2429,7 +2429,7 @@ struct ForceLeafAllocator<RecyclerNonLeafAllocator>
 }
 
 _Ret_notnull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, Recycler * alloc, HeapInfo * heapInfo)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, Recycler * alloc, HeapInfo * heapInfo)
 {
     return alloc->HeapAllocR(heapInfo, byteSize);
 }
@@ -2441,7 +2441,7 @@ operator delete(void * obj, Recycler * alloc, HeapInfo * heapInfo)
 }
 
 _Ret_notnull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, Recycler * recycler, ObjectInfoBits enumClassBits)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, Recycler * recycler, ObjectInfoBits enumClassBits)
 {
     AssertCanHandleOutOfMemory();
     Assert(byteSize != 0);
@@ -2454,7 +2454,7 @@ operator new(__declspec(guard(overflow)) size_t byteSize, Recycler * recycler, O
 
 template<ObjectInfoBits infoBits>
 _Ret_notnull_ inline void * __cdecl
-operator new(__declspec(guard(overflow)) size_t byteSize, Recycler * recycler, const InfoBitsWrapper<infoBits>&)
+operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, Recycler * recycler, const InfoBitsWrapper<infoBits>&)
 {
     AssertCanHandleOutOfMemory();
     Assert(byteSize != 0);

+ 1 - 1
lib/Common/Memory/RecyclerFastAllocator.h

@@ -37,7 +37,7 @@ public:
     }
 
     Recycler * GetRecycler() { return recycler; }
-    char * Alloc(__declspec(guard(overflow)) size_t size)
+    char * Alloc(DECLSPEC_GUARD_OVERFLOW size_t size)
     {
         Assert(recycler != nullptr);
         Assert(!recycler->IsHeapEnumInProgress() || recycler->AllowAllocationDuringHeapEnum());

+ 2 - 2
lib/Common/Memory/RecyclerWriteBarrierManager.h

@@ -55,7 +55,7 @@ public:
     bool OnThreadInit();
 
     // Called when a page allocator segment is allocated
-    bool OnSegmentAlloc(_In_ char* segmentAddress, __declspec(guard(overflow)) size_t numPages);
+    bool OnSegmentAlloc(_In_ char* segmentAddress, DECLSPEC_GUARD_OVERFLOW size_t numPages);
 
     // Called when a page allocator segment is freed
     bool OnSegmentFree(_In_ char* segmentAddress, size_t numPages);
@@ -140,7 +140,7 @@ public:
     // For GC
 #ifdef _M_X64_OR_ARM64
     static bool OnThreadInit();
-    static bool OnSegmentAlloc(_In_ char* segment, __declspec(guard(overflow)) size_t pageCount);
+    static bool OnSegmentAlloc(_In_ char* segment, DECLSPEC_GUARD_OVERFLOW size_t pageCount);
     static bool OnSegmentFree(_In_ char* segment, size_t pageCount);
 #endif
 

+ 3 - 3
lib/Common/Memory/SmallHeapBlockAllocator.h

@@ -15,15 +15,15 @@ public:
     void Initialize();
 
     template <ObjectInfoBits attributes>
-    inline char * InlinedAlloc(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat);
+    inline char * InlinedAlloc(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat);
 
     // Pass through template parameter to InlinedAllocImpl
     template <bool canFaultInject>
-    inline char * SlowAlloc(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, ObjectInfoBits attributes);
+    inline char * SlowAlloc(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, ObjectInfoBits attributes);
 
     // There are paths where we simply can't OOM here, so we shouldn't fault inject as it creates a bit of a mess
     template <bool canFaultInject>
-    inline char* InlinedAllocImpl(Recycler * recycler, __declspec(guard(overflow)) size_t sizeCat, ObjectInfoBits attributes);
+    inline char* InlinedAllocImpl(Recycler * recycler, DECLSPEC_GUARD_OVERFLOW size_t sizeCat, ObjectInfoBits attributes);
 
     TBlockType * GetHeapBlock() const { return heapBlock; }
     SmallHeapBlockAllocator * GetNext() const { return next; }

+ 2 - 2
lib/Common/Memory/VirtualAllocWrapper.h

@@ -16,7 +16,7 @@ namespace Memory
 class VirtualAllocWrapper
 {
 public:
-    LPVOID  Alloc(LPVOID lpAddress, __declspec(guard(overflow)) size_t dwSize, DWORD allocationType, DWORD protectFlags, bool isCustomHeapAllocation = false);
+    LPVOID  Alloc(LPVOID lpAddress, DECLSPEC_GUARD_OVERFLOW size_t dwSize, DWORD allocationType, DWORD protectFlags, bool isCustomHeapAllocation = false);
     BOOL    Free(LPVOID lpAddress, size_t dwSize, DWORD dwFreeType);
 };
 
@@ -42,7 +42,7 @@ public:
 public:
     PreReservedVirtualAllocWrapper();
     ~PreReservedVirtualAllocWrapper();
-    LPVOID      Alloc(LPVOID lpAddress, __declspec(guard(overflow)) size_t dwSize, DWORD allocationType, DWORD protectFlags, bool isCustomHeapAllocation = false);
+    LPVOID      Alloc(LPVOID lpAddress, DECLSPEC_GUARD_OVERFLOW size_t dwSize, DWORD allocationType, DWORD protectFlags, bool isCustomHeapAllocation = false);
     BOOL        Free(LPVOID lpAddress, size_t dwSize, DWORD dwFreeType);
 
     bool        IsInRange(void * address);

+ 2 - 2
lib/Parser/Alloc.h

@@ -10,10 +10,10 @@ NoReleaseAllocator - allocator that never releases until it is destroyed
 class NoReleaseAllocator
 {
 public:
-    NoReleaseAllocator(__declspec(guard(overflow)) int32 cbFirst = 256, __declspec(guard(overflow)) int32 cbMax = 0x4000 /*16K*/);
+    NoReleaseAllocator(DECLSPEC_GUARD_OVERFLOW int32 cbFirst = 256, DECLSPEC_GUARD_OVERFLOW int32 cbMax = 0x4000 /*16K*/);
     ~NoReleaseAllocator(void) { FreeAll(); }
 
-    void *Alloc(__declspec(guard(overflow)) int32 cb);
+    void *Alloc(DECLSPEC_GUARD_OVERFLOW int32 cb);
     void FreeAll();
     void Clear() { FreeAll(); }
 

+ 1 - 1
lib/Runtime/Language/DynamicProfileStorage.h

@@ -18,7 +18,7 @@ public:
     static Js::SourceDynamicProfileManager * Load(__in_z char16 const * filename, Fn loadFn);
     static void SaveRecord(__in_z char16 const * filename, __in_ecount(sizeof(DWORD) + *record) char const * record);
 
-    static char * AllocRecord(__declspec(guard(overflow)) DWORD bufferSize);
+    static char * AllocRecord(DECLSPEC_GUARD_OVERFLOW DWORD bufferSize);
     static void DeleteRecord(__in_ecount(sizeof(DWORD) + *record) char const * record);
     static char const * GetRecordBuffer(__in_ecount(sizeof(DWORD) + *record) char const * record);
     static char * GetRecordBuffer(__in_ecount(sizeof(DWORD) + *record) char * record);

+ 2 - 2
lib/Runtime/Language/JavascriptOperators.h

@@ -563,13 +563,13 @@ namespace Js
         static Var OP_AsyncSpawn(Js::Var aGenerator, Js::Var aThis, ScriptContext* scriptContext);
 
         template <typename T>
-        static void * JitRecyclerAlloc(__declspec(guard(overflow)) size_t size, Recycler* recycler)
+        static void * JitRecyclerAlloc(DECLSPEC_GUARD_OVERFLOW size_t size, Recycler* recycler)
         {
             TRACK_ALLOC_INFO(recycler, T, Recycler, size - sizeof(T), (size_t)-1);
             return recycler->AllocZero(size);
         }
 
-        static void * AllocMemForVarArray(__declspec(guard(overflow)) size_t size, Recycler* recycler);
+        static void * AllocMemForVarArray(DECLSPEC_GUARD_OVERFLOW size_t size, Recycler* recycler);
         static void * AllocUninitializedNumber(RecyclerJavascriptNumberAllocator * allocator);
 
         static void ScriptAbort();

+ 16 - 16
lib/Runtime/Library/ArrayBuffer.h

@@ -54,9 +54,9 @@ namespace Js
         };
 
         template <typename Allocator>
-        ArrayBuffer(__declspec(guard(overflow)) uint32 length, DynamicType * type, Allocator allocator);
+        ArrayBuffer(DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type, Allocator allocator);
 
-        ArrayBuffer(byte* buffer, __declspec(guard(overflow)) uint32 length, DynamicType * type);
+        ArrayBuffer(byte* buffer, DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type);
 
         class EntryInfo
         {
@@ -106,8 +106,8 @@ namespace Js
         virtual bool IsValidVirtualBufferLength(uint length) { return false; }
     protected:
         typedef void __cdecl FreeFn(void* ptr);
-        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, __declspec(guard(overflow)) uint32 bufferLength) = 0;
-        virtual ArrayBuffer * TransferInternal(__declspec(guard(overflow)) uint32 newBufferLength) = 0;
+        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) = 0;
+        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) = 0;
 
         static uint32 GetIndexFromVar(Js::Var arg, uint32 length, ScriptContext* scriptContext);
 
@@ -186,11 +186,11 @@ namespace Js
         DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(JavascriptArrayBuffer);
 
     public:
-        static JavascriptArrayBuffer* Create(__declspec(guard(overflow)) uint32 length, DynamicType * type);
-        static JavascriptArrayBuffer* Create(byte* buffer, __declspec(guard(overflow)) uint32 length, DynamicType * type);
+        static JavascriptArrayBuffer* Create(DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type);
+        static JavascriptArrayBuffer* Create(byte* buffer, DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type);
         virtual void Dispose(bool isShutdown) override;
         virtual void Finalize(bool isShutdown) override;
-        static void*__cdecl  AllocWrapper(__declspec(guard(overflow)) size_t length)
+        static void*__cdecl  AllocWrapper(DECLSPEC_GUARD_OVERFLOW size_t length)
         {
 #if _WIN64
             LPVOID address = VirtualAlloc(nullptr, MAX_ASMJS_ARRAYBUFFER_LENGTH, MEM_RESERVE, PAGE_NOACCESS);
@@ -224,8 +224,8 @@ namespace Js
 
     protected:
         JavascriptArrayBuffer(DynamicType * type);
-        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, __declspec(guard(overflow)) uint32 bufferLength) override;
-        virtual ArrayBuffer * TransferInternal(__declspec(guard(overflow)) uint32 newBufferLength) override;
+        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) override;
+        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override;
     private:
         JavascriptArrayBuffer(uint32 length, DynamicType * type);
         JavascriptArrayBuffer(byte* buffer, uint32 length, DynamicType * type);
@@ -244,17 +244,17 @@ namespace Js
         DEFINE_VTABLE_CTOR(ProjectionArrayBuffer, ArrayBuffer);
         DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(ProjectionArrayBuffer);
         typedef void __stdcall FreeFn(LPVOID ptr);
-        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, __declspec(guard(overflow)) uint32 bufferLength) override
+        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) override
         {
             return HeapNew(ArrayBufferDetachedState<FreeFn>, buffer, bufferLength, CoTaskMemFree, ArrayBufferAllocationType::CoTask);
         }
-        virtual ArrayBuffer * TransferInternal(__declspec(guard(overflow)) uint32 newBufferLength) override;
+        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override;
 
     public:
         // Create constructor. script engine creates a buffer allocated via CoTaskMemAlloc.
-        static ProjectionArrayBuffer* Create(__declspec(guard(overflow)) uint32 length, DynamicType * type);
+        static ProjectionArrayBuffer* Create(DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type);
         // take over ownership. a CoTaskMemAlloc'ed buffer passed in via projection.
-        static ProjectionArrayBuffer* Create(byte* buffer, __declspec(guard(overflow)) uint32 length, DynamicType * type);
+        static ProjectionArrayBuffer* Create(byte* buffer, DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType * type);
         virtual void Dispose(bool isShutdown) override;
         virtual void Finalize(bool isShutdown) override {};
     private:
@@ -269,10 +269,10 @@ namespace Js
         DEFINE_VTABLE_CTOR(ExternalArrayBuffer, ArrayBuffer);
         DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(ExternalArrayBuffer);
     public:
-        ExternalArrayBuffer(byte *buffer, __declspec(guard(overflow)) uint32 length, DynamicType *type);
+        ExternalArrayBuffer(byte *buffer, DECLSPEC_GUARD_OVERFLOW uint32 length, DynamicType *type);
     protected:
-        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, __declspec(guard(overflow)) uint32 bufferLength) override { Assert(UNREACHED); Throw::InternalError(); };
-        virtual ArrayBuffer * TransferInternal(__declspec(guard(overflow)) uint32 newBufferLength) override { Assert(UNREACHED); Throw::InternalError(); };
+        virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) override { Assert(UNREACHED); Throw::InternalError(); };
+        virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) override { Assert(UNREACHED); Throw::InternalError(); };
 
 #if ENABLE_TTD
     public: