Changeset 272797 in webkit


Ignore:
Timestamp:
Feb 12, 2021, 11:25:13 AM (4 years ago)
Author:
mark.lam@apple.com
Message:

Move RootMarkReason out of SlotVisitor.
https://bugs.webkit.org/show_bug.cgi?id=221831

Reviewed by Tadeu Zagallo.

Source/JavaScriptCore:

This will lessen the amount of diff needed for the GC verifier later.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • heap/Heap.cpp:

(JSC::Heap::addCoreConstraints):

  • heap/HeapAnalyzer.h:
  • heap/HeapSnapshotBuilder.cpp:

(JSC::HeapSnapshotBuilder::analyzeEdge):
(JSC::rootTypeToString):

  • heap/HeapSnapshotBuilder.h:
  • heap/RootMarkReason.h: Added.
  • heap/SlotVisitor.h:

(JSC::SetRootMarkReasonScope::SetRootMarkReasonScope):

  • inspector/JSInjectedScriptHost.cpp:

Source/WebCore:

  • bindings/js/DOMGCOutputConstraint.cpp:

(WebCore::DOMGCOutputConstraint::executeImpl):

Location:
trunk/Source
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r272638 r272797  
    683683    heap/PreciseAllocation.h
    684684    heap/RegisterState.h
     685    heap/RootMarkReason.h
    685686    heap/RunningScope.h
    686687    heap/SimpleMarkingConstraint.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r272768 r272797  
     12021-02-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Move RootMarkReason out of SlotVisitor.
     4        https://bugs.webkit.org/show_bug.cgi?id=221831
     5
     6        Reviewed by Tadeu Zagallo.
     7
     8        This will lessen the amount of diff needed for the GC verifier later.
     9
     10        * CMakeLists.txt:
     11        * JavaScriptCore.xcodeproj/project.pbxproj:
     12        * heap/Heap.cpp:
     13        (JSC::Heap::addCoreConstraints):
     14        * heap/HeapAnalyzer.h:
     15        * heap/HeapSnapshotBuilder.cpp:
     16        (JSC::HeapSnapshotBuilder::analyzeEdge):
     17        (JSC::rootTypeToString):
     18        * heap/HeapSnapshotBuilder.h:
     19        * heap/RootMarkReason.h: Added.
     20        * heap/SlotVisitor.h:
     21        (JSC::SetRootMarkReasonScope::SetRootMarkReasonScope):
     22        * inspector/JSInjectedScriptHost.cpp:
     23
    1242021-02-11  Nikita Vasilyev  <nvasilyev@apple.com>
    225
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r272638 r272797  
    19521952                FE3A06BE1C11041200390FDD /* JITLeftShiftGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B71C1103D900390FDD /* JITLeftShiftGenerator.h */; };
    19531953                FE3A06C01C11041A00390FDD /* JITRightShiftGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3A06B91C1103D900390FDD /* JITRightShiftGenerator.h */; };
     1954                FE3B642F25D6FB4D001ADDB4 /* RootMarkReason.h in Headers */ = {isa = PBXBuildFile; fileRef = FE3B642E25D6FB4C001ADDB4 /* RootMarkReason.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19541955                FE476FF4207E85D50093CA2D /* JITCodeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = FE476FF3207E85D40093CA2D /* JITCodeMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19551956                FE48BD4423245E9300F136D0 /* JSCConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = FE48BD4223245E8700F136D0 /* JSCConfig.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    52915292                FE3A06B81C1103D900390FDD /* JITRightShiftGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITRightShiftGenerator.cpp; sourceTree = "<group>"; };
    52925293                FE3A06B91C1103D900390FDD /* JITRightShiftGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITRightShiftGenerator.h; sourceTree = "<group>"; };
     5294                FE3B642E25D6FB4C001ADDB4 /* RootMarkReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootMarkReason.h; sourceTree = "<group>"; };
    52935295                FE42388F1BE18C1200514737 /* JITSubGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITSubGenerator.cpp; sourceTree = "<group>"; };
    52945296                FE476FF3207E85D40093CA2D /* JITCodeMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITCodeMap.h; sourceTree = "<group>"; };
     
    64276429                                0FD0E5EF1E46BF230006AB08 /* RegisterState.h */,
    64286430                                0F7CF94E1DBEEE860098CC12 /* ReleaseHeapAccessScope.h */,
     6431                                FE3B642E25D6FB4C001ADDB4 /* RootMarkReason.h */,
    64296432                                0F2C63A91E4FA42C00C13839 /* RunningScope.h */,
    64306433                                0F4D8C761FCA3CF2001D32AC /* SimpleMarkingConstraint.cpp */,
     
    1054710550                                0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */,
    1054810551                                0F426A481460CBB300131F8F /* ValueRecovery.h in Headers */,
     10552                                FE3B642F25D6FB4D001ADDB4 /* RootMarkReason.h in Headers */,
    1054910553                                79EE0C001B4AFB85000385C9 /* VariableEnvironment.h in Headers */,
    1055010554                                0F6C73511AC9F99F00BE1682 /* VariableWriteFireDetail.h in Headers */,
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r264743 r272797  
    11/*
    2  *  Copyright (C) 2003-2020 Apple Inc. All rights reserved.
     2 *  Copyright (C) 2003-2021 Apple Inc. All rights reserved.
    33 *  Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    44 *
     
    27192719                gatherScratchBufferRoots(conservativeRoots);
    27202720
    2721                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::ConservativeScan);
     2721                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::ConservativeScan);
    27222722                slotVisitor.append(conservativeRoots);
    27232723            }
    27242724            if (Options::useJIT()) {
    27252725                // JITStubRoutines must be visited after scanning ConservativeRoots since JITStubRoutines depend on the hook executed during gathering ConservativeRoots.
    2726                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::JITStubRoutines);
     2726                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::JITStubRoutines);
    27272727                m_jitStubRoutines->traceMarkedStubRoutines(slotVisitor);
    27282728            }
     
    27402740#endif
    27412741            if (m_vm.smallStrings.needsToBeVisited(*m_collectionScope)) {
    2742                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::StrongReferences);
     2742                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::StrongReferences);
    27432743                m_vm.smallStrings.visitStrongReferences(slotVisitor);
    27442744            }
    27452745           
    27462746            {
    2747                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::ProtectedValues);
     2747                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::ProtectedValues);
    27482748                for (auto& pair : m_protectedValues)
    27492749                    slotVisitor.appendUnbarriered(pair.key);
     
    27512751           
    27522752            if (m_markListSet && m_markListSet->size()) {
    2753                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::ConservativeScan);
     2753                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::ConservativeScan);
    27542754                MarkedArgumentBuffer::markLists(slotVisitor, *m_markListSet);
    27552755            }
     
    27602760
    27612761            {
    2762                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::VMExceptions);
     2762                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::VMExceptions);
    27632763                slotVisitor.appendUnbarriered(m_vm.exception());
    27642764                slotVisitor.appendUnbarriered(m_vm.lastException());
     
    27702770        "Sh", "Strong Handles",
    27712771        [this] (SlotVisitor& slotVisitor) {
    2772             SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::StrongHandles);
     2772            SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::StrongHandles);
    27732773            m_handleSet.visitStrongHandles(slotVisitor);
    27742774        },
     
    27782778        "D", "Debugger",
    27792779        [this] (SlotVisitor& slotVisitor) {
    2780             SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::Debugger);
     2780            SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::Debugger);
    27812781
    27822782#if ENABLE(SAMPLING_PROFILER)
     
    28012801        "Ws", "Weak Sets",
    28022802        [this] (SlotVisitor& slotVisitor) {
    2803             SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::WeakSets);
     2803            SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::WeakSets);
    28042804            m_objectSpace.visitWeakSets(slotVisitor);
    28052805        },
     
    28122812
    28132813            auto callOutputConstraint = [] (SlotVisitor& slotVisitor, HeapCell* heapCell, HeapCell::Kind) {
    2814                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::Output);
     2814                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::Output);
    28152815                VM& vm = slotVisitor.vm();
    28162816                JSCell* cell = static_cast<JSCell*>(heapCell);
     
    28342834            "Dw", "DFG Worklists",
    28352835            [this] (SlotVisitor& slotVisitor) {
    2836                 SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::DFGWorkLists);
     2836                SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::DFGWorkLists);
    28372837
    28382838                for (unsigned i = DFG::numberOfWorklists(); i--;)
     
    28572857        "Cb", "CodeBlocks",
    28582858        [this] (SlotVisitor& slotVisitor) {
    2859             SetRootMarkReasonScope rootScope(slotVisitor, SlotVisitor::RootMarkReason::CodeBlocks);
     2859            SetRootMarkReasonScope rootScope(slotVisitor, RootMarkReason::CodeBlocks);
    28602860            iterateExecutingAndCompilingCodeBlocksWithoutHoldingLocks(
    28612861                [&] (CodeBlock* codeBlock) {
  • trunk/Source/JavaScriptCore/heap/HeapAnalyzer.h

    r248925 r272797  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SlotVisitor.h"
     28#include "RootMarkReason.h"
    2929#include <wtf/text/UniquedStringImpl.h>
    3030#include <wtf/text/WTFString.h>
     
    4040
    4141    // A reference from one cell to another.
    42     virtual void analyzeEdge(JSCell* from, JSCell* to, SlotVisitor::RootMarkReason) = 0;
     42    virtual void analyzeEdge(JSCell* from, JSCell* to, RootMarkReason) = 0;
    4343    virtual void analyzePropertyNameEdge(JSCell* from, JSCell* to, UniquedStringImpl* propertyName) = 0;
    4444    virtual void analyzeVariableNameEdge(JSCell* from, JSCell* to, UniquedStringImpl* variableName) = 0;
  • trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp

    r264736 r272797  
    11/*
    2  * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040namespace JSC {
    4141
    42 static const char* rootTypeToString(SlotVisitor::RootMarkReason);
     42static const char* rootTypeToString(RootMarkReason);
    4343
    4444NodeIdentifier HeapSnapshotBuilder::nextAvailableObjectIdentifier = 1;
     
    100100}
    101101
    102 void HeapSnapshotBuilder::analyzeEdge(JSCell* from, JSCell* to, SlotVisitor::RootMarkReason rootMarkReason)
     102void HeapSnapshotBuilder::analyzeEdge(JSCell* from, JSCell* to, RootMarkReason rootMarkReason)
    103103{
    104104    ASSERT(m_profiler.activeHeapAnalyzer() == this);
     
    112112
    113113    if (m_snapshotType == SnapshotType::GCDebuggingSnapshot && !from) {
    114         if (rootMarkReason == SlotVisitor::RootMarkReason::None && m_snapshotType == SnapshotType::GCDebuggingSnapshot)
     114        if (rootMarkReason == RootMarkReason::None && m_snapshotType == SnapshotType::GCDebuggingSnapshot)
    115115            WTFLogAlways("Cell %p is a root but no root marking reason was supplied", to);
    116116
     
    306306}
    307307
    308 static const char* rootTypeToString(SlotVisitor::RootMarkReason type)
     308static const char* rootTypeToString(RootMarkReason type)
    309309{
    310310    switch (type) {
    311     case SlotVisitor::RootMarkReason::None:
     311    case RootMarkReason::None:
    312312        return "None";
    313     case SlotVisitor::RootMarkReason::ConservativeScan:
     313    case RootMarkReason::ConservativeScan:
    314314        return "Conservative scan";
    315     case SlotVisitor::RootMarkReason::StrongReferences:
     315    case RootMarkReason::StrongReferences:
    316316        return "Strong references";
    317     case SlotVisitor::RootMarkReason::ProtectedValues:
     317    case RootMarkReason::ProtectedValues:
    318318        return "Protected values";
    319     case SlotVisitor::RootMarkReason::MarkListSet:
     319    case RootMarkReason::MarkListSet:
    320320        return "Mark list set";
    321     case SlotVisitor::RootMarkReason::VMExceptions:
     321    case RootMarkReason::VMExceptions:
    322322        return "VM exceptions";
    323     case SlotVisitor::RootMarkReason::StrongHandles:
     323    case RootMarkReason::StrongHandles:
    324324        return "Strong handles";
    325     case SlotVisitor::RootMarkReason::Debugger:
     325    case RootMarkReason::Debugger:
    326326        return "Debugger";
    327     case SlotVisitor::RootMarkReason::JITStubRoutines:
     327    case RootMarkReason::JITStubRoutines:
    328328        return "JIT stub routines";
    329     case SlotVisitor::RootMarkReason::WeakSets:
     329    case RootMarkReason::WeakSets:
    330330        return "Weak sets";
    331     case SlotVisitor::RootMarkReason::Output:
     331    case RootMarkReason::Output:
    332332        return "Output";
    333     case SlotVisitor::RootMarkReason::DFGWorkLists:
     333    case RootMarkReason::DFGWorkLists:
    334334        return "DFG work lists";
    335     case SlotVisitor::RootMarkReason::CodeBlocks:
     335    case RootMarkReason::CodeBlocks:
    336336        return "Code blocks";
    337     case SlotVisitor::RootMarkReason::DOMGCOutput:
     337    case RootMarkReason::DOMGCOutput:
    338338        return "DOM GC output";
    339339    }
  • trunk/Source/JavaScriptCore/heap/HeapSnapshotBuilder.h

    r261567 r272797  
    11/*
    2  * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    120120
    121121    // A reference from one cell to another.
    122     void analyzeEdge(JSCell* from, JSCell* to, SlotVisitor::RootMarkReason) final;
     122    void analyzeEdge(JSCell* from, JSCell* to, RootMarkReason) final;
    123123    void analyzePropertyNameEdge(JSCell* from, JSCell* to, UniquedStringImpl* propertyName) final;
    124124    void analyzeVariableNameEdge(JSCell* from, JSCell* to, UniquedStringImpl* variableName) final;
     
    144144    struct RootData {
    145145        const char* reachabilityFromOpaqueRootReasons { nullptr };
    146         SlotVisitor::RootMarkReason markReason { SlotVisitor::RootMarkReason::None };
     146        RootMarkReason markReason { RootMarkReason::None };
    147147    };
    148148   
  • trunk/Source/JavaScriptCore/heap/SlotVisitor.h

    r268993 r272797  
    11/*
    2  * Copyright (C) 2011-2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#include "IterationStatus.h"
    3030#include "MarkStack.h"
     31#include "RootMarkReason.h"
    3132#include "VisitRaceKey.h"
    3233#include <wtf/Forward.h>
     
    5859
    5960public:
    60     enum RootMarkReason {
    61         None,
    62         ConservativeScan,
    63         StrongReferences,
    64         ProtectedValues,
    65         MarkListSet,
    66         VMExceptions,
    67         StrongHandles,
    68         Debugger,
    69         JITStubRoutines,
    70         WeakSets,
    71         Output,
    72         DFGWorkLists,
    73         CodeBlocks,
    74         DOMGCOutput,
    75     };
    76 
    7761    SlotVisitor(Heap&, CString codeName);
    7862    ~SlotVisitor();
     
    290274class SetRootMarkReasonScope {
    291275public:
    292     SetRootMarkReasonScope(SlotVisitor& visitor, SlotVisitor::RootMarkReason reason)
     276    SetRootMarkReasonScope(SlotVisitor& visitor, RootMarkReason reason)
    293277        : m_visitor(visitor)
    294278        , m_previousReason(visitor.rootMarkReason())
     
    304288private:
    305289    SlotVisitor& m_visitor;
    306     SlotVisitor::RootMarkReason m_previousReason;
     290    RootMarkReason m_previousReason;
    307291};
    308292
  • trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp

    r272638 r272797  
    11/*
    2  * Copyright (C) 2013-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    754754    HashSet<JSCell*>& holders() { return m_holders; }
    755755
    756     void analyzeEdge(JSCell* from, JSCell* to, SlotVisitor::RootMarkReason reason) final
     756    void analyzeEdge(JSCell* from, JSCell* to, RootMarkReason reason) final
    757757    {
    758758        ASSERT(to);
     
    774774        }
    775775
    776         if (reason == SlotVisitor::RootMarkReason::Debugger)
     776        if (reason == RootMarkReason::Debugger)
    777777            m_rootsToIgnore.add(to);
    778         else if (!from || reason != SlotVisitor::RootMarkReason::None)
     778        else if (!from || reason != RootMarkReason::None)
    779779            m_rootsToInclude.add(to);
    780780    }
    781     void analyzePropertyNameEdge(JSCell* from, JSCell* to, UniquedStringImpl*) final { analyzeEdge(from, to, SlotVisitor::RootMarkReason::None); }
    782     void analyzeVariableNameEdge(JSCell* from, JSCell* to, UniquedStringImpl*) final { analyzeEdge(from, to, SlotVisitor::RootMarkReason::None); }
    783     void analyzeIndexEdge(JSCell* from, JSCell* to, uint32_t) final { analyzeEdge(from, to, SlotVisitor::RootMarkReason::None); }
     781    void analyzePropertyNameEdge(JSCell* from, JSCell* to, UniquedStringImpl*) final { analyzeEdge(from, to, RootMarkReason::None); }
     782    void analyzeVariableNameEdge(JSCell* from, JSCell* to, UniquedStringImpl*) final { analyzeEdge(from, to, RootMarkReason::None); }
     783    void analyzeIndexEdge(JSCell* from, JSCell* to, uint32_t) final { analyzeEdge(from, to, RootMarkReason::None); }
    784784
    785785    void analyzeNode(JSCell*) final { }
  • trunk/Source/WebCore/ChangeLog

    r272794 r272797  
     12021-02-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Move RootMarkReason out of SlotVisitor.
     4        https://bugs.webkit.org/show_bug.cgi?id=221831
     5
     6        Reviewed by Tadeu Zagallo.
     7
     8        * bindings/js/DOMGCOutputConstraint.cpp:
     9        (WebCore::DOMGCOutputConstraint::executeImpl):
     10
    1112021-02-12  Julian Gonzalez  <julian_a_gonzalez@apple.com>
    212
  • trunk/Source/WebCore/bindings/js/DOMGCOutputConstraint.cpp

    r248925 r272797  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6262        [&] (Subspace& subspace) {
    6363            auto func = [] (SlotVisitor& visitor, HeapCell* heapCell, HeapCell::Kind) {
    64                 SetRootMarkReasonScope rootScope(visitor, SlotVisitor::RootMarkReason::DOMGCOutput);
     64                SetRootMarkReasonScope rootScope(visitor, RootMarkReason::DOMGCOutput);
    6565                JSCell* cell = static_cast<JSCell*>(heapCell);
    6666                cell->methodTable(visitor.vm())->visitOutputConstraints(cell, visitor);
Note: See TracChangeset for help on using the changeset viewer.