Changeset 275490 in webkit


Ignore:
Timestamp:
Apr 5, 2021 9:25:33 PM (3 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Shrink some of Vectors in JSC
https://bugs.webkit.org/show_bug.cgi?id=224162

Reviewed by Simon Fraser.

Source/JavaScriptCore:

  1. Add XXXStatus::shrinkToFit to shrink underlying dynamic Vectors.
  2. Replace tierUpInLoopHierarchy's Vector with RefCountedArray since it is constructed-once-lookup-only data.
  3. Use MemoryCompactLookupOnlyRobinHoodHashSet for StringTables since this is constructed-once-lookup-only data. We also add MemoryCompactLookupOnlyRobinHoodHashSet support for CachedTypes.
  4. Use resizeToFit for StringSwitchJumpTables and SwitchJumpTables.
  5. JITStubRoutineSet's Vector should be shrunk.
  6. BlockDirectoryBits's Vector's initial size should be small.
  7. Make PolyProtoAccessChain RefCounted, and use RefCountedArray for its Vector<StructureID>. And remove PolyProtoAccessChain::clone. Just having Ref is enough since this is immutable data.
  8. Use RefCountedArray for UnlinkedFunctionExecutable's m_classFieldLocations.
  9. Use RefCountedArray for JSWebAssemblyInstance.
  • bytecode/AccessCase.cpp:

(JSC::AccessCase::AccessCase):
(JSC::AccessCase::create):
(JSC::AccessCase::createTransition):

  • bytecode/AccessCase.h:

(JSC::AccessCase::AccessCase): Deleted.

  • bytecode/CallLinkInfo.cpp:

(JSC::CallLinkInfo::setFrameShuffleData):

  • bytecode/CheckPrivateBrandStatus.cpp:

(JSC::CheckPrivateBrandStatus::shrinkToFit):
(JSC::CheckPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback):
(JSC::CheckPrivateBrandStatus::merge):

  • bytecode/CheckPrivateBrandStatus.h:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::finishCreation):

  • bytecode/DeleteByStatus.cpp:

(JSC::DeleteByStatus::shrinkToFit):
(JSC::DeleteByStatus::computeForStubInfoWithoutExitSiteFeedback):
(JSC::DeleteByStatus::merge):

  • bytecode/DeleteByStatus.h:
  • bytecode/GetByStatus.cpp:

(JSC::GetByStatus::shrinkToFit):
(JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback):
(JSC::GetByStatus::computeFor):
(JSC::GetByStatus::merge):

  • bytecode/GetByStatus.h:
  • bytecode/GetterSetterAccessCase.cpp:

(JSC::GetterSetterAccessCase::GetterSetterAccessCase):
(JSC::GetterSetterAccessCase::create):

  • bytecode/GetterSetterAccessCase.h:
  • bytecode/InByIdStatus.cpp:

(JSC::InByIdStatus::shrinkToFit):
(JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback):
(JSC::InByIdStatus::merge):

  • bytecode/InByIdStatus.h:
  • bytecode/InstanceOfStatus.cpp:

(JSC::InstanceOfStatus::shrinkToFit):
(JSC::InstanceOfStatus::computeForStubInfo):

  • bytecode/InstanceOfStatus.h:
  • bytecode/IntrinsicGetterAccessCase.cpp:

(JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase):
(JSC::IntrinsicGetterAccessCase::create):

  • bytecode/IntrinsicGetterAccessCase.h:
  • bytecode/JumpTable.h:
  • bytecode/PolyProtoAccessChain.cpp:

(JSC::PolyProtoAccessChain::tryCreate):
(JSC::PolyProtoAccessChain::create): Deleted.

  • bytecode/PolyProtoAccessChain.h:

(JSC::PolyProtoAccessChain::clone): Deleted.
(JSC::PolyProtoAccessChain::chain const): Deleted.
(JSC::PolyProtoAccessChain::operator!= const): Deleted.
(JSC::PolyProtoAccessChain::forEach const): Deleted.
(JSC::PolyProtoAccessChain::slotBaseStructure const): Deleted.

  • bytecode/PolymorphicAccess.cpp:

(JSC::PolymorphicAccess::visitWeak const):
(JSC::PolymorphicAccess::regenerate):

  • bytecode/PolymorphicAccess.h:
  • bytecode/ProxyableAccessCase.cpp:

(JSC::ProxyableAccessCase::ProxyableAccessCase):
(JSC::ProxyableAccessCase::create):

  • bytecode/ProxyableAccessCase.h:
  • bytecode/PutByIdStatus.cpp:

(JSC::PutByIdStatus::shrinkToFit):
(JSC::PutByIdStatus::computeForStubInfo):
(JSC::PutByIdStatus::computeFor):
(JSC::PutByIdStatus::merge):

  • bytecode/PutByIdStatus.h:
  • bytecode/SetPrivateBrandStatus.cpp:

(JSC::SetPrivateBrandStatus::shrinkToFit):
(JSC::SetPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback):
(JSC::SetPrivateBrandStatus::merge):

  • bytecode/SetPrivateBrandStatus.h:
  • bytecode/UnlinkedCodeBlock.h:
  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::generateUnlinkedFunctionCodeBlock):

  • bytecode/UnlinkedFunctionExecutable.h:
  • dfg/DFGJITCode.h:
  • dfg/DFGPlan.h:

(JSC::DFG::Plan::tierUpInLoopHierarchy):

  • dfg/DFGTierUpCheckInjectionPhase.cpp:

(JSC::DFG::TierUpCheckInjectionPhase::run):

  • heap/BlockDirectoryBits.h:
  • heap/JITStubRoutineSet.cpp:

(JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines):

  • jit/CallFrameShuffleData.h:

(JSC::CallFrameShuffleData::shrinkToFit):

  • jit/GCAwareJITStubRoutine.h:
  • jit/PolymorphicCallStubRoutine.h:
  • jit/Repatch.cpp:

(JSC::tryCacheGetBy):
(JSC::tryCachePutByID):
(JSC::tryCacheInByID):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):
(JSC::parse):

  • runtime/CachedTypes.cpp:

(JSC::CachedFunctionExecutableRareData::encode):
(JSC::CachedFunctionExecutableRareData::decode const):

  • runtime/VM.cpp:

(JSC::VM::popAllCheckpointOSRSideStateUntil):

  • wasm/js/JSWebAssemblyInstance.cpp:

(JSC::JSWebAssemblyInstance::visitChildrenImpl):

  • wasm/js/JSWebAssemblyInstance.h:

Source/WTF:

Add rbegin and rend to make RefCountedArray usable for Vector clients who use these features.

  • wtf/RefCountedArray.h:

(WTF::RefCountedArray::begin):
(WTF::RefCountedArray::end):
(WTF::RefCountedArray::begin const):
(WTF::RefCountedArray::end const):
(WTF::RefCountedArray::rbegin):
(WTF::RefCountedArray::rend):
(WTF::RefCountedArray::rbegin const):
(WTF::RefCountedArray::rend const):

Location:
trunk/Source
Files:
50 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r275484 r275490  
     12021-04-05  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Shrink some of Vectors in JSC
     4        https://bugs.webkit.org/show_bug.cgi?id=224162
     5
     6        Reviewed by Simon Fraser.
     7
     8        1. Add XXXStatus::shrinkToFit to shrink underlying dynamic Vectors.
     9        2. Replace tierUpInLoopHierarchy's Vector with RefCountedArray since it is constructed-once-lookup-only data.
     10        3. Use MemoryCompactLookupOnlyRobinHoodHashSet for StringTables since this is constructed-once-lookup-only data. We also add
     11           MemoryCompactLookupOnlyRobinHoodHashSet support for CachedTypes.
     12        4. Use resizeToFit for StringSwitchJumpTables and SwitchJumpTables.
     13        5. JITStubRoutineSet's Vector should be shrunk.
     14        6. BlockDirectoryBits's Vector's initial size should be small.
     15        7. Make PolyProtoAccessChain RefCounted, and use RefCountedArray for its Vector<StructureID>. And remove PolyProtoAccessChain::clone.
     16           Just having Ref is enough since this is immutable data.
     17        8. Use RefCountedArray for UnlinkedFunctionExecutable's m_classFieldLocations.
     18        9. Use RefCountedArray for JSWebAssemblyInstance.
     19
     20        * bytecode/AccessCase.cpp:
     21        (JSC::AccessCase::AccessCase):
     22        (JSC::AccessCase::create):
     23        (JSC::AccessCase::createTransition):
     24        * bytecode/AccessCase.h:
     25        (JSC::AccessCase::AccessCase): Deleted.
     26        * bytecode/CallLinkInfo.cpp:
     27        (JSC::CallLinkInfo::setFrameShuffleData):
     28        * bytecode/CheckPrivateBrandStatus.cpp:
     29        (JSC::CheckPrivateBrandStatus::shrinkToFit):
     30        (JSC::CheckPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback):
     31        (JSC::CheckPrivateBrandStatus::merge):
     32        * bytecode/CheckPrivateBrandStatus.h:
     33        * bytecode/CodeBlock.cpp:
     34        (JSC::CodeBlock::finishCreation):
     35        * bytecode/DeleteByStatus.cpp:
     36        (JSC::DeleteByStatus::shrinkToFit):
     37        (JSC::DeleteByStatus::computeForStubInfoWithoutExitSiteFeedback):
     38        (JSC::DeleteByStatus::merge):
     39        * bytecode/DeleteByStatus.h:
     40        * bytecode/GetByStatus.cpp:
     41        (JSC::GetByStatus::shrinkToFit):
     42        (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback):
     43        (JSC::GetByStatus::computeFor):
     44        (JSC::GetByStatus::merge):
     45        * bytecode/GetByStatus.h:
     46        * bytecode/GetterSetterAccessCase.cpp:
     47        (JSC::GetterSetterAccessCase::GetterSetterAccessCase):
     48        (JSC::GetterSetterAccessCase::create):
     49        * bytecode/GetterSetterAccessCase.h:
     50        * bytecode/InByIdStatus.cpp:
     51        (JSC::InByIdStatus::shrinkToFit):
     52        (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback):
     53        (JSC::InByIdStatus::merge):
     54        * bytecode/InByIdStatus.h:
     55        * bytecode/InstanceOfStatus.cpp:
     56        (JSC::InstanceOfStatus::shrinkToFit):
     57        (JSC::InstanceOfStatus::computeForStubInfo):
     58        * bytecode/InstanceOfStatus.h:
     59        * bytecode/IntrinsicGetterAccessCase.cpp:
     60        (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase):
     61        (JSC::IntrinsicGetterAccessCase::create):
     62        * bytecode/IntrinsicGetterAccessCase.h:
     63        * bytecode/JumpTable.h:
     64        * bytecode/PolyProtoAccessChain.cpp:
     65        (JSC::PolyProtoAccessChain::tryCreate):
     66        (JSC::PolyProtoAccessChain::create): Deleted.
     67        * bytecode/PolyProtoAccessChain.h:
     68        (JSC::PolyProtoAccessChain::clone): Deleted.
     69        (JSC::PolyProtoAccessChain::chain const): Deleted.
     70        (JSC::PolyProtoAccessChain::operator!= const): Deleted.
     71        (JSC::PolyProtoAccessChain::forEach const): Deleted.
     72        (JSC::PolyProtoAccessChain::slotBaseStructure const): Deleted.
     73        * bytecode/PolymorphicAccess.cpp:
     74        (JSC::PolymorphicAccess::visitWeak const):
     75        (JSC::PolymorphicAccess::regenerate):
     76        * bytecode/PolymorphicAccess.h:
     77        * bytecode/ProxyableAccessCase.cpp:
     78        (JSC::ProxyableAccessCase::ProxyableAccessCase):
     79        (JSC::ProxyableAccessCase::create):
     80        * bytecode/ProxyableAccessCase.h:
     81        * bytecode/PutByIdStatus.cpp:
     82        (JSC::PutByIdStatus::shrinkToFit):
     83        (JSC::PutByIdStatus::computeForStubInfo):
     84        (JSC::PutByIdStatus::computeFor):
     85        (JSC::PutByIdStatus::merge):
     86        * bytecode/PutByIdStatus.h:
     87        * bytecode/SetPrivateBrandStatus.cpp:
     88        (JSC::SetPrivateBrandStatus::shrinkToFit):
     89        (JSC::SetPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback):
     90        (JSC::SetPrivateBrandStatus::merge):
     91        * bytecode/SetPrivateBrandStatus.h:
     92        * bytecode/UnlinkedCodeBlock.h:
     93        * bytecode/UnlinkedFunctionExecutable.cpp:
     94        (JSC::generateUnlinkedFunctionCodeBlock):
     95        * bytecode/UnlinkedFunctionExecutable.h:
     96        * dfg/DFGJITCode.h:
     97        * dfg/DFGPlan.h:
     98        (JSC::DFG::Plan::tierUpInLoopHierarchy):
     99        * dfg/DFGTierUpCheckInjectionPhase.cpp:
     100        (JSC::DFG::TierUpCheckInjectionPhase::run):
     101        * heap/BlockDirectoryBits.h:
     102        * heap/JITStubRoutineSet.cpp:
     103        (JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines):
     104        * jit/CallFrameShuffleData.h:
     105        (JSC::CallFrameShuffleData::shrinkToFit):
     106        * jit/GCAwareJITStubRoutine.h:
     107        * jit/PolymorphicCallStubRoutine.h:
     108        * jit/Repatch.cpp:
     109        (JSC::tryCacheGetBy):
     110        (JSC::tryCachePutByID):
     111        (JSC::tryCacheInByID):
     112        * parser/Parser.cpp:
     113        (JSC::Parser<LexerType>::parseInner):
     114        (JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):
     115        * parser/Parser.h:
     116        (JSC::Parser<LexerType>::parse):
     117        (JSC::parse):
     118        * runtime/CachedTypes.cpp:
     119        (JSC::CachedFunctionExecutableRareData::encode):
     120        (JSC::CachedFunctionExecutableRareData::decode const):
     121        * runtime/VM.cpp:
     122        (JSC::VM::popAllCheckpointOSRSideStateUntil):
     123        * wasm/js/JSWebAssemblyInstance.cpp:
     124        (JSC::JSWebAssemblyInstance::visitChildrenImpl):
     125        * wasm/js/JSWebAssemblyInstance.h:
     126
    11272021-04-05  Alex Christensen  <achristensen@webkit.org>
    2128
  • trunk/Source/JavaScriptCore/bytecode/AccessCase.cpp

    r275392 r275490  
    5858DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(AccessCase);
    5959
    60 AccessCase::AccessCase(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     60AccessCase::AccessCase(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    6161    : m_type(type)
    6262    , m_offset(offset)
     
    6969}
    7070
    71 std::unique_ptr<AccessCase> AccessCase::create(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     71std::unique_ptr<AccessCase> AccessCase::create(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    7272{
    7373    switch (type) {
     
    111111std::unique_ptr<AccessCase> AccessCase::createTransition(
    112112    VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* oldStructure, Structure* newStructure,
    113     const ObjectPropertyConditionSet& conditionSet, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     113    const ObjectPropertyConditionSet& conditionSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    114114{
    115115    RELEASE_ASSERT(oldStructure == newStructure->previousID());
  • trunk/Source/JavaScriptCore/bytecode/AccessCase.h

    r273138 r275490  
    149149
    150150    static std::unique_ptr<AccessCase> create(VM&, JSCell* owner, AccessType, CacheableIdentifier, PropertyOffset = invalidOffset,
    151         Structure* = nullptr, const ObjectPropertyConditionSet& = ObjectPropertyConditionSet(), std::unique_ptr<PolyProtoAccessChain> = nullptr);
     151        Structure* = nullptr, const ObjectPropertyConditionSet& = ObjectPropertyConditionSet(), RefPtr<PolyProtoAccessChain>&& = nullptr);
    152152
    153153    static std::unique_ptr<AccessCase> createTransition(VM&, JSCell* owner, CacheableIdentifier, PropertyOffset, Structure* oldStructure,
    154         Structure* newStructure, const ObjectPropertyConditionSet&, std::unique_ptr<PolyProtoAccessChain>);
     154        Structure* newStructure, const ObjectPropertyConditionSet&, RefPtr<PolyProtoAccessChain>&&);
    155155
    156156    static std::unique_ptr<AccessCase> createDelete(VM&, JSCell* owner, CacheableIdentifier, PropertyOffset, Structure* oldStructure,
     
    256256   
    257257protected:
    258     AccessCase(VM&, JSCell* owner, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, std::unique_ptr<PolyProtoAccessChain>);
     258    AccessCase(VM&, JSCell* owner, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, RefPtr<PolyProtoAccessChain>&&);
    259259    AccessCase(AccessCase&&) = default;
    260     AccessCase(const AccessCase& other)
    261         : m_type(other.m_type)
    262         , m_state(other.m_state)
    263         , m_viaProxy(other.m_viaProxy)
    264         , m_offset(other.m_offset)
    265         , m_structure(other.m_structure)
    266         , m_conditionSet(other.m_conditionSet)
    267         , m_identifier(other.m_identifier)
    268     {
    269         if (other.m_polyProtoAccessChain)
    270             m_polyProtoAccessChain = other.m_polyProtoAccessChain->clone();
    271     }
     260    AccessCase(const AccessCase& other) = default;
    272261
    273262    AccessCase& operator=(const AccessCase&) = delete;
     
    322311    ObjectPropertyConditionSet m_conditionSet;
    323312
    324     std::unique_ptr<PolyProtoAccessChain> m_polyProtoAccessChain;
     313    RefPtr<PolyProtoAccessChain> m_polyProtoAccessChain;
    325314
    326315    CacheableIdentifier m_identifier;
  • trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp

    r266359 r275490  
    282282{
    283283    m_frameShuffleData = makeUnique<CallFrameShuffleData>(shuffleData);
     284    m_frameShuffleData->shrinkToFit();
    284285}
    285286
  • trunk/Source/JavaScriptCore/bytecode/CheckPrivateBrandStatus.cpp

    r273138 r275490  
    4242}
    4343
     44void CheckPrivateBrandStatus::shrinkToFit()
     45{
     46    m_variants.shrinkToFit();
     47}
     48
    4449CheckPrivateBrandStatus CheckPrivateBrandStatus::computeForBaseline(CodeBlock* baselineBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit)
    4550{
     
    110115        }
    111116
     117        result.shrinkToFit();
    112118        return result;
    113119    }
     
    192198                return mergeSlow();
    193199        }
     200        shrinkToFit();
    194201        return;
    195202
  • trunk/Source/JavaScriptCore/bytecode/CheckPrivateBrandStatus.h

    r273138 r275490  
    8888
    8989    bool appendVariant(const CheckPrivateBrandVariant&);
     90    void shrinkToFit();
    9091
    9192    void dump(PrintStream&) const;
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r273972 r275490  
    438438
    439439        if (size_t count = unlinkedCodeBlock->numberOfStringSwitchJumpTables()) {
    440             m_rareData->m_stringSwitchJumpTables.grow(count);
     440            m_rareData->m_stringSwitchJumpTables.resizeToFit(count);
    441441            for (size_t i = 0; i < count; i++) {
    442442                UnlinkedStringJumpTable::StringOffsetTable::iterator ptr = unlinkedCodeBlock->stringSwitchJumpTable(i).offsetTable.begin();
     
    451451
    452452        if (size_t count = unlinkedCodeBlock->numberOfSwitchJumpTables()) {
    453             m_rareData->m_switchJumpTables.grow(count);
     453            m_rareData->m_switchJumpTables.resizeToFit(count);
    454454            for (size_t i = 0; i < count; i++) {
    455455                UnlinkedSimpleJumpTable& sourceTable = unlinkedCodeBlock->switchJumpTable(i);
  • trunk/Source/JavaScriptCore/bytecode/DeleteByStatus.cpp

    r273138 r275490  
    4141}
    4242
     43void DeleteByStatus::shrinkToFit()
     44{
     45    m_variants.shrinkToFit();
     46}
     47
    4348DeleteByStatus DeleteByStatus::computeForBaseline(CodeBlock* baselineBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit)
    4449{
     
    130135        }
    131136
     137        result.shrinkToFit();
    132138        return result;
    133139    }
     
    215221                return mergeSlow();
    216222        }
     223        shrinkToFit();
    217224        return;
    218225
  • trunk/Source/JavaScriptCore/bytecode/DeleteByStatus.h

    r273138 r275490  
    8787
    8888    bool appendVariant(const DeleteByIdVariant&);
     89    void shrinkToFit();
    8990
    9091    void dump(PrintStream&) const;
  • trunk/Source/JavaScriptCore/bytecode/GetByStatus.cpp

    r273138 r275490  
    4444{
    4545    return appendICStatusVariant(m_variants, variant);
     46}
     47
     48void GetByStatus::shrinkToFit()
     49{
     50    m_variants.shrinkToFit();
    4651}
    4752
     
    340345        }
    341346       
     347        result.shrinkToFit();
    342348        return result;
    343349    }
     
    434440    }
    435441   
     442    result.shrinkToFit();
    436443    return result;
    437444}
     
    495502                return mergeSlow();
    496503        }
     504        shrinkToFit();
    497505        return;
    498506       
  • trunk/Source/JavaScriptCore/bytecode/GetByStatus.h

    r273138 r275490  
    124124
    125125    bool appendVariant(const GetByIdVariant&);
     126    void shrinkToFit();
    126127
    127128    void dump(PrintStream&) const;
  • trunk/Source/JavaScriptCore/bytecode/GetterSetterAccessCase.cpp

    r270764 r275490  
    4242}
    4343
    44 GetterSetterAccessCase::GetterSetterAccessCase(VM& vm, JSCell* owner, AccessType accessType, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, bool viaProxy, WatchpointSet* additionalSet, JSObject* customSlotBase, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     44GetterSetterAccessCase::GetterSetterAccessCase(VM& vm, JSCell* owner, AccessType accessType, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, bool viaProxy, WatchpointSet* additionalSet, JSObject* customSlotBase, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    4545    : Base(vm, owner, accessType, identifier, offset, structure, conditionSet, viaProxy, additionalSet, WTFMove(prototypeAccessChain))
    4646{
     
    5151    VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet,
    5252    bool viaProxy, WatchpointSet* additionalSet, FunctionPtr<CustomAccessorPtrTag> customGetter, JSObject* customSlotBase,
    53     Optional<DOMAttributeAnnotation> domAttribute, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     53    Optional<DOMAttributeAnnotation> domAttribute, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    5454{
    5555    switch (type) {
     
    6969
    7070std::unique_ptr<AccessCase> GetterSetterAccessCase::create(VM& vm, JSCell* owner, AccessType type, Structure* structure, CacheableIdentifier identifier, PropertyOffset offset,
    71     const ObjectPropertyConditionSet& conditionSet, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain, bool viaProxy,
     71    const ObjectPropertyConditionSet& conditionSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain, bool viaProxy,
    7272    FunctionPtr<CustomAccessorPtrTag> customSetter, JSObject* customSlotBase)
    7373{
  • trunk/Source/JavaScriptCore/bytecode/GetterSetterAccessCase.h

    r270764 r275490  
    5757        VM&, JSCell* owner, AccessType, CacheableIdentifier, PropertyOffset, Structure*,
    5858        const ObjectPropertyConditionSet&, bool viaProxy, WatchpointSet* additionalSet, FunctionPtr<CustomAccessorPtrTag> customGetter,
    59         JSObject* customSlotBase, Optional<DOMAttributeAnnotation>, std::unique_ptr<PolyProtoAccessChain>);
     59        JSObject* customSlotBase, Optional<DOMAttributeAnnotation>, RefPtr<PolyProtoAccessChain>&&);
    6060
    6161    static std::unique_ptr<AccessCase> create(VM&, JSCell* owner, AccessType, Structure*, CacheableIdentifier, PropertyOffset,
    62         const ObjectPropertyConditionSet&, std::unique_ptr<PolyProtoAccessChain>, bool viaProxy = false,
     62        const ObjectPropertyConditionSet&, RefPtr<PolyProtoAccessChain>&&, bool viaProxy = false,
    6363        FunctionPtr<CustomAccessorPtrTag> customSetter = nullptr, JSObject* customSlotBase = nullptr);
    6464
     
    7171
    7272private:
    73     GetterSetterAccessCase(VM&, JSCell*, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, bool viaProxy, WatchpointSet* additionalSet, JSObject* customSlotBase, std::unique_ptr<PolyProtoAccessChain>);
     73    GetterSetterAccessCase(VM&, JSCell*, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, bool viaProxy, WatchpointSet* additionalSet, JSObject* customSlotBase, RefPtr<PolyProtoAccessChain>&&);
    7474
    7575    GetterSetterAccessCase(const GetterSetterAccessCase&);
  • trunk/Source/JavaScriptCore/bytecode/InByIdStatus.cpp

    r273138 r275490  
    4242}
    4343
     44void InByIdStatus::shrinkToFit()
     45{
     46    m_variants.shrinkToFit();
     47}
     48
    4449#if ENABLE(JIT)
    4550InByIdStatus InByIdStatus::computeFor(CodeBlock* profiledBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, UniquedStringImpl* uid, ExitFlag didExit)
     
    201206        }
    202207
     208        result.shrinkToFit();
    203209        return result;
    204210    }
     
    234240            }
    235241        }
     242        shrinkToFit();
    236243        return;
    237244       
  • trunk/Source/JavaScriptCore/bytecode/InByIdStatus.h

    r273138 r275490  
    117117#endif
    118118    bool appendVariant(const InByIdVariant&);
     119    void shrinkToFit();
    119120
    120121    State m_state { NoInformation };
  • trunk/Source/JavaScriptCore/bytecode/InstanceOfStatus.cpp

    r261993 r275490  
    3838{
    3939    appendICStatusVariant(m_variants, variant);
     40}
     41
     42void InstanceOfStatus::shrinkToFit()
     43{
     44    m_variants.shrinkToFit();
    4045}
    4146
     
    97102    }
    98103   
     104    result.shrinkToFit();
    99105    return result;
    100106}
  • trunk/Source/JavaScriptCore/bytecode/InstanceOfStatus.h

    r255542 r275490  
    107107private:
    108108    void appendVariant(const InstanceOfVariant&);
     109    void shrinkToFit();
    109110   
    110111    State m_state;
  • trunk/Source/JavaScriptCore/bytecode/IntrinsicGetterAccessCase.cpp

    r262054 r275490  
    3434namespace JSC {
    3535
    36 IntrinsicGetterAccessCase::IntrinsicGetterAccessCase(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     36IntrinsicGetterAccessCase::IntrinsicGetterAccessCase(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    3737    : Base(vm, owner, IntrinsicGetter, identifier, offset, structure, conditionSet, WTFMove(prototypeAccessChain))
    3838{
     
    4040}
    4141
    42 std::unique_ptr<AccessCase> IntrinsicGetterAccessCase::create(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     42std::unique_ptr<AccessCase> IntrinsicGetterAccessCase::create(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    4343{
    4444    return std::unique_ptr<AccessCase>(new IntrinsicGetterAccessCase(vm, owner, identifier, offset, structure, conditionSet, intrinsicFunction, WTFMove(prototypeAccessChain)));
  • trunk/Source/JavaScriptCore/bytecode/IntrinsicGetterAccessCase.h

    r261567 r275490  
    4343    void emitIntrinsicGetter(AccessGenerationState&);
    4444
    45     static std::unique_ptr<AccessCase> create(VM&, JSCell*, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, JSFunction* intrinsicFunction, std::unique_ptr<PolyProtoAccessChain>);
     45    static std::unique_ptr<AccessCase> create(VM&, JSCell*, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, JSFunction* intrinsicFunction, RefPtr<PolyProtoAccessChain>&&);
    4646
    4747    std::unique_ptr<AccessCase> clone() const final;
     
    5050
    5151private:
    52     IntrinsicGetterAccessCase(VM&, JSCell*, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, JSFunction* intrinsicFunction, std::unique_ptr<PolyProtoAccessChain>);
     52    IntrinsicGetterAccessCase(VM&, JSCell*, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, JSFunction* intrinsicFunction, RefPtr<PolyProtoAccessChain>&&);
    5353
    5454    WriteBarrier<JSFunction> m_intrinsicFunction;
  • trunk/Source/JavaScriptCore/bytecode/JumpTable.h

    r255687 r275490  
    3131
    3232#include "CodeLocation.h"
    33 #include <wtf/HashMap.h>
     33#include <wtf/RobinHoodHashMap.h>
    3434#include <wtf/Vector.h>
    3535#include <wtf/text/StringImpl.h>
     
    4545
    4646    struct StringJumpTable {
    47         typedef HashMap<RefPtr<StringImpl>, OffsetLocation> StringOffsetTable;
     47        using StringOffsetTable = MemoryCompactLookupOnlyRobinHoodHashMap<RefPtr<StringImpl>, OffsetLocation>;
    4848        StringOffsetTable offsetTable;
    4949#if ENABLE(JIT)
  • trunk/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.cpp

    r261895 r275490  
    3131namespace JSC {
    3232
    33 std::unique_ptr<PolyProtoAccessChain> PolyProtoAccessChain::create(JSGlobalObject* globalObject, JSCell* base, const PropertySlot& slot)
     33RefPtr<PolyProtoAccessChain> PolyProtoAccessChain::tryCreate(JSGlobalObject* globalObject, JSCell* base, const PropertySlot& slot)
    3434{
    3535    JSObject* target = slot.isUnset() ? nullptr : slot.slotBase();
    36     return create(globalObject, base, target);
     36    return tryCreate(globalObject, base, target);
    3737}
    3838
    39 std::unique_ptr<PolyProtoAccessChain> PolyProtoAccessChain::create(JSGlobalObject* globalObject, JSCell* base, JSObject* target)
     39RefPtr<PolyProtoAccessChain> PolyProtoAccessChain::tryCreate(JSGlobalObject* globalObject, JSCell* base, JSObject* target)
    4040{
    4141    JSCell* current = base;
     
    4444    bool found = false;
    4545
    46     std::unique_ptr<PolyProtoAccessChain> result(new PolyProtoAccessChain());
    47 
     46    Vector<StructureID> chain;
    4847    for (unsigned iterationNumber = 0; true; ++iterationNumber) {
    4948        Structure* structure = current->structure(vm);
     
    6160        // AccessCase provide the base to us as needed.
    6261        if (iterationNumber)
    63             result->m_chain.append(structure->id());
     62            chain.append(structure->id());
    6463        else
    6564            RELEASE_ASSERT(current == base);
     
    7978        return nullptr;
    8079
    81     result->m_chain.shrinkToFit();
    82     return result;
     80    return adoptRef(*new PolyProtoAccessChain(WTFMove(chain)));
    8381}
    8482
  • trunk/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h

    r255711 r275490  
    2828#include "StructureIDTable.h"
    2929#include "VM.h"
     30#include <wtf/RefCountedArray.h>
    3031#include <wtf/Vector.h>
    3132
     
    3839class Structure;
    3940
    40 class PolyProtoAccessChain {
    41     WTF_MAKE_FAST_ALLOCATED;
     41class PolyProtoAccessChain final : public ThreadSafeRefCounted<PolyProtoAccessChain> {
     42public:
     43    // Returns nullptr when invalid.
     44    static RefPtr<PolyProtoAccessChain> tryCreate(JSGlobalObject*, JSCell* base, const PropertySlot&);
     45    static RefPtr<PolyProtoAccessChain> tryCreate(JSGlobalObject*, JSCell* base, JSObject* target);
    4246
    43 public:
    44     PolyProtoAccessChain(PolyProtoAccessChain&) = default;
    45 
    46     // Returns nullptr when invalid.
    47     static std::unique_ptr<PolyProtoAccessChain> create(JSGlobalObject*, JSCell* base, const PropertySlot&);
    48     static std::unique_ptr<PolyProtoAccessChain> create(JSGlobalObject*, JSCell* base, JSObject* target);
    49 
    50     std::unique_ptr<PolyProtoAccessChain> clone()
    51     {
    52         return makeUnique<PolyProtoAccessChain>(*this);
    53     }
    54 
    55     const Vector<StructureID>& chain() const { return m_chain; }
     47    const RefCountedArray<StructureID>& chain() const { return m_chain; }
    5648
    5749    void dump(Structure* baseStructure, PrintStream& out) const;
     
    8476
    8577private:
    86     PolyProtoAccessChain() = default;
     78    explicit PolyProtoAccessChain(Vector<StructureID>&& chain)
     79        : m_chain(WTFMove(chain))
     80    {
     81    }
    8782
    8883    // This does not include the base. We rely on AccessCase providing it for us. That said, this data
    8984    // structure is tied to the base that it was created with.
    90     Vector<StructureID> m_chain;
     85    RefCountedArray<StructureID> m_chain;
    9186};
    9287
  • trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp

    r273138 r275490  
    350350            return false;
    351351    }
    352     if (Vector<WriteBarrier<JSCell>>* weakReferences = m_weakReferences.get()) {
    353         for (WriteBarrier<JSCell>& weakReference : *weakReferences) {
    354             if (!vm.heap.isMarked(weakReference.get()))
    355                 return false;
    356         }
     352    for (const WriteBarrier<JSCell>& weakReference : m_weakReferences) {
     353        if (!vm.heap.isMarked(weakReference.get()))
     354            return false;
    357355    }
    358356    return true;
     
    750748    m_stubRoutine = createJITStubRoutine(code, vm, codeBlock, doesCalls, cellsToMark, WTFMove(state.m_callLinkInfos), codeBlockThatOwnsExceptionHandlers, callSiteIndexForExceptionHandling);
    751749    m_watchpoints = WTFMove(state.watchpoints);
    752     if (!state.weakReferences.isEmpty()) {
    753         state.weakReferences.shrinkToFit();
    754         m_weakReferences = makeUnique<Vector<WriteBarrier<JSCell>>>(WTFMove(state.weakReferences));
    755     }
     750    if (!state.weakReferences.isEmpty())
     751        m_weakReferences = RefCountedArray<WriteBarrier<JSCell>>(WTFMove(state.weakReferences));
    756752    if (PolymorphicAccessInternal::verbose)
    757753        dataLog("Returning: ", code.code(), "\n");
  • trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.h

    r273138 r275490  
    3333#include "MacroAssembler.h"
    3434#include "ScratchRegisterAllocator.h"
     35#include <wtf/RefCountedArray.h>
    3536#include <wtf/Vector.h>
    3637
     
    188189    RefPtr<JITStubRoutine> m_stubRoutine;
    189190    std::unique_ptr<WatchpointsOnStructureStubInfo> m_watchpoints;
    190     std::unique_ptr<Vector<WriteBarrier<JSCell>>> m_weakReferences;
     191    RefCountedArray<WriteBarrier<JSCell>> m_weakReferences;
    191192};
    192193
  • trunk/Source/JavaScriptCore/bytecode/ProxyableAccessCase.cpp

    r265600 r275490  
    3232
    3333ProxyableAccessCase::ProxyableAccessCase(VM& vm, JSCell* owner, AccessType accessType, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure,
    34     const ObjectPropertyConditionSet& conditionSet, bool viaProxy, WatchpointSet* additionalSet, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     34    const ObjectPropertyConditionSet& conditionSet, bool viaProxy, WatchpointSet* additionalSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    3535    : Base(vm, owner, accessType, identifier, offset, structure, conditionSet, WTFMove(prototypeAccessChain))
    3636    , m_additionalSet(additionalSet)
     
    3939}
    4040
    41 std::unique_ptr<AccessCase> ProxyableAccessCase::create(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, bool viaProxy, WatchpointSet* additionalSet, std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain)
     41std::unique_ptr<AccessCase> ProxyableAccessCase::create(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, bool viaProxy, WatchpointSet* additionalSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain)
    4242{
    4343    ASSERT(type == Load || type == Miss || type == GetGetter || type == Replace);
  • trunk/Source/JavaScriptCore/bytecode/ProxyableAccessCase.h

    r261567 r275490  
    3939
    4040    static std::unique_ptr<AccessCase> create(VM&, JSCell*, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet& = ObjectPropertyConditionSet(),
    41         bool viaProxy = false, WatchpointSet* additionalSet = nullptr, std::unique_ptr<PolyProtoAccessChain> = nullptr);
     41        bool viaProxy = false, WatchpointSet* additionalSet = nullptr, RefPtr<PolyProtoAccessChain>&& = nullptr);
    4242
    4343    void dumpImpl(PrintStream&, CommaPrinter&) const override;
     
    4747
    4848protected:
    49     ProxyableAccessCase(VM&, JSCell*, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, bool viaProxy, WatchpointSet* additionalSet, std::unique_ptr<PolyProtoAccessChain>);
     49    ProxyableAccessCase(VM&, JSCell*, AccessType, CacheableIdentifier, PropertyOffset, Structure*, const ObjectPropertyConditionSet&, bool viaProxy, WatchpointSet* additionalSet, RefPtr<PolyProtoAccessChain>&&);
    5050
    5151private:
  • trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.cpp

    r273138 r275490  
    4242{
    4343    return appendICStatusVariant(m_variants, variant);
     44}
     45
     46void PutByIdStatus::shrinkToFit()
     47{
     48    m_variants.shrinkToFit();
    4449}
    4550
     
    230235        }
    231236       
     237        result.shrinkToFit();
    232238        return result;
    233239    }
     
    372378    }
    373379   
     380    result.shrinkToFit();
    374381    return result;
    375382}
     
    438445                return mergeSlow();
    439446        }
     447        shrinkToFit();
    440448        return;
    441449       
  • trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.h

    r273138 r275490  
    136136   
    137137    bool appendVariant(const PutByIdVariant&);
     138    void shrinkToFit();
    138139   
    139140    State m_state;
  • trunk/Source/JavaScriptCore/bytecode/SetPrivateBrandStatus.cpp

    r273138 r275490  
    4242}
    4343
     44void SetPrivateBrandStatus::shrinkToFit()
     45{
     46    m_variants.shrinkToFit();
     47}
     48
    4449SetPrivateBrandStatus SetPrivateBrandStatus::computeForBaseline(CodeBlock* baselineBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit)
    4550{
     
    114119        }
    115120
     121        result.shrinkToFit();
    116122        return result;
    117123    }
     
    196202                return mergeSlow();
    197203        }
     204        shrinkToFit();
    198205        return;
    199206
  • trunk/Source/JavaScriptCore/bytecode/SetPrivateBrandStatus.h

    r273138 r275490  
    8989
    9090    bool appendVariant(const SetPrivateBrandVariant&);
     91    void shrinkToFit();
    9192
    9293    void dump(PrintStream&) const;
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h

    r273931 r275490  
    4343#include <algorithm>
    4444#include <wtf/BitVector.h>
    45 #include <wtf/HashSet.h>
    4645#include <wtf/RefCountedArray.h>
     46#include <wtf/RobinHoodHashMap.h>
    4747#include <wtf/TriState.h>
    4848#include <wtf/Vector.h>
     
    8181    };
    8282
    83     typedef HashMap<RefPtr<StringImpl>, OffsetLocation> StringOffsetTable;
     83    using StringOffsetTable = MemoryCompactLookupOnlyRobinHoodHashMap<RefPtr<StringImpl>, OffsetLocation>;
    8484    StringOffsetTable offsetTable;
    8585
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r273931 r275490  
    5757    JSParserScriptMode scriptMode = executable->scriptMode();
    5858    ASSERT(isFunctionParseMode(executable->parseMode()));
    59     Vector<JSTextPosition>* classFieldLocations = executable->classFieldLocations();
     59    auto* classFieldLocations = executable->classFieldLocations();
    6060    std::unique_ptr<FunctionNode> function = parse<FunctionNode>(
    6161        vm, source, executable->name(), builtinMode, strictMode, scriptMode, executable->parseMode(), executable->superBinding(), error, nullptr, ConstructorKind::None, DerivedContextType::None, EvalContextType::None, nullptr, nullptr, classFieldLocations);
     
    7474
    7575    auto parentScopeTDZVariables = executable->parentScopeTDZVariables();
    76     PrivateNameEnvironment parentPrivateNameEnvironment = executable->parentPrivateNameEnvironment();
     76    const PrivateNameEnvironment* parentPrivateNameEnvironment = executable->parentPrivateNameEnvironment();
    7777    ECMAMode ecmaMode = executable->isInStrictContext() ? ECMAMode::strict() : ECMAMode::sloppy();
    78     error = BytecodeGenerator::generate(vm, function.get(), source, result, codeGenerationMode, parentScopeTDZVariables, &parentPrivateNameEnvironment, ecmaMode);
     78    error = BytecodeGenerator::generate(vm, function.get(), source, result, codeGenerationMode, parentScopeTDZVariables, parentPrivateNameEnvironment, ecmaMode);
    7979
    8080    if (error.isValid())
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r273138 r275490  
    4040#include "VariableEnvironment.h"
    4141#include <wtf/Optional.h>
     42#include <wtf/RefCountedArray.h>
    4243
    4344namespace JSC {
     
    178179    }
    179180
    180     PrivateNameEnvironment parentPrivateNameEnvironment() const
     181    const PrivateNameEnvironment* parentPrivateNameEnvironment() const
    181182    {
    182183        if (!m_rareData)
    183             return PrivateNameEnvironment();
    184         return m_rareData->m_parentPrivateNameEnvironment;
     184            return nullptr;
     185        return &m_rareData->m_parentPrivateNameEnvironment;
    185186    }
    186187   
     
    219220        String m_sourceMappingURLDirective;
    220221        RefPtr<TDZEnvironmentLink> m_parentScopeTDZVariables;
    221         Vector<JSTextPosition> m_classFieldLocations;
     222        RefCountedArray<JSTextPosition> m_classFieldLocations;
    222223        PrivateNameEnvironment m_parentPrivateNameEnvironment;
    223224    };
     
    225226    NeedsClassFieldInitializer needsClassFieldInitializer() const { return static_cast<NeedsClassFieldInitializer>(m_needsClassFieldInitializer); }
    226227
    227     Vector<JSTextPosition>* classFieldLocations() const
     228    RefCountedArray<JSTextPosition>* classFieldLocations() const
    228229    {
    229230        if (m_rareData)
     
    236237        if (classFieldLocations.isEmpty())
    237238            return;
    238         ensureRareData().m_classFieldLocations = WTFMove(classFieldLocations);
     239        ensureRareData().m_classFieldLocations = RefCountedArray<JSTextPosition>(WTFMove(classFieldLocations));
    239240    }
    240241
  • trunk/Source/JavaScriptCore/dfg/DFGJITCode.h

    r261567 r275490  
    152152    // The key may not always be a target for OSR Entry but the list in the value is guaranteed
    153153    // to be usable for OSR Entry.
    154     HashMap<BytecodeIndex, Vector<BytecodeIndex>> tierUpInLoopHierarchy;
     154    HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>> tierUpInLoopHierarchy;
    155155
    156156    // Map each bytecode of CheckTierUpAndOSREnter to its stream index.
  • trunk/Source/JavaScriptCore/dfg/DFGPlan.h

    r273138 r275490  
    107107    void setWillTryToTierUp(bool willTryToTierUp) { m_willTryToTierUp = willTryToTierUp; }
    108108
    109     HashMap<BytecodeIndex, Vector<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; }
     109    HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; }
    110110    Vector<BytecodeIndex>& tierUpAndOSREnterBytecodes() { return m_tierUpAndOSREnterBytecodes; }
    111111
     
    160160    RecordedStatuses m_recordedStatuses;
    161161
    162     HashMap<BytecodeIndex, Vector<BytecodeIndex>> m_tierUpInLoopHierarchy;
     162    HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>> m_tierUpInLoopHierarchy;
    163163    Vector<BytecodeIndex> m_tierUpAndOSREnterBytecodes;
    164164
  • trunk/Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp

    r262928 r275490  
    148148
    149149            if (!tierUpCandidates.isEmpty())
    150                 m_graph.m_plan.tierUpInLoopHierarchy().add(entry.key, WTFMove(tierUpCandidates));
     150                m_graph.m_plan.tierUpInLoopHierarchy().add(entry.key, tierUpCandidates);
    151151        }
    152152        m_graph.m_plan.setWillTryToTierUp(true);
  • trunk/Source/JavaScriptCore/heap/BlockDirectoryBits.h

    r252452 r275490  
    223223
    224224private:
    225     Vector<Segment> m_segments;
     225    Vector<Segment, 0, CrashOnOverflow, 2> m_segments;
    226226    unsigned m_numBits { 0 };
    227227};
  • trunk/Source/JavaScriptCore/heap/JITStubRoutineSet.cpp

    r273138 r275490  
    126126        routine.routine->deleteFromGC();
    127127    }
    128     m_routines.shrink(dstIndex);
     128    m_routines.shrinkCapacity(dstIndex);
    129129}
    130130
  • trunk/Source/JavaScriptCore/jit/CallFrameShuffleData.h

    r250094 r275490  
    3636    WTF_MAKE_FAST_ALLOCATED;
    3737public:
     38    void shrinkToFit()
     39    {
     40        args.shrinkToFit();
     41    }
     42
    3843    Vector<ValueRecovery> args;
    3944    unsigned numLocals { UINT_MAX };
  • trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h

    r273138 r275490  
    3131#include "JSObject.h"
    3232#include "WriteBarrier.h"
     33#include <wtf/RefCountedArray.h>
    3334#include <wtf/Vector.h>
    3435
     
    9798
    9899private:
    99     Vector<WriteBarrier<JSCell>> m_cells;
     100    RefCountedArray<WriteBarrier<JSCell>> m_cells;
    100101    Bag<CallLinkInfo> m_callLinkInfos;
    101102};
  • trunk/Source/JavaScriptCore/jit/PolymorphicCallStubRoutine.h

    r273138 r275490  
    110110    void markRequiredObjectsInternal(SlotVisitor&) final;
    111111
    112     Vector<WriteBarrier<JSCell>, 2> m_variants;
     112    RefCountedArray<WriteBarrier<JSCell>> m_variants;
    113113    UniqueArray<uint32_t> m_fastCounts;
    114114    Bag<PolymorphicCallNode> m_callNodes;
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r272580 r275490  
    294294            }
    295295
    296             std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
     296            RefPtr<PolyProtoAccessChain> prototypeAccessChain;
    297297
    298298            PropertyOffset offset = slot.isUnset() ? invalidOffset : slot.cachedOffset();
     
    334334
    335335                    if (cacheStatus->usesPolyProto) {
    336                         prototypeAccessChain = PolyProtoAccessChain::create(globalObject, baseCell, slot);
     336                        prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, slot);
    337337                        if (!prototypeAccessChain)
    338338                            return GiveUpOnCache;
     
    695695                ASSERT(newStructure->isObject());
    696696               
    697                 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
     697                RefPtr<PolyProtoAccessChain> prototypeAccessChain;
    698698                ObjectPropertyConditionSet conditionSet;
    699699                if (putKind == PutKind::NotDirect) {
     
    703703
    704704                    if (cacheStatus->usesPolyProto) {
    705                         prototypeAccessChain = PolyProtoAccessChain::create(globalObject, baseCell, nullptr);
     705                        prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, nullptr);
    706706                        if (!prototypeAccessChain)
    707707                            return GiveUpOnCache;
     
    727727            if (slot.isCacheableCustom()) {
    728728                ObjectPropertyConditionSet conditionSet;
    729                 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
     729                RefPtr<PolyProtoAccessChain> prototypeAccessChain;
    730730
    731731                // We need to do this even if we're a self custom, since we must disallow dictionaries
     
    738738                if (slot.base() != baseValue) {
    739739                    if (cacheStatus->usesPolyProto) {
    740                         prototypeAccessChain = PolyProtoAccessChain::create(globalObject, baseCell, slot.base());
     740                        prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, slot.base());
    741741                        if (!prototypeAccessChain)
    742742                            return GiveUpOnCache;
     
    756756                ASSERT(slot.isCacheableSetter());
    757757                ObjectPropertyConditionSet conditionSet;
    758                 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
     758                RefPtr<PolyProtoAccessChain> prototypeAccessChain;
    759759                PropertyOffset offset = slot.cachedOffset();
    760760
     
    767767
    768768                    if (cacheStatus->usesPolyProto) {
    769                         prototypeAccessChain = PolyProtoAccessChain::create(globalObject, baseCell, slot.base());
     769                        prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, slot.base());
    770770                        if (!prototypeAccessChain)
    771771                            return GiveUpOnCache;
     
    921921        Structure* structure = base->structure(vm);
    922922       
    923         std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;
     923        RefPtr<PolyProtoAccessChain> prototypeAccessChain;
    924924        ObjectPropertyConditionSet conditionSet;
    925925        if (wasFound) {
     
    952952
    953953                if (cacheStatus->usesPolyProto) {
    954                     prototypeAccessChain = PolyProtoAccessChain::create(globalObject, base, slot);
     954                    prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, base, slot);
    955955                    if (!prototypeAccessChain)
    956956                        return GiveUpOnCache;
     
    971971
    972972            if (cacheStatus->usesPolyProto) {
    973                 prototypeAccessChain = PolyProtoAccessChain::create(globalObject, base, slot);
     973                prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, base, slot);
    974974                if (!prototypeAccessChain)
    975975                    return GiveUpOnCache;
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r275439 r275490  
    216216
    217217template <typename LexerType>
    218 Expected<typename Parser<LexerType>::ParseInnerResult, String> Parser<LexerType>::parseInner(const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const Vector<JSTextPosition>* classFieldLocations, const PrivateNameEnvironment* parentScopePrivateNames)
     218Expected<typename Parser<LexerType>::ParseInnerResult, String> Parser<LexerType>::parseInner(const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const RefCountedArray<JSTextPosition>* classFieldLocations, const PrivateNameEnvironment* parentScopePrivateNames)
    219219{
    220220    ASTBuilder context(const_cast<VM&>(m_vm), m_parserArena, const_cast<SourceCode*>(m_source));
     
    31813181
    31823182template <typename LexerType>
    3183 template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const Vector<JSTextPosition>& classFieldLocations)
     3183template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const RefCountedArray<JSTextPosition>& classFieldLocations)
    31843184{
    31853185    TreeSourceElements sourceElements = context.createSourceElements();
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r274102 r275490  
    3838#include <wtf/Forward.h>
    3939#include <wtf/Noncopyable.h>
     40#include <wtf/RefCountedArray.h>
    4041#include <wtf/RefPtr.h>
    4142
     
    992993
    993994    template <class ParsedNode>
    994     std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const Vector<JSTextPosition>* = nullptr);
     995    std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const RefCountedArray<JSTextPosition>* = nullptr);
    995996
    996997    JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
     
    15121513        int numConstants;
    15131514    };
    1514     Expected<ParseInnerResult, String> parseInner(const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition, const Vector<JSTextPosition>*, const PrivateNameEnvironment* parentScopePrivateNames);
     1515    Expected<ParseInnerResult, String> parseInner(const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition, const RefCountedArray<JSTextPosition>*, const PrivateNameEnvironment* parentScopePrivateNames);
    15151516
    15161517    // Used to determine type of error to report.
     
    17431744    template <class TreeBuilder> TreeSourceElements parseAsyncGeneratorFunctionSourceElements(TreeBuilder&, bool isArrowFunctionBodyExpression, SourceElementsMode);
    17441745    template <class TreeBuilder> TreeSourceElements parseSingleFunction(TreeBuilder&, Optional<int> functionConstructorParametersEndPosition);
    1745     template <class TreeBuilder> TreeSourceElements parseClassFieldInitializerSourceElements(TreeBuilder&, const Vector<JSTextPosition>&);
     1746    template <class TreeBuilder> TreeSourceElements parseClassFieldInitializerSourceElements(TreeBuilder&, const RefCountedArray<JSTextPosition>&);
    17461747    template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength);
    17471748    template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = nullptr);
     
    21282129template <typename LexerType>
    21292130template <class ParsedNode>
    2130 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const Vector<JSTextPosition>* classFieldLocations)
     2131std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const RefCountedArray<JSTextPosition>* classFieldLocations)
    21312132{
    21322133    int errLine;
     
    22292230    DebuggerParseData* debuggerParseData = nullptr,
    22302231    const PrivateNameEnvironment* parentScopePrivateNames = nullptr,
    2231     const Vector<JSTextPosition>* classFieldLocations = nullptr,
     2232    const RefCountedArray<JSTextPosition>* classFieldLocations = nullptr,
    22322233    bool isInsideOrdinaryFunction = false)
    22332234{
  • trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp

    r273931 r275490  
    4444#include <wtf/Optional.h>
    4545#include <wtf/Packed.h>
     46#include <wtf/RobinHoodHashMap.h>
    4647#include <wtf/UUID.h>
    4748#include <wtf/text/AtomStringImpl.h>
     
    670671};
    671672
    672 template<typename Key, typename Value, typename HashArg = DefaultHash<SourceType<Key>>, typename KeyTraitsArg = HashTraits<SourceType<Key>>, typename MappedTraitsArg = HashTraits<SourceType<Value>>>
    673 class CachedHashMap : public VariableLengthObject<HashMap<SourceType<Key>, SourceType<Value>, HashArg, KeyTraitsArg, MappedTraitsArg>> {
     673template<typename Key, typename Value, typename HashArg = DefaultHash<SourceType<Key>>, typename KeyTraitsArg = HashTraits<SourceType<Key>>, typename MappedTraitsArg = HashTraits<SourceType<Value>>, typename TableTraits = WTF::HashTableTraits>
     674class CachedHashMap : public VariableLengthObject<HashMap<SourceType<Key>, SourceType<Value>, HashArg, KeyTraitsArg, MappedTraitsArg, TableTraits>> {
    674675    template<typename K, typename V>
    675     using Map = HashMap<K, V, HashArg, KeyTraitsArg, MappedTraitsArg>;
     676    using Map = HashMap<K, V, HashArg, KeyTraitsArg, MappedTraitsArg, TableTraits>;
    676677
    677678public:
     
    696697    CachedVector<CachedPair<Key, Value>> m_entries;
    697698};
     699
     700template<typename Key, typename Value, typename HashArg = DefaultHash<SourceType<Key>>, typename KeyTraitsArg = HashTraits<SourceType<Key>>, typename MappedTraitsArg = HashTraits<SourceType<Value>>>
     701using CachedMemoryCompactLookupOnlyRobinHoodHashMap = CachedHashMap<Key, Value, HashArg, KeyTraitsArg, MappedTraitsArg, WTF::MemoryCompactLookupOnlyRobinHoodHashTableTraits>;
    698702
    699703template<typename T>
     
    911915
    912916private:
    913     CachedHashMap<CachedRefPtr<CachedStringImpl>, UnlinkedStringJumpTable:: OffsetLocation> m_offsetTable;
     917    CachedMemoryCompactLookupOnlyRobinHoodHashMap<CachedRefPtr<CachedStringImpl>, UnlinkedStringJumpTable::OffsetLocation> m_offsetTable;
    914918};
    915919
     
    17771781        m_classSource.encode(encoder, rareData.m_classSource);
    17781782        m_parentScopeTDZVariables.encode(encoder, rareData.m_parentScopeTDZVariables);
     1783        m_classFieldLocations.encode(encoder, rareData.m_classFieldLocations);
    17791784        m_parentPrivateNameEnvironment.encode(encoder, rareData.m_parentPrivateNameEnvironment);
    17801785    }
     
    17851790        m_classSource.decode(decoder, rareData->m_classSource);
    17861791        m_parentScopeTDZVariables.decode(decoder, rareData->m_parentScopeTDZVariables);
     1792        m_classFieldLocations.decode(decoder, rareData->m_classFieldLocations);
    17871793        m_parentPrivateNameEnvironment.decode(decoder, rareData->m_parentPrivateNameEnvironment);
    17881794        return rareData;
     
    17921798    CachedSourceCodeWithoutProvider m_classSource;
    17931799    CachedRefPtr<CachedTDZEnvironmentLink> m_parentScopeTDZVariables;
     1800    CachedVector<JSTextPosition> m_classFieldLocations;
    17941801    CachedPrivateNameEnvironment m_parentPrivateNameEnvironment;
    17951802};
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r274817 r275490  
    11281128    while (m_checkpointSideState.size() && bounds.contains(m_checkpointSideState.last()->associatedCallFrame))
    11291129        m_checkpointSideState.takeLast();
     1130    m_checkpointSideState.shrinkToFit();
    11301131}
    11311132
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp

    r274609 r275490  
    8585    visitor.append(thisObject->m_moduleRecord);
    8686    visitor.append(thisObject->m_memory);
    87     for (unsigned i = 0; i < thisObject->instance().module().moduleInformation().tableCount(); ++i)
    88         visitor.append(thisObject->m_tables[i]);
     87    for (auto& table : thisObject->m_tables)
     88        visitor.append(table);
    8989    visitor.reportExtraMemoryVisited(thisObject->m_instance->extraMemoryAllocated());
    9090    for (unsigned i = 0; i < thisObject->instance().numImportFunctions(); ++i)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h

    r273138 r275490  
    3636#include "WasmInstance.h"
    3737#include <wtf/Ref.h>
     38#include <wtf/RefCountedArray.h>
    3839
    3940namespace JSC {
     
    116117    WriteBarrier<WebAssemblyModuleRecord> m_moduleRecord;
    117118    WriteBarrier<JSWebAssemblyMemory> m_memory;
    118     Vector<WriteBarrier<JSWebAssemblyTable>> m_tables;
     119    RefCountedArray<WriteBarrier<JSWebAssemblyTable>> m_tables;
    119120};
    120121
  • trunk/Source/WTF/ChangeLog

    r275484 r275490  
     12021-04-05  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Shrink some of Vectors in JSC
     4        https://bugs.webkit.org/show_bug.cgi?id=224162
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add rbegin and rend to make RefCountedArray usable for Vector clients who use these features.
     9
     10        * wtf/RefCountedArray.h:
     11        (WTF::RefCountedArray::begin):
     12        (WTF::RefCountedArray::end):
     13        (WTF::RefCountedArray::begin const):
     14        (WTF::RefCountedArray::end const):
     15        (WTF::RefCountedArray::rbegin):
     16        (WTF::RefCountedArray::rend):
     17        (WTF::RefCountedArray::rbegin const):
     18        (WTF::RefCountedArray::rend const):
     19
    1202021-04-05  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WTF/wtf/RefCountedArray.h

    r268993 r275490  
    5151
    5252public:
     53    using iterator = T*;
     54    using const_iterator = const T*;
     55    using reverse_iterator = std::reverse_iterator<iterator>;
     56    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
     57
    5358    RefCountedArray() = default;
    5459   
     
    170175   
    171176    T* data() { return PtrTraits::unwrap(m_data); }
    172     T* begin() { return data(); }
    173     T* end()
     177    iterator begin() { return data(); }
     178    iterator end()
    174179    {
    175180        if (!m_data)
     
    180185   
    181186    const T* data() const { return const_cast<RefCountedArray*>(this)->data(); }
    182     const T* begin() const { return const_cast<RefCountedArray*>(this)->begin(); }
    183     const T* end() const { return const_cast<RefCountedArray*>(this)->end(); }
     187    const_iterator begin() const { return const_cast<RefCountedArray*>(this)->begin(); }
     188    const_iterator end() const { return const_cast<RefCountedArray*>(this)->end(); }
     189
     190    reverse_iterator rbegin() { return reverse_iterator(end()); }
     191    reverse_iterator rend() { return reverse_iterator(begin()); }
     192    const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
     193    const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
    184194   
    185195    T& at(size_t i)
Note: See TracChangeset for help on using the changeset viewer.