diff --git a/lib/Backend/EmitBuffer.h b/lib/Backend/EmitBuffer.h index bf7201d9f11..501237e3063 100644 --- a/lib/Backend/EmitBuffer.h +++ b/lib/Backend/EmitBuffer.h @@ -37,7 +37,7 @@ class EmitBufferManager 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 @@ class EmitBufferManager 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; diff --git a/lib/Backend/GlobHashTable.h b/lib/Backend/GlobHashTable.h index d3e1f3f3f7a..f462e6eab58 100644 --- a/lib/Backend/GlobHashTable.h +++ b/lib/Backend/GlobHashTable.h @@ -55,7 +55,7 @@ class ValueHashTable SListBase * 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)), ValueHashTable, allocator, tableSize); } diff --git a/lib/Backend/NativeCodeData.h b/lib/Backend/NativeCodeData.h index 4f3afd92a4a..d026647df01 100644 --- a/lib/Backend/NativeCodeData.h +++ b/lib/Backend/NativeCodeData.h @@ -36,8 +36,8 @@ class NativeCodeData 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); diff --git a/lib/Common/CommonPal.h b/lib/Common/CommonPal.h index 4bfe4a7dcaf..9b87b58bbef 100644 --- a/lib/Common/CommonPal.h +++ b/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")\ diff --git a/lib/Common/Core/AllocSizeMath.h b/lib/Common/Core/AllocSizeMath.h index 6f8e7e15d82..3f73ce0a229 100644 --- a/lib/Common/Core/AllocSizeMath.h +++ b/lib/Common/Core/AllocSizeMath.h @@ -10,7 +10,7 @@ class AllocSizeMath // 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 @@ class AllocSizeMath } // 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)) diff --git a/lib/Common/DataStructures/BaseDictionary.h b/lib/Common/DataStructures/BaseDictionary.h index 06633fbfbd2..27b3d692645 100644 --- a/lib/Common/DataStructures/BaseDictionary.h +++ b/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( @@ -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 diff --git a/lib/Common/DataStructures/FixedBitVector.h b/lib/Common/DataStructures/FixedBitVector.h index 26bfb22f743..157431de60f 100644 --- a/lib/Common/DataStructures/FixedBitVector.h +++ b/lib/Common/DataStructures/FixedBitVector.h @@ -35,10 +35,10 @@ class BVFixed static BVFixed * New(TAllocator* alloc, BVFixed * initBv); template - 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 - 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 void Delete(TAllocator * alloc); @@ -152,14 +152,14 @@ BVFixed * BVFixed::New(TAllocator * alloc, BVFixed * initBv) } template -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 -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; diff --git a/lib/Common/DataStructures/HashTable.h b/lib/Common/DataStructures/HashTable.h index 49ded30b79f..aa6ccc0af7e 100644 --- a/lib/Common/DataStructures/HashTable.h +++ b/lib/Common/DataStructures/HashTable.h @@ -33,7 +33,7 @@ class HashTable SListBase> * table; public: - static HashTable * New(TAllocator *allocator, __declspec(guard(overflow)) uint tableSize) + static HashTable * New(TAllocator *allocator, DECLSPEC_GUARD_OVERFLOW uint tableSize) { return AllocatorNewPlus(TAllocator, allocator, (tableSize*sizeof(SListBase>)), HashTable, allocator, tableSize); } @@ -382,7 +382,7 @@ class HashTable #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 diff --git a/lib/Common/DataStructures/InternalString.h b/lib/Common/DataStructures/InternalString.h index 079af687834..24f73170adb 100644 --- a/lib/Common/DataStructures/InternalString.h +++ b/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 { diff --git a/lib/Common/DataStructures/List.h b/lib/Common/DataStructures/List.h index 1f0b4a92542..6ea5e01a6b8 100644 --- a/lib/Common/DataStructures/List.h +++ b/lib/Common/DataStructures/List.h @@ -64,7 +64,7 @@ namespace JsUtil } template - 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) { diff --git a/lib/Common/DataStructures/MruDictionary.h b/lib/Common/DataStructures/MruDictionary.h index 18ea75e1b71..85ff5ef5152 100644 --- a/lib/Common/DataStructures/MruDictionary.h +++ b/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); } diff --git a/lib/Common/Memory/AllocationPolicyManager.h b/lib/Common/Memory/AllocationPolicyManager.h index 0221eb55b6f..769c6f4cd7e 100644 --- a/lib/Common/Memory/AllocationPolicyManager.h +++ b/lib/Common/Memory/AllocationPolicyManager.h @@ -63,7 +63,7 @@ typedef bool (__stdcall * PageAllocatorMemoryAllocationCallback)(__in LPVOID con memoryLimit = newLimit; } - bool RequestAlloc(__declspec(guard(overflow)) size_t byteCount) + bool RequestAlloc(DECLSPEC_GUARD_OVERFLOW size_t byteCount) { if (supportConcurrency) { diff --git a/lib/Common/Memory/Allocator.h b/lib/Common/Memory/Allocator.h index 291abe06e87..f80a62a4171 100644 --- a/lib/Common/Memory/Allocator.h +++ b/lib/Common/Memory/Allocator.h @@ -270,7 +270,7 @@ void DeleteObject(typename AllocatorInfo::AllocatorType * allocat #define ZERO_LENGTH_ARRAY (void *)sizeof(void *) template _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 _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 _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 _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 _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 _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 _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 _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); diff --git a/lib/Common/Memory/ArenaAllocator.h b/lib/Common/Memory/ArenaAllocator.h index 74e20fbcedb..8d7e6eddf09 100644 --- a/lib/Common/Memory/ArenaAllocator.h +++ b/lib/Common/Memory/ArenaAllocator.h @@ -224,9 +224,9 @@ class ArenaAllocatorBase : public Allocator, public ArenaData 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 @@ class ArenaAllocatorBase : public Allocator, public ArenaData #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 @@ class ArenaAllocatorBase : public Allocator, public ArenaData static size_t Size(BigBlock * blockList); void FullReset(); void SetCacheBlock(BigBlock * cacheBlock); - template char * AllocFromHeap(__declspec(guard(overflow)) size_t nbytes); + template 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 @@ class InPlaceFreeListPolicy static const unsigned char DbgFreeMemFill = DbgMemFill; #endif static void * New(ArenaAllocatorBase * 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 @@ class StandAloneFreeListPolicy static const char DbgFreeMemFill = 0x0; #endif static void * New(ArenaAllocatorBase * 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 @@ class ArenaAllocator : public ArenaAllocatorBase } __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 @@ class ArenaAllocator : public ArenaAllocatorBase 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 @@ class ArenaAllocator : public ArenaAllocatorBase 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 @@ class ArenaAllocator : public ArenaAllocatorBase 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 @@ class ArenaAllocator : public ArenaAllocatorBase 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 @@ class JitArenaAllocator : public ArenaAllocator { } - 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 @@ class JitArenaAllocator : public ArenaAllocator 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 @@ class InlineCacheFreeListPolicy : public InlineCacheAllocatorInfo static const unsigned char DbgFreeMemFill = DbgMemFill; #endif static void * New(ArenaAllocatorBase * 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 @@ class InlineCacheAllocator : public InlineCacheAllocatorInfo, public ArenaAlloca #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 @@ class InlineCacheAllocator : public ArenaAllocatorBase(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 @@ class IsInstInlineCacheAllocator : public IsInstInlineCacheAllocatorInfo, public IsInstInlineCacheAllocator(__in LPCWSTR name, PageAllocator * pageAllocator, void(*outOfMemoryFunc)()) : ArenaAllocatorBase(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); diff --git a/lib/Common/Memory/CustomHeap.h b/lib/Common/Memory/CustomHeap.h index 54c1274d8cd..5ccdba16fcb 100644 --- a/lib/Common/Memory/CustomHeap.h +++ b/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 @@ class CodePageAllocators } 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 @@ class Heap /** * 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(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 @@ class Heap 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 @@ class Heap /** * 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 @@ class Heap * 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 @@ class Heap // 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); }; } diff --git a/lib/Common/Memory/HeapAllocator.h b/lib/Common/Memory/HeapAllocator.h index 10a829c42e1..48992bfdac4 100644 --- a/lib/Common/Memory/HeapAllocator.h +++ b/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(byteSize); } template - 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(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 @@ class NoCheckHeapAllocator } 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 @@ class MemoryLeakCheck //---------------------------------------- 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; diff --git a/lib/Common/Memory/HeapAllocatorOperators.cpp b/lib/Common/Memory/HeapAllocatorOperators.cpp index 5084e637461..66a165c1833 100644 --- a/lib/Common/Memory/HeapAllocatorOperators.cpp +++ b/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); } diff --git a/lib/Common/Memory/HeapBucket.h b/lib/Common/Memory/HeapBucket.h index a415f7483c8..3330ffacadf 100644 --- a/lib/Common/Memory/HeapBucket.h +++ b/lib/Common/Memory/HeapBucket.h @@ -128,12 +128,12 @@ class HeapBucketT : public HeapBucket 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 @@ class HeapBucketT : public HeapBucket 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 @@ class HeapBucketT : public HeapBucket template 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(); diff --git a/lib/Common/Memory/LargeHeapBlock.h b/lib/Common/Memory/LargeHeapBlock.h index ffecc70302b..4191167dddd 100644 --- a/lib/Common/Memory/LargeHeapBlock.h +++ b/lib/Common/Memory/LargeHeapBlock.h @@ -110,7 +110,7 @@ class LargeHeapBlock sealed : public HeapBlock 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 @@ class LargeHeapBlock sealed : public HeapBlock 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 @@ class LargeHeapBlock sealed : public HeapBlock 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 @@ class LargeHeapBlock sealed : public HeapBlock 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); diff --git a/lib/Common/Memory/LargeHeapBucket.h b/lib/Common/Memory/LargeHeapBucket.h index ae8c165ff46..f4411ee07b2 100644 --- a/lib/Common/Memory/LargeHeapBucket.h +++ b/lib/Common/Memory/LargeHeapBucket.h @@ -36,14 +36,14 @@ class LargeHeapBucket: public HeapBucket ~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 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 @@ class LargeHeapBucket: public HeapBucket #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 void ForEachLargeHeapBlock(Fn fn); template void ForEachEditingLargeHeapBlock(Fn fn); diff --git a/lib/Common/Memory/PageAllocator.h b/lib/Common/Memory/PageAllocator.h index d8eebd6952a..c6354f345f8 100644 --- a/lib/Common/Memory/PageAllocator.h +++ b/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 class SegmentBase { public: - SegmentBase(PageAllocatorBase * allocator, __declspec(guard(overflow)) size_t pageCount); + SegmentBase(PageAllocatorBase * allocator, DECLSPEC_GUARD_OVERFLOW size_t pageCount); virtual ~SegmentBase(); size_t GetPageCount() const { return segmentPageCount; } @@ -221,10 +221,10 @@ class PageSegmentBase : public SegmentBase static bool IsAllocationPageAligned(__in char* address, size_t pageCount); template - char * AllocDecommitPages(__declspec(guard(overflow)) uint pageCount, T freePages, T decommitPages); + char * AllocDecommitPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, T freePages, T decommitPages); template - char * AllocPages(__declspec(guard(overflow)) uint pageCount); + char * AllocPages(DECLSPEC_GUARD_OVERFLOW uint pageCount); void ReleasePages(__in void * address, uint pageCount); template @@ -247,7 +247,7 @@ class PageSegmentBase : public SegmentBase void ClearRangeInDecommitPagesBitVector(uint index, uint pageCount); template - 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 @@ class PageAllocatorBase 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 @@ class PageAllocatorBase void Release(void * address, size_t pageCount, void * segment); - char * AllocPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); - char * AllocPagesPageAligned(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); + char * AllocPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); + char * AllocPagesPageAligned(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); void ReleasePages(__in void * address, uint pageCount, __in void * pageSegment); #if ENABLE_BACKGROUND_PAGE_FREEING @@ -499,23 +499,23 @@ class PageAllocatorBase char16 const * debugName; #endif protected: - SegmentBase * AllocSegment(__declspec(guard(overflow)) size_t pageCount); + SegmentBase * AllocSegment(DECLSPEC_GUARD_OVERFLOW size_t pageCount); void ReleaseSegment(SegmentBase * segment); template char * AllocInternal(size_t * pageCount, SegmentBase ** segment); template - char * SnailAllocPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); - void OnAllocFromNewSegment(__declspec(guard(overflow)) uint pageCount, __in void* pages, SegmentBase* segment); + char * SnailAllocPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); + void OnAllocFromNewSegment(DECLSPEC_GUARD_OVERFLOW uint pageCount, __in void* pages, SegmentBase* segment); template - char * TryAllocFreePages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); - char * TryAllocFromZeroPagesList(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment, SLIST_HEADER& zeroPagesList, bool isPendingZeroList); - char * TryAllocFromZeroPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); + char * TryAllocFreePages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); + char * TryAllocFromZeroPagesList(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment, SLIST_HEADER& zeroPagesList, bool isPendingZeroList); + char * TryAllocFromZeroPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); template - char * TryAllocDecommittedPages(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); + char * TryAllocDecommittedPages(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); DListBase> * GetSegmentList(PageSegmentBase * segment); void TransferSegment(PageSegmentBase * segment, DListBase> * fromSegmentList); @@ -642,7 +642,7 @@ class PageAllocatorBase #endif template - char* AllocPagesInternal(__declspec(guard(overflow)) uint pageCount, PageSegmentBase ** pageSegment); + char* AllocPagesInternal(DECLSPEC_GUARD_OVERFLOW uint pageCount, PageSegmentBase ** pageSegment); #ifdef PROFILE_MEM PageMemoryData * memoryData; @@ -756,7 +756,7 @@ class HeapPageAllocator : public PageAllocatorBase 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); diff --git a/lib/Common/Memory/Recycler.h b/lib/Common/Memory/Recycler.h index 2ec352082fa..a5b05f2a3ec 100644 --- a/lib/Common/Memory/Recycler.h +++ b/lib/Common/Memory/Recycler.h @@ -1073,7 +1073,7 @@ class Recycler 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 @@ class Recycler #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(size); \ } \ - __forceinline char * AllocFunc##Inlined(__declspec(guard(overflow)) size_t size) \ + __forceinline char * AllocFunc##Inlined(DECLSPEC_GUARD_OVERFLOW size_t size) \ { \ return AllocWithAttributesFunc##Inlined(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(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(size); \ } \ @@ -1326,7 +1326,7 @@ class Recycler DEFINE_RECYCLER_NOTHROW_ALLOC_ZERO(AllocImplicitRoot, ImplicitRootBit); template - 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 @@ class Recycler } template - char * AllocWithInfoBits(__declspec(guard(overflow)) size_t size) + char * AllocWithInfoBits(DECLSPEC_GUARD_OVERFLOW size_t size) { return AllocWithAttributes(size); } @@ -1393,7 +1393,7 @@ class Recycler template 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(eHeap, size); } @@ -1406,10 +1406,10 @@ class Recycler void RootRelease(void* obj, uint *count = nullptr); template - inline char* RealAlloc(HeapInfo* heap, __declspec(guard(overflow)) size_t size); + inline char* RealAlloc(HeapInfo* heap, DECLSPEC_GUARD_OVERFLOW size_t size); template - 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 @@ class Recycler // Allocation template - inline char * AllocWithAttributesInlined(__declspec(guard(overflow)) size_t size); + inline char * AllocWithAttributesInlined(DECLSPEC_GUARD_OVERFLOW size_t size); template - char * AllocWithAttributes(__declspec(guard(overflow)) size_t size) + char * AllocWithAttributes(DECLSPEC_GUARD_OVERFLOW size_t size) { return AllocWithAttributesInlined(size); } template - inline char* AllocZeroWithAttributesInlined(__declspec(guard(overflow)) size_t size); + inline char* AllocZeroWithAttributesInlined(DECLSPEC_GUARD_OVERFLOW size_t size); template - char* AllocZeroWithAttributes(__declspec(guard(overflow)) size_t size) + char* AllocZeroWithAttributes(DECLSPEC_GUARD_OVERFLOW size_t size) { return AllocZeroWithAttributesInlined(size); } - char* AllocWeakReferenceEntry(__declspec(guard(overflow)) size_t size) + char* AllocWeakReferenceEntry(DECLSPEC_GUARD_OVERFLOW size_t size) { return AllocWithAttributes(size); } @@ -1556,10 +1556,10 @@ class Recycler 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 - 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 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(this, allocator, sizeCat, size); } @@ -2429,7 +2429,7 @@ struct ForceLeafAllocator } _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 _Ret_notnull_ inline void * __cdecl -operator new(__declspec(guard(overflow)) size_t byteSize, Recycler * recycler, const InfoBitsWrapper&) +operator new(DECLSPEC_GUARD_OVERFLOW size_t byteSize, Recycler * recycler, const InfoBitsWrapper&) { AssertCanHandleOutOfMemory(); Assert(byteSize != 0); diff --git a/lib/Common/Memory/RecyclerFastAllocator.h b/lib/Common/Memory/RecyclerFastAllocator.h index 8fde89c9fe0..e1e5c077dec 100644 --- a/lib/Common/Memory/RecyclerFastAllocator.h +++ b/lib/Common/Memory/RecyclerFastAllocator.h @@ -37,7 +37,7 @@ class RecyclerFastAllocator } 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()); diff --git a/lib/Common/Memory/RecyclerWriteBarrierManager.h b/lib/Common/Memory/RecyclerWriteBarrierManager.h index bfc22a4592c..b3d83c30f79 100644 --- a/lib/Common/Memory/RecyclerWriteBarrierManager.h +++ b/lib/Common/Memory/RecyclerWriteBarrierManager.h @@ -55,7 +55,7 @@ class X64WriteBarrierCardTableManager 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 @@ class RecyclerWriteBarrierManager // 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 diff --git a/lib/Common/Memory/SmallHeapBlockAllocator.h b/lib/Common/Memory/SmallHeapBlockAllocator.h index 23dea5d3977..57502fae188 100644 --- a/lib/Common/Memory/SmallHeapBlockAllocator.h +++ b/lib/Common/Memory/SmallHeapBlockAllocator.h @@ -15,15 +15,15 @@ class SmallHeapBlockAllocator void Initialize(); template - 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 - 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 - 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; } diff --git a/lib/Common/Memory/VirtualAllocWrapper.h b/lib/Common/Memory/VirtualAllocWrapper.h index 8ebd9038946..9dbff564b52 100644 --- a/lib/Common/Memory/VirtualAllocWrapper.h +++ b/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 @@ class PreReservedVirtualAllocWrapper 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); diff --git a/lib/Parser/Alloc.h b/lib/Parser/Alloc.h index 13d42bb2d85..6e6b6c99eeb 100644 --- a/lib/Parser/Alloc.h +++ b/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(); } diff --git a/lib/Runtime/Language/DynamicProfileStorage.h b/lib/Runtime/Language/DynamicProfileStorage.h index a93c094279c..0e6fed63944 100644 --- a/lib/Runtime/Language/DynamicProfileStorage.h +++ b/lib/Runtime/Language/DynamicProfileStorage.h @@ -18,7 +18,7 @@ class DynamicProfileStorage 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); diff --git a/lib/Runtime/Language/JavascriptOperators.h b/lib/Runtime/Language/JavascriptOperators.h index 12c156f7bc0..102fef73de1 100644 --- a/lib/Runtime/Language/JavascriptOperators.h +++ b/lib/Runtime/Language/JavascriptOperators.h @@ -563,13 +563,13 @@ namespace Js static Var OP_AsyncSpawn(Js::Var aGenerator, Js::Var aThis, ScriptContext* scriptContext); template - 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(); diff --git a/lib/Runtime/Library/ArrayBuffer.h b/lib/Runtime/Library/ArrayBuffer.h index 809064c94b2..d49e92d33fb 100644 --- a/lib/Runtime/Library/ArrayBuffer.h +++ b/lib/Runtime/Library/ArrayBuffer.h @@ -54,9 +54,9 @@ namespace Js }; template - 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, 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: