Skip to content

Commit 226a96e

Browse files
committed
[1.2>master] Merge remaining code changes from internal RS1 branch
2 parents 3d6ef20 + 898582f commit 226a96e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1064
-298
lines changed

Build/Common.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<RuntimeTypeInfo>false</RuntimeTypeInfo>
2121
<!-- /Zi -->
2222
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
23+
<DebugInformationFormat Condition="'$(MultiProcessorCompilation)' == 'true'">OldStyle</DebugInformationFormat>
2324
<!-- /EHsc- -->
2425
<ExceptionHandling>SyncCThrow</ExceptionHandling>
2526
<!-- /Gz -->

lib/Backend/EmitBuffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class EmitBufferManager
3737
void Decommit();
3838
void Clear();
3939

40-
EmitBufferAllocation* AllocateBuffer(__in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer, ushort pdataCount = 0, ushort xdataSize = 0, bool canAllocInPreReservedHeapPageSegment = false, bool isAnyJittedCode = false);
40+
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);
4141
bool CommitBuffer(EmitBufferAllocation* allocation, __out_bcount(bytes) BYTE* destBuffer, __in size_t bytes, __in_bcount(bytes) const BYTE* sourceBuffer, __in DWORD alignPad = 0);
4242
bool ProtectBufferWithExecuteReadWriteForInterpreter(EmitBufferAllocation* allocation);
4343
bool CommitReadWriteBufferForInterpreter(EmitBufferAllocation* allocation, _In_reads_bytes_(bufferSize) BYTE* pBuffer, _In_ size_t bufferSize);
@@ -72,8 +72,8 @@ class EmitBufferManager
7272
ArenaAllocator * allocator;
7373
Js::ScriptContext * scriptContext;
7474

75-
EmitBufferAllocation * NewAllocation(size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode);
76-
EmitBufferAllocation* GetBuffer(EmitBufferAllocation *allocation, __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer);
75+
EmitBufferAllocation * NewAllocation(__declspec(guard(overflow)) size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode);
76+
EmitBufferAllocation* GetBuffer(EmitBufferAllocation *allocation, __declspec(guard(overflow)) __in size_t bytes, __deref_bcount(bytes) BYTE** ppBuffer);
7777

7878
bool FinalizeAllocation(EmitBufferAllocation *allocation);
7979
CustomHeap::Heap allocationHeap;

lib/Backend/GlobHashTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ValueHashTable
5555
SListBase<HashBucket> * table;
5656

5757
public:
58-
static ValueHashTable * New(JitArenaAllocator *allocator, uint tableSize)
58+
static ValueHashTable * New(JitArenaAllocator *allocator, __declspec(guard(overflow)) uint tableSize)
5959
{
6060
return AllocatorNewPlus(JitArenaAllocator, allocator, (tableSize*sizeof(SListBase<HashBucket>)), ValueHashTable, allocator, tableSize);
6161
}

lib/Backend/Lower.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include "ExternalLowerer.h"
1515

16-
#include "ExternalLowerer.h"
17-
1816
///----------------------------------------------------------------------------
1917
///
2018
/// Lowerer::Lower
@@ -8404,6 +8402,7 @@ Lowerer::LowerLdArrViewElem(IR::Instr * instr)
84048402
IR::Opnd * src2 = instr->GetSrc2();
84058403

84068404
IR::Instr * done;
8405+
84078406
if (indexOpnd || m_func->GetJnFunction()->GetAsmJsFunctionInfoWithLock()->AccessNeedsBoundCheck((uint32)src1->AsIndirOpnd()->GetOffset()))
84088407
{
84098408
// CMP indexOpnd, src2(arrSize)
@@ -20242,7 +20241,7 @@ Lowerer::GenerateLdSuper(IR::Instr* instrInsert)
2024220241
Assert(dstOpnd->IsRegOpnd());
2024320242
LowererMD::CreateAssign(dstOpnd, opndUndefAddress, instrInsert);
2024420243

20245-
IR::Opnd * functionObjOpnd;
20244+
IR::Opnd * functionObjOpnd = nullptr;
2024620245
m_lowererMD.LoadFunctionObjectOpnd(instrInsert, functionObjOpnd);
2024720246
LowererMD::CreateAssign(instanceRegOpnd, functionObjOpnd, instrInsert);
2024820247

lib/Backend/NativeCodeData.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class NativeCodeData
3636
Allocator();
3737
~Allocator();
3838

39-
char * Alloc(size_t requestedBytes);
40-
char * AllocZero(size_t requestedBytes);
39+
char * Alloc(__declspec(guard(overflow)) size_t requestedBytes);
40+
char * AllocZero(__declspec(guard(overflow)) size_t requestedBytes);
4141
NativeCodeData * Finalize();
4242
void Free(void * buffer, size_t byteSize);
4343

lib/Backend/amd64/LowererMDArch.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,20 @@ LowererMDArch::LoadDynamicArgumentUsingLength(IR::Instr *instr)
12211221
IR::Instr *
12221222
LowererMDArch::LoadDoubleHelperArgument(IR::Instr * instrInsert, IR::Opnd * opndArg)
12231223
{
1224-
Assert(opndArg->IsFloat64());
1224+
IR::Opnd * float64Opnd;
1225+
if (opndArg->GetType() == TyFloat32)
1226+
{
1227+
float64Opnd = IR::RegOpnd::New(TyFloat64, m_func);
1228+
IR::Instr * instr = IR::Instr::New(Js::OpCode::CVTSS2SD, float64Opnd, opndArg, this->m_func);
1229+
instrInsert->InsertBefore(instr);
1230+
}
1231+
else
1232+
{
1233+
float64Opnd = opndArg;
1234+
}
1235+
1236+
Assert(opndArg->IsFloat());
1237+
12251238
return LoadHelperArgument(instrInsert, opndArg);
12261239
}
12271240

lib/Backend/arm/Thunks.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
;Js::JavascriptMethod NativeCodeGenerator::CheckCodeGen(Js::JavascriptFunction * function)
1515
IMPORT |?CheckCodeGen@NativeCodeGenerator@@SAP6APAXPAVRecyclableObject@Js@@UCallInfo@3@ZZPAVScriptFunction@3@@Z|
1616

17+
#if defined(_CONTROL_FLOW_GUARD)
18+
IMPORT __guard_check_icall_fptr
19+
#endif
20+
1721
TEXTAREA
1822

1923
;;============================================================================================================

lib/Common/Core/AllocSizeMath.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class AllocSizeMath
1010
// Works for both 32bit and 64bit size_t arithmetic. It's also pretty
1111
// optimal in the cases where either left or right or both are small, compile-
1212
// time constants.
13-
static size_t Add(size_t left, size_t right)
13+
static size_t Add(__declspec(guard(overflow)) size_t left, __declspec(guard(overflow)) size_t right)
1414
{
1515
size_t allocSize = left + right;
1616
if (allocSize < left)
@@ -28,7 +28,7 @@ class AllocSizeMath
2828
}
2929

3030
// Optimized for right being a constant power of 2...
31-
static size_t Mul(size_t left, size_t right)
31+
static size_t Mul(__declspec(guard(overflow)) size_t left, __declspec(guard(overflow)) size_t right)
3232
{
3333
size_t allocSize = left * right;
3434
if (left != (allocSize / right))

lib/Common/DataStructures/BaseDictionary.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ namespace JsUtil
10431043
entries = newEntries;
10441044
}
10451045

1046-
__ecount(bucketCount) int *AllocateBuckets(const uint bucketCount)
1046+
__ecount(bucketCount) int *AllocateBuckets(__declspec(guard(overflow)) const uint bucketCount)
10471047
{
10481048
return
10491049
AllocateArray<AllocatorType, int, false>(
@@ -1052,7 +1052,7 @@ namespace JsUtil
10521052
bucketCount);
10531053
}
10541054

1055-
__ecount(size) EntryType * AllocateEntries(int size, const bool zeroAllocate = true)
1055+
__ecount(size) EntryType * AllocateEntries(__declspec(guard(overflow)) int size, const bool zeroAllocate = true)
10561056
{
10571057
// Note that the choice of leaf/non-leaf node is decided for the EntryType on the basis of TValue. By default, if
10581058
// TValue is a pointer, a non-leaf allocation is done. This behavior can be overridden by specializing
@@ -1080,7 +1080,7 @@ namespace JsUtil
10801080
AllocatorFree(alloc, EntryAllocatorFuncType::GetFreeFunc(), entries, size * sizeof(EntryType));
10811081
}
10821082

1083-
void Allocate(__deref_out_ecount(bucketCount) int** ppBuckets, __deref_out_ecount(size) EntryType** ppEntries, uint bucketCount, int size)
1083+
void Allocate(__deref_out_ecount(bucketCount) int** ppBuckets, __deref_out_ecount(size) EntryType** ppEntries, __declspec(guard(overflow)) uint bucketCount, __declspec(guard(overflow)) int size)
10841084
{
10851085
int *const buckets = AllocateBuckets(bucketCount);
10861086
Assert(buckets); // no-throw allocators are currently not supported

lib/Common/DataStructures/FixedBitVector.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class BVFixed
3535
static BVFixed * New(TAllocator* alloc, BVFixed * initBv);
3636

3737
template <typename TAllocator>
38-
static BVFixed * New(BVIndex length, TAllocator* alloc, bool initialSet = false);
38+
static BVFixed * New(__declspec(guard(overflow)) BVIndex length, TAllocator* alloc, bool initialSet = false);
3939

4040
template <typename TAllocator>
41-
static BVFixed * NewNoThrow(BVIndex length, TAllocator* alloc, bool initialSet = false);
41+
static BVFixed * NewNoThrow(__declspec(guard(overflow)) BVIndex length, TAllocator* alloc, bool initialSet = false);
4242

4343
template <typename TAllocator>
4444
void Delete(TAllocator * alloc);
@@ -152,14 +152,14 @@ BVFixed * BVFixed::New(TAllocator * alloc, BVFixed * initBv)
152152
}
153153

154154
template <typename TAllocator>
155-
BVFixed * BVFixed::New(BVIndex length, TAllocator * alloc, bool initialSet)
155+
BVFixed * BVFixed::New(__declspec(guard(overflow)) BVIndex length, TAllocator * alloc, bool initialSet)
156156
{
157157
BVFixed *result = AllocatorNewPlus(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, length, initialSet);
158158
return result;
159159
}
160160

161161
template <typename TAllocator>
162-
BVFixed * BVFixed::NewNoThrow(BVIndex length, TAllocator * alloc, bool initialSet)
162+
BVFixed * BVFixed::NewNoThrow(__declspec(guard(overflow)) BVIndex length, TAllocator * alloc, bool initialSet)
163163
{
164164
BVFixed *result = AllocatorNewNoThrowPlus(TAllocator, alloc, sizeof(BVUnit) * BVFixed::WordCount(length), BVFixed, length, initialSet);
165165
return result;

lib/Common/DataStructures/HashTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class HashTable
3333
SListBase<Bucket<T>> * table;
3434

3535
public:
36-
static HashTable<T, TAllocator> * New(TAllocator *allocator, uint tableSize)
36+
static HashTable<T, TAllocator> * New(TAllocator *allocator, __declspec(guard(overflow)) uint tableSize)
3737
{
3838
return AllocatorNewPlus(TAllocator, allocator, (tableSize*sizeof(SListBase<Bucket<T>>)), HashTable, allocator, tableSize);
3939
}
@@ -382,7 +382,7 @@ class HashTable
382382
#endif
383383

384384
protected:
385-
HashTable(TAllocator * allocator, uint tableSize) : alloc(allocator), tableSize(tableSize)
385+
HashTable(TAllocator * allocator, __declspec(guard(overflow)) uint tableSize) : alloc(allocator), tableSize(tableSize)
386386
{
387387
Init();
388388
#if PROFILE_DICTIONARY

lib/Common/DataStructures/InternalString.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ namespace Js
1414

1515
public:
1616
InternalString() : m_charLength(0), m_content(NULL), m_offset(0) { };
17-
InternalString(const char16* content, charcount_t charLength, unsigned char offset = 0);
18-
static InternalString* New(ArenaAllocator* alloc, const char16* content, charcount_t length);
19-
static InternalString* New(Recycler* recycler, const char16* content, charcount_t length);
20-
static InternalString* NewNoCopy(ArenaAllocator* alloc, const char16* content, charcount_t length);
17+
InternalString(const char16* content, __declspec(guard(overflow)) charcount_t charLength, unsigned char offset = 0);
18+
static InternalString* New(ArenaAllocator* alloc, const char16* content, __declspec(guard(overflow)) charcount_t length);
19+
static InternalString* New(Recycler* recycler, const char16* content, __declspec(guard(overflow)) charcount_t length);
20+
static InternalString* NewNoCopy(ArenaAllocator* alloc, const char16* content, __declspec(guard(overflow)) charcount_t length);
2121

2222
inline charcount_t GetLength() const
2323
{

lib/Common/DataStructures/List.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace JsUtil
6464
}
6565

6666
template<class TAllocator>
67-
static ReadOnlyList * New(TAllocator* alloc, __in_ecount(count) T* buffer, int count)
67+
static ReadOnlyList * New(TAllocator* alloc, __in_ecount(count) T* buffer, __declspec(guard(overflow)) int count)
6868
{
6969
return AllocatorNew(TAllocator, alloc, ReadOnlyList, buffer, count, alloc);
7070
}
@@ -213,7 +213,7 @@ namespace JsUtil
213213
int increment;
214214
TRemovePolicyType removePolicy;
215215

216-
T * AllocArray(int size) { return AllocatorNewArrayBaseFuncPtr(TAllocator, this->alloc, AllocatorInfo::GetAllocFunc(), T, size); }
216+
T * AllocArray(__declspec(guard(overflow)) int size) { return AllocatorNewArrayBaseFuncPtr(TAllocator, this->alloc, AllocatorInfo::GetAllocFunc(), T, size); }
217217
void FreeArray(T * oldBuffer, int oldBufferSize) { AllocatorFree(this->alloc, AllocatorInfo::GetFreeFunc(), oldBuffer, oldBufferSize); }
218218

219219
PREVENT_COPY(List); // Disable copy constructor and operator=
@@ -234,7 +234,7 @@ namespace JsUtil
234234
EnsureArray(0);
235235
}
236236

237-
void EnsureArray(int32 requiredCapacity)
237+
void EnsureArray(__declspec(guard(overflow)) int32 requiredCapacity)
238238
{
239239
if (this->buffer == nullptr)
240240
{

lib/Common/DataStructures/MruDictionary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ namespace JsUtil
111111
Assert(mruListCapacity > 0);
112112
}
113113

114-
static MruDictionary *New(TAllocator *const allocator, const int mruListCapacity)
114+
static MruDictionary *New(TAllocator *const allocator, __declspec(guard(overflow)) const int mruListCapacity)
115115
{
116116
return AllocatorNew(TAllocator, allocator, MruDictionary, allocator, mruListCapacity);
117117
}

lib/Common/Memory/AllocationPolicyManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typedef bool (__stdcall * PageAllocatorMemoryAllocationCallback)(__in LPVOID con
6363
memoryLimit = newLimit;
6464
}
6565

66-
bool RequestAlloc(size_t byteCount)
66+
bool RequestAlloc(__declspec(guard(overflow)) size_t byteCount)
6767
{
6868
if (supportConcurrency)
6969
{

lib/Common/Memory/Allocator.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void DeleteObject(typename AllocatorInfo<TAllocator, T>::AllocatorType * allocat
270270
#define ZERO_LENGTH_ARRAY (void *)sizeof(void *)
271271
template <typename TAllocator, typename T, bool nothrow>
272272
_When_(nothrow, _Ret_writes_to_maybenull_(count, 0)) _When_(!nothrow, _Ret_writes_to_(count, 0))
273-
inline T * AllocateArray(TAllocator * allocator, char * (TAllocator::*AllocFunc)(size_t), size_t count)
273+
inline T * AllocateArray(TAllocator * allocator, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t count)
274274
{
275275
if (count == 0 && TAllocator::FakeZeroLengthArray)
276276
{
@@ -349,7 +349,7 @@ void AssertValue(void * mem, T value, uint byteCount)
349349
_Ret_notnull_
350350
inline void * __cdecl
351351
operator new(
352-
size_t byteSize,
352+
__declspec(guard(overflow)) size_t byteSize,
353353
_In_ void * previousAllocation) throw()
354354
{
355355
return previousAllocation;
@@ -372,7 +372,7 @@ void * previousAllocation // Previously allocated memory
372372
//----------------------------------------
373373
template <typename TAllocator>
374374
_Ret_notnull_ void * __cdecl
375-
operator new(size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
375+
operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
376376
{
377377
AssertCanHandleOutOfMemory();
378378
Assert(byteSize != 0);
@@ -383,7 +383,7 @@ operator new(size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc
383383

384384
template <typename TAllocator>
385385
_Ret_notnull_ inline void * __cdecl
386-
operator new[](size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
386+
operator new[](__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t))
387387
{
388388
AssertCanHandleOutOfMemory();
389389
Assert(byteSize != 0 || !TAllocator::FakeZeroLengthArray);
@@ -394,7 +394,7 @@ operator new[](size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFu
394394

395395
template <typename TAllocator>
396396
_Ret_notnull_ inline void * __cdecl
397-
operator new(size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t), size_t plusSize)
397+
operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize)
398398
{
399399
AssertCanHandleOutOfMemory();
400400
Assert(byteSize != 0);
@@ -411,7 +411,7 @@ operator new(size_t byteSize, TAllocator * alloc, char * (TAllocator::*AllocFunc
411411
//----------------------------------------
412412
template <typename TAllocator>
413413
_Ret_maybenull_ inline void * __cdecl
414-
operator new(size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
414+
operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
415415
{
416416
Assert(nothrow);
417417
Assert(byteSize != 0);
@@ -422,7 +422,7 @@ operator new(size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocat
422422

423423
template <typename TAllocator>
424424
_Ret_maybenull_ inline void * __cdecl
425-
operator new[](size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
425+
operator new[](__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t))
426426
{
427427
Assert(nothrow);
428428
Assert(byteSize != 0 || !TAllocator::FakeZeroLengthArray);
@@ -433,7 +433,7 @@ operator new[](size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAlloc
433433

434434
template <typename TAllocator>
435435
_Ret_maybenull_ inline void * __cdecl
436-
operator new(size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), size_t plusSize)
436+
operator new(__declspec(guard(overflow)) size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), __declspec(guard(overflow)) size_t plusSize)
437437
{
438438
Assert(nothrow);
439439
Assert(byteSize != 0);
@@ -447,7 +447,7 @@ operator new(size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocat
447447

448448
template <typename TAllocator>
449449
_Ret_maybenull_ inline void * __cdecl
450-
operator new(size_t byteSize, TAllocator * alloc, bool nothrow, char * (TAllocator::*AllocFunc)(size_t), size_t plusSize, bool prefix)
450+
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)
451451
{
452452
Assert(nothrow);
453453
Assert(prefix);

0 commit comments

Comments
 (0)