Changeset 277117 in webkit


Ignore:
Timestamp:
May 6, 2021 1:54:16 PM (3 years ago)
Author:
fpizlo@apple.com
Message:

Reduce use of dmb ish on ARM64
https://bugs.webkit.org/show_bug.cgi?id=225465

Reviewed by Keith Miller.
Source/JavaScriptCore:


We use loadLoadFence a lot, often in situations like:

Foo* ptr = loadStuff;
loadLoadFence();
use ptr

On ARM64, we don't need a dmb ish here. This introduces a dependentLoadLoadFence() for these
cases; it's just a compiler fence on ARM64 and Intel.

We also used loadLoadFence in some places where I couldn't think of any good reason for the
fence other than paranoia. I got rid of those.

  • bytecode/CallLinkStatus.cpp:

(JSC::CallLinkStatus::computeFromCallLinkInfo):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::jitType const):

  • bytecode/ObjectAllocationProfile.h:

(JSC::ObjectAllocationProfileBase::structure):
(JSC::ObjectAllocationProfileWithPrototype::prototype):

  • bytecode/Watchpoint.h:

(JSC::WatchpointSet::state const):
(JSC::InlineWatchpointSet::state const):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::handlePutByVal):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetByValOnString):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):

  • runtime/GetterSetter.h:
  • runtime/InferredValue.h:

(JSC::InferredValue::state const):

  • runtime/Structure.h:

(JSC::Structure::tryRareData):

  • runtime/StructureInlines.h:

(JSC::Structure::propertyReplacementWatchpointSet):

Source/WTF:

  • wtf/Atomics.h:

(WTF::dependentLoadLoadFence):

Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r277110 r277117  
     12021-05-06  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Reduce use of dmb ish on ARM64
     4        https://bugs.webkit.org/show_bug.cgi?id=225465
     5
     6        Reviewed by Keith Miller.
     7       
     8        We use loadLoadFence a lot, often in situations like:
     9       
     10        Foo* ptr = loadStuff;
     11        loadLoadFence();
     12        use ptr
     13       
     14        On ARM64, we don't need a dmb ish here.  This introduces a dependentLoadLoadFence() for these
     15        cases; it's just a compiler fence on ARM64 and Intel.
     16
     17        We also used loadLoadFence in some places where I couldn't think of any good reason for the
     18        fence other than paranoia. I got rid of those.
     19
     20        * bytecode/CallLinkStatus.cpp:
     21        (JSC::CallLinkStatus::computeFromCallLinkInfo):
     22        * bytecode/CodeBlock.h:
     23        (JSC::CodeBlock::jitType const):
     24        * bytecode/ObjectAllocationProfile.h:
     25        (JSC::ObjectAllocationProfileBase::structure):
     26        (JSC::ObjectAllocationProfileWithPrototype::prototype):
     27        * bytecode/Watchpoint.h:
     28        (JSC::WatchpointSet::state const):
     29        (JSC::InlineWatchpointSet::state const):
     30        * dfg/DFGByteCodeParser.cpp:
     31        (JSC::DFG::ByteCodeParser::parseBlock):
     32        (JSC::DFG::ByteCodeParser::handlePutByVal):
     33        * dfg/DFGSpeculativeJIT.cpp:
     34        (JSC::DFG::SpeculativeJIT::compileGetByValOnString):
     35        * ftl/FTLLowerDFGToB3.cpp:
     36        (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):
     37        * runtime/GetterSetter.h:
     38        * runtime/InferredValue.h:
     39        (JSC::InferredValue::state const):
     40        * runtime/Structure.h:
     41        (JSC::Structure::tryRareData):
     42        * runtime/StructureInlines.h:
     43        (JSC::Structure::propertyReplacementWatchpointSet):
     44
    1452021-05-06  Filip Pizlo  <fpizlo@apple.com>
    246
  • trunk/Source/JavaScriptCore/bytecode/CallLinkStatus.cpp

    r263054 r277117  
    194194    // fencing in place to make sure that we see the variants list after construction.
    195195    if (PolymorphicCallStubRoutine* stub = callLinkInfo.stub()) {
    196         WTF::loadLoadFence();
     196        WTF::dependentLoadLoadFence();
    197197       
    198198        if (!stub->hasEdges()) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r276610 r277117  
    435435    {
    436436        JITCode* jitCode = m_jitCode.get();
    437         WTF::loadLoadFence();
    438437        JITType result = JITCode::jitTypeFor(jitCode);
    439         WTF::loadLoadFence(); // This probably isn't needed. Oh well, paranoia is good.
    440438        return result;
    441439    }
  • trunk/Source/JavaScriptCore/bytecode/ObjectAllocationProfile.h

    r273138 r277117  
    5353        Structure* structure = m_structure.get();
    5454        // Ensure that if we see the structure, it has been properly created
    55         WTF::loadLoadFence();
     55        WTF::dependentLoadLoadFence();
    5656        return structure;
    5757    }
     
    101101    {
    102102        JSObject* prototype = m_prototype.get();
    103         WTF::loadLoadFence();
     103        WTF::dependentLoadLoadFence();
    104104        return prototype;
    105105    }
  • trunk/Source/JavaScriptCore/bytecode/Watchpoint.h

    r272174 r277117  
    209209    WatchpointState state() const
    210210    {
    211         WTF::loadLoadFence();
    212211        WatchpointState result = static_cast<WatchpointState>(m_state);
    213         WTF::loadLoadFence();
    214212        return result;
    215213    }
     
    362360    WatchpointState state() const
    363361    {
    364         WTF::loadLoadFence();
    365362        uintptr_t data = m_data;
    366         WTF::loadLoadFence();
    367363        if (isFat(data))
    368364            return fat(data)->state();
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r276823 r277117  
    56565656            // Unfortunately, we can't allocate a new JSImmutableButterfly if the profile tells us new information because we
    56575657            // cannot allocate from compilation threads.
    5658             WTF::loadLoadFence();
    56595658            FrozenValue* frozen = get(VirtualRegister(bytecode.m_immutableButterfly))->constant();
    5660             WTF::loadLoadFence();
     5659            WTF::dependentLoadLoadFence();
    56615660            JSImmutableButterfly* immutableButterfly = frozen->cast<JSImmutableButterfly*>();
    56625661            NewArrayBufferData data { };
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r276686 r277117  
    24052405        Structure* stringPrototypeStructure = globalObject->stringPrototype()->structure(vm);
    24062406        Structure* objectPrototypeStructure = globalObject->objectPrototype()->structure(vm);
    2407         WTF::loadLoadFence();
     2407        WTF::dependentLoadLoadFence();
    24082408
    24092409        if (globalObject->stringPrototypeChainIsSane()) {
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r276609 r277117  
    84948494            Structure* stringPrototypeStructure = globalObject->stringPrototype()->structure(vm());
    84958495            Structure* objectPrototypeStructure = globalObject->objectPrototype()->structure(vm());
    8496             WTF::loadLoadFence();
     8496            WTF::dependentLoadLoadFence();
    84978497
    84988498            if (globalObject->stringPrototypeChainIsSane()) {
  • trunk/Source/JavaScriptCore/runtime/GetterSetter.h

    r276592 r277117  
    9090    {
    9191        JSObject* result = getter();
    92         WTF::loadLoadFence();
     92        WTF::dependentLoadLoadFence();
    9393        return result;
    9494    }
  • trunk/Source/JavaScriptCore/runtime/InferredValue.h

    r261755 r277117  
    8282    WatchpointState state() const
    8383    {
    84         WTF::loadLoadFence();
    8584        uintptr_t data = m_data;
    86         WTF::loadLoadFence();
    8785        if (isFat(data))
    8886            return fat(data)->state();
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r276592 r277117  
    4444#include "Watchpoint.h"
    4545#include "WriteBarrierInlines.h"
     46#include <wtf/Atomics.h>
    4647#include <wtf/PrintStream.h>
    4748
     
    339340    }
    340341
     342    StructureRareData* tryRareData()
     343    {
     344        JSCell* value = m_previousOrRareData.get();
     345        WTF::dependentLoadLoadFence();
     346        if (isRareData(value))
     347            return static_cast<StructureRareData*>(value);
     348        return nullptr;
     349    }
     350
    341351    const StructureRareData* rareData() const
    342352    {
  • trunk/Source/JavaScriptCore/runtime/StructureInlines.h

    r272580 r277117  
    368368{
    369369    ConcurrentJSLocker locker(m_lock);
    370     if (!hasRareData())
     370    StructureRareData* rareData = tryRareData();
     371    if (!rareData)
    371372        return nullptr;
    372     WTF::loadLoadFence();
    373     StructureRareData::PropertyWatchpointMap* map = rareData()->m_replacementWatchpointSets.get();
     373    StructureRareData::PropertyWatchpointMap* map = rareData->m_replacementWatchpointSets.get();
    374374    if (!map)
    375375        return nullptr;
  • trunk/Source/WTF/ChangeLog

    r277104 r277117  
     12021-05-06  Filip Pizlo  <fpizlo@apple.com>
     2
     3        Reduce use of dmb ish on ARM64
     4        https://bugs.webkit.org/show_bug.cgi?id=225465
     5
     6        Reviewed by Keith Miller.
     7
     8        * wtf/Atomics.h:
     9        (WTF::dependentLoadLoadFence):
     10
    1112021-05-06  Per Arne Vollan  <pvollan@apple.com>
    212
  • trunk/Source/WTF/wtf/Atomics.h

    r248546 r277117  
    329329#endif
    330330
     331#if CPU(ARM64) || CPU(X86) || CPU(X86_64)
     332// Use this fence if you want a fence between loads that are already depdendent.
     333inline void dependentLoadLoadFence() { compilerFence(); }
     334#else
     335inline void dependentLoadLoadFence() { loadLoadFence(); }
     336#endif
     337
    331338typedef unsigned InternalDependencyType;
    332339
Note: See TracChangeset for help on using the changeset viewer.