From d5de45d13c95663fb0e631708ed649f077374303 Mon Sep 17 00:00:00 2001 From: Derek Morris Date: Thu, 19 Jul 2018 03:03:35 -0700 Subject: [PATCH] deps: update ChakraCore to Microsoft/ChakraCore@1fc4e1f08b [MERGE #5476 @Penguinwizzard] Fix a set of permissive- issues Merge pull request #5476 from Penguinwizzard:permissiveminus This is a set of fixes for some of the issues that permissive- hits in our codebase. There's a few more (~15 or so right now) that I didn't get around to yet, and won't address in this PR (they tend to look like they need more extensive changes to address). Fixes #4596 Fixes #5189 Reviewed-By: chakrabot --- .../core/lib/Backend/GlobHashTable.h | 6 +- deps/chakrashim/core/lib/Common/CommonMin.h | 2 +- .../lib/Common/DataStructures/ClusterList.h | 10 +-- .../lib/Common/DataStructures/EvalMapString.h | 2 +- .../core/lib/Common/DataStructures/List.h | 4 +- .../Common/Memory/AutoAllocatorObjectPtr.h | 16 ++-- .../core/lib/Common/Memory/AutoPtr.h | 12 +-- .../core/lib/Common/PlatformAgnostic/Arrays.h | 2 +- deps/chakrashim/core/lib/Parser/Parse.cpp | 24 ------ deps/chakrashim/core/lib/Parser/Parse.h | 26 ++++++- .../core/lib/Runtime/Base/ThreadContext.h | 2 + .../core/lib/Runtime/Library/TypedArray.h | 74 +++++++++++++------ .../Platform/Windows/HiResTimer.cpp | 4 +- 13 files changed, 107 insertions(+), 77 deletions(-) diff --git a/deps/chakrashim/core/lib/Backend/GlobHashTable.h b/deps/chakrashim/core/lib/Backend/GlobHashTable.h index 6c043473da3..65418bcb931 100644 --- a/deps/chakrashim/core/lib/Backend/GlobHashTable.h +++ b/deps/chakrashim/core/lib/Backend/GlobHashTable.h @@ -329,13 +329,13 @@ class ValueHashTable { _TYPENAME SListBase::Iterator iter2(&this2->table[i]); iter2.Next(); - FOREACH_SLISTBASE_ENTRY_EDITING((HashBucket), bucket, &this->table[i], iter) + FOREACH_SLISTBASE_ENTRY_EDITING(HashBucket, bucket, &this->table[i], iter) { while (iter2.IsValid() && bucket.value < iter2.Data().value) { HashBucket * newBucket = iter.InsertNodeBefore(this->alloc); newBucket->value = iter2.Data().value; - newBucket->element = fn(null, iter2.Data().element); + newBucket->element = fn(nullptr, iter2.Data().element); iter2.Next(); } @@ -354,7 +354,7 @@ class ValueHashTable { HashBucket * newBucket = iter.InsertNodeBefore(this->alloc); newBucket->value = iter2.Data().value; - newBucket->element = fn(null, iter2.Data().element); + newBucket->element = fn(nullptr, iter2.Data().element); iter2.Next(); } } diff --git a/deps/chakrashim/core/lib/Common/CommonMin.h b/deps/chakrashim/core/lib/Common/CommonMin.h index 89b32437877..ca81b5e97c5 100644 --- a/deps/chakrashim/core/lib/Common/CommonMin.h +++ b/deps/chakrashim/core/lib/Common/CommonMin.h @@ -53,8 +53,8 @@ using namespace Memory; #include "DataStructures/SList.h" #include "DataStructures/DList.h" #include "DataStructures/KeyValuePair.h" -#include "DataStructures/BaseDictionary.h" #include "DataStructures/DictionaryEntry.h" +#include "DataStructures/BaseDictionary.h" #include "DataStructures/ClusterList.h" // === Configurations Header === diff --git a/deps/chakrashim/core/lib/Common/DataStructures/ClusterList.h b/deps/chakrashim/core/lib/Common/DataStructures/ClusterList.h index 9b44a150b4e..b2c94a27643 100644 --- a/deps/chakrashim/core/lib/Common/DataStructures/ClusterList.h +++ b/deps/chakrashim/core/lib/Common/DataStructures/ClusterList.h @@ -44,8 +44,8 @@ class ClusterList , consolidated(true) #endif { - list = AllocatorNewArrayLeaf(TAllocator, this->alloc, indexType, maxCount); - for (indextype i = 0; i < maxIndex; i++) + list = AllocatorNewArrayLeaf(TAllocator, this->alloc, indexType, maxIndex); + for (indexType i = 0; i < maxIndex; i++) { list[i] = i; } @@ -68,7 +68,7 @@ class ClusterList { if (this->list != nullptr) { - AllocatorDeleteArrayLeaf(TAllocator, this->alloc, maxCount, this->list); + AllocatorDeleteArrayLeaf(TAllocator, this->alloc, maxIndex, this->list); this->list = nullptr; } } @@ -86,7 +86,7 @@ class ClusterList // Reset the list; useful if we're re-using the data structure void Reset() { - for (indextype i = 0; i < maxIndex; i++) + for (indexType i = 0; i < maxIndex; i++) { list[i] = i; } @@ -313,7 +313,7 @@ class SegmentClusterList { if (backingStore[i] != nullptr) { - AllocatorDeleteArrayLeaf(TAllocator, alloc, numPerSegment, backingstore[i]); + AllocatorDeleteArrayLeaf(TAllocator, alloc, numPerSegment, backingStore[i]); backingStore[i] = nullptr; } } diff --git a/deps/chakrashim/core/lib/Common/DataStructures/EvalMapString.h b/deps/chakrashim/core/lib/Common/DataStructures/EvalMapString.h index 2483bbcad0e..335dcbb25d3 100644 --- a/deps/chakrashim/core/lib/Common/DataStructures/EvalMapString.h +++ b/deps/chakrashim/core/lib/Common/DataStructures/EvalMapString.h @@ -34,7 +34,7 @@ namespace Js EvalMapStringInternal& operator=(void * str) { Assert(str == null); - memset(this, 0, sizeof(EvalMapString)); + memset(this, 0, sizeof(*this)); return (*this); } diff --git a/deps/chakrashim/core/lib/Common/DataStructures/List.h b/deps/chakrashim/core/lib/Common/DataStructures/List.h index 40b4b385348..8def4634c3a 100644 --- a/deps/chakrashim/core/lib/Common/DataStructures/List.h +++ b/deps/chakrashim/core/lib/Common/DataStructures/List.h @@ -341,7 +341,7 @@ namespace JsUtil template bool Last(TConditionalFunction function, T& outElement) { - for (int i = count - 1; i >= 0; --i) + for (int i = this->count - 1; i >= 0; --i) { if (function(this->buffer[i])) { @@ -420,7 +420,7 @@ namespace JsUtil JsUtil::ExternalApi::RaiseOnIntOverflow(); } - js_memcpy_s(buffer + this->count, availableByteSpace, items, givenBufferSize); + js_memcpy_s(this->buffer + this->count, availableByteSpace, items, givenBufferSize); this->count = requiredSize; return requiredSize; //Returns count diff --git a/deps/chakrashim/core/lib/Common/Memory/AutoAllocatorObjectPtr.h b/deps/chakrashim/core/lib/Common/Memory/AutoAllocatorObjectPtr.h index 254ca9e5e50..de8d7815c35 100644 --- a/deps/chakrashim/core/lib/Common/Memory/AutoAllocatorObjectPtr.h +++ b/deps/chakrashim/core/lib/Common/Memory/AutoAllocatorObjectPtr.h @@ -61,10 +61,10 @@ class AutoAllocatorArrayPtr : public BasePtr private: void Clear() { - if (ptr != nullptr) + if (this->ptr != nullptr) { - DeleteArray(m_allocator, m_elementCount, ptr); - ptr = nullptr; + DeleteArray(m_allocator, this->m_elementCount, this->ptr); + this->ptr = nullptr; } } }; @@ -98,14 +98,14 @@ class AutoAllocatorObjectArrayPtr : public AutoAllocatorArrayPtrptr != nullptr) { - for (size_t i = 0; i < m_elementCount; i++) + for (size_t i = 0; i < this->m_elementCount; i++) { - if (ptr[i] != nullptr) + if (this->ptr[i] != nullptr) { - DeleteObject(m_allocator, ptr[i]); - ptr[i] = nullptr; + DeleteObject(this->m_allocator, this->ptr[i]); + this->ptr[i] = nullptr; } } } diff --git a/deps/chakrashim/core/lib/Common/Memory/AutoPtr.h b/deps/chakrashim/core/lib/Common/Memory/AutoPtr.h index c9752cc1487..c92205e7815 100644 --- a/deps/chakrashim/core/lib/Common/Memory/AutoPtr.h +++ b/deps/chakrashim/core/lib/Common/Memory/AutoPtr.h @@ -76,18 +76,18 @@ class AutoArrayAndItemsPtr : public AutoArrayPtr private: void Clear() { - if (ptr != nullptr){ + if (this->ptr != nullptr){ for (size_t i = 0; i < this->m_elementCount; i++) { - if (ptr[i] != nullptr) + if (this->ptr[i] != nullptr) { - ptr[i]->CleanUp(); - ptr[i] = nullptr; + this->ptr[i]->CleanUp(); + this->ptr[i] = nullptr; } } - HeapDeleteArray(m_elementCount, ptr); - ptr = nullptr; + HeapDeleteArray(this->m_elementCount, this->ptr); + this->ptr = nullptr; } } }; diff --git a/deps/chakrashim/core/lib/Common/PlatformAgnostic/Arrays.h b/deps/chakrashim/core/lib/Common/PlatformAgnostic/Arrays.h index b04334c1b7c..b1f5ed864ea 100644 --- a/deps/chakrashim/core/lib/Common/PlatformAgnostic/Arrays.h +++ b/deps/chakrashim/core/lib/Common/PlatformAgnostic/Arrays.h @@ -31,7 +31,7 @@ namespace Arrays bool GetLocaleSeparator(char16* szSeparator, uint32* sepOutLength, uint32 sepBufferSize); template - inline bool GetLocaleSeparator(char16(&szSepatator)[sepBufferSize], uint32 *sepOutLength) + inline bool GetLocaleSeparator(char16(&szSeparator)[sepBufferSize], uint32 *sepOutLength) { return GetLocaleSeparator(szSeparator, sepOutLength, sepBufferSize); } diff --git a/deps/chakrashim/core/lib/Parser/Parse.cpp b/deps/chakrashim/core/lib/Parser/Parse.cpp index 6960249ac41..838c165dc70 100644 --- a/deps/chakrashim/core/lib/Parser/Parse.cpp +++ b/deps/chakrashim/core/lib/Parser/Parse.cpp @@ -31,30 +31,6 @@ bool Parser::IsES6DestructuringEnabled() const return m_scriptContext->GetConfig()->IsES6DestructuringEnabled(); } -struct StmtNest -{ - union - { - struct - { - ParseNodeStmt * pnodeStmt; // This statement node. - }; - struct - { - bool isDeferred : 1; - OpCode op; // This statement operation. - }; - }; - LabelId* pLabelId; // Labels for this statement. - StmtNest *pstmtOuter; // Enclosing statement. - - OpCode GetNop() const - { - AnalysisAssert(isDeferred || pnodeStmt != nullptr); - return isDeferred ? op : pnodeStmt->nop; - } -}; - struct BlockInfoStack { StmtNest pstmt; diff --git a/deps/chakrashim/core/lib/Parser/Parse.h b/deps/chakrashim/core/lib/Parser/Parse.h index 97dc23cbd68..3e0c6768336 100644 --- a/deps/chakrashim/core/lib/Parser/Parse.h +++ b/deps/chakrashim/core/lib/Parser/Parse.h @@ -76,8 +76,32 @@ struct PidRefStack; struct DeferredFunctionStub; -struct StmtNest; struct BlockInfoStack; + +struct StmtNest +{ + union + { + struct + { + ParseNodeStmt * pnodeStmt; // This statement node. + }; + struct + { + bool isDeferred : 1; + OpCode op; // This statement operation. + }; + }; + LabelId* pLabelId; // Labels for this statement. + StmtNest *pstmtOuter; // Enclosing statement. + + inline OpCode GetNop() const + { + AnalysisAssert(isDeferred || pnodeStmt != nullptr); + return isDeferred ? op : pnodeStmt->nop; + } +}; + struct ParseContext { LPCUTF8 pszSrc; diff --git a/deps/chakrashim/core/lib/Runtime/Base/ThreadContext.h b/deps/chakrashim/core/lib/Runtime/Base/ThreadContext.h index 3270db6b44f..134919c5b10 100644 --- a/deps/chakrashim/core/lib/Runtime/Base/ThreadContext.h +++ b/deps/chakrashim/core/lib/Runtime/Base/ThreadContext.h @@ -322,6 +322,8 @@ class ThreadConfiguration } }; +class AutoReentrancyHandler; + class ThreadContext sealed : public DefaultRecyclerCollectionWrapper, public JsUtil::DoublyLinkedListElement, diff --git a/deps/chakrashim/core/lib/Runtime/Library/TypedArray.h b/deps/chakrashim/core/lib/Runtime/Library/TypedArray.h index 1562782f6d5..2e37c8ea0ca 100644 --- a/deps/chakrashim/core/lib/Runtime/Library/TypedArray.h +++ b/deps/chakrashim/core/lib/Runtime/Library/TypedArray.h @@ -217,6 +217,34 @@ namespace Js }; template + class TypedArray; + + // These are referenced in the TypedArray implementation, so we need to forward-typedef these. + + typedef TypedArray Int8Array; + typedef TypedArray Uint8Array; + typedef TypedArray Uint8ClampedArray; + typedef TypedArray Int16Array; + typedef TypedArray Uint16Array; + typedef TypedArray Int32Array; + typedef TypedArray Uint32Array; + typedef TypedArray Float32Array; + typedef TypedArray Float64Array; + typedef TypedArray Int64Array; + typedef TypedArray Uint64Array; + typedef TypedArray BoolArray; + typedef TypedArray Int8VirtualArray; + typedef TypedArray Uint8VirtualArray; + typedef TypedArray Uint8ClampedVirtualArray; + typedef TypedArray Int16VirtualArray; + typedef TypedArray Uint16VirtualArray; + typedef TypedArray Int32VirtualArray; + typedef TypedArray Uint32VirtualArray; + typedef TypedArray Float32VirtualArray; + typedef TypedArray Float64VirtualArray; + + + template class TypedArray : public TypedArrayBase { protected: @@ -625,34 +653,34 @@ namespace Js #if defined(__clang__) // hack for clang message: "...add an explicit instantiation declaration to .." -#define __EXPLICIT_INSTANTINATE_TA(x) x;\ +#define __EXPLICIT_INSTANTINATE_TA(x) \ template<> FunctionInfo Js::x::EntryInfo::NewInstance;\ template<> FunctionInfo Js::x::EntryInfo::Set #else // MSVC -#define __EXPLICIT_INSTANTINATE_TA(x) x +#define __EXPLICIT_INSTANTINATE_TA(x) #endif - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int8Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint8Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint8ClampedArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int16Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint16Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int32Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint32Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Float32Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Float64Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int64Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint64Array); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(BoolArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int8VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint8VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint8ClampedVirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int16VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint16VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Int32VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Uint32VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Float32VirtualArray); - typedef TypedArray __EXPLICIT_INSTANTINATE_TA(Float64VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Int8Array); + __EXPLICIT_INSTANTINATE_TA(Uint8Array); + __EXPLICIT_INSTANTINATE_TA(Uint8ClampedArray); + __EXPLICIT_INSTANTINATE_TA(Int16Array); + __EXPLICIT_INSTANTINATE_TA(Uint16Array); + __EXPLICIT_INSTANTINATE_TA(Int32Array); + __EXPLICIT_INSTANTINATE_TA(Uint32Array); + __EXPLICIT_INSTANTINATE_TA(Float32Array); + __EXPLICIT_INSTANTINATE_TA(Float64Array); + __EXPLICIT_INSTANTINATE_TA(Int64Array); + __EXPLICIT_INSTANTINATE_TA(Uint64Array); + __EXPLICIT_INSTANTINATE_TA(BoolArray); + __EXPLICIT_INSTANTINATE_TA(Int8VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Uint8VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Uint8ClampedVirtualArray); + __EXPLICIT_INSTANTINATE_TA(Int16VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Uint16VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Int32VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Uint32VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Float32VirtualArray); + __EXPLICIT_INSTANTINATE_TA(Float64VirtualArray); #undef __EXPLICIT_INSTANTINATE_TA } diff --git a/deps/chakrashim/core/lib/Runtime/PlatformAgnostic/Platform/Windows/HiResTimer.cpp b/deps/chakrashim/core/lib/Runtime/PlatformAgnostic/Platform/Windows/HiResTimer.cpp index 1584239a5ef..0bc9999d5d0 100644 --- a/deps/chakrashim/core/lib/Runtime/PlatformAgnostic/Platform/Windows/HiResTimer.cpp +++ b/deps/chakrashim/core/lib/Runtime/PlatformAgnostic/Platform/Windows/HiResTimer.cpp @@ -22,7 +22,7 @@ namespace DateTime double currentRandomWindowScaled = 0.0; ULONGLONG currentQuantizedQpc = 0; public: - JitterManager::JitterManager() + JitterManager() { // NOTE: We could cache the (1000/frequency) operation, as a double, // that is used later to convert from seconds to milliseconds so that @@ -68,7 +68,7 @@ namespace DateTime quantizationToSelectedScaleFactor = max(quantizationToSelectedScaleFactor, 1.0); } - uint64 JitterManager::QuantizedQPC(uint64 qpc) + uint64 QuantizedQPC(uint64 qpc) { // Due to further analysis of some attacks, we're jittering on a more granular // frequency of as much as a full millisecond.