Changeset 94814 in webkit
- Timestamp:
- Sep 8, 2011 3:52:04 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r94811 r94814 1 2011-09-08 Oliver Hunt <oliver@apple.com> 2 3 Use bump allocator for initial property storage 4 https://bugs.webkit.org/show_bug.cgi?id=67494 5 6 Reviewed by Geoffrey Garen. 7 8 Use a bump allocator for initial allocation of property storage, 9 and promote to fastMalloc memory only if it survives a GC pass. 10 11 Comes out as a 1% win on v8, and is a useful step on the way to 12 GC allocation of all property storage. 13 14 * JavaScriptCore.exp: 15 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 16 * JavaScriptCore.xcodeproj/project.pbxproj: 17 * heap/Heap.cpp: 18 (JSC::Heap::collect): 19 * heap/Heap.h: 20 (JSC::Heap::allocatePropertyStorage): 21 (JSC::Heap::inPropertyStorageNursery): 22 * heap/MarkedBlock.h: 23 * heap/NewSpace.cpp: 24 (JSC::NewSpace::NewSpace): 25 * heap/NewSpace.h: 26 (JSC::NewSpace::resetPropertyStorageNursery): 27 (JSC::NewSpace::allocatePropertyStorage): 28 (JSC::NewSpace::inPropertyStorageNursery): 29 * jit/JITStubs.cpp: 30 (JSC::DEFINE_STUB_FUNCTION): 31 * runtime/JSObject.cpp: 32 (JSC::JSObject::allocatePropertyStorage): 33 * runtime/JSObject.h: 34 (JSC::JSObject::isUsingInlineStorage): 35 (JSC::JSObject::JSObject): 36 (JSC::JSObject::propertyStorage): 37 (JSC::JSObject::~JSObject): 38 (JSC::JSObject::putDirectInternal): 39 (JSC::JSObject::putDirectWithoutTransition): 40 (JSC::JSObject::putDirectFunctionWithoutTransition): 41 (JSC::JSObject::transitionTo): 42 (JSC::JSObject::visitChildrenDirect): 43 * runtime/StorageBarrier.h: Added. 44 (JSC::StorageBarrier::StorageBarrier): 45 (JSC::StorageBarrier::set): 46 (JSC::StorageBarrier::operator->): 47 (JSC::StorageBarrier::operator*): 48 (JSC::StorageBarrier::operator[]): 49 (JSC::StorageBarrier::get): 50 1 51 2011-09-08 Sam Weinig <sam@webkit.org> 2 52 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r94701 r94814 418 418 Source/JavaScriptCore/runtime/SmallStrings.cpp \ 419 419 Source/JavaScriptCore/runtime/SmallStrings.h \ 420 Source/JavaScriptCore/runtime/StorageBarrier.h \ 420 421 Source/JavaScriptCore/runtime/StrictEvalActivation.cpp \ 421 422 Source/JavaScriptCore/runtime/StrictEvalActivation.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r94811 r94814 216 216 __ZN3JSC22objectConstructorTableE 217 217 __ZN3JSC23AbstractSamplingCounter4dumpEv 218 __ZN3JSC23AbstractSamplingCounter30s_abstractSamplingCounterChainE 218 219 __ZN3JSC23objectProtoFuncToStringEPNS_9ExecStateE 219 220 __ZN3JSC23setUpStaticFunctionSlotEPNS_9ExecStateEPKNS_9HashEntryEPNS_8JSObjectERKNS_10IdentifierERNS_12PropertySlotE … … 321 322 __ZN3JSC8JSObject21getPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE 322 323 __ZN3JSC8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPNS_16WriteBarrierBaseINS_7UnknownEEE 323 __ZN3JSC8JSObject23allocatePropertyStorageE mm324 __ZN3JSC8JSObject23allocatePropertyStorageERNS_12JSGlobalDataEmm 324 325 __ZN3JSC8JSObject24getOwnPropertyDescriptorEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorE 325 326 __ZN3JSC8JSObject3putEPNS_9ExecStateERKNS_10IdentifierENS_7JSValueERNS_15PutPropertySlotE -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r94701 r94814 115 115 'runtime/ScopeChain.h', 116 116 'runtime/SmallStrings.h', 117 'runtime/StorageBarrier.h', 117 118 'runtime/StringObject.h', 118 119 'runtime/StringObjectThatMasqueradesAsUndefined.h', -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r94811 r94814 60 60 ?addStaticGlobals@JSGlobalObject@JSC@@IAEXPAUGlobalPropertyInfo@12@H@Z 61 61 ?allocate@Heap@JSC@@QAEPAXAAUSizeClass@NewSpace@2@@Z 62 ?allocatePropertyStorage@JSObject@JSC@@QAEX II@Z62 ?allocatePropertyStorage@JSObject@JSC@@QAEXAAVJSGlobalData@2@II@Z 63 63 ?allocateSlowCase@Heap@JSC@@AAEPAXAAUSizeClass@NewSpace@2@@Z 64 64 ?append@StringBuilder@WTF@@QAEXPBDI@Z -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r94802 r94814 417 417 A76C51761182748D00715B05 /* JSInterfaceJIT.h in Headers */ = {isa = PBXBuildFile; fileRef = A76C51741182748D00715B05 /* JSInterfaceJIT.h */; }; 418 418 A76F54A313B28AAB00EF2BCE /* JITWriteBarrier.h in Headers */ = {isa = PBXBuildFile; fileRef = A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */; }; 419 A781E359141970C700094D90 /* StorageBarrier.h in Headers */ = {isa = PBXBuildFile; fileRef = A781E358141970C700094D90 /* StorageBarrier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 419 420 A784A26111D16622005776AC /* ASTBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A7EE7411B98B8D0065A14F /* ASTBuilder.h */; }; 420 421 A784A26211D16622005776AC /* JSParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A7EE7511B98B8D0065A14F /* JSParser.cpp */; }; … … 1183 1184 A76C51741182748D00715B05 /* JSInterfaceJIT.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInterfaceJIT.h; sourceTree = "<group>"; }; 1184 1185 A76F54A213B28AAB00EF2BCE /* JITWriteBarrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITWriteBarrier.h; sourceTree = "<group>"; }; 1186 A781E358141970C700094D90 /* StorageBarrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StorageBarrier.h; sourceTree = "<group>"; }; 1185 1187 A791EF260F11E07900AE1F68 /* JSByteArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSByteArray.h; sourceTree = "<group>"; }; 1186 1188 A791EF270F11E07900AE1F68 /* JSByteArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSByteArray.cpp; sourceTree = "<group>"; }; … … 2105 2107 93303FE80E6A72B500786E6A /* SmallStrings.cpp */, 2106 2108 93303FEA0E6A72C000786E6A /* SmallStrings.h */, 2109 A781E358141970C700094D90 /* StorageBarrier.h */, 2107 2110 A730B6111250068F009D25B1 /* StrictEvalActivation.cpp */, 2108 2111 A730B6101250068F009D25B1 /* StrictEvalActivation.h */, … … 2749 2752 BC66BAE413F492CC00C23FAE /* Compiler.h in Headers */, 2750 2753 A7BC0C82140608B000B1BB71 /* CheckedArithmetic.h in Headers */, 2754 A781E359141970C700094D90 /* StorageBarrier.h in Headers */, 2751 2755 ); 2752 2756 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r94522 r94814 691 691 size_t proportionalBytes = 2 * size(); 692 692 m_newSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle)); 693 693 m_newSpace.resetPropertyStorageNursery(); 694 694 JAVASCRIPTCORE_GC_END(); 695 695 -
trunk/Source/JavaScriptCore/heap/Heap.h
r94522 r94814 92 92 void collectAllGarbage(); 93 93 94 inline void* allocatePropertyStorage(size_t); 95 inline bool inPropertyStorageNursery(void*); 96 94 97 void reportExtraMemoryCost(size_t cost); 95 98 … … 164 167 165 168 static void writeBarrierSlowCase(const JSCell*, JSCell*); 166 169 167 170 #if ENABLE(LAZY_BLOCK_FREEING) 168 171 void waitForRelativeTimeWhileHoldingLock(double relative); … … 360 363 } 361 364 365 inline void* Heap::allocatePropertyStorage(size_t bytes) 366 { 367 ASSERT(!(bytes % sizeof(JSValue))); 368 if (bytes >= NewSpace::PropertyStorageNurserySize) 369 return 0; 370 if (void* result = m_newSpace.allocatePropertyStorage(bytes)) 371 return result; 372 collect(DoNotSweep); 373 return m_newSpace.allocatePropertyStorage(bytes); 374 } 375 376 inline bool Heap::inPropertyStorageNursery(void* ptr) 377 { 378 return m_newSpace.inPropertyStorageNursery(ptr); 379 } 380 362 381 } // namespace JSC 363 382 -
trunk/Source/JavaScriptCore/heap/MarkedBlock.h
r94461 r94814 49 49 50 50 static const size_t KB = 1024; 51 static const size_t MB = 1024 * 1024; 51 52 52 53 // A marked block is a page-aligned container for heap-allocated objects. -
trunk/Source/JavaScriptCore/heap/NewSpace.cpp
r94522 r94814 33 33 34 34 NewSpace::NewSpace(Heap* heap) 35 : m_waterMark(0) 35 : m_propertyStorageNursery(static_cast<char*>(fastMalloc(PropertyStorageNurserySize))) 36 , m_propertyStorageAllocationPoint(m_propertyStorageNursery) 37 , m_waterMark(0) 36 38 , m_highWaterMark(0) 37 39 , m_heap(heap) -
trunk/Source/JavaScriptCore/heap/NewSpace.h
r94522 r94814 47 47 public: 48 48 static const size_t maxCellSize = 1024; 49 static const size_t PropertyStorageNurserySize = 4 * MB; 49 50 50 51 struct SizeClass { … … 64 65 SizeClass& sizeClassFor(size_t); 65 66 void* allocate(SizeClass&); 67 inline void* allocatePropertyStorage(size_t); 68 inline bool inPropertyStorageNursery(void* ptr); 69 inline void resetPropertyStorageNursery(); 70 66 71 void resetAllocator(); 67 72 … … 92 97 SizeClass m_preciseSizeClasses[preciseCount]; 93 98 SizeClass m_impreciseSizeClasses[impreciseCount]; 99 char* m_propertyStorageNursery; 100 char* m_propertyStorageAllocationPoint; 94 101 size_t m_waterMark; 95 102 size_t m_highWaterMark; … … 161 168 } 162 169 170 inline void NewSpace::resetPropertyStorageNursery() 171 { 172 m_propertyStorageAllocationPoint = m_propertyStorageNursery; 173 } 174 175 inline void* NewSpace::allocatePropertyStorage(size_t size) 176 { 177 char* result = m_propertyStorageAllocationPoint; 178 if (size > PropertyStorageNurserySize) 179 CRASH(); 180 m_propertyStorageAllocationPoint += size; 181 if (static_cast<size_t>(m_propertyStorageAllocationPoint - m_propertyStorageNursery) > PropertyStorageNurserySize) { 182 m_propertyStorageAllocationPoint = result; 183 return 0; 184 } 185 return result; 186 } 187 188 inline bool NewSpace::inPropertyStorageNursery(void* ptr) 189 { 190 char* addr = static_cast<char*>(ptr); 191 return static_cast<size_t>(addr - m_propertyStorageNursery) < PropertyStorageNurserySize; 192 } 193 163 194 template <typename Functor> inline typename Functor::ReturnType NewSpace::forEachBlock(Functor& functor) 164 195 { -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r94701 r94814 1482 1482 ASSERT(baseValue.isObject()); 1483 1483 JSObject* base = asObject(baseValue); 1484 base->allocatePropertyStorage( oldSize, newSize);1484 base->allocatePropertyStorage(*stackFrame.globalData, oldSize, newSize); 1485 1485 1486 1486 return base; -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r94599 r94814 595 595 } 596 596 597 void JSObject::allocatePropertyStorage( size_t oldSize, size_t newSize)597 void JSObject::allocatePropertyStorage(JSGlobalData& globalData, size_t oldSize, size_t newSize) 598 598 { 599 599 ASSERT(newSize > oldSize); … … 601 601 // It's important that this function not rely on m_structure, since 602 602 // we might be in the middle of a transition. 603 bool wasInline = (oldSize < JSObject::baseExternalStorageCapacity); 604 605 PropertyStorage oldPropertyStorage = m_propertyStorage; 606 PropertyStorage newPropertyStorage = new WriteBarrierBase<Unknown>[newSize]; 603 PropertyStorage newPropertyStorage = 0; 604 if (globalData.heap.inPropertyStorageNursery(m_propertyStorage.get())) { 605 newPropertyStorage = static_cast<PropertyStorage>(globalData.heap.allocatePropertyStorage(newSize * sizeof(WriteBarrierBase<Unknown>))); 606 if (!newPropertyStorage || !globalData.heap.inPropertyStorageNursery(m_propertyStorage.get())) { 607 // If allocation failed because it's too big, or it triggered a GC 608 // that promoted us to old space, we need to allocate our property 609 // storage in old space. 610 newPropertyStorage = new WriteBarrierBase<Unknown>[newSize]; 611 } 612 } else 613 newPropertyStorage = new WriteBarrierBase<Unknown>[newSize]; 614 615 PropertyStorage oldPropertyStorage = m_propertyStorage.get(); 616 ASSERT(newPropertyStorage); 607 617 608 618 for (unsigned i = 0; i < oldSize; ++i) 609 619 newPropertyStorage[i] = oldPropertyStorage[i]; 610 620 611 if (! wasInline)621 if (!isUsingInlineStorage() && !globalData.heap.inPropertyStorageNursery(m_propertyStorage.get())) 612 622 delete [] oldPropertyStorage; 613 623 614 m_propertyStorage = newPropertyStorage;624 m_propertyStorage.set(globalData, this, newPropertyStorage); 615 625 } 616 626 -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r94811 r94814 32 32 #include "PutPropertySlot.h" 33 33 #include "ScopeChain.h" 34 #include "StorageBarrier.h" 34 35 #include "Structure.h" 35 36 #include "JSGlobalData.h" … … 69 70 }; 70 71 71 typedef WriteBarrierBase<Unknown>* PropertyStorage;72 typedef const WriteBarrierBase<Unknown>* ConstPropertyStorage;73 74 72 class JSObject : public JSCell { 75 73 friend class BatchedTransitionOptimizer; … … 219 217 bool isExtensible() { return m_structure->isExtensible(); } 220 218 221 void allocatePropertyStorage( size_t oldSize, size_t newSize);222 bool isUsingInlineStorage() const { return static_cast<const void*>(m_propertyStorage ) == static_cast<const void*>(this + 1); }219 void allocatePropertyStorage(JSGlobalData&, size_t oldSize, size_t newSize); 220 bool isUsingInlineStorage() const { return static_cast<const void*>(m_propertyStorage.get()) == static_cast<const void*>(this + 1); } 223 221 224 222 void* addressOfPropertyAtOffset(size_t offset) … … 292 290 JSObject(VPtrStealingHackType, PropertyStorage inlineStorage) 293 291 : JSCell(VPtrStealingHack) 294 , m_propertyStorage(inlineStorage )292 , m_propertyStorage(inlineStorage, StorageBarrier::Unchecked) 295 293 { 296 294 } … … 306 304 void isString(); 307 305 308 ConstPropertyStorage propertyStorage() const { return m_propertyStorage ; }309 PropertyStorage propertyStorage() { return m_propertyStorage ; }306 ConstPropertyStorage propertyStorage() const { return m_propertyStorage.get(); } 307 PropertyStorage propertyStorage() { return m_propertyStorage.get(); } 310 308 311 309 const WriteBarrierBase<Unknown>* locationForOffset(size_t offset) const … … 328 326 Structure* createInheritorID(JSGlobalData&); 329 327 330 PropertyStoragem_propertyStorage;328 StorageBarrier m_propertyStorage; 331 329 WriteBarrier<Structure> m_inheritorID; 332 330 }; … … 462 460 inline JSObject::JSObject(JSGlobalData& globalData, Structure* structure, PropertyStorage inlineStorage) 463 461 : JSCell(globalData, structure) 464 , m_propertyStorage( inlineStorage)462 , m_propertyStorage(globalData, this, inlineStorage) 465 463 { 466 464 } … … 468 466 inline JSObject::~JSObject() 469 467 { 470 if (!isUsingInlineStorage() )471 delete [] m_propertyStorage ;468 if (!isUsingInlineStorage() && !Heap::heap(this)->inPropertyStorageNursery(m_propertyStorage.get())) 469 delete [] m_propertyStorage.get(); 472 470 } 473 471 … … 662 660 offset = m_structure->addPropertyWithoutTransition(globalData, propertyName, attributes, specificFunction); 663 661 if (currentCapacity != m_structure->propertyStorageCapacity()) 664 allocatePropertyStorage( currentCapacity, m_structure->propertyStorageCapacity());662 allocatePropertyStorage(globalData, currentCapacity, m_structure->propertyStorageCapacity()); 665 663 666 664 ASSERT(offset < m_structure->propertyStorageCapacity()); … … 676 674 if (Structure* structure = Structure::addPropertyTransitionToExistingStructure(m_structure.get(), propertyName, attributes, specificFunction, offset)) { 677 675 if (currentCapacity != structure->propertyStorageCapacity()) 678 allocatePropertyStorage( currentCapacity, structure->propertyStorageCapacity());676 allocatePropertyStorage(globalData, currentCapacity, structure->propertyStorageCapacity()); 679 677 680 678 ASSERT(offset < structure->propertyStorageCapacity()); … … 726 724 727 725 if (currentCapacity != structure->propertyStorageCapacity()) 728 allocatePropertyStorage( currentCapacity, structure->propertyStorageCapacity());726 allocatePropertyStorage(globalData, currentCapacity, structure->propertyStorageCapacity()); 729 727 730 728 ASSERT(offset < structure->propertyStorageCapacity()); … … 787 785 size_t offset = m_structure->addPropertyWithoutTransition(globalData, propertyName, attributes, 0); 788 786 if (currentCapacity != m_structure->propertyStorageCapacity()) 789 allocatePropertyStorage( currentCapacity, m_structure->propertyStorageCapacity());787 allocatePropertyStorage(globalData, currentCapacity, m_structure->propertyStorageCapacity()); 790 788 putDirectOffset(globalData, offset, value); 791 789 } … … 796 794 size_t offset = m_structure->addPropertyWithoutTransition(globalData, propertyName, attributes, value); 797 795 if (currentCapacity != m_structure->propertyStorageCapacity()) 798 allocatePropertyStorage( currentCapacity, m_structure->propertyStorageCapacity());796 allocatePropertyStorage(globalData, currentCapacity, m_structure->propertyStorageCapacity()); 799 797 putDirectOffset(globalData, offset, value); 800 798 } … … 803 801 { 804 802 if (m_structure->propertyStorageCapacity() != newStructure->propertyStorageCapacity()) 805 allocatePropertyStorage( m_structure->propertyStorageCapacity(), newStructure->propertyStorageCapacity());803 allocatePropertyStorage(globalData, m_structure->propertyStorageCapacity(), newStructure->propertyStorageCapacity()); 806 804 setStructure(globalData, newStructure); 807 805 } … … 894 892 895 893 PropertyStorage storage = propertyStorage(); 894 if (Heap::heap(this)->inPropertyStorageNursery(storage)) { 895 m_propertyStorage.set(new WriteBarrierBase<Unknown>[structure()->propertyStorageCapacity()], StorageBarrier::Unchecked); 896 if (structure()->propertyStorageCapacity() > m_structure->propertyStorageSize()) 897 ASSERT(!storage[m_structure->propertyStorageSize()]); 898 memcpy(m_propertyStorage.get(), storage, m_structure->propertyStorageSize() * sizeof(WriteBarrierBase<Unknown>)); 899 } 896 900 size_t storageSize = m_structure->propertyStorageSize(); 897 901 visitor.appendValues(storage, storageSize); -
trunk/Source/WebCore/ChangeLog
r94813 r94814 1 2011-09-08 Oliver Hunt <oliver@apple.com> 2 3 Use bump allocator for initial property storage 4 https://bugs.webkit.org/show_bug.cgi?id=67494 5 6 Reviewed by Geoffrey Garen. 7 8 Add a forwarding header. 9 10 * ForwardingHeaders/runtime/StorageBarrier.h: Added. 11 1 12 2011-09-08 Roland Steiner <rolandsteiner@chromium.org> 2 13
Note: See TracChangeset
for help on using the changeset viewer.