WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
more
blah.patch (text/plain), 35.23 KB, created by
Filip Pizlo
on 2018-01-28 19:39:55 PST
(
hide
)
Description:
more
Filename:
MIME Type:
Creator:
Filip Pizlo
Created:
2018-01-28 19:39:55 PST
Size:
35.23 KB
patch
obsolete
>Index: Source/JavaScriptCore/Sources.txt >=================================================================== >--- Source/JavaScriptCore/Sources.txt (revision 227720) >+++ Source/JavaScriptCore/Sources.txt (working copy) >@@ -502,6 +502,7 @@ heap/IsoSubspace.cpp > heap/JITStubRoutineSet.cpp > heap/LargeAllocation.cpp > heap/LocalAllocator.cpp >+heap/LocalSideAllocator.cpp > heap/MachineStackMarker.cpp > heap/MarkStack.cpp > heap/MarkStackMergingConstraint.cpp >@@ -512,6 +513,7 @@ heap/MarkingConstraintSet.cpp > heap/MarkingConstraintSolver.cpp > heap/MutatorScheduler.cpp > heap/MutatorState.cpp >+heap/SecurityOriginToken.cpp > heap/SimpleMarkingConstraint.cpp > heap/SlotVisitor.cpp > heap/SpaceTimeMutatorScheduler.cpp >Index: Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >=================================================================== >--- Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (revision 227720) >+++ Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (working copy) >@@ -294,6 +294,8 @@ > 0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A451460CBAB00131F8F /* ValueRecovery.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F426A491460CBB700131F8F /* VirtualRegister.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A461460CBAB00131F8F /* VirtualRegister.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F426A4B1460CD6E00131F8F /* DataFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F426A4A1460CD6B00131F8F /* DataFormat.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 0F42B3C1201EB50F00357031 /* LocalSideAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F42B3BC201EB4C800357031 /* LocalSideAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 0F42B3C3201EC9FF00357031 /* SecurityOriginToken.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F42B3C2201EC9FD00357031 /* SecurityOriginToken.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F431738146BAC69007E3890 /* ListableHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F431736146BAC65007E3890 /* ListableHandler.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 0F4570391BE44C910062A629 /* AirEliminateDeadCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F4570371BE44C910062A629 /* AirEliminateDeadCode.h */; }; > 0F45703D1BE45F0A0062A629 /* AirReportUsedRegisters.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F45703B1BE45F0A0062A629 /* AirReportUsedRegisters.h */; }; >@@ -2262,6 +2264,10 @@ > 0F426A451460CBAB00131F8F /* ValueRecovery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueRecovery.h; sourceTree = "<group>"; }; > 0F426A461460CBAB00131F8F /* VirtualRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VirtualRegister.h; sourceTree = "<group>"; }; > 0F426A4A1460CD6B00131F8F /* DataFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataFormat.h; sourceTree = "<group>"; }; >+ 0F42B3BC201EB4C800357031 /* LocalSideAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalSideAllocator.h; sourceTree = "<group>"; }; >+ 0F42B3BF201EB4C900357031 /* LocalSideAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalSideAllocator.cpp; sourceTree = "<group>"; }; >+ 0F42B3C0201EB50900357031 /* Allocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Allocator.cpp; sourceTree = "<group>"; }; >+ 0F42B3C2201EC9FD00357031 /* SecurityOriginToken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecurityOriginToken.h; sourceTree = "<group>"; }; > 0F431736146BAC65007E3890 /* ListableHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListableHandler.h; sourceTree = "<group>"; }; > 0F4570361BE44C910062A629 /* AirEliminateDeadCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AirEliminateDeadCode.cpp; path = b3/air/AirEliminateDeadCode.cpp; sourceTree = "<group>"; }; > 0F4570371BE44C910062A629 /* AirEliminateDeadCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AirEliminateDeadCode.h; path = b3/air/AirEliminateDeadCode.h; sourceTree = "<group>"; }; >@@ -5559,21 +5565,14 @@ > 142E312A134FF0A600AFADB5 /* heap */ = { > isa = PBXGroup; > children = ( >- 0F75A054200D25EF0038E2CF /* Allocator.h */, >- 0F75A05D200D25F10038E2CF /* AllocatorInlines.h */, >- 0F75A059200D25F00038E2CF /* LocalAllocator.cpp */, >- 0F75A057200D25F00038E2CF /* LocalAllocator.h */, >- 0F75A05A200D25F00038E2CF /* LocalAllocatorInlines.h */, >- 0F75A058200D25F00038E2CF /* ThreadLocalCache.cpp */, >- 0F75A055200D25EF0038E2CF /* ThreadLocalCache.h */, >- 0F75A056200D25EF0038E2CF /* ThreadLocalCacheInlines.h */, >- 0F75A05B200D25F10038E2CF /* ThreadLocalCacheLayout.cpp */, >- 0F75A05C200D25F10038E2CF /* ThreadLocalCacheLayout.h */, > 0FEC3C501F33A41600F59B6C /* AlignedMemoryAllocator.cpp */, > 0FEC3C511F33A41600F59B6C /* AlignedMemoryAllocator.h */, > 0FA7620A1DB959F600B7A2FD /* AllocatingScope.h */, > 0FDCE11B1FAE61F4006F3901 /* AllocationFailureMode.h */, >+ 0F42B3C0201EB50900357031 /* Allocator.cpp */, >+ 0F75A054200D25EF0038E2CF /* Allocator.h */, > 0F30CB5D1FCE46B4004B5323 /* AllocatorForMode.h */, >+ 0F75A05D200D25F10038E2CF /* AllocatorInlines.h */, > 0FB4677E1FDDA6E5003FCB09 /* AtomIndices.h */, > C2B916C414DA040C00CBAC86 /* BlockDirectory.cpp */, > C2B916C114DA014E00CBAC86 /* BlockDirectory.h */, >@@ -5674,6 +5673,11 @@ > 0F070A451D543A89006E7232 /* LargeAllocation.cpp */, > 0F070A461D543A89006E7232 /* LargeAllocation.h */, > 0F431736146BAC65007E3890 /* ListableHandler.h */, >+ 0F75A059200D25F00038E2CF /* LocalAllocator.cpp */, >+ 0F75A057200D25F00038E2CF /* LocalAllocator.h */, >+ 0F75A05A200D25F00038E2CF /* LocalAllocatorInlines.h */, >+ 0F42B3BF201EB4C900357031 /* LocalSideAllocator.cpp */, >+ 0F42B3BC201EB4C800357031 /* LocalSideAllocator.h */, > 0F208AD61DF0925A007D3269 /* LockDuringMarking.h */, > 14B7233F12D7D0DA003BD5ED /* MachineStackMarker.cpp */, > 14B7234012D7D0DA003BD5ED /* MachineStackMarker.h */, >@@ -5703,6 +5707,7 @@ > 0FD0E5EF1E46BF230006AB08 /* RegisterState.h */, > 0F7CF94E1DBEEE860098CC12 /* ReleaseHeapAccessScope.h */, > 0F2C63A91E4FA42C00C13839 /* RunningScope.h */, >+ 0F42B3C2201EC9FD00357031 /* SecurityOriginToken.h */, > 0F4D8C761FCA3CF2001D32AC /* SimpleMarkingConstraint.cpp */, > 0F4D8C771FCA3CF3001D32AC /* SimpleMarkingConstraint.h */, > C225494215F7DBAA0065E898 /* SlotVisitor.cpp */, >@@ -5724,6 +5729,11 @@ > 0FD79A2C1EBBBDB200DA88D3 /* Synchronousness.h */, > 0F1FB38A1E173A6200A9BE50 /* SynchronousStopTheWorldMutatorScheduler.cpp */, > 0F1FB38B1E173A6200A9BE50 /* SynchronousStopTheWorldMutatorScheduler.h */, >+ 0F75A058200D25F00038E2CF /* ThreadLocalCache.cpp */, >+ 0F75A055200D25EF0038E2CF /* ThreadLocalCache.h */, >+ 0F75A056200D25EF0038E2CF /* ThreadLocalCacheInlines.h */, >+ 0F75A05B200D25F10038E2CF /* ThreadLocalCacheLayout.cpp */, >+ 0F75A05C200D25F10038E2CF /* ThreadLocalCacheLayout.h */, > 141448CC13A1783700F5BA1A /* TinyBloomFilter.h */, > 0F5F08CE146C762F000472A9 /* UnconditionalFinalizer.h */, > 0F4D8C721FC7A973001D32AC /* VisitCounter.h */, >@@ -8522,6 +8532,7 @@ > 0F7C39FF1C90C55B00480151 /* DFGOpInfo.h in Headers */, > A7D89CFE17A0B8CC00773AD8 /* DFGOSRAvailabilityAnalysisPhase.h in Headers */, > 0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */, >+ 0F42B3C3201EC9FF00357031 /* SecurityOriginToken.h in Headers */, > 0FD8A32617D51F5700CA2C40 /* DFGOSREntrypointCreationPhase.h in Headers */, > 0FC0976A1468A6F700CF2442 /* DFGOSRExit.h in Headers */, > 0F235BEC17178E7300690C7F /* DFGOSRExitBase.h in Headers */, >@@ -9069,6 +9080,7 @@ > BC18C4310E16F5CD00B34460 /* Lexer.h in Headers */, > BC18C52E0E16FCE100B34460 /* Lexer.lut.h in Headers */, > 86D3B3C310159D7F002865E7 /* LinkBuffer.h in Headers */, >+ 0F42B3C1201EB50F00357031 /* LocalSideAllocator.h in Headers */, > 0F431738146BAC69007E3890 /* ListableHandler.h in Headers */, > A7E2EA6B0FB460CF00601F06 /* LiteralParser.h in Headers */, > 70DE9A091BE7D69E005D89D9 /* LLIntAssembly.h in Headers */, >Index: Source/JavaScriptCore/heap/BlockDirectory.cpp >=================================================================== >--- Source/JavaScriptCore/heap/BlockDirectory.cpp (revision 227720) >+++ Source/JavaScriptCore/heap/BlockDirectory.cpp (working copy) >@@ -33,6 +33,7 @@ > #include "JSCInlines.h" > #include "MarkedBlockInlines.h" > #include "SuperSampler.h" >+#include "ThreadLocalCacheInlines.h" > #include "VM.h" > #include <wtf/CurrentTime.h> > >@@ -72,22 +73,29 @@ bool BlockDirectory::isPagedOut(double d > return false; > } > >-MarkedBlock::Handle* BlockDirectory::findEmptyBlockToSteal() >+MarkedBlock::Handle* BlockDirectory::findEmptyBlockToSteal(ThreadLocalCache& tlc) > { >- m_emptyCursor = m_empty.findBit(m_emptyCursor, true); >- if (m_emptyCursor >= m_blocks.size()) >+ LocalSideAllocator& allocator = tlc.sideAllocator(m_tlcOffset); >+ allocator.m_emptyCursor = m_empty.findBit(allocator.m_emptyCursor, true); >+ if (allocator.m_emptyCursor >= m_blocks.size()) > return nullptr; >- return m_blocks[m_emptyCursor]; >+ return m_blocks[allocator.m_emptyCursor]; > } > >-MarkedBlock::Handle* BlockDirectory::findBlockForAllocation() >+MarkedBlock::Handle* BlockDirectory::findBlockForAllocation(LocalAllocator& allocator) > { >- m_allocationCursor = (m_canAllocateButNotEmpty | m_empty).findBit(m_allocationCursor, true); >- if (m_allocationCursor >= m_blocks.size()) >- return nullptr; >- >- setIsCanAllocateButNotEmpty(NoLockingNecessary, m_allocationCursor, false); >- return m_blocks[m_allocationCursor]; >+ for (;;) { >+ allocator.m_allocationCursor = (m_canAllocateButNotEmpty | m_empty).findBit(allocator.m_allocationCursor, true); >+ if (allocator.m_allocationCursor >= m_blocks.size()) >+ return nullptr; >+ >+ size_t blockIndex = allocator.m_allocationCursor++; >+ MarkedBlock::Handle* result = m_blocks[blockIndex]; >+ if (result->securityOriginToken() == allocator.tlc()->securityOriginToken()) { >+ setIsCanAllocateButNotEmpty(NoLockingNecessary, blockIndex, false); >+ return result; >+ } >+ } > } > > MarkedBlock::Handle* BlockDirectory::tryAllocateBlock() >@@ -182,9 +190,11 @@ void BlockDirectory::prepareForAllocatio > [&] (LocalAllocator* allocator) { > allocator->prepareForAllocation(); > }); >+ m_localSideAllocators.forEach( >+ [&] (LocalSideAllocator* sideAllocator) { >+ sideAllocator->prepareForAllocation(); >+ }); > >- m_allocationCursor = 0; >- m_emptyCursor = 0; > m_unsweptCursor = 0; > > m_eden.clearAll(); >@@ -209,6 +219,8 @@ void BlockDirectory::stopAllocatingForGo > auto locker = holdLock(m_localAllocatorsLock); > while (!m_localAllocators.isEmpty()) > m_localAllocators.begin()->remove(); >+ while (!m_localSideAllocators.isEmpty()) >+ m_localSideAllocators.begin()->remove(); > } > > void BlockDirectory::lastChanceToFinalize() >Index: Source/JavaScriptCore/heap/BlockDirectory.h >=================================================================== >--- Source/JavaScriptCore/heap/BlockDirectory.h (revision 227720) >+++ Source/JavaScriptCore/heap/BlockDirectory.h (working copy) >@@ -30,6 +30,7 @@ > #include "CellAttributes.h" > #include "FreeList.h" > #include "LocalAllocator.h" >+#include "LocalSideAllocator.h" > #include "MarkedBlock.h" > #include <wtf/DataLog.h> > #include <wtf/FastBitVector.h> >@@ -43,6 +44,7 @@ class Heap; > class IsoCellSet; > class MarkedSpace; > class LLIntOffsetsExtractor; >+class ThreadLocalCache; > class ThreadLocalCacheLayout; > > #define FOR_EACH_BLOCK_DIRECTORY_BIT(macro) \ >@@ -149,7 +151,7 @@ public: > void setNextDirectoryInSubspace(BlockDirectory* directory) { m_nextDirectoryInSubspace = directory; } > void setNextDirectoryInAlignedMemoryAllocator(BlockDirectory* directory) { m_nextDirectoryInAlignedMemoryAllocator = directory; } > >- MarkedBlock::Handle* findEmptyBlockToSteal(); >+ MarkedBlock::Handle* findEmptyBlockToSteal(ThreadLocalCache&); > > MarkedBlock::Handle* findBlockToSweep(); > >@@ -162,12 +164,13 @@ public: > void dumpBits(PrintStream& = WTF::dataFile()); > > private: >- friend class LocalAllocator; > friend class IsoCellSet; >+ friend class LocalAllocator; >+ friend class LocalSideAllocator; > friend class MarkedBlock; > friend class ThreadLocalCacheLayout; > >- MarkedBlock::Handle* findBlockForAllocation(); >+ MarkedBlock::Handle* findBlockForAllocation(LocalAllocator&); > > MarkedBlock::Handle* tryAllocateBlock(); > >@@ -184,8 +187,6 @@ private: > > // After you do something to a block based on one of these cursors, you clear the bit in the > // corresponding bitvector and leave the cursor where it was. >- size_t m_allocationCursor { 0 }; // Points to the next block that is a candidate for allocation. >- size_t m_emptyCursor { 0 }; // Points to the next block that is a candidate for empty allocation (allocating in empty blocks). > size_t m_unsweptCursor { 0 }; // Points to the next block that is a candidate for incremental sweeping. > > unsigned m_cellSize; >@@ -201,6 +202,7 @@ private: > Lock m_localAllocatorsLock; > size_t m_tlcOffset; > SentinelLinkedList<LocalAllocator, BasicRawSentinelNode<LocalAllocator>> m_localAllocators; >+ SentinelLinkedList<LocalSideAllocator, BasicRawSentinelNode<LocalSideAllocator>> m_localSideAllocators; > }; > > } // namespace JSC >Index: Source/JavaScriptCore/heap/LocalAllocator.cpp >=================================================================== >--- Source/JavaScriptCore/heap/LocalAllocator.cpp (revision 227720) >+++ Source/JavaScriptCore/heap/LocalAllocator.cpp (working copy) >@@ -32,8 +32,9 @@ > > namespace JSC { > >-LocalAllocator::LocalAllocator(BlockDirectory* directory) >- : m_directory(directory) >+LocalAllocator::LocalAllocator(ThreadLocalCache* tlc, BlockDirectory* directory) >+ : m_tlc(tlc) >+ , m_directory(directory) > , m_cellSize(directory->m_cellSize) > , m_freeList(m_cellSize) > { >@@ -42,11 +43,13 @@ LocalAllocator::LocalAllocator(BlockDire > } > > LocalAllocator::LocalAllocator(LocalAllocator&& other) >- : m_directory(other.m_directory) >+ : m_tlc(other.m_tlc) >+ , m_directory(other.m_directory) > , m_cellSize(other.m_cellSize) > , m_freeList(WTFMove(other.m_freeList)) > , m_currentBlock(other.m_currentBlock) > , m_lastActiveBlock(other.m_lastActiveBlock) >+ , m_allocationCursor(other.m_allocationCursor) > { > other.reset(); > if (other.isOnList()) { >@@ -61,6 +64,7 @@ void LocalAllocator::reset() > m_freeList.clear(); > m_currentBlock = nullptr; > m_lastActiveBlock = nullptr; >+ m_allocationCursor = 0; > } > > LocalAllocator::~LocalAllocator() >@@ -164,6 +168,7 @@ void* LocalAllocator::allocateSlowCase(G > else > return nullptr; > } >+ block->associateWithOrigin(m_tlc->securityOriginToken()); > m_directory->addBlock(block); > result = allocateIn(block); > ASSERT(result); >@@ -201,7 +206,7 @@ void* LocalAllocator::tryAllocateWithout > ASSERT(m_freeList.allocationWillFail()); > > for (;;) { >- MarkedBlock::Handle* block = m_directory->findBlockForAllocation(); >+ MarkedBlock::Handle* block = m_directory->findBlockForAllocation(*this); > if (!block) > break; > >@@ -211,7 +216,7 @@ void* LocalAllocator::tryAllocateWithout > > if (Options::stealEmptyBlocksFromOtherAllocators() > && (Options::tradeDestructorBlocks() || !m_directory->needsDestruction())) { >- if (MarkedBlock::Handle* block = m_directory->m_subspace->findEmptyBlockToSteal()) { >+ if (MarkedBlock::Handle* block = m_directory->m_subspace->findEmptyBlockToSteal(*m_tlc)) { > RELEASE_ASSERT(block->alignedMemoryAllocator() == m_directory->m_subspace->alignedMemoryAllocator()); > > block->sweep(nullptr); >@@ -220,6 +225,7 @@ void* LocalAllocator::tryAllocateWithout > // because there is a remote chance that a block may have both canAllocateButNotEmpty > // and empty set at the same time. > block->removeFromDirectory(); >+ block->associateWithOrigin(m_tlc->securityOriginToken()); > m_directory->addBlock(block); > return allocateIn(block); > } >Index: Source/JavaScriptCore/heap/LocalAllocator.h >=================================================================== >--- Source/JavaScriptCore/heap/LocalAllocator.h (revision 227720) >+++ Source/JavaScriptCore/heap/LocalAllocator.h (working copy) >@@ -33,12 +33,13 @@ namespace JSC { > > class BlockDirectory; > class GCDeferralContext; >+class ThreadLocalCache; > > class LocalAllocator : public BasicRawSentinelNode<LocalAllocator> { > WTF_MAKE_NONCOPYABLE(LocalAllocator); > > public: >- LocalAllocator(BlockDirectory*); >+ LocalAllocator(ThreadLocalCache*, BlockDirectory*); > LocalAllocator(LocalAllocator&&); > ~LocalAllocator(); > >@@ -53,8 +54,12 @@ public: > static ptrdiff_t offsetOfCellSize(); > > bool isFreeListedCell(const void*) const; >+ >+ ThreadLocalCache* tlc() const { return m_tlc; } > > private: >+ friend class BlockDirectory; >+ > void reset(); > JS_EXPORT_PRIVATE void* allocateSlowCase(GCDeferralContext*, AllocationFailureMode failureMode); > void didConsumeFreeList(); >@@ -63,11 +68,16 @@ private: > void* allocateIn(MarkedBlock::Handle*); > ALWAYS_INLINE void doTestCollectionsIfNeeded(GCDeferralContext*); > >+ ThreadLocalCache* m_tlc; > BlockDirectory* m_directory; > unsigned m_cellSize; > FreeList m_freeList; > MarkedBlock::Handle* m_currentBlock { nullptr }; > MarkedBlock::Handle* m_lastActiveBlock { nullptr }; >+ >+ // After you do something to a block based on one of these cursors, you clear the bit in the >+ // corresponding bitvector and leave the cursor where it was. >+ size_t m_allocationCursor { 0 }; // Points to the next block that is a candidate for allocation. > }; > > inline ptrdiff_t LocalAllocator::offsetOfFreeList() >Index: Source/JavaScriptCore/heap/LocalSideAllocator.cpp >=================================================================== >--- Source/JavaScriptCore/heap/LocalSideAllocator.cpp (nonexistent) >+++ Source/JavaScriptCore/heap/LocalSideAllocator.cpp (working copy) >@@ -0,0 +1,54 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "LocalSideAllocator.h" >+ >+#include "BlockDirectory.h" >+ >+namespace JSC { >+ >+LocalSideAllocator::LocalSideAllocator(BlockDirectory* directory) >+ : m_directory(directory) >+{ >+ auto locker = holdLock(directory->m_localAllocatorsLock); >+ directory->m_localSideAllocators.append(this); >+} >+ >+LocalSideAllocator::~LocalSideAllocator() >+{ >+ if (isOnList()) { >+ auto locker = holdLock(m_directory->m_localAllocatorsLock); >+ remove(); >+ } >+} >+ >+void LocalSideAllocator::prepareForAllocation() >+{ >+ m_emptyCursor = 0; >+} >+ >+} // namespace JSC >+ >Index: Source/JavaScriptCore/heap/LocalSideAllocator.h >=================================================================== >--- Source/JavaScriptCore/heap/LocalSideAllocator.h (nonexistent) >+++ Source/JavaScriptCore/heap/LocalSideAllocator.h (working copy) >@@ -0,0 +1,56 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/FastMalloc.h> >+#include <wtf/Noncopyable.h> >+ >+namespace JSC { >+ >+class BlockDirectory; >+ >+class LocalSideAllocator : public BasicRawSentinelNode<LocalSideAllocator> { >+ WTF_MAKE_NONCOPYABLE(LocalSideAllocator); >+ WTF_MAKE_FAST_ALLOCATED; >+ >+public: >+ LocalSideAllocator(BlockDirectory*); >+ ~LocalSideAllocator(); >+ >+ void prepareForAllocation(); >+ >+private: >+ friend class BlockDirectory; >+ >+ BlockDirectory* m_directory; >+ >+ // After you do something to a block based on one of these cursors, you clear the bit in the >+ // corresponding bitvector and leave the cursor where it was. >+ size_t m_emptyCursor { 0 }; >+}; >+ >+} // namespace JSC >+ >Index: Source/JavaScriptCore/heap/MarkStackMergingConstraint.cpp >=================================================================== >--- Source/JavaScriptCore/heap/MarkStackMergingConstraint.cpp (revision 227720) >+++ Source/JavaScriptCore/heap/MarkStackMergingConstraint.cpp (working copy) >@@ -26,6 +26,9 @@ > #include "config.h" > #include "MarkStackMergingConstraint.h" > >+#include "GCSegmentedArrayInlines.h" >+#include "JSCInlines.h" >+ > namespace JSC { > > MarkStackMergingConstraint::MarkStackMergingConstraint(Heap& heap) >Index: Source/JavaScriptCore/heap/MarkStackMergingConstraint.h >=================================================================== >--- Source/JavaScriptCore/heap/MarkStackMergingConstraint.h (revision 227720) >+++ Source/JavaScriptCore/heap/MarkStackMergingConstraint.h (working copy) >@@ -29,6 +29,9 @@ > > namespace JSC { > >+class Heap; >+class SlotVisitor; >+ > class MarkStackMergingConstraint : public MarkingConstraint { > public: > MarkStackMergingConstraint(Heap&); >Index: Source/JavaScriptCore/heap/MarkedBlock.cpp >=================================================================== >--- Source/JavaScriptCore/heap/MarkedBlock.cpp (revision 227720) >+++ Source/JavaScriptCore/heap/MarkedBlock.cpp (working copy) >@@ -488,6 +488,15 @@ bool MarkedBlock::Handle::isFreeListedCe > return m_directory->isFreeListedCell(target); > } > >+void MarkedBlock::Handle::associatedWithOrigin(SecurityOriginToken securityOriginToken) >+{ >+ if (m_securityOriginToken == securityOriginToken) >+ return; >+ >+ memset(&block(), payloadSize); >+ m_securityOriginToken = securityOriginToken; >+} >+ > } // namespace JSC > > namespace WTF { >Index: Source/JavaScriptCore/heap/MarkedBlock.h >=================================================================== >--- Source/JavaScriptCore/heap/MarkedBlock.h (revision 227720) >+++ Source/JavaScriptCore/heap/MarkedBlock.h (working copy) >@@ -25,6 +25,7 @@ > #include "DestructionMode.h" > #include "HeapCell.h" > #include "IterationStatus.h" >+#include "SecurityOriginToken.h" > #include "WeakSet.h" > #include <wtf/Atomics.h> > #include <wtf/Bitmap.h> >@@ -194,6 +195,9 @@ public: > > void dumpState(PrintStream&); > >+ void associateWithOrigin(SecurityOriginToken); >+ SecurityOriginToken securityOriginToken() const { return m_securityOriginToken; } >+ > private: > Handle(Heap&, AlignedMemoryAllocator*, void*); > >@@ -229,6 +233,8 @@ public: > WeakSet m_weakSet; > > MarkedBlock* m_block { nullptr }; >+ >+ SecurityOriginToken m_securityOriginToken { 0 }; > }; > > private: >Index: Source/JavaScriptCore/heap/SecurityOriginToken.cpp >=================================================================== >--- Source/JavaScriptCore/heap/SecurityOriginToken.cpp (nonexistent) >+++ Source/JavaScriptCore/heap/SecurityOriginToken.cpp (working copy) >@@ -0,0 +1,41 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "SecurityOriginToken.h" >+ >+#include <wtf/Atomic.h> >+ >+namespace JSC { >+ >+SecurityOriginToken uniqueSecurityOriginToken() >+{ >+ static SecurityOriginToken counter; >+ return atomicExchangeAdd(&counter, 1) + 1; >+} >+ >+} // namespace JSC >+ >+ >Index: Source/JavaScriptCore/heap/SecurityOriginToken.h >=================================================================== >--- Source/JavaScriptCore/heap/SecurityOriginToken.h (nonexistent) >+++ Source/JavaScriptCore/heap/SecurityOriginToken.h (working copy) >@@ -0,0 +1,35 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+namespace JSC { >+ >+typedef uint64_t SecurityOriginToken; >+ >+SecurityOriginToken uniqueSecurityOriginToken(); >+ >+} // namespace JSC >+ >Index: Source/JavaScriptCore/heap/Subspace.cpp >=================================================================== >--- Source/JavaScriptCore/heap/Subspace.cpp (revision 227720) >+++ Source/JavaScriptCore/heap/Subspace.cpp (working copy) >@@ -80,10 +80,10 @@ void Subspace::prepareForAllocation() > m_directoryForEmptyAllocation = m_alignedMemoryAllocator->firstDirectory(); > } > >-MarkedBlock::Handle* Subspace::findEmptyBlockToSteal() >+MarkedBlock::Handle* Subspace::findEmptyBlockToSteal(ThreadLocalCache& tlc) > { > for (; m_directoryForEmptyAllocation; m_directoryForEmptyAllocation = m_directoryForEmptyAllocation->nextDirectoryInAlignedMemoryAllocator()) { >- if (MarkedBlock::Handle* block = m_directoryForEmptyAllocation->findEmptyBlockToSteal()) >+ if (MarkedBlock::Handle* block = m_directoryForEmptyAllocation->findEmptyBlockToSteal(tlc)) > return block; > } > return nullptr; >Index: Source/JavaScriptCore/heap/Subspace.h >=================================================================== >--- Source/JavaScriptCore/heap/Subspace.h (revision 227720) >+++ Source/JavaScriptCore/heap/Subspace.h (working copy) >@@ -36,6 +36,7 @@ namespace JSC { > > class AlignedMemoryAllocator; > class HeapCellType; >+class ThreadLocalCache; > > // The idea of subspaces is that you can provide some custom behavior for your objects if you > // allocate them from a custom Subspace in which you override some of the virtual methods. This >@@ -65,7 +66,7 @@ public: > void didCreateFirstDirectory(BlockDirectory* directory) { m_directoryForEmptyAllocation = directory; } > > // Finds an empty block from any Subspace that agrees to trade blocks with us. >- MarkedBlock::Handle* findEmptyBlockToSteal(); >+ MarkedBlock::Handle* findEmptyBlockToSteal(ThreadLocalCache&); > > template<typename Func> > void forEachDirectory(const Func&); >Index: Source/JavaScriptCore/heap/ThreadLocalCache.cpp >=================================================================== >--- Source/JavaScriptCore/heap/ThreadLocalCache.cpp (revision 227720) >+++ Source/JavaScriptCore/heap/ThreadLocalCache.cpp (working copy) >@@ -32,13 +32,14 @@ > > namespace JSC { > >-RefPtr<ThreadLocalCache> ThreadLocalCache::create(Heap& heap) >+RefPtr<ThreadLocalCache> ThreadLocalCache::create(Heap& heap, SecurityOriginToken securityOriginToken) > { >- return adoptRef(new ThreadLocalCache(heap)); >+ return adoptRef(new ThreadLocalCache(heap, securityOriginToken)); > } > >-ThreadLocalCache::ThreadLocalCache(Heap& heap) >+ThreadLocalCache::ThreadLocalCache(Heap& heap, SecurityOriginToken securityOriginToken) > : m_heap(heap) >+ , m_securityOriginToken(securityOriginToken) > { > m_data = allocateData(); > } >@@ -48,6 +49,20 @@ ThreadLocalCache::~ThreadLocalCache() > destroyData(m_data); > } > >+LocalSideAllocator& ThreadLocalCache::sideAllocator(size_t offset) >+{ >+ size_t index = offset / sizeof(LocalAllocator); >+ if (index < m_sideAllocators.size()) >+ return *m_sideAllocators[index]; >+ >+ ThreadLocalCacheLayout::Snapshot layout = m_heap.threadLocalCacheLayout().snapshot(); >+ while (m_sideAllocators.size() < layout.directories.size()) >+ m_sideAllocators.append(std::make_unique<LocalSideAllocator>(layout.directories[m_sideAllocators.size()])); >+ >+ RELEASE_ASSERT(index < m_sideAllocators.size()); >+ return *m_sideAllocators[index]; >+} >+ > ThreadLocalCache::Data* ThreadLocalCache::allocateData() > { > size_t oldSize = m_data ? m_data->size : 0; >@@ -59,7 +74,7 @@ ThreadLocalCache::Data* ThreadLocalCache > for (size_t offset = 0; offset < oldSize; offset += sizeof(LocalAllocator)) > new (&allocator(*result, offset)) LocalAllocator(WTFMove(allocator(*m_data, offset))); > for (size_t offset = oldSize; offset < layout.size; offset += sizeof(LocalAllocator)) >- new (&allocator(*result, offset)) LocalAllocator(layout.directories[offset / sizeof(LocalAllocator)]); >+ new (&allocator(*result, offset)) LocalAllocator(this, layout.directories[offset / sizeof(LocalAllocator)]); > return result; > } > >Index: Source/JavaScriptCore/heap/ThreadLocalCache.h >=================================================================== >--- Source/JavaScriptCore/heap/ThreadLocalCache.h (revision 227720) >+++ Source/JavaScriptCore/heap/ThreadLocalCache.h (working copy) >@@ -25,13 +25,18 @@ > > #pragma once > >+#include "AllocationFailureMode.h" >+#include "LocalAllocator.h" >+#include "SecurityOriginToken.h" > #include <wtf/FastMalloc.h> > #include <wtf/FastTLS.h> > #include <wtf/ThreadSafeRefCounted.h> >+#include <wtf/Vector.h> > > namespace JSC { > > class Heap; >+class LocalSideAllocator; > class VM; > > class ThreadLocalCache : public ThreadSafeRefCounted<ThreadLocalCache> { >@@ -39,7 +44,7 @@ class ThreadLocalCache : public ThreadSa > WTF_MAKE_FAST_ALLOCATED; > > public: >- static RefPtr<ThreadLocalCache> create(Heap&); >+ static RefPtr<ThreadLocalCache> create(Heap&, SecurityOriginToken = uniqueSecurityOriginToken()); > > JS_EXPORT_PRIVATE ~ThreadLocalCache(); > >@@ -53,16 +58,20 @@ public: > > static LocalAllocator& allocator(VM&, size_t offset); > >+ LocalSideAllocator& sideAllocator(size_t offset); >+ > template<typename SuccessFunc, typename FailureFunc> > static void tryGetAllocator(VM&, size_t offset, const SuccessFunc&, const FailureFunc&); > > static ptrdiff_t offsetOfSizeInData() { return OBJECT_OFFSETOF(Data, size); } > static ptrdiff_t offsetOfFirstAllocatorInData() { return OBJECT_OFFSETOF(Data, allocator); } > >+ SecurityOriginToken securityOriginToken() const { return m_securityOriginToken; } >+ > private: > friend class VM; > >- ThreadLocalCache(Heap&); >+ ThreadLocalCache(Heap&, SecurityOriginToken); > > struct Data { > size_t size; >@@ -91,6 +100,10 @@ private: > // it's correct for immortal caches. > Heap& m_heap; > Data* m_data { nullptr }; >+ >+ Vector<std::unique_ptr<LocalSideAllocator>> m_sideAllocators; >+ >+ SecurityOriginToken m_securityOriginToken; > > #if USE(FAST_TLS_FOR_TLC) > static const pthread_key_t tlsKey = WTF_GC_TLC_KEY; >Index: Source/JavaScriptCore/heap/ThreadLocalCacheInlines.h >=================================================================== >--- Source/JavaScriptCore/heap/ThreadLocalCacheInlines.h (revision 227720) >+++ Source/JavaScriptCore/heap/ThreadLocalCacheInlines.h (working copy) >@@ -26,6 +26,7 @@ > #pragma once > > #include "ThreadLocalCache.h" >+#include "VM.h" > > namespace JSC { >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 182227
:
332502
|
332503
|
332508
|
332588
|
332666
|
332810
|
332811
|
333100
|
333104
|
333138
|
333139