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

Changeset 275866 in webkit


Ignore:
Timestamp:
Apr 13, 2021, 12:35:38 AM (6 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Remove CodeBlock::m_constantsSourceCodeRepresentation
​https://bugs.webkit.org/show_bug.cgi?id=224473

Reviewed by Mark Lam.

CodeBlock::m_constantsSourceCodeRepresentation is identical to UnlinkedCodeBlock::m_constantsSourceCodeRepresentation.

  1. For all constants existing at bytecode compile time, elements of the above vectors are identical.
  2. For lazily added constants from DFG, it is always SourceCodeRepresentation::Other.

And the array is effectively accessed only when compiling DFG code. So we should remove copy of that in CodeBlock, and
get SourceCodeRepresentation from UnlinkedCodeBlock.

  • bytecode/BytecodeDumper.cpp:

(JSC::CodeBlockBytecodeDumper<Block>::dumpConstants):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::setConstantRegisters):
(JSC::CodeBlock::shrinkToFit):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::constants):
(JSC::CodeBlock::addConstant):
(JSC::CodeBlock::addConstantLazily):
(JSC::CodeBlock::constantSourceCodeRepresentation const):
(JSC::CodeBlock::constantsSourceCodeRepresentation): Deleted.

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::constantSourceCodeRepresentation const):

  • bytecode/UnlinkedCodeBlockGenerator.h:

(JSC::UnlinkedCodeBlockGenerator::constantSourceCodeRepresentation const):
(JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): Deleted.

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::registerFrozenValues):

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r275860 r275866  
     12021-04-12  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Remove CodeBlock::m_constantsSourceCodeRepresentation
     4        https://bugs.webkit.org/show_bug.cgi?id=224473
     5
     6        Reviewed by Mark Lam.
     7
     8        CodeBlock::m_constantsSourceCodeRepresentation is identical to UnlinkedCodeBlock::m_constantsSourceCodeRepresentation.
     9
     10        1. For all constants existing at bytecode compile time, elements of the above vectors are identical.
     11        2. For lazily added constants from DFG, it is always SourceCodeRepresentation::Other.
     12
     13        And the array is effectively accessed only when compiling DFG code. So we should remove copy of that in CodeBlock, and
     14        get SourceCodeRepresentation from UnlinkedCodeBlock.
     15
     16        * bytecode/BytecodeDumper.cpp:
     17        (JSC::CodeBlockBytecodeDumper<Block>::dumpConstants):
     18        * bytecode/CodeBlock.cpp:
     19        (JSC::CodeBlock::CodeBlock):
     20        (JSC::CodeBlock::setConstantRegisters):
     21        (JSC::CodeBlock::shrinkToFit):
     22        * bytecode/CodeBlock.h:
     23        (JSC::CodeBlock::constants):
     24        (JSC::CodeBlock::addConstant):
     25        (JSC::CodeBlock::addConstantLazily):
     26        (JSC::CodeBlock::constantSourceCodeRepresentation const):
     27        (JSC::CodeBlock::constantsSourceCodeRepresentation): Deleted.
     28        * bytecode/UnlinkedCodeBlock.h:
     29        (JSC::UnlinkedCodeBlock::constantSourceCodeRepresentation const):
     30        * bytecode/UnlinkedCodeBlockGenerator.h:
     31        (JSC::UnlinkedCodeBlockGenerator::constantSourceCodeRepresentation const):
     32        (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): Deleted.
     33        * dfg/DFGGraph.cpp:
     34        (JSC::DFG::Graph::registerFrozenValues):
     35
    1362021-04-12  Mark Lam  <mark.lam@apple.com>
    237
  • trunk/Source/JavaScriptCore/bytecode/BytecodeDumper.cpp

    r275840 r275866  
    138138        for (const auto& constant : this->block()->constantRegisters()) {
    139139            const char* sourceCodeRepresentationDescription = nullptr;
    140             switch (this->block()->constantsSourceCodeRepresentation()[i]) {
     140            switch (this->block()->constantSourceCodeRepresentation(i)) {
    141141            case SourceCodeRepresentation::Double:
    142142                sourceCodeRepresentationDescription = ": in source as double";
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r275840 r275866  
    297297    , m_instructionsRawPointer(other.m_instructionsRawPointer)
    298298    , m_constantRegisters(other.m_constantRegisters)
    299     , m_constantsSourceCodeRepresentation(other.m_constantsSourceCodeRepresentation)
    300299    , m_functionDecls(other.m_functionDecls)
    301300    , m_functionExprs(other.m_functionExprs)
    … …  
    884883        ConcurrentJSLocker locker(m_lock);
    885884        m_constantRegisters.resizeToFit(count);
    886         m_constantsSourceCodeRepresentation.resizeToFit(count);
    887885    }
    888886    for (size_t i = 0; i < count; i++) {
    889887        JSValue constant = constants[i].get();
    890888        SourceCodeRepresentation representation = constantsSourceCodeRepresentation[i];
    891         m_constantsSourceCodeRepresentation[i] = representation;
    892889        switch (representation) {
    893890        case SourceCodeRepresentation::LinkTimeConstant:
    … …  
    21252122    m_constantRegisters.shrinkToFit();
    21262123#endif
    2127     m_constantsSourceCodeRepresentation.shrinkToFit();
    21282124
    21292125    if (shrinkMode == ShrinkMode::EarlyShrink) {
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r275840 r275866  
    573573
    574574    Vector<WriteBarrier<Unknown>>& constants() { return m_constantRegisters; }
    575     Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }
    576575    unsigned addConstant(const ConcurrentJSLocker&, JSValue v)
    577576    {
    … …  
    579578        m_constantRegisters.append(WriteBarrier<Unknown>());
    580579        m_constantRegisters.last().set(*m_vm, this, v);
    581         m_constantsSourceCodeRepresentation.append(SourceCodeRepresentation::Other);
    582580        return result;
    583581    }
    … …  
    587585        unsigned result = m_constantRegisters.size();
    588586        m_constantRegisters.append(WriteBarrier<Unknown>());
    589         m_constantsSourceCodeRepresentation.append(SourceCodeRepresentation::Other);
    590587        return result;
    591588    }
    … …  
    594591    WriteBarrier<Unknown>& constantRegister(VirtualRegister reg) { return m_constantRegisters[reg.toConstantIndex()]; }
    595592    ALWAYS_INLINE JSValue getConstant(VirtualRegister reg) const { return m_constantRegisters[reg.toConstantIndex()].get(); }
    596     ALWAYS_INLINE SourceCodeRepresentation constantSourceCodeRepresentation(VirtualRegister reg) const { return m_constantsSourceCodeRepresentation[reg.toConstantIndex()]; }
     593    ALWAYS_INLINE SourceCodeRepresentation constantSourceCodeRepresentation(VirtualRegister reg) const { return m_unlinkedCode->constantSourceCodeRepresentation(reg); }
     594    ALWAYS_INLINE SourceCodeRepresentation constantSourceCodeRepresentation(unsigned index) const { return m_unlinkedCode->constantSourceCodeRepresentation(index); }
    597595
    598596    FunctionExecutable* functionDecl(int index) { return m_functionDecls[index].get(); }
    … …  
    10471045    // it, so we're stuck with it for now.
    10481046    Vector<WriteBarrier<Unknown>> m_constantRegisters;
    1049     Vector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation;
    10501047    FixedVector<WriteBarrier<FunctionExecutable>> m_functionDecls;
    10511048    FixedVector<WriteBarrier<FunctionExecutable>> m_functionExprs;
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r275840 r275866  
    162162    const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }
    163163
     164    SourceCodeRepresentation constantSourceCodeRepresentation(VirtualRegister reg) const
     165    {
     166        return constantSourceCodeRepresentation(reg.toConstantIndex());
     167    }
     168    SourceCodeRepresentation constantSourceCodeRepresentation(unsigned index) const
     169    {
     170        if (index < m_constantsSourceCodeRepresentation.size())
     171            return m_constantsSourceCodeRepresentation[index];
     172        return SourceCodeRepresentation::Other;
     173    }
     174
    164175    unsigned numberOfConstantIdentifierSets() const { return m_rareData ? m_rareData->m_constantIdentifierSets.size() : 0; }
    165176    const FixedVector<IdentifierSet>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; }
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlockGenerator.h

    r275840 r275866  
    125125    const Vector<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; }
    126126    ALWAYS_INLINE JSValue getConstant(VirtualRegister reg) const { return m_constantRegisters[reg.toConstantIndex()].get(); }
    127     const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }
     127
     128    SourceCodeRepresentation constantSourceCodeRepresentation(VirtualRegister reg) const
     129    {
     130        return constantSourceCodeRepresentation(reg.toConstantIndex());
     131    }
     132    SourceCodeRepresentation constantSourceCodeRepresentation(unsigned index) const
     133    {
     134        if (index < m_constantsSourceCodeRepresentation.size())
     135            return m_constantsSourceCodeRepresentation[index];
     136        return SourceCodeRepresentation::Other;
     137    }
    128138
    129139    unsigned addConstant(JSValue v, SourceCodeRepresentation sourceCodeRepresentation = SourceCodeRepresentation::Other)
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r275626 r275866  
    14251425    ConcurrentJSLocker locker(m_codeBlock->m_lock);
    14261426    m_codeBlock->constants().shrink(0);
    1427     m_codeBlock->constantsSourceCodeRepresentation().resize(0);
    14281427    for (FrozenValue* value : m_frozenValues) {
    14291428        if (!value->pointsToHeap())
    … …  
    14461445    }
    14471446    m_codeBlock->constants().shrinkToFit();
    1448     m_codeBlock->constantsSourceCodeRepresentation().shrinkToFit();
    14491447}
    14501448
Note: See TracChangeset for help on using the changeset viewer.