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

Changeset 284664 in webkit


Ignore:
Timestamp:
Oct 21, 2021, 9:31:45 PM (5 years ago)
Author:
sbarati@apple.com
Message:

Clean up some code around checking the state of Watchpoints
https://bugs.webkit.org/show_bug.cgi?id=232111

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

No need to have state() and stateOnJSThread(), since they're now the same.
Also, there is no need to check the allocation watchpoint twice for the
function/internal function allocation profiles.

  • bytecode/Watchpoint.h:

(JSC::WatchpointSet::isStillValid const):
(JSC::WatchpointSet::stateOnJSThread const): Deleted.
(JSC::WatchpointSet::isStillValidOnJSThread const): Deleted.
(JSC::InlineWatchpointSet::stateOnJSThread const): Deleted.

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::handleCreateInternalFieldObject):

  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::foldConstants):

  • runtime/ArrayPrototype.cpp:

(JSC::speciesWatchpointIsValid):
(JSC::canUseDefaultArrayJoinForToString):

  • runtime/InferredValue.h:

(JSC::InferredValue::notifyWrite):
(JSC::InferredValue::stateOnJSThread const): Deleted.

  • runtime/JSArrayBufferPrototypeInlines.h:

(JSC::speciesWatchpointIsValid):

  • runtime/ObjectPropertyChangeAdaptiveWatchpoint.h:

Source/WebCore:

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::getOwnPropertySlot):

Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r284663 r284664  
     12021-10-21  Saam Barati  <sbarati@apple.com>
     2
     3        Clean up some code around checking the state of Watchpoints
     4        https://bugs.webkit.org/show_bug.cgi?id=232111
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        No need to have state() and stateOnJSThread(), since they're now the same.
     9        Also, there is no need to check the allocation watchpoint twice for the
     10        function/internal function allocation profiles.
     11
     12        * bytecode/Watchpoint.h:
     13        (JSC::WatchpointSet::isStillValid const):
     14        (JSC::WatchpointSet::stateOnJSThread const): Deleted.
     15        (JSC::WatchpointSet::isStillValidOnJSThread const): Deleted.
     16        (JSC::InlineWatchpointSet::stateOnJSThread const): Deleted.
     17        * dfg/DFGAbstractInterpreterInlines.h:
     18        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     19        * dfg/DFGByteCodeParser.cpp:
     20        (JSC::DFG::ByteCodeParser::parseBlock):
     21        (JSC::DFG::ByteCodeParser::handleCreateInternalFieldObject):
     22        * dfg/DFGConstantFoldingPhase.cpp:
     23        (JSC::DFG::ConstantFoldingPhase::foldConstants):
     24        * runtime/ArrayPrototype.cpp:
     25        (JSC::speciesWatchpointIsValid):
     26        (JSC::canUseDefaultArrayJoinForToString):
     27        * runtime/InferredValue.h:
     28        (JSC::InferredValue::notifyWrite):
     29        (JSC::InferredValue::stateOnJSThread const): Deleted.
     30        * runtime/JSArrayBufferPrototypeInlines.h:
     31        (JSC::speciesWatchpointIsValid):
     32        * runtime/ObjectPropertyChangeAdaptiveWatchpoint.h:
     33
    1342021-10-21  Mark Lam  <mark.lam@apple.com>
    235
  • trunk/Source/JavaScriptCore/bytecode/Watchpoint.h

    r282014 r284664  
    191191    }
    192192   
    193     // Fast way of getting the state, which only works from the main thread.
    194     WatchpointState stateOnJSThread() const
    195     {
    196         return static_cast<WatchpointState>(m_state);
    197     }
    198    
    199     // It is safe to call this from another thread. It may return an old
    200     // state. Guarantees that if *first* read the state() of the thing being
    201     // watched and it returned IsWatched and *second* you actually read its
    202     // value then it's safe to assume that if the state being watched changes
    203     // then also the watchpoint state() will change to IsInvalidated.
     193    // It is always safe to call this from the main thread.
     194    // It is also safe to call this from another thread. It may return an old
     195    // state. Generally speaking, a safe pattern to use in a concurrent compiler
     196    // thread is:
     197    // if (watchpoint.isValid()) {
     198    //     watch(watchpoint);
     199    //     do optimizations;
     200    // }
    204201    WatchpointState state() const
    205202    {
     
    217214    {
    218215        return state() != IsInvalidated;
    219     }
    220     // Fast way of testing isStillValid(), which only works from the main thread.
    221     bool isStillValidOnJSThread() const
    222     {
    223         return stateOnJSThread() != IsInvalidated;
    224216    }
    225217    // Like isStillValid(), may be called from another thread.
     
    341333    }
    342334   
    343     // Fast way of getting the state, which only works from the main thread.
    344     WatchpointState stateOnJSThread() const
    345     {
    346         uintptr_t data = m_data;
    347         if (isFat(data))
    348             return fat(data)->stateOnJSThread();
    349         return decodeState(data);
    350     }
    351 
    352     // It is safe to call this from another thread. It may return a prior state,
    353     // but that should be fine since you should only perform actions based on the
    354     // state if you also add a watchpoint.
     335    // See comment about state() in Watchpoint above.
    355336    WatchpointState state() const
    356337    {
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r284590 r284664  
    30433043                        if (structure
    30443044                            && structure->classInfo() == (node->isInternalPromise() ? JSInternalPromise::info() : JSPromise::info())
    3045                             && structure->globalObject() == globalObject
    3046                             && rareData->allocationProfileWatchpointSet().isStillValid()) {
     3045                            && structure->globalObject() == globalObject) {
    30473046                            m_graph.freeze(rareData);
    30483047                            m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
     
    30723071                            if (structure
    30733072                                && structure->classInfo() == classInfo
    3074                                 && structure->globalObject() == globalObject
    3075                                 && rareData->allocationProfileWatchpointSet().isStillValid()) {
     3073                                && structure->globalObject() == globalObject) {
    30763074                                m_graph.freeze(rareData);
    30773075                                m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r284590 r284664  
    55475547                        JSObject* prototype = rareData->objectAllocationPrototype();
    55485548                        if (structure
    5549                             && (structure->hasMonoProto() || prototype)
    5550                             && rareData->allocationProfileWatchpointSet().isStillValid()) {
     5549                            && (structure->hasMonoProto() || prototype)) {
    55515550
    55525551                            m_graph.freeze(rareData);
     
    56295628                            if (structure
    56305629                                && structure->classInfo() == (bytecode.m_isInternalPromise ? JSInternalPromise::info() : JSPromise::info())
    5631                                 && structure->globalObject() == globalObject
    5632                                 && rareData->allocationProfileWatchpointSet().isStillValid()) {
     5630                                && structure->globalObject() == globalObject) {
    56335631                                m_graph.freeze(rareData);
    56345632                                m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
     
    90139011                if (structure
    90149012                    && structure->classInfo() == classInfo
    9015                     && structure->globalObject() == globalObject
    9016                     && rareData->allocationProfileWatchpointSet().isStillValid()) {
     9013                    && structure->globalObject() == globalObject) {
    90179014                    m_graph.freeze(rareData);
    90189015                    m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
  • trunk/Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp

    r284576 r284664  
    737737                                JSObject* prototype = rareData->objectAllocationPrototype();
    738738                                if (structure
    739                                     && (structure->hasMonoProto() || prototype)
    740                                     && rareData->allocationProfileWatchpointSet().isStillValid()) {
    741 
     739                                    && (structure->hasMonoProto() || prototype)) {
    742740                                    m_graph.freeze(rareData);
    743741                                    m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
     
    759757                                    changed = true;
    760758                                    break;
    761 
    762759                                }
    763760                            }
     
    782779                                if (structure
    783780                                    && structure->classInfo() == (node->isInternalPromise() ? JSInternalPromise::info() : JSPromise::info())
    784                                     && structure->globalObject() == globalObject
    785                                     && rareData->allocationProfileWatchpointSet().isStillValid()) {
     781                                    && structure->globalObject() == globalObject) {
    786782                                    m_graph.freeze(rareData);
    787783                                    m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
     
    808804                                    if (structure
    809805                                        && structure->classInfo() == classInfo
    810                                         && structure->globalObject() == globalObject
    811                                         && rareData->allocationProfileWatchpointSet().isStillValid()) {
     806                                        && structure->globalObject() == globalObject) {
    812807                                        m_graph.freeze(rareData);
    813808                                        m_graph.watchpoints().addLazily(rareData->allocationProfileWatchpointSet());
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r281369 r284664  
    187187    ArrayPrototype* arrayPrototype = globalObject->arrayPrototype();
    188188
    189     if (globalObject->arraySpeciesWatchpointSet().stateOnJSThread() == ClearWatchpoint) {
     189    if (globalObject->arraySpeciesWatchpointSet().state() == ClearWatchpoint) {
    190190        dataLogLnIf(ArrayPrototypeInternal::verbose, "Initializing Array species watchpoints for Array.prototype: ", pointerDump(arrayPrototype), " with structure: ", pointerDump(arrayPrototype->structure(vm)), "\nand Array: ", pointerDump(globalObject->arrayConstructor()), " with structure: ", pointerDump(globalObject->arrayConstructor()->structure(vm)));
    191191        globalObject->tryInstallArraySpeciesWatchpoint();
    192         ASSERT(globalObject->arraySpeciesWatchpointSet().stateOnJSThread() != ClearWatchpoint);
     192        ASSERT(globalObject->arraySpeciesWatchpointSet().state() != ClearWatchpoint);
    193193    }
    194194
    195195    return !thisObject->hasCustomProperties(vm)
    196196        && arrayPrototype == thisObject->getPrototypeDirect(vm)
    197         && globalObject->arraySpeciesWatchpointSet().stateOnJSThread() == IsWatched;
     197        && globalObject->arraySpeciesWatchpointSet().state() == IsWatched;
    198198}
    199199
     
    584584    JSGlobalObject* globalObject = thisObject->globalObject();
    585585
    586     if (globalObject->arrayJoinWatchpointSet().stateOnJSThread() != IsWatched)
     586    if (globalObject->arrayJoinWatchpointSet().state() != IsWatched)
    587587        return false;
    588588
  • trunk/Source/JavaScriptCore/runtime/InferredValue.h

    r277117 r284664  
    6868    }
    6969
    70     // Fast way of getting the state, which only works from the main thread.
    71     WatchpointState stateOnJSThread() const
    72     {
    73         uintptr_t data = m_data;
    74         if (isFat(data))
    75             return fat(data)->stateOnJSThread();
    76         return decodeState(data);
    77     }
    78 
    7970    // It is safe to call this from another thread. It may return a prior state,
    8071    // but that should be fine since you should only perform actions based on the
     
    121112    void notifyWrite(VM& vm, JSCell* owner, JSCellType* value, const FireDetail& detail)
    122113    {
    123         if (LIKELY(stateOnJSThread() == IsInvalidated))
     114        if (LIKELY(state() == IsInvalidated))
    124115            return;
    125116        notifyWriteSlow(vm, owner, value, detail);
     
    128119    void notifyWrite(VM& vm, JSCell* owner, JSCellType* value, const char* reason)
    129120    {
    130         if (LIKELY(stateOnJSThread() == IsInvalidated))
     121        if (LIKELY(state() == IsInvalidated))
    131122            return;
    132123        notifyWriteSlow(vm, owner, value, reason);
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferPrototypeInlines.h

    r278253 r284664  
    4040    auto* prototype = globalObject->arrayBufferPrototype(mode);
    4141
    42     if (globalObject->arrayBufferSpeciesWatchpointSet(mode).stateOnJSThread() == ClearWatchpoint) {
     42    if (globalObject->arrayBufferSpeciesWatchpointSet(mode).state() == ClearWatchpoint) {
    4343        dataLogLnIf(JSArrayBufferPrototypeInternal::verbose, "Initializing ArrayBuffer species watchpoints for ArrayBuffer.prototype: ", pointerDump(prototype), " with structure: ", pointerDump(prototype->structure(vm)), "\nand ArrayBuffer: ", pointerDump(globalObject->arrayBufferConstructor(mode)), " with structure: ", pointerDump(globalObject->arrayBufferConstructor(mode)->structure(vm)));
    4444        globalObject->tryInstallArrayBufferSpeciesWatchpoint(mode);
    45         ASSERT(globalObject->arrayBufferSpeciesWatchpointSet(mode).stateOnJSThread() != ClearWatchpoint);
     45        ASSERT(globalObject->arrayBufferSpeciesWatchpointSet(mode).state() != ClearWatchpoint);
    4646    }
    4747
    4848    return !thisObject->hasCustomProperties(vm)
    4949        && prototype == thisObject->getPrototypeDirect(vm)
    50         && globalObject->arrayBufferSpeciesWatchpointSet(mode).stateOnJSThread() == IsWatched;
     50        && globalObject->arrayBufferSpeciesWatchpointSet(mode).state() == IsWatched;
    5151}
    5252
  • trunk/Source/JavaScriptCore/runtime/ObjectPropertyChangeAdaptiveWatchpoint.h

    r261569 r284664  
    3939        , m_watchpointSet(watchpointSet)
    4040    {
    41         RELEASE_ASSERT(watchpointSet.stateOnJSThread() == IsWatched);
     41        RELEASE_ASSERT(watchpointSet.state() == IsWatched);
    4242    }
    4343
  • trunk/Source/WebCore/ChangeLog

    r284660 r284664  
     12021-10-21  Saam Barati  <sbarati@apple.com>
     2
     3        Clean up some code around checking the state of Watchpoints
     4        https://bugs.webkit.org/show_bug.cgi?id=232111
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * bindings/js/JSDOMWindowCustom.cpp:
     9        (WebCore::JSDOMWindow::getOwnPropertySlot):
     10
    1112021-10-21  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r280280 r284664  
    205205    // We use m_windowCloseWatchpoints to clear any inline caches once the frame is cleared.
    206206    // This is sound because DOMWindow can be associated with at most one frame in its lifetime.
    207     if (thisObject->m_windowCloseWatchpoints->isStillValidOnJSThread())
     207    if (thisObject->m_windowCloseWatchpoints->isStillValid())
    208208        slot.setWatchpointSet(*thisObject->m_windowCloseWatchpoints);
    209209
Note: See TracChangeset for help on using the changeset viewer.