⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245908 in webkit


Ignore:
Timestamp:
May 30, 2019, 4:07:27 PM (7 years ago)
Author:
keith_miller@apple.com
Message:

IsoHeaps don't notice uncommitted VA becoming the first eligible.
https://bugs.webkit.org/show_bug.cgi?id=198301

Reviewed by Yusuke Suzuki.

Source/bmalloc:

IsoDirectory has a firstEligible member that is used as an
optimization to help find the first fit. However if the scavenger
decommitted a page before firstEligible then we wouldn't move
firstEligible. Thus, if no space is ever freed below firstEligible
we will never reused the decommitted memory (e.g. if the VA page
is decommitted). The fix is to make IsoDirectory::didDecommit move
the firstEligible page back if the decommitted page is smaller
than the current firstEligible. As such, this patch renames
firstEligible to firstEligibleOrDecommitted.

Also, this patch changes gigacageEnabledForProcess to check if the
process starts with Test rather than just test as TestWTF does.

Lastly, unbeknownst to me IsoHeaps are dependent on gigacage, so
by removing gigacage from arm64 I accidentally disabled
IsoHeaps...

  • bmalloc.xcodeproj/project.pbxproj:
  • bmalloc/IsoDirectory.h:
  • bmalloc/IsoDirectoryInlines.h:

(bmalloc::passedNumPages>::takeFirstEligible):
(bmalloc::passedNumPages>::didBecome):
(bmalloc::passedNumPages>::didDecommit):

  • bmalloc/IsoHeapImpl.h:
  • bmalloc/IsoHeapImplInlines.h:

(bmalloc::IsoHeapImpl<Config>::takeFirstEligible):
(bmalloc::IsoHeapImpl<Config>::didBecomeEligibleOrDecommited):
(bmalloc::IsoHeapImpl<Config>::didCommit):
(bmalloc::IsoHeapImpl<Config>::didBecomeEligible): Deleted.

  • bmalloc/IsoTLS.cpp:

(bmalloc::IsoTLS::determineMallocFallbackState):

  • bmalloc/ProcessCheck.mm:

(bmalloc::gigacageEnabledForProcess):

Tools:

Move testbmalloc.cpp to TestWTF so it runs in automation.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp: Renamed from Source/bmalloc/test/testbmalloc.cpp.

(TEST):

Location:
trunk
Files:
1 added
1 deleted
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r245723 r245908  
     12019-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
    1422019-05-23  Don Olmstead  <don.olmstead@sony.com>
    243
  • trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj

    r244481 r245908  
    3434                0F74B93E1F89713E00B935D3 /* CryptoRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F74B93C1F89713E00B935D3 /* CryptoRandom.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3535                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 */; };
    3836                0F7EB8231F9541B000F1ABCB /* EligibilityResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7EB7FC1F9541AD00F1ABCB /* EligibilityResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3937                0F7EB8241F9541B000F1ABCB /* IsoHeapImplInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7EB7FD1F9541AD00F1ABCB /* IsoHeapImplInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    138136                7939885B2076EEB60074A2E7 /* BulkDecommit.h in Headers */ = {isa = PBXBuildFile; fileRef = 7939885A2076EEB50074A2E7 /* BulkDecommit.h */; settings = {ATTRIBUTES = (Private, ); }; };
    139137                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 */; };
    141138                7C571F0122388B840077A3C7 /* StdLibExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C571F0022388B840077A3C7 /* StdLibExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
    142139                AD0934331FCF406D00E85EB5 /* BCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = AD0934321FCF405000E85EB5 /* BCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    155152
    156153/* Begin PBXContainerItemProxy section */
    157                 0F7EB7F71F95412900F1ABCB /* PBXContainerItemProxy */ = {
    158                         isa = PBXContainerItemProxy;
    159                         containerPortal = 145F6837179DC45F00D65598 /* Project object */;
    160                         proxyType = 1;
    161                         remoteGlobalIDString = 14F271BD18EA3963008C152F;
    162                         remoteInfo = bmalloc;
    163                 };
    164154                0F7EB8551F95505400F1ABCB /* PBXContainerItemProxy */ = {
    165155                        isa = PBXContainerItemProxy;
     
    177167                };
    178168/* 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 */
    191169
    192170/* Begin PBXFileReference section */
     
    203181                0F74B93C1F89713E00B935D3 /* CryptoRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoRandom.h; path = bmalloc/CryptoRandom.h; sourceTree = "<group>"; };
    204182                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>"; };
    207183                0F7EB7FC1F9541AD00F1ABCB /* EligibilityResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EligibilityResult.h; path = bmalloc/EligibilityResult.h; sourceTree = SOURCE_ROOT; };
    208184                0F7EB7FD1F9541AD00F1ABCB /* IsoHeapImplInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IsoHeapImplInlines.h; path = bmalloc/IsoHeapImplInlines.h; sourceTree = SOURCE_ROOT; };
     
    329305
    330306/* 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                 };
    340307                14CC394118EA8743004AFE34 /* Frameworks */ = {
    341308                        isa = PBXFrameworksBuildPhase;
     
    357324
    358325/* Begin PBXGroup section */
    359                 0F7EB7F01F95285300F1ABCB /* test */ = {
    360                         isa = PBXGroup;
    361                         children = (
    362                                 0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */,
    363                         );
    364                         path = test;
    365                         sourceTree = "<group>";
    366                 };
    367326                0F7EB7F91F95414C00F1ABCB /* Frameworks */ = {
    368327                        isa = PBXGroup;
     
    452411                                145F6840179DC45F00D65598 /* Products */,
    453412                                14D9DB4F17F2868900EAAB79 /* stdlib */,
    454                                 0F7EB7F01F95285300F1ABCB /* test */,
    455413                        );
    456414                        sourceTree = "<group>";
     
    459417                        isa = PBXGroup;
    460418                        children = (
    461                                 0F7EB7EF1F95285300F1ABCB /* testbmalloc */,
    462419                                14F271BE18EA3963008C152F /* libbmalloc.a */,
    463420                                14CC394418EA8743004AFE34 /* libmbmalloc.dylib */,
     
    708665
    709666/* 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                 };
    728667                14CC394318EA8743004AFE34 /* mbmalloc */ = {
    729668                        isa = PBXNativeTarget;
     
    770709                                LastUpgradeCheck = 1000;
    771710                                TargetAttributes = {
    772                                         0F7EB7EE1F95285300F1ABCB = {
    773                                                 CreatedOnToolsVersion = 9.0;
    774                                                 ProvisioningStyle = Manual;
    775                                         };
    776711                                        0F7EB8501F95504B00F1ABCB = {
    777712                                                CreatedOnToolsVersion = 9.0;
     
    795730                                14F271BD18EA3963008C152F /* bmalloc */,
    796731                                14CC394318EA8743004AFE34 /* mbmalloc */,
    797                                 0F7EB7EE1F95285300F1ABCB /* testbmalloc */,
    798732                        );
    799733                };
     
    801735
    802736/* 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                 };
    811737                14CC394018EA8743004AFE34 /* Sources */ = {
    812738                        isa = PBXSourcesBuildPhase;
     
    857783
    858784/* Begin PBXTargetDependency section */
    859                 0F7EB7F81F95412900F1ABCB /* PBXTargetDependency */ = {
    860                         isa = PBXTargetDependency;
    861                         target = 14F271BD18EA3963008C152F /* bmalloc */;
    862                         targetProxy = 0F7EB7F71F95412900F1ABCB /* PBXContainerItemProxy */;
    863                 };
    864785                0F7EB8561F95505400F1ABCB /* PBXTargetDependency */ = {
    865786                        isa = PBXTargetDependency;
     
    875796
    876797/* 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                 };
    901798                0F7EB8521F95504B00F1ABCB /* Debug */ = {
    902799                        isa = XCBuildConfiguration;
     
    993890
    994891/* 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                 };
    1005892                0F7EB8511F95504B00F1ABCB /* Build configuration list for PBXAggregateTarget "All" */ = {
    1006893                        isa = XCConfigurationList;
  • trunk/Source/bmalloc/bmalloc/IsoDirectory.h

    r243144 r245908  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8989    Bits<numPages> m_committed;
    9090    std::array<IsoPage<Config>*, numPages> m_pages;
    91     unsigned m_firstEligible { 0 };
     91    unsigned m_firstEligibleOrDecommitted { 0 };
    9292};
    9393
  • trunk/Source/bmalloc/bmalloc/IsoDirectoryInlines.h

    r243144 r245908  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4747EligibilityResult<Config> IsoDirectory<Config, passedNumPages>::takeFirstEligible()
    4848{
    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);
    5152    if (pageIndex >= numPages)
    5253        return EligibilityKind::Full;
     
    9899            fprintf(stderr, "%p: %p did become eligible.\n", this, page);
    99100        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);
    102103        return;
    103104    case IsoPageTrigger::Empty:
     
    123124    this->m_heap.isNoLongerFreeable(m_pages[index], IsoPageBase::pageSize);
    124125    m_committed[index] = false;
     126    m_firstEligibleOrDecommitted = std::min(m_firstEligibleOrDecommitted, index);
     127    this->m_heap.didBecomeEligibleOrDecommited(this);
    125128    this->m_heap.didDecommit(m_pages[index], IsoPageBase::pageSize);
    126129}
  • trunk/Source/bmalloc/bmalloc/IsoHeapImpl.h

    r244666 r245908  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8181   
    8282    // 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>*);
    8585   
    8686    void scavenge(Vector<DeferredDecommit>&) override;
     
    135135    unsigned m_directoryHighWatermark { 0 };
    136136   
    137     bool m_isInlineDirectoryEligible { true };
    138     IsoDirectoryPage<Config>* m_firstEligibleDirectory { nullptr };
     137    bool m_isInlineDirectoryEligibleOrDecommitted { true };
     138    IsoDirectoryPage<Config>* m_firstEligibleOrDecommitedDirectory { nullptr };
    139139   
    140140    IsoTLSAllocatorEntry<Config> m_allocator;
  • trunk/Source/bmalloc/bmalloc/IsoHeapImplInlines.h

    r244666 r245908  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545EligibilityResult<Config> IsoHeapImpl<Config>::takeFirstEligible()
    4646{
    47     if (m_isInlineDirectoryEligible) {
     47    if (m_isInlineDirectoryEligibleOrDecommitted) {
    4848        EligibilityResult<Config> result = m_inlineDirectory.takeFirstEligible();
    4949        if (result.kind == EligibilityKind::Full)
    50             m_isInlineDirectoryEligible = false;
     50            m_isInlineDirectoryEligibleOrDecommitted = false;
    5151        else
    5252            return result;
    5353    }
    5454   
    55     if (!m_firstEligibleDirectory) {
     55    if (!m_firstEligibleOrDecommitedDirectory) {
    5656        // 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 need
     57        // of the world if we broke this invariant. It would only mean that didBecomeEligibleOrDecommited() would need
    5858        // a null check.
    5959        RELEASE_BASSERT(!m_headDirectory);
     
    6161    }
    6262   
    63     for (; m_firstEligibleDirectory; m_firstEligibleDirectory = m_firstEligibleDirectory->next) {
    64         EligibilityResult<Config> result = m_firstEligibleDirectory->payload.takeFirstEligible();
     63    for (; m_firstEligibleOrDecommitedDirectory; m_firstEligibleOrDecommitedDirectory = m_firstEligibleOrDecommitedDirectory->next) {
     64        EligibilityResult<Config> result = m_firstEligibleOrDecommitedDirectory->payload.takeFirstEligible();
    6565        if (result.kind != EligibilityKind::Full) {
    66             m_directoryHighWatermark = std::max(m_directoryHighWatermark, m_firstEligibleDirectory->index());
     66            m_directoryHighWatermark = std::max(m_directoryHighWatermark, m_firstEligibleOrDecommitedDirectory->index());
    6767            return result;
    6868        }
     
    7979    }
    8080    m_directoryHighWatermark = newDirectory->index();
    81     m_firstEligibleDirectory = newDirectory;
     81    m_firstEligibleOrDecommitedDirectory = newDirectory;
    8282    EligibilityResult<Config> result = newDirectory->payload.takeFirstEligible();
    8383    RELEASE_BASSERT(result.kind != EligibilityKind::Full);
     
    8686
    8787template<typename Config>
    88 void IsoHeapImpl<Config>::didBecomeEligible(IsoDirectory<Config, numPagesInInlineDirectory>* directory)
     88void IsoHeapImpl<Config>::didBecomeEligibleOrDecommited(IsoDirectory<Config, numPagesInInlineDirectory>* directory)
    8989{
    9090    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_firstEligibleDirectory);
     91    m_isInlineDirectoryEligibleOrDecommitted = true;
     92}
     93
     94template<typename Config>
     95void IsoHeapImpl<Config>::didBecomeEligibleOrDecommited(IsoDirectory<Config, IsoDirectoryPage<Config>::numPages>* directory)
     96{
     97    RELEASE_BASSERT(m_firstEligibleOrDecommitedDirectory);
    9898    auto* directoryPage = IsoDirectoryPage<Config>::pageFor(directory);
    99     if (directoryPage->index() < m_firstEligibleDirectory->index())
    100         m_firstEligibleDirectory = directoryPage;
     99    if (directoryPage->index() < m_firstEligibleOrDecommitedDirectory->index())
     100        m_firstEligibleOrDecommitedDirectory = directoryPage;
    101101}
    102102
  • trunk/Source/bmalloc/bmalloc/IsoTLS.cpp

    r242938 r245908  
    184184                return;
    185185
    186 #if GIGACAGE_ENABLED
     186#if GIGACAGE_ENABLED || BCPU(ARM64)
     187#if !BCPU(ARM64)
    187188            if (!Gigacage::shouldBeEnabled()) {
    188189                s_mallocFallbackState = MallocFallbackState::FallBackToMalloc;
    189190                return;
    190191            }
     192#endif
    191193            const char* env = getenv("bmalloc_IsoHeap");
    192194            if (env && (!strcasecmp(env, "false") || !strcasecmp(env, "no") || !strcmp(env, "0")))
  • trunk/Source/bmalloc/bmalloc/ProcessCheck.mm

    r236474 r245908  
    4747        || [processName isEqualToString:@"DumpRenderTree"]
    4848        || [processName isEqualToString:@"wasm"]
    49         || [processName hasPrefix:@"test"];
     49        || [processName hasPrefix:@"test"]
     50        || [processName hasPrefix:@"Test"];
    5051
    5152    return isOptInBinary;
  • trunk/Tools/ChangeLog

    r245907 r245908  
     12019-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
    1142019-05-30  Wenson Hsieh  <wenson_hsieh@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r245904 r245908  
    269269                536770361CC81B6100D425B1 /* WebScriptObjectDescription.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 536770351CC812F900D425B1 /* WebScriptObjectDescription.html */; };
    270270                53EC25411E96FD87000831B9 /* PriorityQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC253F1E96BC80000831B9 /* PriorityQueue.cpp */; };
     271                53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */; };
    271272                55226A2F1EBA44B900C36AD0 /* large-red-square-image.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 55226A2E1EB969B600C36AD0 /* large-red-square-image.html */; };
    272273                5597F8361D9596C80066BC21 /* SynchronizedFixedQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */; };
     
    17021703                536770351CC812F900D425B1 /* WebScriptObjectDescription.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = WebScriptObjectDescription.html; sourceTree = "<group>"; };
    17031704                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>"; };
    17041706                55226A2E1EB969B600C36AD0 /* large-red-square-image.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-red-square-image.html"; sourceTree = "<group>"; };
    17051707                5597F8341D9596C80066BC21 /* SynchronizedFixedQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SynchronizedFixedQueue.cpp; sourceTree = "<group>"; };
     
    28552857                        sourceTree = "<group>";
    28562858                };
     2859                53FCDE69229EFF6800598ECF /* bmalloc */ = {
     2860                        isa = PBXGroup;
     2861                        children = (
     2862                                53FCDE6A229EFFB900598ECF /* IsoHeap.cpp */,
     2863                        );
     2864                        path = bmalloc;
     2865                        sourceTree = "<group>";
     2866                };
    28572867                7560917619259C59009EF06E /* ios */ = {
    28582868                        isa = PBXGroup;
     
    33323342                        isa = PBXGroup;
    33333343                        children = (
     3344                                53FCDE69229EFF6800598ECF /* bmalloc */,
    33343345                                C0991C4F143C7D68007998F2 /* cf */,
    33353346                                E3C21A7821B25C82003B31A3 /* cocoa */,
     
    39733984                                7C83DED41D0A590C00FEBCF3 /* HashSet.cpp in Sources */,
    39743985                                7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */,
     3986                                53FCDE6B229EFFB900598ECF /* IsoHeap.cpp in Sources */,
    39753987                                7CEB62AB223609DE0069CBB0 /* IteratorRange.cpp in Sources */,
    39763988                                7A0509411FB9F06400B33FB8 /* JSONValue.cpp in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WTF/bmalloc/IsoHeap.cpp

    r245907 r245908  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1111 *    documentation and/or other materials provided with the distribution.
    1212 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
    17  * 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, OR
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * 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.
    2424 */
     25
     26#include "config.h"
     27
     28#if !USE(SYSTEM_MALLOC)
    2529
    2630#include <bmalloc/bmalloc.h>
    2731#include <bmalloc/Environment.h>
    2832#include <bmalloc/IsoHeapInlines.h>
     33
    2934#include <cmath>
    3035#include <cstdlib>
     
    3540using namespace bmalloc::api;
    3641
    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 
    4742#define RUN(test) do {                          \
    48         if (!shouldRun(#test))                  \
    49             break;                              \
    50         puts(#test "...");                      \
    51         test;                                   \
    52         puts(#test ": OK!");                    \
    53     } while (false)
     43if (!shouldRun(#test))                  \
     44break;                              \
     45puts(#test "...");                      \
     46test;                                   \
     47puts(#test ": OK!");                    \
     48} while (false)
    5449
    5550// Nothing fancy for now; we just use the existing WTF assertion machinery.
    5651#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)
     52if (!!(x))                                                      \
     53break;                                                      \
     54fprintf(stderr, "%s:%d: in %s: assertion %s failed.\n",         \
     55__FILE__, __LINE__, __PRETTY_FUNCTION__, #x);               \
     56abort();                                                        \
     57} while (false)
    6358
    6459static std::set<void*> toptrset(const std::vector<void*>& ptrs)
     
    139134}
    140135
    141 static void testIsoSimple()
     136TEST(bmalloc, IsoSimple)
    142137{
    143138    static IsoHeap<double> heap;
     
    154149}
    155150
    156 static void testIsoSimpleScavengeBeforeDealloc()
     151TEST(bmalloc, IsoSimpleScavengeBeforeDealloc)
    157152{
    158153    static IsoHeap<double> heap;
     
    170165}
    171166
    172 static void testIsoFlipFlopFragmentedPages()
     167TEST(bmalloc, IsoFlipFlopFragmentedPages)
    173168{
    174169    static IsoHeap<double> heap;
     
    190185}
    191186
    192 static void testIsoFlipFlopFragmentedPagesScavengeInMiddle()
     187TEST(bmalloc, IsoFlipFlopFragmentedPagesScavengeInMiddle)
    193188{
    194189    static IsoHeap<double> heap;
     
    223218}
    224219
    225 static void testIsoFlipFlopFragmentedPagesScavengeInMiddle288()
     220TEST(bmalloc, IsoFlipFlopFragmentedPagesScavengeInMiddle288)
    226221{
    227222    static IsoHeap<char[288]> heap;
     
    256251}
    257252
    258 static void testIsoMallocAndFreeFast()
     253TEST(bmalloc, IsoMallocAndFreeFast)
    259254{
    260255    static IsoHeap<char[256]> heap;
     
    275270    {
    276271    }
    277    
     272
    278273    int x;
    279274    float y;
     
    282277MAKE_BISO_MALLOCED_IMPL(BisoMalloced);
    283278
    284 static void testBisoMalloced()
     279TEST(bmalloc, BisoMalloced)
    285280{
    286281    BisoMalloced* ptr = new BisoMalloced(4, 5);
     
    298293    {
    299294    }
    300    
     295
    301296    int x;
    302297    float y;
    303298};
    304299
    305 static void testBisoMallocedInline()
     300TEST(bmalloc, BisoMallocedInline)
    306301{
    307302    BisoMallocedInline* ptr = new BisoMallocedInline(4, 5);
     
    311306}
    312307
    313 static void run(const char* filter)
    314 {
    315     auto shouldRun = [&] (const char* testName) -> bool {
    316         return !filter || !!strcasestr(testName, filter);
     308
     309TEST(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);
    317341    };
    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.