Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Backend/EmitBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Backend/GlobHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ValueHashTable
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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Backend/NativeCodeData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 7 additions & 0 deletions lib/Common/CommonPal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
#define __forceinline inline
#endif

// Only VC compiler support overflow guard
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about gcc's 'stack-protector' compiler flag?

#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")\
Expand Down
4 changes: 2 additions & 2 deletions lib/Common/Core/AllocSizeMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions lib/Common/DataStructures/BaseDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/Common/DataStructures/FixedBitVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class BVFixed
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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/Common/DataStructures/HashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HashTable
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);
}
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/Common/DataStructures/InternalString.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Common/DataStructures/List.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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=
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Common/DataStructures/MruDictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Common/Memory/AllocationPolicyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
18 changes: 9 additions & 9 deletions lib/Common/Memory/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading