Changeset 89156 in webkit
- Timestamp:
- Jun 17, 2011 12:11:44 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r89153 r89156 1 2011-06-16 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Added some write barrier action, compiled out by default 6 https://bugs.webkit.org/show_bug.cgi?id=62844 7 8 * JavaScriptCore.exp: Build! 9 10 * JavaScriptCore.xcodeproj/project.pbxproj: Fixed an incremental build 11 issue with Heap.cpp. 12 13 * heap/Heap.cpp: 14 (JSC::Heap::writeBarrierSlowCase): 15 * heap/Heap.h: 16 (JSC::Heap::writeBarrier): 17 * heap/MarkedBlock.h: 18 (JSC::MarkedBlock::isAtomAligned): 19 (JSC::MarkedBlock::blockFor): 20 (JSC::MarkedBlock::atomNumber): 21 (JSC::MarkedBlock::ownerSetNumber): 22 (JSC::MarkedBlock::addOldSpaceOwner): 23 (JSC::MarkedBlock::OwnerSet::OwnerSet): 24 (JSC::MarkedBlock::OwnerSet::add): 25 (JSC::MarkedBlock::OwnerSet::clear): 26 (JSC::MarkedBlock::OwnerSet::size): 27 (JSC::MarkedBlock::OwnerSet::didOverflow): 28 (JSC::MarkedBlock::OwnerSet::owners): Added a basic write barrier that 29 tracks owners for regions within blocks. Currently unused. 30 1 31 2011-06-17 Raphael Kubo da Costa <kubo@profusion.mobi> 2 32 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r89069 r89156 228 228 __ZN3JSC4Heap19setActivityCallbackEN3WTF10PassOwnPtrINS_18GCActivityCallbackEEE 229 229 __ZN3JSC4Heap20protectedObjectCountEv 230 __ZN3JSC4Heap20writeBarrierSlowCaseEPKNS_6JSCellEPS1_ 230 231 __ZN3JSC4Heap25protectedObjectTypeCountsEv 231 232 __ZN3JSC4Heap26protectedGlobalObjectCountEv -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r89077 r89156 375 375 ?writable@PropertyDescriptor@JSC@@QBE_NXZ 376 376 ?writeBarrier@HandleHeap@JSC@@QAEXPAVJSValue@2@ABV32@@Z 377 ?writeBarrierSlowCase@Heap@JSC@@CAXPBVJSCell@2@PAV32@@Z 377 378 ?yield@WTF@@YAXXZ 378 379 WTFLog -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r89075 r89156 184 184 14B8EC720A5652090062BE54 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; }; 185 185 14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BA78F013AAB88F005B7C2C /* SlotVisitor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 186 14BA7A9713AADFF8005B7C2C /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BA7A9513AADFF8005B7C2C /* Heap.cpp */; }; 187 14BA7A9813AADFF8005B7C2C /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BA7A9613AADFF8005B7C2C /* Heap.h */; }; 186 188 14BD59C50A3E8F9F00BAF59C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; }; 187 189 14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */; }; … … 195 197 14F8BA43107EC88C009892DC /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; }; 196 198 14F97447138C853E00DA1C67 /* HeapRootVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F97446138C853E00DA1C67 /* HeapRootVisitor.h */; settings = {ATTRIBUTES = (Private, ); }; }; 197 14FB986D135225410085A5DB /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FB986B135225410085A5DB /* Heap.cpp */; };198 14FB986E135225410085A5DB /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FB986C135225410085A5DB /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };199 199 14FFF98C12BFFF7500795BB8 /* PageAllocationAligned.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FFF98A12BFFF7500795BB8 /* PageAllocationAligned.cpp */; }; 200 200 14FFF98D12BFFF7500795BB8 /* PageAllocationAligned.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FFF98B12BFFF7500795BB8 /* PageAllocationAligned.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 816 816 14B8ECA60A5653980062BE54 /* JavaScriptCore.exp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.exp; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; }; 817 817 14BA78F013AAB88F005B7C2C /* SlotVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotVisitor.h; sourceTree = "<group>"; }; 818 14BA7A9513AADFF8005B7C2C /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = ../../../webkit/Source/JavaScriptCore/heap/Heap.cpp; sourceTree = SOURCE_ROOT; }; 819 14BA7A9613AADFF8005B7C2C /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Heap.h; path = ../../../webkit/Source/JavaScriptCore/heap/Heap.h; sourceTree = SOURCE_ROOT; }; 818 820 14BD59BF0A3E8F9000BAF59C /* testapi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testapi; sourceTree = BUILT_PRODUCTS_DIR; }; 819 821 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSContextRef.cpp; sourceTree = "<group>"; }; … … 831 833 14F252560D08DD8D004ECFFF /* JSVariableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVariableObject.h; sourceTree = "<group>"; }; 832 834 14F97446138C853E00DA1C67 /* HeapRootVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapRootVisitor.h; sourceTree = "<group>"; }; 833 14FB986B135225410085A5DB /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Heap.cpp; sourceTree = "<group>"; };834 14FB986C135225410085A5DB /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Heap.h; sourceTree = "<group>"; };835 835 14FFF98A12BFFF7500795BB8 /* PageAllocationAligned.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAllocationAligned.cpp; sourceTree = "<group>"; }; 836 836 14FFF98B12BFFF7500795BB8 /* PageAllocationAligned.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocationAligned.h; sourceTree = "<group>"; }; … … 1501 1501 142E312F134FF0A600AFADB5 /* HandleStack.h */, 1502 1502 146FA5A81378F6B0003627A3 /* HandleTypes.h */, 1503 14 FB986B135225410085A5DB/* Heap.cpp */,1504 14 FB986C135225410085A5DB/* Heap.h */,1503 14BA7A9513AADFF8005B7C2C /* Heap.cpp */, 1504 14BA7A9613AADFF8005B7C2C /* Heap.h */, 1505 1505 14F97446138C853E00DA1C67 /* HeapRootVisitor.h */, 1506 1506 142E3130134FF0A600AFADB5 /* Local.h */, … … 2549 2549 86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */, 2550 2550 5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */, 2551 14FB986E135225410085A5DB /* Heap.h in Headers */,2552 2551 865A30F1135007E100CDB49E /* JSValueInlineMethods.h in Headers */, 2553 2552 142D6F0913539A2800B02E86 /* MarkedBlock.h in Headers */, … … 2571 2570 142A1D8413A19C84009DA5FE /* OldSpace.h in Headers */, 2572 2571 14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */, 2572 14BA7A9813AADFF8005B7C2C /* Heap.h in Headers */, 2573 2573 ); 2574 2574 runOnlyForDeploymentPostprocessing = 0; … … 3011 3011 86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */, 3012 3012 86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */, 3013 14FB986D135225410085A5DB /* Heap.cpp in Sources */,3014 3013 142D6F0813539A2800B02E86 /* MarkedBlock.cpp in Sources */, 3015 3014 142D6F1113539A4100B02E86 /* MarkStack.cpp in Sources */, … … 3019 3018 14D2F3DA139F4BE200491031 /* NewSpace.cpp in Sources */, 3020 3019 142A1D8313A19C84009DA5FE /* OldSpace.cpp in Sources */, 3020 14BA7A9713AADFF8005B7C2C /* Heap.cpp in Sources */, 3021 3021 ); 3022 3022 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r89069 r89156 606 606 } 607 607 608 #if ENABLE(GGC) 609 void Heap::writeBarrierSlowCase(const JSCell* owner, JSCell* cell) 610 { 611 if (!cell) 612 return; 613 MarkedBlock::blockFor(cell)->addOldSpaceOwner(owner, cell); 614 } 615 616 #else 617 618 void Heap::writeBarrierSlowCase(const JSCell*, JSCell*) 619 { 620 } 621 #endif 622 608 623 } // namespace JSC -
trunk/Source/JavaScriptCore/heap/Heap.h
r89069 r89156 142 142 RegisterFile& registerFile(); 143 143 144 static void writeBarrierSlowCase(const JSCell*, JSCell*); 145 144 146 OperationInProgress m_operationInProgress; 145 147 NewSpace m_newSpace; … … 199 201 } 200 202 203 #if ENABLE(GGC) 204 inline void Heap::writeBarrier(const JSCell* owner, JSCell* cell) 205 { 206 if (MarkedBlock::blockFor(owner)->inNewSpace()) 207 return; 208 writeBarrierSlowCase(owner, cell); 209 } 210 211 inline void Heap::writeBarrier(const JSCell* owner, JSValue value) 212 { 213 if (!value) 214 return; 215 if (!value.isCell()) 216 return; 217 writeBarrier(owner, value.asCell()); 218 } 219 220 #else 221 222 inline void Heap::writeBarrier(const JSCell*, JSCell*) 223 { 224 } 225 201 226 inline void Heap::writeBarrier(const JSCell*, JSValue) 202 227 { 203 228 } 204 205 inline void Heap::writeBarrier(const JSCell*, JSCell*) 206 { 207 } 229 #endif 208 230 209 231 inline void Heap::reportExtraMemoryCost(size_t cost) -
trunk/Source/JavaScriptCore/heap/MarkedBlock.h
r88519 r89156 43 43 friend class WTF::DoublyLinkedListNode<MarkedBlock>; 44 44 public: 45 static const size_t atomSize = sizeof(double); // Ensures natural alignment for all built-in types. 46 static const size_t blockSize = 16 * KB; 47 48 static const size_t atomsPerBlock = blockSize / atomSize; // ~1.5% overhead 49 static const size_t ownerSetsPerBlock = 8; // ~2% overhead. 50 45 51 struct VoidFunctor { 46 52 typedef void ReturnType; … … 48 54 }; 49 55 50 static const size_t atomSize = sizeof(double); // Ensures natural alignment for all built-in types. 51 static const size_t blockSize = 16 * KB; 56 class OwnerSet { 57 public: 58 OwnerSet(); 59 60 void add(const JSCell*); 61 void clear(); 62 63 size_t size(); 64 bool didOverflow(); 65 66 const JSCell** owners(); 67 68 private: 69 static const size_t capacity = 5; 70 unsigned char m_size; 71 const JSCell* m_owners[capacity]; 72 }; 52 73 53 74 static MarkedBlock* create(Heap*, size_t cellSize); … … 77 98 size_t capacity(); 78 99 79 size_t atomNumber(const void*);80 100 bool isMarked(const void*); 81 101 bool testAndSetMarked(const void*); 82 102 bool testAndClearMarked(const void*); 83 103 void setMarked(const void*); 84 104 105 void addOldSpaceOwner(const JSCell* owner, const JSCell*); 106 85 107 template <typename Functor> void forEachCell(Functor&); 86 108 87 109 private: 88 110 static const size_t blockMask = ~(blockSize - 1); // blockSize must be a power of two. 89 90 111 static const size_t atomMask = ~(atomSize - 1); // atomSize must be a power of two. 91 92 static const size_t atomsPerBlock = blockSize / atomSize;93 112 94 113 typedef char Atom[atomSize]; … … 96 115 MarkedBlock(const PageAllocationAligned&, Heap*, size_t cellSize); 97 116 Atom* atoms(); 117 118 size_t atomNumber(const void*); 119 size_t ownerSetNumber(const JSCell*); 98 120 99 121 size_t m_nextAtom; … … 102 124 WTF::Bitmap<blockSize / atomSize> m_marks; 103 125 bool m_inNewSpace; 126 OwnerSet m_ownerSets[ownerSetsPerBlock]; 104 127 PageAllocationAligned m_allocation; 105 128 Heap* m_heap; … … 120 143 inline bool MarkedBlock::isAtomAligned(const void* p) 121 144 { 122 return !( (intptr_t)(p) & ~atomMask);145 return !(reinterpret_cast<Bits>(p) & ~atomMask); 123 146 } 124 147 125 148 inline MarkedBlock* MarkedBlock::blockFor(const void* p) 126 149 { 127 return reinterpret_cast<MarkedBlock*>(reinterpret_cast< uintptr_t>(p) & blockMask);150 return reinterpret_cast<MarkedBlock*>(reinterpret_cast<Bits>(p) & blockMask); 128 151 } 129 152 … … 182 205 inline size_t MarkedBlock::atomNumber(const void* p) 183 206 { 184 return (reinterpret_cast< uintptr_t>(p) - reinterpret_cast<uintptr_t>(this)) / atomSize;207 return (reinterpret_cast<Bits>(p) - reinterpret_cast<Bits>(this)) / atomSize; 185 208 } 186 209 … … 228 251 return 0; 229 252 } 230 253 254 inline size_t MarkedBlock::ownerSetNumber(const JSCell* cell) 255 { 256 return (reinterpret_cast<Bits>(cell) - reinterpret_cast<Bits>(this)) * ownerSetsPerBlock / blockSize; 257 } 258 259 inline void MarkedBlock::addOldSpaceOwner(const JSCell* owner, const JSCell* cell) 260 { 261 OwnerSet& ownerSet = m_ownerSets[ownerSetNumber(cell)]; 262 ownerSet.add(owner); 263 } 264 265 inline MarkedBlock::OwnerSet::OwnerSet() 266 : m_size(0) 267 { 268 } 269 270 inline void MarkedBlock::OwnerSet::add(const JSCell* owner) 271 { 272 if (m_size < capacity) { 273 m_owners[m_size++] = owner; 274 return; 275 } 276 m_size = capacity + 1; // Signals overflow. 277 } 278 279 inline void MarkedBlock::OwnerSet::clear() 280 { 281 m_size = 0; 282 } 283 284 inline size_t MarkedBlock::OwnerSet::size() 285 { 286 return m_size; 287 } 288 289 inline bool MarkedBlock::OwnerSet::didOverflow() 290 { 291 return m_size > capacity; 292 } 293 294 inline const JSCell** MarkedBlock::OwnerSet::owners() 295 { 296 return m_owners; 297 } 298 231 299 } // namespace JSC 232 300
Note: See TracChangeset
for help on using the changeset viewer.