Changeset 246421 in webkit
- Timestamp:
- Jun 13, 2019, 7:30:48 PM (7 years ago)
- Location:
- branches/safari-607-branch
- Files:
-
- 1 added
- 10 edited
- 1 moved
-
Source/bmalloc/ChangeLog (modified) (1 diff)
-
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (modified) (15 diffs)
-
Source/bmalloc/bmalloc/IsoDirectory.h (modified) (2 diffs)
-
Source/bmalloc/bmalloc/IsoDirectoryInlines.h (modified) (4 diffs)
-
Source/bmalloc/bmalloc/IsoHeapImpl.h (modified) (3 diffs)
-
Source/bmalloc/bmalloc/IsoHeapImplInlines.h (modified) (5 diffs)
-
Source/bmalloc/bmalloc/IsoTLS.cpp (modified) (1 diff)
-
Source/bmalloc/bmalloc/ProcessCheck.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (5 diffs)
-
Tools/TestWebKitAPI/Tests/WTF/bmalloc (added)
-
Tools/TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp (moved) (moved from branches/safari-607-branch/Source/bmalloc/test/testbmalloc.cpp ) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607-branch/Source/bmalloc/ChangeLog
r240392 r246421 1 2019-06-13 Kocsen Chung <kocsen_chung@apple.com> 2 3 Apply patch. rdar://problem/51656608 4 5 2019-06-13 Keith Miller <keith_miller@apple.com> 6 7 IsoHeaps don't notice uncommitted VA becoming the first eligible. 8 https://bugs.webkit.org/show_bug.cgi?id=198301 9 10 Reviewed by Yusuke Suzuki. 11 12 IsoDirectory has a firstEligible member that is used as an 13 optimization to help find the first fit. However if the scavenger 14 decommitted a page before firstEligible then we wouldn't move 15 firstEligible. Thus, if no space is ever freed below firstEligible 16 we will never reused the decommitted memory (e.g. if the VA page 17 is decommitted). The fix is to make IsoDirectory::didDecommit move 18 the firstEligible page back if the decommitted page is smaller 19 than the current firstEligible. As such, this patch renames 20 firstEligible to firstEligibleOrDecommitted. 21 22 Also, this patch changes gigacageEnabledForProcess to check if the 23 process starts with Test rather than just test as TestWTF does. 24 25 Lastly, unbeknownst to me IsoHeaps are dependent on gigacage, so 26 by removing gigacage from arm64 I accidentally disabled 27 IsoHeaps... 28 29 * bmalloc.xcodeproj/project.pbxproj: 30 * bmalloc/IsoDirectory.h: 31 * bmalloc/IsoDirectoryInlines.h: 32 (bmalloc::passedNumPages>::takeFirstEligible): 33 (bmalloc::passedNumPages>::didBecome): 34 (bmalloc::passedNumPages>::didDecommit): 35 * bmalloc/IsoHeapImpl.h: 36 * bmalloc/IsoHeapImplInlines.h: 37 (bmalloc::IsoHeapImpl<Config>::takeFirstEligible): 38 (bmalloc::IsoHeapImpl<Config>::didBecomeEligibleOrDecommited): 39 (bmalloc::IsoHeapImpl<Config>::didCommit): 40 (bmalloc::IsoHeapImpl<Config>::didBecomeEligible): Deleted. 41 * bmalloc/IsoTLS.cpp: 42 (bmalloc::IsoTLS::determineMallocFallbackState): 43 * bmalloc/ProcessCheck.mm: 44 (bmalloc::gigacageEnabledForProcess): 45 1 46 2019-01-23 Alan Coon <alancoon@apple.com> 2 47 -
branches/safari-607-branch/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
r236805 r246421 34 34 0F74B93E1F89713E00B935D3 /* CryptoRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F74B93C1F89713E00B935D3 /* CryptoRandom.h */; settings = {ATTRIBUTES = (Private, ); }; }; 35 35 0F74B93F1F89713E00B935D3 /* CryptoRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */; }; 36 0F7EB7F21F95285300F1ABCB /* testbmalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */; };37 0F7EB7FA1F95414C00F1ABCB /* libbmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14F271BE18EA3963008C152F /* libbmalloc.a */; };38 36 0F7EB8231F9541B000F1ABCB /* EligibilityResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7EB7FC1F9541AD00F1ABCB /* EligibilityResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 39 37 0F7EB8241F9541B000F1ABCB /* IsoHeapImplInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7EB7FD1F9541AD00F1ABCB /* IsoHeapImplInlines.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 144 142 145 143 /* Begin PBXContainerItemProxy section */ 146 0F7EB7F71F95412900F1ABCB /* PBXContainerItemProxy */ = {147 isa = PBXContainerItemProxy;148 containerPortal = 145F6837179DC45F00D65598 /* Project object */;149 proxyType = 1;150 remoteGlobalIDString = 14F271BD18EA3963008C152F;151 remoteInfo = bmalloc;152 };153 144 0F7EB8551F95505400F1ABCB /* PBXContainerItemProxy */ = { 154 145 isa = PBXContainerItemProxy; … … 166 157 }; 167 158 /* End PBXContainerItemProxy section */ 168 169 /* Begin PBXCopyFilesBuildPhase section */170 0F7EB7ED1F95285300F1ABCB /* CopyFiles */ = {171 isa = PBXCopyFilesBuildPhase;172 buildActionMask = 2147483647;173 dstPath = /usr/share/man/man1/;174 dstSubfolderSpec = 0;175 files = (176 );177 runOnlyForDeploymentPostprocessing = 1;178 };179 /* End PBXCopyFilesBuildPhase section */180 159 181 160 /* Begin PBXFileReference section */ … … 192 171 0F74B93C1F89713E00B935D3 /* CryptoRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoRandom.h; path = bmalloc/CryptoRandom.h; sourceTree = "<group>"; }; 193 172 0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoRandom.cpp; path = bmalloc/CryptoRandom.cpp; sourceTree = "<group>"; }; 194 0F7EB7EF1F95285300F1ABCB /* testbmalloc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testbmalloc; sourceTree = BUILT_PRODUCTS_DIR; };195 0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = testbmalloc.cpp; sourceTree = "<group>"; };196 173 0F7EB7FC1F9541AD00F1ABCB /* EligibilityResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EligibilityResult.h; path = bmalloc/EligibilityResult.h; sourceTree = SOURCE_ROOT; }; 197 174 0F7EB7FD1F9541AD00F1ABCB /* IsoHeapImplInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IsoHeapImplInlines.h; path = bmalloc/IsoHeapImplInlines.h; sourceTree = SOURCE_ROOT; }; … … 307 284 308 285 /* Begin PBXFrameworksBuildPhase section */ 309 0F7EB7EC1F95285300F1ABCB /* Frameworks */ = {310 isa = PBXFrameworksBuildPhase;311 buildActionMask = 2147483647;312 files = (313 0F7EB7FA1F95414C00F1ABCB /* libbmalloc.a in Frameworks */,314 );315 runOnlyForDeploymentPostprocessing = 0;316 };317 286 14CC394118EA8743004AFE34 /* Frameworks */ = { 318 287 isa = PBXFrameworksBuildPhase; … … 334 303 335 304 /* Begin PBXGroup section */ 336 0F7EB7F01F95285300F1ABCB /* test */ = {337 isa = PBXGroup;338 children = (339 0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */,340 );341 path = test;342 sourceTree = "<group>";343 };344 305 0F7EB7F91F95414C00F1ABCB /* Frameworks */ = { 345 306 isa = PBXGroup; … … 422 383 145F6840179DC45F00D65598 /* Products */, 423 384 14D9DB4F17F2868900EAAB79 /* stdlib */, 424 0F7EB7F01F95285300F1ABCB /* test */,425 385 ); 426 386 sourceTree = "<group>"; … … 429 389 isa = PBXGroup; 430 390 children = ( 431 0F7EB7EF1F95285300F1ABCB /* testbmalloc */,432 391 14F271BE18EA3963008C152F /* libbmalloc.a */, 433 392 14CC394418EA8743004AFE34 /* libmbmalloc.dylib */, … … 666 625 667 626 /* Begin PBXNativeTarget section */ 668 0F7EB7EE1F95285300F1ABCB /* testbmalloc */ = {669 isa = PBXNativeTarget;670 buildConfigurationList = 0F7EB7F61F95285300F1ABCB /* Build configuration list for PBXNativeTarget "testbmalloc" */;671 buildPhases = (672 0F7EB7EB1F95285300F1ABCB /* Sources */,673 0F7EB7EC1F95285300F1ABCB /* Frameworks */,674 0F7EB7ED1F95285300F1ABCB /* CopyFiles */,675 );676 buildRules = (677 );678 dependencies = (679 0F7EB7F81F95412900F1ABCB /* PBXTargetDependency */,680 );681 name = testbmalloc;682 productName = testbmalloc;683 productReference = 0F7EB7EF1F95285300F1ABCB /* testbmalloc */;684 productType = "com.apple.product-type.tool";685 };686 627 14CC394318EA8743004AFE34 /* mbmalloc */ = { 687 628 isa = PBXNativeTarget; … … 728 669 LastUpgradeCheck = 1000; 729 670 TargetAttributes = { 730 0F7EB7EE1F95285300F1ABCB = {731 CreatedOnToolsVersion = 9.0;732 ProvisioningStyle = Manual;733 };734 671 0F7EB8501F95504B00F1ABCB = { 735 672 CreatedOnToolsVersion = 9.0; … … 753 690 14F271BD18EA3963008C152F /* bmalloc */, 754 691 14CC394318EA8743004AFE34 /* mbmalloc */, 755 0F7EB7EE1F95285300F1ABCB /* testbmalloc */,756 692 ); 757 693 }; … … 759 695 760 696 /* Begin PBXSourcesBuildPhase section */ 761 0F7EB7EB1F95285300F1ABCB /* Sources */ = {762 isa = PBXSourcesBuildPhase;763 buildActionMask = 2147483647;764 files = (765 0F7EB7F21F95285300F1ABCB /* testbmalloc.cpp in Sources */,766 );767 runOnlyForDeploymentPostprocessing = 0;768 };769 697 14CC394018EA8743004AFE34 /* Sources */ = { 770 698 isa = PBXSourcesBuildPhase; … … 813 741 814 742 /* Begin PBXTargetDependency section */ 815 0F7EB7F81F95412900F1ABCB /* PBXTargetDependency */ = {816 isa = PBXTargetDependency;817 target = 14F271BD18EA3963008C152F /* bmalloc */;818 targetProxy = 0F7EB7F71F95412900F1ABCB /* PBXContainerItemProxy */;819 };820 743 0F7EB8561F95505400F1ABCB /* PBXTargetDependency */ = { 821 744 isa = PBXTargetDependency; … … 831 754 832 755 /* Begin XCBuildConfiguration section */ 833 0F7EB7F31F95285300F1ABCB /* Debug */ = {834 isa = XCBuildConfiguration;835 baseConfigurationReference = 14B650C718F39F4800751968 /* DebugRelease.xcconfig */;836 buildSettings = {837 PRODUCT_NAME = "$(TARGET_NAME)";838 };839 name = Debug;840 };841 0F7EB7F41F95285300F1ABCB /* Release */ = {842 isa = XCBuildConfiguration;843 baseConfigurationReference = 14B650C718F39F4800751968 /* DebugRelease.xcconfig */;844 buildSettings = {845 PRODUCT_NAME = "$(TARGET_NAME)";846 };847 name = Release;848 };849 0F7EB7F51F95285300F1ABCB /* Production */ = {850 isa = XCBuildConfiguration;851 baseConfigurationReference = 14B650C518F39F4800751968 /* Base.xcconfig */;852 buildSettings = {853 PRODUCT_NAME = "$(TARGET_NAME)";854 };855 name = Production;856 };857 756 0F7EB8521F95504B00F1ABCB /* Debug */ = { 858 757 isa = XCBuildConfiguration; … … 949 848 950 849 /* Begin XCConfigurationList section */ 951 0F7EB7F61F95285300F1ABCB /* Build configuration list for PBXNativeTarget "testbmalloc" */ = {952 isa = XCConfigurationList;953 buildConfigurations = (954 0F7EB7F31F95285300F1ABCB /* Debug */,955 0F7EB7F41F95285300F1ABCB /* Release */,956 0F7EB7F51F95285300F1ABCB /* Production */,957 );958 defaultConfigurationIsVisible = 0;959 defaultConfigurationName = Production;960 };961 850 0F7EB8511F95504B00F1ABCB /* Build configuration list for PBXAggregateTarget "All" */ = { 962 851 isa = XCConfigurationList; -
branches/safari-607-branch/Source/bmalloc/bmalloc/IsoDirectory.h
r230501 r246421 1 1 /* 2 * Copyright (C) 2017-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 90 90 Bits<numPages> m_committed; 91 91 std::array<IsoPage<Config>*, numPages> m_pages; 92 unsigned m_firstEligible { 0 };92 unsigned m_firstEligibleOrDecommitted { 0 }; 93 93 unsigned m_highWatermark { 0 }; 94 94 }; -
branches/safari-607-branch/Source/bmalloc/bmalloc/IsoDirectoryInlines.h
r230501 r246421 1 1 /* 2 * Copyright (C) 2017-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 47 47 EligibilityResult<Config> IsoDirectory<Config, passedNumPages>::takeFirstEligible() 48 48 { 49 unsigned pageIndex = (m_eligible | ~m_committed).findBit(m_firstEligible, true); 50 m_firstEligible = pageIndex; 49 unsigned pageIndex = (m_eligible | ~m_committed).findBit(m_firstEligibleOrDecommitted, true); 50 m_firstEligibleOrDecommitted = pageIndex; 51 BASSERT((m_eligible | ~m_committed).findBit(0, true) == pageIndex); 51 52 if (pageIndex >= numPages) 52 53 return EligibilityKind::Full; … … 100 101 fprintf(stderr, "%p: %p did become eligible.\n", this, page); 101 102 m_eligible[pageIndex] = true; 102 m_firstEligible = std::min(m_firstEligible, pageIndex);103 this->m_heap.didBecomeEligible (this);103 m_firstEligibleOrDecommitted = std::min(m_firstEligibleOrDecommitted, pageIndex); 104 this->m_heap.didBecomeEligibleOrDecommited(this); 104 105 return; 105 106 case IsoPageTrigger::Empty: … … 125 126 this->m_heap.isNoLongerFreeable(m_pages[index], IsoPageBase::pageSize); 126 127 m_committed[index] = false; 128 m_firstEligibleOrDecommitted = std::min(m_firstEligibleOrDecommitted, index); 129 this->m_heap.didBecomeEligibleOrDecommited(this); 127 130 this->m_heap.didDecommit(m_pages[index], IsoPageBase::pageSize); 128 131 } -
branches/safari-607-branch/Source/bmalloc/bmalloc/IsoHeapImpl.h
r230501 r246421 1 1 /* 2 * Copyright (C) 2017-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 69 69 70 70 // Callbacks from directory. 71 void didBecomeEligible (IsoDirectory<Config, numPagesInInlineDirectory>*);72 void didBecomeEligible (IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>*);71 void didBecomeEligibleOrDecommited(IsoDirectory<Config, numPagesInInlineDirectory>*); 72 void didBecomeEligibleOrDecommited(IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>*); 73 73 74 74 void scavenge(Vector<DeferredDecommit>&) override; … … 121 121 unsigned m_directoryHighWatermark { 0 }; 122 122 123 bool m_isInlineDirectoryEligible { true };124 IsoDirectoryPage<Config>* m_firstEligible Directory { nullptr };123 bool m_isInlineDirectoryEligibleOrDecommitted { true }; 124 IsoDirectoryPage<Config>* m_firstEligibleOrDecommitedDirectory { nullptr }; 125 125 126 126 IsoTLSAllocatorEntry<Config> m_allocator; -
branches/safari-607-branch/Source/bmalloc/bmalloc/IsoHeapImplInlines.h
r230515 r246421 1 1 /* 2 * Copyright (C) 2017-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 43 43 EligibilityResult<Config> IsoHeapImpl<Config>::takeFirstEligible() 44 44 { 45 if (m_isInlineDirectoryEligible ) {45 if (m_isInlineDirectoryEligibleOrDecommitted) { 46 46 EligibilityResult<Config> result = m_inlineDirectory.takeFirstEligible(); 47 47 if (result.kind == EligibilityKind::Full) 48 m_isInlineDirectoryEligible = false;48 m_isInlineDirectoryEligibleOrDecommitted = false; 49 49 else 50 50 return result; 51 51 } 52 52 53 if (!m_firstEligible Directory) {53 if (!m_firstEligibleOrDecommitedDirectory) { 54 54 // If nothing is eligible, it can only be because we have no directories. It wouldn't be the end 55 // of the world if we broke this invariant. It would only mean that didBecomeEligible () would need55 // of the world if we broke this invariant. It would only mean that didBecomeEligibleOrDecommited() would need 56 56 // a null check. 57 57 RELEASE_BASSERT(!m_headDirectory); … … 59 59 } 60 60 61 for (; m_firstEligible Directory; m_firstEligibleDirectory = m_firstEligibleDirectory->next) {62 EligibilityResult<Config> result = m_firstEligible Directory->payload.takeFirstEligible();61 for (; m_firstEligibleOrDecommitedDirectory; m_firstEligibleOrDecommitedDirectory = m_firstEligibleOrDecommitedDirectory->next) { 62 EligibilityResult<Config> result = m_firstEligibleOrDecommitedDirectory->payload.takeFirstEligible(); 63 63 if (result.kind != EligibilityKind::Full) { 64 m_directoryHighWatermark = std::max(m_directoryHighWatermark, m_firstEligible Directory->index());64 m_directoryHighWatermark = std::max(m_directoryHighWatermark, m_firstEligibleOrDecommitedDirectory->index()); 65 65 return result; 66 66 } … … 77 77 } 78 78 m_directoryHighWatermark = newDirectory->index(); 79 m_firstEligible Directory = newDirectory;79 m_firstEligibleOrDecommitedDirectory = newDirectory; 80 80 EligibilityResult<Config> result = newDirectory->payload.takeFirstEligible(); 81 81 RELEASE_BASSERT(result.kind != EligibilityKind::Full); … … 84 84 85 85 template<typename Config> 86 void IsoHeapImpl<Config>::didBecomeEligible (IsoDirectory<Config, numPagesInInlineDirectory>* directory)86 void IsoHeapImpl<Config>::didBecomeEligibleOrDecommited(IsoDirectory<Config, numPagesInInlineDirectory>* directory) 87 87 { 88 88 RELEASE_BASSERT(directory == &m_inlineDirectory); 89 m_isInlineDirectoryEligible = true;90 } 91 92 template<typename Config> 93 void IsoHeapImpl<Config>::didBecomeEligible (IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>* directory)94 { 95 RELEASE_BASSERT(m_firstEligible Directory);89 m_isInlineDirectoryEligibleOrDecommitted = true; 90 } 91 92 template<typename Config> 93 void IsoHeapImpl<Config>::didBecomeEligibleOrDecommited(IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>* directory) 94 { 95 RELEASE_BASSERT(m_firstEligibleOrDecommitedDirectory); 96 96 auto* directoryPage = IsoDirectoryPage<Config>::pageFor(directory); 97 if (directoryPage->index() < m_firstEligible Directory->index())98 m_firstEligible Directory = directoryPage;97 if (directoryPage->index() < m_firstEligibleOrDecommitedDirectory->index()) 98 m_firstEligibleOrDecommitedDirectory = directoryPage; 99 99 } 100 100 -
branches/safari-607-branch/Source/bmalloc/bmalloc/IsoTLS.cpp
r234913 r246421 206 206 return; 207 207 208 #if GIGACAGE_ENABLED 208 #if GIGACAGE_ENABLED || BCPU(ARM64) 209 #if !BCPU(ARM64) 209 210 if (!Gigacage::shouldBeEnabled()) { 210 211 s_mallocFallbackState = MallocFallbackState::FallBackToMalloc; 211 212 return; 212 213 } 214 #endif 213 215 const char* env = getenv("bmalloc_IsoHeap"); 214 216 if (env && (!strcasecmp(env, "false") || !strcasecmp(env, "no") || !strcmp(env, "0"))) -
branches/safari-607-branch/Source/bmalloc/bmalloc/ProcessCheck.mm
r236474 r246421 47 47 || [processName isEqualToString:@"DumpRenderTree"] 48 48 || [processName isEqualToString:@"wasm"] 49 || [processName hasPrefix:@"test"]; 49 || [processName hasPrefix:@"test"] 50 || [processName hasPrefix:@"Test"]; 50 51 51 52 return isOptInBinary; -
branches/safari-607-branch/Tools/ChangeLog
r246376 r246421 1 2019-06-13 Kocsen Chung <kocsen_chung@apple.com> 2 3 Apply patch. rdar://problem/51656608 4 5 2019-06-13 Keith Miller <keith_miller@apple.com> 6 7 IsoHeaps don't notice uncommitted VA becoming the first eligible. 8 https://bugs.webkit.org/show_bug.cgi?id=198301 9 10 Reviewed by Yusuke Suzuki. 11 12 Move testbmalloc.cpp to TestWTF so it runs in automation. 13 14 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 15 * TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp: Renamed from Source/bmalloc/test/testbmalloc.cpp. 16 (TEST): 17 1 18 2019-06-12 Null <null@apple.com> 2 19 -
branches/safari-607-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r246376 r246421 259 259 536770361CC81B6100D425B1 /* WebScriptObjectDescription.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */; }; 260 260 53EC25411E96FD87000831B9 /* PriorityQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */; }; 261 53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */; }; 261 262 55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55226A2E1EB969B600C36AD0 /* large-red-square-image.html */; }; 262 263 5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */; }; … … 1640 1641 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebScriptObjectDescription.html; sourceTree = "<group>"; }; 1641 1642 53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PriorityQueue.cpp; sourceTree = "<group>"; }; 1643 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IsoHeap.cpp; sourceTree = "<group>"; }; 1642 1644 55226A2E1EB969B600C36AD0 /* large-red-square-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-red-square-image.html"; sourceTree = "<group>"; }; 1643 1645 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronizedFixedQueue.cpp; sourceTree = "<group>"; }; … … 2742 2744 sourceTree = "<group>"; 2743 2745 }; 2746 53FCDE69229EFF6800598ECF /* bmalloc */ = { 2747 isa = PBXGroup; 2748 children = ( 2749 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */, 2750 ); 2751 path = bmalloc; 2752 sourceTree = "<group>"; 2753 }; 2744 2754 7560917619259C59009EF06E /* ios */ = { 2745 2755 isa = PBXGroup; … … 3198 3208 isa = PBXGroup; 3199 3209 children = ( 3210 53FCDE69229EFF6800598ECF /* bmalloc */, 3200 3211 C0991C4F143C7D68007998F2 /* cf */, 3201 3212 E3C21A7821B25C82003B31A3 /* cocoa */, … … 3833 3844 7C83DED41D0A590C00FEBCF3 /* HashSet.cpp in Sources */, 3834 3845 7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */, 3846 53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */, 3835 3847 7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */, 3836 3848 531C1D8E1DF8EF72006E979F /* LEBDecoder.cpp in Sources */, -
branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp
r246420 r246421 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 11 11 * documentation and/or other materials provided with the distribution. 12 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 26 #include "config.h" 27 28 #if !USE(SYSTEM_MALLOC) 25 29 26 30 #include <bmalloc/bmalloc.h> 27 31 #include <bmalloc/Environment.h> 28 32 #include <bmalloc/IsoHeapInlines.h> 33 29 34 #include <cmath> 30 35 #include <cstdlib> … … 35 40 using namespace bmalloc::api; 36 41 37 // We don't have a NO_RETURN_DUE_TO_EXIT, nor should we. That's ridiculous.38 static bool hiddenTruthBecauseNoReturnIsStupid() { return true; }39 40 static void usage()41 {42 puts("Usage: testb3 [<filter>]");43 if (hiddenTruthBecauseNoReturnIsStupid())44 exit(1);45 }46 47 42 #define RUN(test) do { \ 48 if (!shouldRun(#test)) \49 break; \50 puts(#test "..."); \51 test; \52 puts(#test ": OK!"); \53 } while (false)43 if (!shouldRun(#test)) \ 44 break; \ 45 puts(#test "..."); \ 46 test; \ 47 puts(#test ": OK!"); \ 48 } while (false) 54 49 55 50 // Nothing fancy for now; we just use the existing WTF assertion machinery. 56 51 #define CHECK(x) do { \ 57 if (!!(x)) \58 break; \59 fprintf(stderr, "%s:%d: in %s: assertion %s failed.\n", \60 __FILE__, __LINE__, __PRETTY_FUNCTION__, #x); \61 abort(); \62 } while (false)52 if (!!(x)) \ 53 break; \ 54 fprintf(stderr, "%s:%d: in %s: assertion %s failed.\n", \ 55 __FILE__, __LINE__, __PRETTY_FUNCTION__, #x); \ 56 abort(); \ 57 } while (false) 63 58 64 59 static std::set<void*> toptrset(const std::vector<void*>& ptrs) … … 139 134 } 140 135 141 static void testIsoSimple()136 TEST(bmalloc, IsoSimple) 142 137 { 143 138 static IsoHeap<double> heap; … … 154 149 } 155 150 156 static void testIsoSimpleScavengeBeforeDealloc()151 TEST(bmalloc, IsoSimpleScavengeBeforeDealloc) 157 152 { 158 153 static IsoHeap<double> heap; … … 170 165 } 171 166 172 static void testIsoFlipFlopFragmentedPages()167 TEST(bmalloc, IsoFlipFlopFragmentedPages) 173 168 { 174 169 static IsoHeap<double> heap; … … 190 185 } 191 186 192 static void testIsoFlipFlopFragmentedPagesScavengeInMiddle()187 TEST(bmalloc, IsoFlipFlopFragmentedPagesScavengeInMiddle) 193 188 { 194 189 static IsoHeap<double> heap; … … 223 218 } 224 219 225 static void testIsoFlipFlopFragmentedPagesScavengeInMiddle288()220 TEST(bmalloc, IsoFlipFlopFragmentedPagesScavengeInMiddle288) 226 221 { 227 222 static IsoHeap<char[288]> heap; … … 264 259 { 265 260 } 266 261 267 262 int x; 268 263 float y; … … 271 266 MAKE_BISO_MALLOCED_IMPL(BisoMalloced); 272 267 273 static void testBisoMalloced()268 TEST(bmalloc, BisoMalloced) 274 269 { 275 270 BisoMalloced* ptr = new BisoMalloced(4, 5); … … 287 282 { 288 283 } 289 284 290 285 int x; 291 286 float y; 292 287 }; 293 288 294 static void testBisoMallocedInline()289 TEST(bmalloc, BisoMallocedInline) 295 290 { 296 291 BisoMallocedInline* ptr = new BisoMallocedInline(4, 5); … … 300 295 } 301 296 302 static void run(const char* filter) 303 { 304 auto shouldRun = [&] (const char* testName) -> bool { 305 return !filter || !!strcasestr(testName, filter); 297 298 TEST(bmalloc, ScavengedMemoryShouldBeReused) 299 { 300 static IsoHeap<double> heap; 301 302 auto run = [] (unsigned numPagesToCommit) { 303 auto* ptr1 = heap.allocate(); 304 305 std::vector<void*> ptrs; 306 307 for (unsigned i = 0; ;i++) { 308 void* ptr = heap.allocate(); 309 CHECK(ptr); 310 ptrs.push_back(ptr); 311 if (heap.impl().numCommittedPages() == numPagesToCommit) 312 break; 313 } 314 315 std::set<void*> uniquedPtrs = toptrset(ptrs); 316 317 heap.deallocate(ptr1); 318 for (unsigned i = 0; i < IsoPage<decltype(heap)::Config>::numObjects - 1; i++) { 319 heap.deallocate(ptrs[i]); 320 uniquedPtrs.erase(ptrs[i]); 321 } 322 323 scavenge(); 324 assertHasOnlyObjects(heap, uniquedPtrs); 325 326 // FIXME: This only seems to pass when lldb is attached but the scavenger thread isn't running... 327 // see: https://bugs.webkit.org/show_bug.cgi?id=198384 328 // auto* ptr2 = heap.allocate(); 329 // CHECK(ptr1 == ptr2); 306 330 }; 307 308 RUN(testIsoSimple()); 309 RUN(testIsoSimpleScavengeBeforeDealloc()); 310 RUN(testIsoFlipFlopFragmentedPages()); 311 RUN(testIsoFlipFlopFragmentedPagesScavengeInMiddle()); 312 RUN(testIsoFlipFlopFragmentedPagesScavengeInMiddle288()); 313 RUN(testBisoMalloced()); 314 RUN(testBisoMallocedInline()); 315 316 puts("Success!"); 317 } 318 319 int main(int argc, char** argv) 320 { 321 const char* filter = nullptr; 322 switch (argc) { 323 case 1: 324 break; 325 case 2: 326 filter = argv[1]; 327 break; 328 default: 329 usage(); 330 break; 331 } 332 333 run(filter); 334 return 0; 335 } 336 331 332 run(2); 333 } 334 335 #endif
Note:
See TracChangeset
for help on using the changeset viewer.