Changeset 245908 in webkit
- Timestamp:
- May 30, 2019, 4:07:27 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 10 edited
- 1 copied
-
Source/bmalloc/ChangeLog (modified) (1 diff)
-
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (modified) (16 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)
-
Source/bmalloc/test (deleted)
-
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 (copied) (copied from trunk/Source/bmalloc/test/testbmalloc.cpp ) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r245723 r245908 1 2019-05-30 Keith Miller <keith_miller@apple.com> 2 3 IsoHeaps don't notice uncommitted VA becoming the first eligible. 4 https://bugs.webkit.org/show_bug.cgi?id=198301 5 6 Reviewed by Yusuke Suzuki. 7 8 IsoDirectory has a firstEligible member that is used as an 9 optimization to help find the first fit. However if the scavenger 10 decommitted a page before firstEligible then we wouldn't move 11 firstEligible. Thus, if no space is ever freed below firstEligible 12 we will never reused the decommitted memory (e.g. if the VA page 13 is decommitted). The fix is to make IsoDirectory::didDecommit move 14 the firstEligible page back if the decommitted page is smaller 15 than the current firstEligible. As such, this patch renames 16 firstEligible to firstEligibleOrDecommitted. 17 18 Also, this patch changes gigacageEnabledForProcess to check if the 19 process starts with Test rather than just test as TestWTF does. 20 21 Lastly, unbeknownst to me IsoHeaps are dependent on gigacage, so 22 by removing gigacage from arm64 I accidentally disabled 23 IsoHeaps... 24 25 * bmalloc.xcodeproj/project.pbxproj: 26 * bmalloc/IsoDirectory.h: 27 * bmalloc/IsoDirectoryInlines.h: 28 (bmalloc::passedNumPages>::takeFirstEligible): 29 (bmalloc::passedNumPages>::didBecome): 30 (bmalloc::passedNumPages>::didDecommit): 31 * bmalloc/IsoHeapImpl.h: 32 * bmalloc/IsoHeapImplInlines.h: 33 (bmalloc::IsoHeapImpl<Config>::takeFirstEligible): 34 (bmalloc::IsoHeapImpl<Config>::didBecomeEligibleOrDecommited): 35 (bmalloc::IsoHeapImpl<Config>::didCommit): 36 (bmalloc::IsoHeapImpl<Config>::didBecomeEligible): Deleted. 37 * bmalloc/IsoTLS.cpp: 38 (bmalloc::IsoTLS::determineMallocFallbackState): 39 * bmalloc/ProcessCheck.mm: 40 (bmalloc::gigacageEnabledForProcess): 41 1 42 2019-05-23 Don Olmstead <don.olmstead@sony.com> 2 43 -
trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
r244481 r245908 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, ); }; }; … … 138 136 7939885B2076EEB60074A2E7 /* BulkDecommit.h in Headers */ = {isa = PBXBuildFile; fileRef = 7939885A2076EEB50074A2E7 /* BulkDecommit.h */; settings = {ATTRIBUTES = (Private, ); }; }; 139 137 795AB3C7206E0D340074FE76 /* PhysicalPageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 795AB3C6206E0D250074FE76 /* PhysicalPageMap.h */; settings = {ATTRIBUTES = (Private, ); }; }; 140 7C571EFF22388B080077A3C7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 142FC6212096409E00A99362 /* Foundation.framework */; };141 138 7C571F0122388B840077A3C7 /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C571F0022388B840077A3C7 /* StdLibExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; 142 139 AD0934331FCF406D00E85EB5 /* BCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = AD0934321FCF405000E85EB5 /* BCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 155 152 156 153 /* Begin PBXContainerItemProxy section */ 157 0F7EB7F71F95412900F1ABCB /* PBXContainerItemProxy */ = {158 isa = PBXContainerItemProxy;159 containerPortal = 145F6837179DC45F00D65598 /* Project object */;160 proxyType = 1;161 remoteGlobalIDString = 14F271BD18EA3963008C152F;162 remoteInfo = bmalloc;163 };164 154 0F7EB8551F95505400F1ABCB /* PBXContainerItemProxy */ = { 165 155 isa = PBXContainerItemProxy; … … 177 167 }; 178 168 /* End PBXContainerItemProxy section */ 179 180 /* Begin PBXCopyFilesBuildPhase section */181 0F7EB7ED1F95285300F1ABCB /* CopyFiles */ = {182 isa = PBXCopyFilesBuildPhase;183 buildActionMask = 2147483647;184 dstPath = /usr/share/man/man1/;185 dstSubfolderSpec = 0;186 files = (187 );188 runOnlyForDeploymentPostprocessing = 1;189 };190 /* End PBXCopyFilesBuildPhase section */191 169 192 170 /* Begin PBXFileReference section */ … … 203 181 0F74B93C1F89713E00B935D3 /* CryptoRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoRandom.h; path = bmalloc/CryptoRandom.h; sourceTree = "<group>"; }; 204 182 0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoRandom.cpp; path = bmalloc/CryptoRandom.cpp; sourceTree = "<group>"; }; 205 0F7EB7EF1F95285300F1ABCB /* testbmalloc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testbmalloc; sourceTree = BUILT_PRODUCTS_DIR; };206 0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = testbmalloc.cpp; sourceTree = "<group>"; };207 183 0F7EB7FC1F9541AD00F1ABCB /* EligibilityResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EligibilityResult.h; path = bmalloc/EligibilityResult.h; sourceTree = SOURCE_ROOT; }; 208 184 0F7EB7FD1F9541AD00F1ABCB /* IsoHeapImplInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IsoHeapImplInlines.h; path = bmalloc/IsoHeapImplInlines.h; sourceTree = SOURCE_ROOT; }; … … 329 305 330 306 /* Begin PBXFrameworksBuildPhase section */ 331 0F7EB7EC1F95285300F1ABCB /* Frameworks */ = {332 isa = PBXFrameworksBuildPhase;333 buildActionMask = 2147483647;334 files = (335 7C571EFF22388B080077A3C7 /* Foundation.framework in Frameworks */,336 0F7EB7FA1F95414C00F1ABCB /* libbmalloc.a in Frameworks */,337 );338 runOnlyForDeploymentPostprocessing = 0;339 };340 307 14CC394118EA8743004AFE34 /* Frameworks */ = { 341 308 isa = PBXFrameworksBuildPhase; … … 357 324 358 325 /* Begin PBXGroup section */ 359 0F7EB7F01F95285300F1ABCB /* test */ = {360 isa = PBXGroup;361 children = (362 0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */,363 );364 path = test;365 sourceTree = "<group>";366 };367 326 0F7EB7F91F95414C00F1ABCB /* Frameworks */ = { 368 327 isa = PBXGroup; … … 452 411 145F6840179DC45F00D65598 /* Products */, 453 412 14D9DB4F17F2868900EAAB79 /* stdlib */, 454 0F7EB7F01F95285300F1ABCB /* test */,455 413 ); 456 414 sourceTree = "<group>"; … … 459 417 isa = PBXGroup; 460 418 children = ( 461 0F7EB7EF1F95285300F1ABCB /* testbmalloc */,462 419 14F271BE18EA3963008C152F /* libbmalloc.a */, 463 420 14CC394418EA8743004AFE34 /* libmbmalloc.dylib */, … … 708 665 709 666 /* Begin PBXNativeTarget section */ 710 0F7EB7EE1F95285300F1ABCB /* testbmalloc */ = {711 isa = PBXNativeTarget;712 buildConfigurationList = 0F7EB7F61F95285300F1ABCB /* Build configuration list for PBXNativeTarget "testbmalloc" */;713 buildPhases = (714 0F7EB7EB1F95285300F1ABCB /* Sources */,715 0F7EB7EC1F95285300F1ABCB /* Frameworks */,716 0F7EB7ED1F95285300F1ABCB /* CopyFiles */,717 );718 buildRules = (719 );720 dependencies = (721 0F7EB7F81F95412900F1ABCB /* PBXTargetDependency */,722 );723 name = testbmalloc;724 productName = testbmalloc;725 productReference = 0F7EB7EF1F95285300F1ABCB /* testbmalloc */;726 productType = "com.apple.product-type.tool";727 };728 667 14CC394318EA8743004AFE34 /* mbmalloc */ = { 729 668 isa = PBXNativeTarget; … … 770 709 LastUpgradeCheck = 1000; 771 710 TargetAttributes = { 772 0F7EB7EE1F95285300F1ABCB = {773 CreatedOnToolsVersion = 9.0;774 ProvisioningStyle = Manual;775 };776 711 0F7EB8501F95504B00F1ABCB = { 777 712 CreatedOnToolsVersion = 9.0; … … 795 730 14F271BD18EA3963008C152F /* bmalloc */, 796 731 14CC394318EA8743004AFE34 /* mbmalloc */, 797 0F7EB7EE1F95285300F1ABCB /* testbmalloc */,798 732 ); 799 733 }; … … 801 735 802 736 /* Begin PBXSourcesBuildPhase section */ 803 0F7EB7EB1F95285300F1ABCB /* Sources */ = {804 isa = PBXSourcesBuildPhase;805 buildActionMask = 2147483647;806 files = (807 0F7EB7F21F95285300F1ABCB /* testbmalloc.cpp in Sources */,808 );809 runOnlyForDeploymentPostprocessing = 0;810 };811 737 14CC394018EA8743004AFE34 /* Sources */ = { 812 738 isa = PBXSourcesBuildPhase; … … 857 783 858 784 /* Begin PBXTargetDependency section */ 859 0F7EB7F81F95412900F1ABCB /* PBXTargetDependency */ = {860 isa = PBXTargetDependency;861 target = 14F271BD18EA3963008C152F /* bmalloc */;862 targetProxy = 0F7EB7F71F95412900F1ABCB /* PBXContainerItemProxy */;863 };864 785 0F7EB8561F95505400F1ABCB /* PBXTargetDependency */ = { 865 786 isa = PBXTargetDependency; … … 875 796 876 797 /* Begin XCBuildConfiguration section */ 877 0F7EB7F31F95285300F1ABCB /* Debug */ = {878 isa = XCBuildConfiguration;879 baseConfigurationReference = 14B650C718F39F4800751968 /* DebugRelease.xcconfig */;880 buildSettings = {881 PRODUCT_NAME = "$(TARGET_NAME)";882 };883 name = Debug;884 };885 0F7EB7F41F95285300F1ABCB /* Release */ = {886 isa = XCBuildConfiguration;887 baseConfigurationReference = 14B650C718F39F4800751968 /* DebugRelease.xcconfig */;888 buildSettings = {889 PRODUCT_NAME = "$(TARGET_NAME)";890 };891 name = Release;892 };893 0F7EB7F51F95285300F1ABCB /* Production */ = {894 isa = XCBuildConfiguration;895 baseConfigurationReference = 14B650C518F39F4800751968 /* Base.xcconfig */;896 buildSettings = {897 PRODUCT_NAME = "$(TARGET_NAME)";898 };899 name = Production;900 };901 798 0F7EB8521F95504B00F1ABCB /* Debug */ = { 902 799 isa = XCBuildConfiguration; … … 993 890 994 891 /* Begin XCConfigurationList section */ 995 0F7EB7F61F95285300F1ABCB /* Build configuration list for PBXNativeTarget "testbmalloc" */ = {996 isa = XCConfigurationList;997 buildConfigurations = (998 0F7EB7F31F95285300F1ABCB /* Debug */,999 0F7EB7F41F95285300F1ABCB /* Release */,1000 0F7EB7F51F95285300F1ABCB /* Production */,1001 );1002 defaultConfigurationIsVisible = 0;1003 defaultConfigurationName = Production;1004 };1005 892 0F7EB8511F95504B00F1ABCB /* Build configuration list for PBXAggregateTarget "All" */ = { 1006 893 isa = XCConfigurationList; -
trunk/Source/bmalloc/bmalloc/IsoDirectory.h
r243144 r245908 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 … … 89 89 Bits<numPages> m_committed; 90 90 std::array<IsoPage<Config>*, numPages> m_pages; 91 unsigned m_firstEligible { 0 };91 unsigned m_firstEligibleOrDecommitted { 0 }; 92 92 }; 93 93 -
trunk/Source/bmalloc/bmalloc/IsoDirectoryInlines.h
r243144 r245908 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; … … 98 99 fprintf(stderr, "%p: %p did become eligible.\n", this, page); 99 100 m_eligible[pageIndex] = true; 100 m_firstEligible = std::min(m_firstEligible, pageIndex);101 this->m_heap.didBecomeEligible (this);101 m_firstEligibleOrDecommitted = std::min(m_firstEligibleOrDecommitted, pageIndex); 102 this->m_heap.didBecomeEligibleOrDecommited(this); 102 103 return; 103 104 case IsoPageTrigger::Empty: … … 123 124 this->m_heap.isNoLongerFreeable(m_pages[index], IsoPageBase::pageSize); 124 125 m_committed[index] = false; 126 m_firstEligibleOrDecommitted = std::min(m_firstEligibleOrDecommitted, index); 127 this->m_heap.didBecomeEligibleOrDecommited(this); 125 128 this->m_heap.didDecommit(m_pages[index], IsoPageBase::pageSize); 126 129 } -
trunk/Source/bmalloc/bmalloc/IsoHeapImpl.h
r244666 r245908 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 … … 81 81 82 82 // Callbacks from directory. 83 void didBecomeEligible (IsoDirectory<Config, numPagesInInlineDirectory>*);84 void didBecomeEligible (IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>*);83 void didBecomeEligibleOrDecommited(IsoDirectory<Config, numPagesInInlineDirectory>*); 84 void didBecomeEligibleOrDecommited(IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>*); 85 85 86 86 void scavenge(Vector<DeferredDecommit>&) override; … … 135 135 unsigned m_directoryHighWatermark { 0 }; 136 136 137 bool m_isInlineDirectoryEligible { true };138 IsoDirectoryPage<Config>* m_firstEligible Directory { nullptr };137 bool m_isInlineDirectoryEligibleOrDecommitted { true }; 138 IsoDirectoryPage<Config>* m_firstEligibleOrDecommitedDirectory { nullptr }; 139 139 140 140 IsoTLSAllocatorEntry<Config> m_allocator; -
trunk/Source/bmalloc/bmalloc/IsoHeapImplInlines.h
r244666 r245908 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 … … 45 45 EligibilityResult<Config> IsoHeapImpl<Config>::takeFirstEligible() 46 46 { 47 if (m_isInlineDirectoryEligible ) {47 if (m_isInlineDirectoryEligibleOrDecommitted) { 48 48 EligibilityResult<Config> result = m_inlineDirectory.takeFirstEligible(); 49 49 if (result.kind == EligibilityKind::Full) 50 m_isInlineDirectoryEligible = false;50 m_isInlineDirectoryEligibleOrDecommitted = false; 51 51 else 52 52 return result; 53 53 } 54 54 55 if (!m_firstEligible Directory) {55 if (!m_firstEligibleOrDecommitedDirectory) { 56 56 // If nothing is eligible, it can only be because we have no directories. It wouldn't be the end 57 // of the world if we broke this invariant. It would only mean that didBecomeEligible () would need57 // of the world if we broke this invariant. It would only mean that didBecomeEligibleOrDecommited() would need 58 58 // a null check. 59 59 RELEASE_BASSERT(!m_headDirectory); … … 61 61 } 62 62 63 for (; m_firstEligible Directory; m_firstEligibleDirectory = m_firstEligibleDirectory->next) {64 EligibilityResult<Config> result = m_firstEligible Directory->payload.takeFirstEligible();63 for (; m_firstEligibleOrDecommitedDirectory; m_firstEligibleOrDecommitedDirectory = m_firstEligibleOrDecommitedDirectory->next) { 64 EligibilityResult<Config> result = m_firstEligibleOrDecommitedDirectory->payload.takeFirstEligible(); 65 65 if (result.kind != EligibilityKind::Full) { 66 m_directoryHighWatermark = std::max(m_directoryHighWatermark, m_firstEligible Directory->index());66 m_directoryHighWatermark = std::max(m_directoryHighWatermark, m_firstEligibleOrDecommitedDirectory->index()); 67 67 return result; 68 68 } … … 79 79 } 80 80 m_directoryHighWatermark = newDirectory->index(); 81 m_firstEligible Directory = newDirectory;81 m_firstEligibleOrDecommitedDirectory = newDirectory; 82 82 EligibilityResult<Config> result = newDirectory->payload.takeFirstEligible(); 83 83 RELEASE_BASSERT(result.kind != EligibilityKind::Full); … … 86 86 87 87 template<typename Config> 88 void IsoHeapImpl<Config>::didBecomeEligible (IsoDirectory<Config, numPagesInInlineDirectory>* directory)88 void IsoHeapImpl<Config>::didBecomeEligibleOrDecommited(IsoDirectory<Config, numPagesInInlineDirectory>* directory) 89 89 { 90 90 RELEASE_BASSERT(directory == &m_inlineDirectory); 91 m_isInlineDirectoryEligible = true;92 } 93 94 template<typename Config> 95 void IsoHeapImpl<Config>::didBecomeEligible (IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>* directory)96 { 97 RELEASE_BASSERT(m_firstEligible Directory);91 m_isInlineDirectoryEligibleOrDecommitted = true; 92 } 93 94 template<typename Config> 95 void IsoHeapImpl<Config>::didBecomeEligibleOrDecommited(IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>* directory) 96 { 97 RELEASE_BASSERT(m_firstEligibleOrDecommitedDirectory); 98 98 auto* directoryPage = IsoDirectoryPage<Config>::pageFor(directory); 99 if (directoryPage->index() < m_firstEligible Directory->index())100 m_firstEligible Directory = directoryPage;99 if (directoryPage->index() < m_firstEligibleOrDecommitedDirectory->index()) 100 m_firstEligibleOrDecommitedDirectory = directoryPage; 101 101 } 102 102 -
trunk/Source/bmalloc/bmalloc/IsoTLS.cpp
r242938 r245908 184 184 return; 185 185 186 #if GIGACAGE_ENABLED 186 #if GIGACAGE_ENABLED || BCPU(ARM64) 187 #if !BCPU(ARM64) 187 188 if (!Gigacage::shouldBeEnabled()) { 188 189 s_mallocFallbackState = MallocFallbackState::FallBackToMalloc; 189 190 return; 190 191 } 192 #endif 191 193 const char* env = getenv("bmalloc_IsoHeap"); 192 194 if (env && (!strcasecmp(env, "false") || !strcasecmp(env, "no") || !strcmp(env, "0"))) -
trunk/Source/bmalloc/bmalloc/ProcessCheck.mm
r236474 r245908 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; -
trunk/Tools/ChangeLog
r245907 r245908 1 2019-05-30 Keith Miller <keith_miller@apple.com> 2 3 IsoHeaps don't notice uncommitted VA becoming the first eligible. 4 https://bugs.webkit.org/show_bug.cgi?id=198301 5 6 Reviewed by Yusuke Suzuki. 7 8 Move testbmalloc.cpp to TestWTF so it runs in automation. 9 10 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 11 * TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp: Renamed from Source/bmalloc/test/testbmalloc.cpp. 12 (TEST): 13 1 14 2019-05-30 Wenson Hsieh <wenson_hsieh@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r245904 r245908 269 269 536770361CC81B6100D425B1 /* WebScriptObjectDescription.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */; }; 270 270 53EC25411E96FD87000831B9 /* PriorityQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */; }; 271 53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */; }; 271 272 55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55226A2E1EB969B600C36AD0 /* large-red-square-image.html */; }; 272 273 5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */; }; … … 1702 1703 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebScriptObjectDescription.html; sourceTree = "<group>"; }; 1703 1704 53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PriorityQueue.cpp; sourceTree = "<group>"; }; 1705 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IsoHeap.cpp; sourceTree = "<group>"; }; 1704 1706 55226A2E1EB969B600C36AD0 /* large-red-square-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-red-square-image.html"; sourceTree = "<group>"; }; 1705 1707 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronizedFixedQueue.cpp; sourceTree = "<group>"; }; … … 2855 2857 sourceTree = "<group>"; 2856 2858 }; 2859 53FCDE69229EFF6800598ECF /* bmalloc */ = { 2860 isa = PBXGroup; 2861 children = ( 2862 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */, 2863 ); 2864 path = bmalloc; 2865 sourceTree = "<group>"; 2866 }; 2857 2867 7560917619259C59009EF06E /* ios */ = { 2858 2868 isa = PBXGroup; … … 3332 3342 isa = PBXGroup; 3333 3343 children = ( 3344 53FCDE69229EFF6800598ECF /* bmalloc */, 3334 3345 C0991C4F143C7D68007998F2 /* cf */, 3335 3346 E3C21A7821B25C82003B31A3 /* cocoa */, … … 3973 3984 7C83DED41D0A590C00FEBCF3 /* HashSet.cpp in Sources */, 3974 3985 7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */, 3986 53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */, 3975 3987 7CEB62AB223609DE0069CBB0 /* IteratorRange.cpp in Sources */, 3976 3988 7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp
r245907 r245908 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; … … 256 251 } 257 252 258 static void testIsoMallocAndFreeFast()253 TEST(bmalloc, IsoMallocAndFreeFast) 259 254 { 260 255 static IsoHeap<char[256]> heap; … … 275 270 { 276 271 } 277 272 278 273 int x; 279 274 float y; … … 282 277 MAKE_BISO_MALLOCED_IMPL(BisoMalloced); 283 278 284 static void testBisoMalloced()279 TEST(bmalloc, BisoMalloced) 285 280 { 286 281 BisoMalloced* ptr = new BisoMalloced(4, 5); … … 298 293 { 299 294 } 300 295 301 296 int x; 302 297 float y; 303 298 }; 304 299 305 static void testBisoMallocedInline()300 TEST(bmalloc, BisoMallocedInline) 306 301 { 307 302 BisoMallocedInline* ptr = new BisoMallocedInline(4, 5); … … 311 306 } 312 307 313 static void run(const char* filter) 314 { 315 auto shouldRun = [&] (const char* testName) -> bool { 316 return !filter || !!strcasestr(testName, filter); 308 309 TEST(bmalloc, ScavengedMemoryShouldBeReused) 310 { 311 static IsoHeap<double> heap; 312 313 auto run = [] (unsigned numPagesToCommit) { 314 auto* ptr1 = heap.allocate(); 315 316 std::vector<void*> ptrs; 317 318 for (unsigned i = 0; ;i++) { 319 void* ptr = heap.allocate(); 320 CHECK(ptr); 321 ptrs.push_back(ptr); 322 if (heap.impl().numCommittedPages() == numPagesToCommit) 323 break; 324 } 325 326 std::set<void*> uniquedPtrs = toptrset(ptrs); 327 328 heap.deallocate(ptr1); 329 for (unsigned i = 0; i < IsoPage<decltype(heap)::Config>::numObjects - 1; i++) { 330 heap.deallocate(ptrs[i]); 331 uniquedPtrs.erase(ptrs[i]); 332 } 333 334 scavenge(); 335 assertHasOnlyObjects(heap, uniquedPtrs); 336 337 // FIXME: This only seems to pass when lldb is attached but the scavenger thread isn't running... 338 // see: https://bugs.webkit.org/show_bug.cgi?id=198384 339 // auto* ptr2 = heap.allocate(); 340 // CHECK(ptr1 == ptr2); 317 341 }; 318 319 RUN(testIsoSimple()); 320 RUN(testIsoSimpleScavengeBeforeDealloc()); 321 RUN(testIsoFlipFlopFragmentedPages()); 322 RUN(testIsoFlipFlopFragmentedPagesScavengeInMiddle()); 323 RUN(testIsoFlipFlopFragmentedPagesScavengeInMiddle288()); 324 RUN(testIsoMallocAndFreeFast()); 325 RUN(testBisoMalloced()); 326 RUN(testBisoMallocedInline()); 327 328 puts("Success!"); 329 } 330 331 int main(int argc, char** argv) 332 { 333 const char* filter = nullptr; 334 switch (argc) { 335 case 1: 336 break; 337 case 2: 338 filter = argv[1]; 339 break; 340 default: 341 usage(); 342 break; 343 } 344 345 run(filter); 346 return 0; 347 } 348 342 343 run(2); 344 } 345 346 #endif
Note:
See TracChangeset
for help on using the changeset viewer.