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

Changeset 284808 in webkit


Ignore:
Timestamp:
Oct 25, 2021, 12:10:00 PM (5 years ago)
Author:
Alan Coon
Message:

Cherry-pick r284576. rdar://problem/84338462

We should watch isHavingABadTime if we read from the structureCache
https://bugs.webkit.org/show_bug.cgi?id=232019

Reviewed by Yusuke Suzuki.

We should lock the structure cache when we clear it, and the compiler thread should
watch isHavingABadTime in the case that the cache might get cleared.

  • dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
  • dfg/DFGConstantFoldingPhase.cpp: (JSC::DFG::ConstantFoldingPhase::foldConstants):
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::haveABadTime):
  • runtime/StructureCache.cpp: (JSC::StructureCache::clear):
  • runtime/StructureCache.h: (JSC::StructureCache::clear): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284576 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612-branch/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-612-branch/Source/JavaScriptCore/ChangeLog

    r284807 r284808  
     12021-10-25  Null  <null@apple.com>
     2
     3        Cherry-pick r284576. rdar://problem/84338462
     4
     5    We should watch isHavingABadTime if we read from the structureCache
     6    https://bugs.webkit.org/show_bug.cgi?id=232019
     7   
     8    Reviewed by Yusuke Suzuki.
     9   
     10    We should lock the structure cache when we clear it, and the compiler thread should
     11    watch isHavingABadTime in the case that the cache might get cleared.
     12   
     13    * dfg/DFGAbstractInterpreterInlines.h:
     14    (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     15    * dfg/DFGConstantFoldingPhase.cpp:
     16    (JSC::DFG::ConstantFoldingPhase::foldConstants):
     17    * runtime/JSGlobalObject.cpp:
     18    (JSC::JSGlobalObject::haveABadTime):
     19    * runtime/StructureCache.cpp:
     20    (JSC::StructureCache::clear):
     21    * runtime/StructureCache.h:
     22    (JSC::StructureCache::clear): Deleted.
     23   
     24   
     25    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284576 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     26
     27    2021-10-20  Justin Michaud  <justin_michaud@apple.com>
     28
     29            We should watch isHavingABadTime if we read from the structureCache
     30            https://bugs.webkit.org/show_bug.cgi?id=232019
     31
     32            Reviewed by Yusuke Suzuki.
     33
     34            We should lock the structure cache when we clear it, and the compiler thread should
     35            watch isHavingABadTime in the case that the cache might get cleared.
     36
     37            * dfg/DFGAbstractInterpreterInlines.h:
     38            (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     39            * dfg/DFGConstantFoldingPhase.cpp:
     40            (JSC::DFG::ConstantFoldingPhase::foldConstants):
     41            * runtime/JSGlobalObject.cpp:
     42            (JSC::JSGlobalObject::haveABadTime):
     43            * runtime/StructureCache.cpp:
     44            (JSC::StructureCache::clear):
     45            * runtime/StructureCache.h:
     46            (JSC::StructureCache::clear): Deleted.
     47
    1482021-10-25  Null  <null@apple.com>
    249
  • branches/safari-612-branch/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r284401 r284808  
    31423142            if (base.isNull())
    31433143                structure = globalObject->nullPrototypeObjectStructure();
    3144             else if (base.isObject())
    3145                 structure = m_vm.structureCache.emptyObjectStructureConcurrently(globalObject, base.getObject(), JSFinalObject::defaultInlineCapacity());
     3144            else if (base.isObject()) {
     3145                // Having a bad time clears the structureCache, and so it should invalidate this structure.
     3146                bool isHavingABadTime = globalObject->isHavingABadTime();
     3147                WTF::loadLoadFence();
     3148                if (!isHavingABadTime)
     3149                    m_graph.watchpoints().addLazily(globalObject->havingABadTimeWatchpoint());
     3150                // Normally, we would always install a watchpoint. In this case, however, if we haveABadTime, we
     3151                // still want to optimize. There is no watchpoint for that case though, so we need to make sure this load
     3152                // does not get hoisted above the check.
     3153                WTF::loadLoadFence();
     3154                structure = m_vm.structureCache
     3155                    .emptyObjectStructureConcurrently(globalObject, base.getObject(), JSFinalObject::defaultInlineCapacity());
     3156            }
    31463157           
    31473158            if (structure) {
  • branches/safari-612-branch/Source/JavaScriptCore/dfg/DFGConstantFoldingPhase.cpp

    r284401 r284808  
    842842                    if (base.isNull())
    843843                        structure = globalObject->nullPrototypeObjectStructure();
    844                     else if (base.isObject())
    845                         structure = globalObject->vm().structureCache.emptyObjectStructureConcurrently(globalObject, base.getObject(), JSFinalObject::defaultInlineCapacity());
     844                    else if (base.isObject()) {
     845                        // Having a bad time clears the structureCache, and so it should invalidate this structure.
     846                        bool isHavingABadTime = globalObject->isHavingABadTime();
     847                        WTF::loadLoadFence();
     848                        if (!isHavingABadTime)
     849                            m_graph.watchpoints().addLazily(globalObject->havingABadTimeWatchpoint());
     850                        // Normally, we would always install a watchpoint. In this case, however, if we haveABadTime, we
     851                        // still want to optimize. There is no watchpoint for that case though, so we need to make sure this load
     852                        // does not get hoisted above the check.
     853                        WTF::loadLoadFence();
     854                        structure = globalObject->vm().structureCache
     855                            .emptyObjectStructureConcurrently(globalObject, base.getObject(), JSFinalObject::defaultInlineCapacity());
     856                    }
    846857                   
    847858                    if (structure) {
  • branches/safari-612-branch/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r284403 r284808  
    19291929        return;
    19301930
     1931    // This must happen first, because the compiler thread may race with haveABadTime.
     1932    // Let R_BT, W_BT <- Read/Fire the watchpoint, R_SC, W_SC <- Read/clear the structure cache.
     1933    // The possible interleavings are:
     1934    // R_BT, R_SC, W_SC, W_BT: Compiler thread installs a watchpoint, and the code is discarded.
     1935    // R_BT, W_SC, R_SC, W_BT: ^ Same
     1936    // R_BT, W_SC, W_BT, W_SC: ^ Same
     1937    // W_SC, R_BT, R_SC, W_BT: ^ Same
     1938    // W_SC, R_BT, W_BT, R_SC: ^ Same
     1939    // W_SC, W_BT, R_BT, R_SC: No watchpoint is installed, but we could not see old structures from the cache.
    19311940    vm.structureCache.clear(); // We may be caching array structures in here.
    19321941
  • branches/safari-612-branch/Source/JavaScriptCore/runtime/StructureCache.cpp

    r277909 r284808  
    3131
    3232namespace JSC {
     33
     34void StructureCache::clear()
     35{
     36    Locker locker { m_lock };
     37    m_structures.clear();
     38}
    3339
    3440inline Structure* StructureCache::createEmptyStructure(JSGlobalObject* globalObject, JSObject* prototype, const TypeInfo& typeInfo, const ClassInfo* classInfo, IndexingType indexingType, unsigned inlineCapacity, bool makePolyProtoStructure, FunctionExecutable* executable)
  • branches/safari-612-branch/Source/JavaScriptCore/runtime/StructureCache.h

    r244313 r284808  
    4949    }
    5050
    51     void clear() { m_structures.clear(); }
     51    JS_EXPORT_PRIVATE void clear();
    5252
    5353    JS_EXPORT_PRIVATE Structure* emptyObjectStructureForPrototype(JSGlobalObject*, JSObject*, unsigned inlineCapacity, bool makePolyProtoStructure = false, FunctionExecutable* = nullptr);
Note: See TracChangeset for help on using the changeset viewer.