Changeset 275490 in webkit
- Timestamp:
- Apr 5, 2021 9:25:33 PM (3 years ago)
- Location:
- trunk/Source
- Files:
-
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r275484 r275490 1 2021-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 1 127 2021-04-05 Alex Christensen <achristensen@webkit.org> 2 128 -
trunk/Source/JavaScriptCore/bytecode/AccessCase.cpp
r275392 r275490 58 58 DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(AccessCase); 59 59 60 AccessCase::AccessCase(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, std::unique_ptr<PolyProtoAccessChain>prototypeAccessChain)60 AccessCase::AccessCase(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain) 61 61 : m_type(type) 62 62 , m_offset(offset) … … 69 69 } 70 70 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)71 std::unique_ptr<AccessCase> AccessCase::create(VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain) 72 72 { 73 73 switch (type) { … … 111 111 std::unique_ptr<AccessCase> AccessCase::createTransition( 112 112 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) 114 114 { 115 115 RELEASE_ASSERT(oldStructure == newStructure->previousID()); -
trunk/Source/JavaScriptCore/bytecode/AccessCase.h
r273138 r275490 149 149 150 150 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); 152 152 153 153 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>&&); 155 155 156 156 static std::unique_ptr<AccessCase> createDelete(VM&, JSCell* owner, CacheableIdentifier, PropertyOffset, Structure* oldStructure, … … 256 256 257 257 protected: 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>&&); 259 259 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; 272 261 273 262 AccessCase& operator=(const AccessCase&) = delete; … … 322 311 ObjectPropertyConditionSet m_conditionSet; 323 312 324 std::unique_ptr<PolyProtoAccessChain> m_polyProtoAccessChain;313 RefPtr<PolyProtoAccessChain> m_polyProtoAccessChain; 325 314 326 315 CacheableIdentifier m_identifier; -
trunk/Source/JavaScriptCore/bytecode/CallLinkInfo.cpp
r266359 r275490 282 282 { 283 283 m_frameShuffleData = makeUnique<CallFrameShuffleData>(shuffleData); 284 m_frameShuffleData->shrinkToFit(); 284 285 } 285 286 -
trunk/Source/JavaScriptCore/bytecode/CheckPrivateBrandStatus.cpp
r273138 r275490 42 42 } 43 43 44 void CheckPrivateBrandStatus::shrinkToFit() 45 { 46 m_variants.shrinkToFit(); 47 } 48 44 49 CheckPrivateBrandStatus CheckPrivateBrandStatus::computeForBaseline(CodeBlock* baselineBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit) 45 50 { … … 110 115 } 111 116 117 result.shrinkToFit(); 112 118 return result; 113 119 } … … 192 198 return mergeSlow(); 193 199 } 200 shrinkToFit(); 194 201 return; 195 202 -
trunk/Source/JavaScriptCore/bytecode/CheckPrivateBrandStatus.h
r273138 r275490 88 88 89 89 bool appendVariant(const CheckPrivateBrandVariant&); 90 void shrinkToFit(); 90 91 91 92 void dump(PrintStream&) const; -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r273972 r275490 438 438 439 439 if (size_t count = unlinkedCodeBlock->numberOfStringSwitchJumpTables()) { 440 m_rareData->m_stringSwitchJumpTables. grow(count);440 m_rareData->m_stringSwitchJumpTables.resizeToFit(count); 441 441 for (size_t i = 0; i < count; i++) { 442 442 UnlinkedStringJumpTable::StringOffsetTable::iterator ptr = unlinkedCodeBlock->stringSwitchJumpTable(i).offsetTable.begin(); … … 451 451 452 452 if (size_t count = unlinkedCodeBlock->numberOfSwitchJumpTables()) { 453 m_rareData->m_switchJumpTables. grow(count);453 m_rareData->m_switchJumpTables.resizeToFit(count); 454 454 for (size_t i = 0; i < count; i++) { 455 455 UnlinkedSimpleJumpTable& sourceTable = unlinkedCodeBlock->switchJumpTable(i); -
trunk/Source/JavaScriptCore/bytecode/DeleteByStatus.cpp
r273138 r275490 41 41 } 42 42 43 void DeleteByStatus::shrinkToFit() 44 { 45 m_variants.shrinkToFit(); 46 } 47 43 48 DeleteByStatus DeleteByStatus::computeForBaseline(CodeBlock* baselineBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit) 44 49 { … … 130 135 } 131 136 137 result.shrinkToFit(); 132 138 return result; 133 139 } … … 215 221 return mergeSlow(); 216 222 } 223 shrinkToFit(); 217 224 return; 218 225 -
trunk/Source/JavaScriptCore/bytecode/DeleteByStatus.h
r273138 r275490 87 87 88 88 bool appendVariant(const DeleteByIdVariant&); 89 void shrinkToFit(); 89 90 90 91 void dump(PrintStream&) const; -
trunk/Source/JavaScriptCore/bytecode/GetByStatus.cpp
r273138 r275490 44 44 { 45 45 return appendICStatusVariant(m_variants, variant); 46 } 47 48 void GetByStatus::shrinkToFit() 49 { 50 m_variants.shrinkToFit(); 46 51 } 47 52 … … 340 345 } 341 346 347 result.shrinkToFit(); 342 348 return result; 343 349 } … … 434 440 } 435 441 442 result.shrinkToFit(); 436 443 return result; 437 444 } … … 495 502 return mergeSlow(); 496 503 } 504 shrinkToFit(); 497 505 return; 498 506 -
trunk/Source/JavaScriptCore/bytecode/GetByStatus.h
r273138 r275490 124 124 125 125 bool appendVariant(const GetByIdVariant&); 126 void shrinkToFit(); 126 127 127 128 void dump(PrintStream&) const; -
trunk/Source/JavaScriptCore/bytecode/GetterSetterAccessCase.cpp
r270764 r275490 42 42 } 43 43 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)44 GetterSetterAccessCase::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) 45 45 : Base(vm, owner, accessType, identifier, offset, structure, conditionSet, viaProxy, additionalSet, WTFMove(prototypeAccessChain)) 46 46 { … … 51 51 VM& vm, JSCell* owner, AccessType type, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, 52 52 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) 54 54 { 55 55 switch (type) { … … 69 69 70 70 std::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, 72 72 FunctionPtr<CustomAccessorPtrTag> customSetter, JSObject* customSlotBase) 73 73 { -
trunk/Source/JavaScriptCore/bytecode/GetterSetterAccessCase.h
r270764 r275490 57 57 VM&, JSCell* owner, AccessType, CacheableIdentifier, PropertyOffset, Structure*, 58 58 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>&&); 60 60 61 61 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, 63 63 FunctionPtr<CustomAccessorPtrTag> customSetter = nullptr, JSObject* customSlotBase = nullptr); 64 64 … … 71 71 72 72 private: 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>&&); 74 74 75 75 GetterSetterAccessCase(const GetterSetterAccessCase&); -
trunk/Source/JavaScriptCore/bytecode/InByIdStatus.cpp
r273138 r275490 42 42 } 43 43 44 void InByIdStatus::shrinkToFit() 45 { 46 m_variants.shrinkToFit(); 47 } 48 44 49 #if ENABLE(JIT) 45 50 InByIdStatus InByIdStatus::computeFor(CodeBlock* profiledBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, UniquedStringImpl* uid, ExitFlag didExit) … … 201 206 } 202 207 208 result.shrinkToFit(); 203 209 return result; 204 210 } … … 234 240 } 235 241 } 242 shrinkToFit(); 236 243 return; 237 244 -
trunk/Source/JavaScriptCore/bytecode/InByIdStatus.h
r273138 r275490 117 117 #endif 118 118 bool appendVariant(const InByIdVariant&); 119 void shrinkToFit(); 119 120 120 121 State m_state { NoInformation }; -
trunk/Source/JavaScriptCore/bytecode/InstanceOfStatus.cpp
r261993 r275490 38 38 { 39 39 appendICStatusVariant(m_variants, variant); 40 } 41 42 void InstanceOfStatus::shrinkToFit() 43 { 44 m_variants.shrinkToFit(); 40 45 } 41 46 … … 97 102 } 98 103 104 result.shrinkToFit(); 99 105 return result; 100 106 } -
trunk/Source/JavaScriptCore/bytecode/InstanceOfStatus.h
r255542 r275490 107 107 private: 108 108 void appendVariant(const InstanceOfVariant&); 109 void shrinkToFit(); 109 110 110 111 State m_state; -
trunk/Source/JavaScriptCore/bytecode/IntrinsicGetterAccessCase.cpp
r262054 r275490 34 34 namespace JSC { 35 35 36 IntrinsicGetterAccessCase::IntrinsicGetterAccessCase(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, std::unique_ptr<PolyProtoAccessChain>prototypeAccessChain)36 IntrinsicGetterAccessCase::IntrinsicGetterAccessCase(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain) 37 37 : Base(vm, owner, IntrinsicGetter, identifier, offset, structure, conditionSet, WTFMove(prototypeAccessChain)) 38 38 { … … 40 40 } 41 41 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)42 std::unique_ptr<AccessCase> IntrinsicGetterAccessCase::create(VM& vm, JSCell* owner, CacheableIdentifier identifier, PropertyOffset offset, Structure* structure, const ObjectPropertyConditionSet& conditionSet, JSFunction* intrinsicFunction, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain) 43 43 { 44 44 return std::unique_ptr<AccessCase>(new IntrinsicGetterAccessCase(vm, owner, identifier, offset, structure, conditionSet, intrinsicFunction, WTFMove(prototypeAccessChain))); -
trunk/Source/JavaScriptCore/bytecode/IntrinsicGetterAccessCase.h
r261567 r275490 43 43 void emitIntrinsicGetter(AccessGenerationState&); 44 44 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>&&); 46 46 47 47 std::unique_ptr<AccessCase> clone() const final; … … 50 50 51 51 private: 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>&&); 53 53 54 54 WriteBarrier<JSFunction> m_intrinsicFunction; -
trunk/Source/JavaScriptCore/bytecode/JumpTable.h
r255687 r275490 31 31 32 32 #include "CodeLocation.h" 33 #include <wtf/ HashMap.h>33 #include <wtf/RobinHoodHashMap.h> 34 34 #include <wtf/Vector.h> 35 35 #include <wtf/text/StringImpl.h> … … 45 45 46 46 struct StringJumpTable { 47 typedef HashMap<RefPtr<StringImpl>, OffsetLocation> StringOffsetTable;47 using StringOffsetTable = MemoryCompactLookupOnlyRobinHoodHashMap<RefPtr<StringImpl>, OffsetLocation>; 48 48 StringOffsetTable offsetTable; 49 49 #if ENABLE(JIT) -
trunk/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.cpp
r261895 r275490 31 31 namespace JSC { 32 32 33 std::unique_ptr<PolyProtoAccessChain> PolyProtoAccessChain::create(JSGlobalObject* globalObject, JSCell* base, const PropertySlot& slot)33 RefPtr<PolyProtoAccessChain> PolyProtoAccessChain::tryCreate(JSGlobalObject* globalObject, JSCell* base, const PropertySlot& slot) 34 34 { 35 35 JSObject* target = slot.isUnset() ? nullptr : slot.slotBase(); 36 return create(globalObject, base, target);36 return tryCreate(globalObject, base, target); 37 37 } 38 38 39 std::unique_ptr<PolyProtoAccessChain> PolyProtoAccessChain::create(JSGlobalObject* globalObject, JSCell* base, JSObject* target)39 RefPtr<PolyProtoAccessChain> PolyProtoAccessChain::tryCreate(JSGlobalObject* globalObject, JSCell* base, JSObject* target) 40 40 { 41 41 JSCell* current = base; … … 44 44 bool found = false; 45 45 46 std::unique_ptr<PolyProtoAccessChain> result(new PolyProtoAccessChain()); 47 46 Vector<StructureID> chain; 48 47 for (unsigned iterationNumber = 0; true; ++iterationNumber) { 49 48 Structure* structure = current->structure(vm); … … 61 60 // AccessCase provide the base to us as needed. 62 61 if (iterationNumber) 63 result->m_chain.append(structure->id());62 chain.append(structure->id()); 64 63 else 65 64 RELEASE_ASSERT(current == base); … … 79 78 return nullptr; 80 79 81 result->m_chain.shrinkToFit(); 82 return result; 80 return adoptRef(*new PolyProtoAccessChain(WTFMove(chain))); 83 81 } 84 82 -
trunk/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h
r255711 r275490 28 28 #include "StructureIDTable.h" 29 29 #include "VM.h" 30 #include <wtf/RefCountedArray.h> 30 31 #include <wtf/Vector.h> 31 32 … … 38 39 class Structure; 39 40 40 class PolyProtoAccessChain { 41 WTF_MAKE_FAST_ALLOCATED; 41 class PolyProtoAccessChain final : public ThreadSafeRefCounted<PolyProtoAccessChain> { 42 public: 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); 42 46 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; } 56 48 57 49 void dump(Structure* baseStructure, PrintStream& out) const; … … 84 76 85 77 private: 86 PolyProtoAccessChain() = default; 78 explicit PolyProtoAccessChain(Vector<StructureID>&& chain) 79 : m_chain(WTFMove(chain)) 80 { 81 } 87 82 88 83 // This does not include the base. We rely on AccessCase providing it for us. That said, this data 89 84 // structure is tied to the base that it was created with. 90 Vector<StructureID> m_chain;85 RefCountedArray<StructureID> m_chain; 91 86 }; 92 87 -
trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp
r273138 r275490 350 350 return false; 351 351 } 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; 357 355 } 358 356 return true; … … 750 748 m_stubRoutine = createJITStubRoutine(code, vm, codeBlock, doesCalls, cellsToMark, WTFMove(state.m_callLinkInfos), codeBlockThatOwnsExceptionHandlers, callSiteIndexForExceptionHandling); 751 749 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)); 756 752 if (PolymorphicAccessInternal::verbose) 757 753 dataLog("Returning: ", code.code(), "\n"); -
trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.h
r273138 r275490 33 33 #include "MacroAssembler.h" 34 34 #include "ScratchRegisterAllocator.h" 35 #include <wtf/RefCountedArray.h> 35 36 #include <wtf/Vector.h> 36 37 … … 188 189 RefPtr<JITStubRoutine> m_stubRoutine; 189 190 std::unique_ptr<WatchpointsOnStructureStubInfo> m_watchpoints; 190 std::unique_ptr<Vector<WriteBarrier<JSCell>>> m_weakReferences;191 RefCountedArray<WriteBarrier<JSCell>> m_weakReferences; 191 192 }; 192 193 -
trunk/Source/JavaScriptCore/bytecode/ProxyableAccessCase.cpp
r265600 r275490 32 32 33 33 ProxyableAccessCase::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) 35 35 : Base(vm, owner, accessType, identifier, offset, structure, conditionSet, WTFMove(prototypeAccessChain)) 36 36 , m_additionalSet(additionalSet) … … 39 39 } 40 40 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)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, RefPtr<PolyProtoAccessChain>&& prototypeAccessChain) 42 42 { 43 43 ASSERT(type == Load || type == Miss || type == GetGetter || type == Replace); -
trunk/Source/JavaScriptCore/bytecode/ProxyableAccessCase.h
r261567 r275490 39 39 40 40 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); 42 42 43 43 void dumpImpl(PrintStream&, CommaPrinter&) const override; … … 47 47 48 48 protected: 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>&&); 50 50 51 51 private: -
trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.cpp
r273138 r275490 42 42 { 43 43 return appendICStatusVariant(m_variants, variant); 44 } 45 46 void PutByIdStatus::shrinkToFit() 47 { 48 m_variants.shrinkToFit(); 44 49 } 45 50 … … 230 235 } 231 236 237 result.shrinkToFit(); 232 238 return result; 233 239 } … … 372 378 } 373 379 380 result.shrinkToFit(); 374 381 return result; 375 382 } … … 438 445 return mergeSlow(); 439 446 } 447 shrinkToFit(); 440 448 return; 441 449 -
trunk/Source/JavaScriptCore/bytecode/PutByIdStatus.h
r273138 r275490 136 136 137 137 bool appendVariant(const PutByIdVariant&); 138 void shrinkToFit(); 138 139 139 140 State m_state; -
trunk/Source/JavaScriptCore/bytecode/SetPrivateBrandStatus.cpp
r273138 r275490 42 42 } 43 43 44 void SetPrivateBrandStatus::shrinkToFit() 45 { 46 m_variants.shrinkToFit(); 47 } 48 44 49 SetPrivateBrandStatus SetPrivateBrandStatus::computeForBaseline(CodeBlock* baselineBlock, ICStatusMap& map, BytecodeIndex bytecodeIndex, ExitFlag didExit) 45 50 { … … 114 119 } 115 120 121 result.shrinkToFit(); 116 122 return result; 117 123 } … … 196 202 return mergeSlow(); 197 203 } 204 shrinkToFit(); 198 205 return; 199 206 -
trunk/Source/JavaScriptCore/bytecode/SetPrivateBrandStatus.h
r273138 r275490 89 89 90 90 bool appendVariant(const SetPrivateBrandVariant&); 91 void shrinkToFit(); 91 92 92 93 void dump(PrintStream&) const; -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r273931 r275490 43 43 #include <algorithm> 44 44 #include <wtf/BitVector.h> 45 #include <wtf/HashSet.h>46 45 #include <wtf/RefCountedArray.h> 46 #include <wtf/RobinHoodHashMap.h> 47 47 #include <wtf/TriState.h> 48 48 #include <wtf/Vector.h> … … 81 81 }; 82 82 83 typedef HashMap<RefPtr<StringImpl>, OffsetLocation> StringOffsetTable;83 using StringOffsetTable = MemoryCompactLookupOnlyRobinHoodHashMap<RefPtr<StringImpl>, OffsetLocation>; 84 84 StringOffsetTable offsetTable; 85 85 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp
r273931 r275490 57 57 JSParserScriptMode scriptMode = executable->scriptMode(); 58 58 ASSERT(isFunctionParseMode(executable->parseMode())); 59 Vector<JSTextPosition>* classFieldLocations = executable->classFieldLocations();59 auto* classFieldLocations = executable->classFieldLocations(); 60 60 std::unique_ptr<FunctionNode> function = parse<FunctionNode>( 61 61 vm, source, executable->name(), builtinMode, strictMode, scriptMode, executable->parseMode(), executable->superBinding(), error, nullptr, ConstructorKind::None, DerivedContextType::None, EvalContextType::None, nullptr, nullptr, classFieldLocations); … … 74 74 75 75 auto parentScopeTDZVariables = executable->parentScopeTDZVariables(); 76 PrivateNameEnvironmentparentPrivateNameEnvironment = executable->parentPrivateNameEnvironment();76 const PrivateNameEnvironment* parentPrivateNameEnvironment = executable->parentPrivateNameEnvironment(); 77 77 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); 79 79 80 80 if (error.isValid()) -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
r273138 r275490 40 40 #include "VariableEnvironment.h" 41 41 #include <wtf/Optional.h> 42 #include <wtf/RefCountedArray.h> 42 43 43 44 namespace JSC { … … 178 179 } 179 180 180 PrivateNameEnvironmentparentPrivateNameEnvironment() const181 const PrivateNameEnvironment* parentPrivateNameEnvironment() const 181 182 { 182 183 if (!m_rareData) 183 return PrivateNameEnvironment();184 return m_rareData->m_parentPrivateNameEnvironment;184 return nullptr; 185 return &m_rareData->m_parentPrivateNameEnvironment; 185 186 } 186 187 … … 219 220 String m_sourceMappingURLDirective; 220 221 RefPtr<TDZEnvironmentLink> m_parentScopeTDZVariables; 221 Vector<JSTextPosition> m_classFieldLocations;222 RefCountedArray<JSTextPosition> m_classFieldLocations; 222 223 PrivateNameEnvironment m_parentPrivateNameEnvironment; 223 224 }; … … 225 226 NeedsClassFieldInitializer needsClassFieldInitializer() const { return static_cast<NeedsClassFieldInitializer>(m_needsClassFieldInitializer); } 226 227 227 Vector<JSTextPosition>* classFieldLocations() const228 RefCountedArray<JSTextPosition>* classFieldLocations() const 228 229 { 229 230 if (m_rareData) … … 236 237 if (classFieldLocations.isEmpty()) 237 238 return; 238 ensureRareData().m_classFieldLocations = WTFMove(classFieldLocations);239 ensureRareData().m_classFieldLocations = RefCountedArray<JSTextPosition>(WTFMove(classFieldLocations)); 239 240 } 240 241 -
trunk/Source/JavaScriptCore/dfg/DFGJITCode.h
r261567 r275490 152 152 // The key may not always be a target for OSR Entry but the list in the value is guaranteed 153 153 // to be usable for OSR Entry. 154 HashMap<BytecodeIndex, Vector<BytecodeIndex>> tierUpInLoopHierarchy;154 HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>> tierUpInLoopHierarchy; 155 155 156 156 // Map each bytecode of CheckTierUpAndOSREnter to its stream index. -
trunk/Source/JavaScriptCore/dfg/DFGPlan.h
r273138 r275490 107 107 void setWillTryToTierUp(bool willTryToTierUp) { m_willTryToTierUp = willTryToTierUp; } 108 108 109 HashMap<BytecodeIndex, Vector<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; }109 HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; } 110 110 Vector<BytecodeIndex>& tierUpAndOSREnterBytecodes() { return m_tierUpAndOSREnterBytecodes; } 111 111 … … 160 160 RecordedStatuses m_recordedStatuses; 161 161 162 HashMap<BytecodeIndex, Vector<BytecodeIndex>> m_tierUpInLoopHierarchy;162 HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>> m_tierUpInLoopHierarchy; 163 163 Vector<BytecodeIndex> m_tierUpAndOSREnterBytecodes; 164 164 -
trunk/Source/JavaScriptCore/dfg/DFGTierUpCheckInjectionPhase.cpp
r262928 r275490 148 148 149 149 if (!tierUpCandidates.isEmpty()) 150 m_graph.m_plan.tierUpInLoopHierarchy().add(entry.key, WTFMove(tierUpCandidates));150 m_graph.m_plan.tierUpInLoopHierarchy().add(entry.key, tierUpCandidates); 151 151 } 152 152 m_graph.m_plan.setWillTryToTierUp(true); -
trunk/Source/JavaScriptCore/heap/BlockDirectoryBits.h
r252452 r275490 223 223 224 224 private: 225 Vector<Segment > m_segments;225 Vector<Segment, 0, CrashOnOverflow, 2> m_segments; 226 226 unsigned m_numBits { 0 }; 227 227 }; -
trunk/Source/JavaScriptCore/heap/JITStubRoutineSet.cpp
r273138 r275490 126 126 routine.routine->deleteFromGC(); 127 127 } 128 m_routines.shrink (dstIndex);128 m_routines.shrinkCapacity(dstIndex); 129 129 } 130 130 -
trunk/Source/JavaScriptCore/jit/CallFrameShuffleData.h
r250094 r275490 36 36 WTF_MAKE_FAST_ALLOCATED; 37 37 public: 38 void shrinkToFit() 39 { 40 args.shrinkToFit(); 41 } 42 38 43 Vector<ValueRecovery> args; 39 44 unsigned numLocals { UINT_MAX }; -
trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h
r273138 r275490 31 31 #include "JSObject.h" 32 32 #include "WriteBarrier.h" 33 #include <wtf/RefCountedArray.h> 33 34 #include <wtf/Vector.h> 34 35 … … 97 98 98 99 private: 99 Vector<WriteBarrier<JSCell>> m_cells;100 RefCountedArray<WriteBarrier<JSCell>> m_cells; 100 101 Bag<CallLinkInfo> m_callLinkInfos; 101 102 }; -
trunk/Source/JavaScriptCore/jit/PolymorphicCallStubRoutine.h
r273138 r275490 110 110 void markRequiredObjectsInternal(SlotVisitor&) final; 111 111 112 Vector<WriteBarrier<JSCell>, 2> m_variants;112 RefCountedArray<WriteBarrier<JSCell>> m_variants; 113 113 UniqueArray<uint32_t> m_fastCounts; 114 114 Bag<PolymorphicCallNode> m_callNodes; -
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r272580 r275490 294 294 } 295 295 296 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;296 RefPtr<PolyProtoAccessChain> prototypeAccessChain; 297 297 298 298 PropertyOffset offset = slot.isUnset() ? invalidOffset : slot.cachedOffset(); … … 334 334 335 335 if (cacheStatus->usesPolyProto) { 336 prototypeAccessChain = PolyProtoAccessChain:: create(globalObject, baseCell, slot);336 prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, slot); 337 337 if (!prototypeAccessChain) 338 338 return GiveUpOnCache; … … 695 695 ASSERT(newStructure->isObject()); 696 696 697 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;697 RefPtr<PolyProtoAccessChain> prototypeAccessChain; 698 698 ObjectPropertyConditionSet conditionSet; 699 699 if (putKind == PutKind::NotDirect) { … … 703 703 704 704 if (cacheStatus->usesPolyProto) { 705 prototypeAccessChain = PolyProtoAccessChain:: create(globalObject, baseCell, nullptr);705 prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, nullptr); 706 706 if (!prototypeAccessChain) 707 707 return GiveUpOnCache; … … 727 727 if (slot.isCacheableCustom()) { 728 728 ObjectPropertyConditionSet conditionSet; 729 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;729 RefPtr<PolyProtoAccessChain> prototypeAccessChain; 730 730 731 731 // We need to do this even if we're a self custom, since we must disallow dictionaries … … 738 738 if (slot.base() != baseValue) { 739 739 if (cacheStatus->usesPolyProto) { 740 prototypeAccessChain = PolyProtoAccessChain:: create(globalObject, baseCell, slot.base());740 prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, slot.base()); 741 741 if (!prototypeAccessChain) 742 742 return GiveUpOnCache; … … 756 756 ASSERT(slot.isCacheableSetter()); 757 757 ObjectPropertyConditionSet conditionSet; 758 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;758 RefPtr<PolyProtoAccessChain> prototypeAccessChain; 759 759 PropertyOffset offset = slot.cachedOffset(); 760 760 … … 767 767 768 768 if (cacheStatus->usesPolyProto) { 769 prototypeAccessChain = PolyProtoAccessChain:: create(globalObject, baseCell, slot.base());769 prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, baseCell, slot.base()); 770 770 if (!prototypeAccessChain) 771 771 return GiveUpOnCache; … … 921 921 Structure* structure = base->structure(vm); 922 922 923 std::unique_ptr<PolyProtoAccessChain> prototypeAccessChain;923 RefPtr<PolyProtoAccessChain> prototypeAccessChain; 924 924 ObjectPropertyConditionSet conditionSet; 925 925 if (wasFound) { … … 952 952 953 953 if (cacheStatus->usesPolyProto) { 954 prototypeAccessChain = PolyProtoAccessChain:: create(globalObject, base, slot);954 prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, base, slot); 955 955 if (!prototypeAccessChain) 956 956 return GiveUpOnCache; … … 971 971 972 972 if (cacheStatus->usesPolyProto) { 973 prototypeAccessChain = PolyProtoAccessChain:: create(globalObject, base, slot);973 prototypeAccessChain = PolyProtoAccessChain::tryCreate(globalObject, base, slot); 974 974 if (!prototypeAccessChain) 975 975 return GiveUpOnCache; -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r275439 r275490 216 216 217 217 template <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)218 Expected<typename Parser<LexerType>::ParseInnerResult, String> Parser<LexerType>::parseInner(const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const RefCountedArray<JSTextPosition>* classFieldLocations, const PrivateNameEnvironment* parentScopePrivateNames) 219 219 { 220 220 ASTBuilder context(const_cast<VM&>(m_vm), m_parserArena, const_cast<SourceCode*>(m_source)); … … 3181 3181 3182 3182 template <typename LexerType> 3183 template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const Vector<JSTextPosition>& classFieldLocations)3183 template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const RefCountedArray<JSTextPosition>& classFieldLocations) 3184 3184 { 3185 3185 TreeSourceElements sourceElements = context.createSourceElements(); -
trunk/Source/JavaScriptCore/parser/Parser.h
r274102 r275490 38 38 #include <wtf/Forward.h> 39 39 #include <wtf/Noncopyable.h> 40 #include <wtf/RefCountedArray.h> 40 41 #include <wtf/RefPtr.h> 41 42 … … 992 993 993 994 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); 995 996 996 997 JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); } … … 1512 1513 int numConstants; 1513 1514 }; 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); 1515 1516 1516 1517 // Used to determine type of error to report. … … 1743 1744 template <class TreeBuilder> TreeSourceElements parseAsyncGeneratorFunctionSourceElements(TreeBuilder&, bool isArrowFunctionBodyExpression, SourceElementsMode); 1744 1745 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>&); 1746 1747 template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength); 1747 1748 template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = nullptr); … … 2128 2129 template <typename LexerType> 2129 2130 template <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)2131 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const RefCountedArray<JSTextPosition>* classFieldLocations) 2131 2132 { 2132 2133 int errLine; … … 2229 2230 DebuggerParseData* debuggerParseData = nullptr, 2230 2231 const PrivateNameEnvironment* parentScopePrivateNames = nullptr, 2231 const Vector<JSTextPosition>* classFieldLocations = nullptr,2232 const RefCountedArray<JSTextPosition>* classFieldLocations = nullptr, 2232 2233 bool isInsideOrdinaryFunction = false) 2233 2234 { -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r273931 r275490 44 44 #include <wtf/Optional.h> 45 45 #include <wtf/Packed.h> 46 #include <wtf/RobinHoodHashMap.h> 46 47 #include <wtf/UUID.h> 47 48 #include <wtf/text/AtomStringImpl.h> … … 670 671 }; 671 672 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 >> {673 template<typename Key, typename Value, typename HashArg = DefaultHash<SourceType<Key>>, typename KeyTraitsArg = HashTraits<SourceType<Key>>, typename MappedTraitsArg = HashTraits<SourceType<Value>>, typename TableTraits = WTF::HashTableTraits> 674 class CachedHashMap : public VariableLengthObject<HashMap<SourceType<Key>, SourceType<Value>, HashArg, KeyTraitsArg, MappedTraitsArg, TableTraits>> { 674 675 template<typename K, typename V> 675 using Map = HashMap<K, V, HashArg, KeyTraitsArg, MappedTraitsArg >;676 using Map = HashMap<K, V, HashArg, KeyTraitsArg, MappedTraitsArg, TableTraits>; 676 677 677 678 public: … … 696 697 CachedVector<CachedPair<Key, Value>> m_entries; 697 698 }; 699 700 template<typename Key, typename Value, typename HashArg = DefaultHash<SourceType<Key>>, typename KeyTraitsArg = HashTraits<SourceType<Key>>, typename MappedTraitsArg = HashTraits<SourceType<Value>>> 701 using CachedMemoryCompactLookupOnlyRobinHoodHashMap = CachedHashMap<Key, Value, HashArg, KeyTraitsArg, MappedTraitsArg, WTF::MemoryCompactLookupOnlyRobinHoodHashTableTraits>; 698 702 699 703 template<typename T> … … 911 915 912 916 private: 913 Cached HashMap<CachedRefPtr<CachedStringImpl>, UnlinkedStringJumpTable::OffsetLocation> m_offsetTable;917 CachedMemoryCompactLookupOnlyRobinHoodHashMap<CachedRefPtr<CachedStringImpl>, UnlinkedStringJumpTable::OffsetLocation> m_offsetTable; 914 918 }; 915 919 … … 1777 1781 m_classSource.encode(encoder, rareData.m_classSource); 1778 1782 m_parentScopeTDZVariables.encode(encoder, rareData.m_parentScopeTDZVariables); 1783 m_classFieldLocations.encode(encoder, rareData.m_classFieldLocations); 1779 1784 m_parentPrivateNameEnvironment.encode(encoder, rareData.m_parentPrivateNameEnvironment); 1780 1785 } … … 1785 1790 m_classSource.decode(decoder, rareData->m_classSource); 1786 1791 m_parentScopeTDZVariables.decode(decoder, rareData->m_parentScopeTDZVariables); 1792 m_classFieldLocations.decode(decoder, rareData->m_classFieldLocations); 1787 1793 m_parentPrivateNameEnvironment.decode(decoder, rareData->m_parentPrivateNameEnvironment); 1788 1794 return rareData; … … 1792 1798 CachedSourceCodeWithoutProvider m_classSource; 1793 1799 CachedRefPtr<CachedTDZEnvironmentLink> m_parentScopeTDZVariables; 1800 CachedVector<JSTextPosition> m_classFieldLocations; 1794 1801 CachedPrivateNameEnvironment m_parentPrivateNameEnvironment; 1795 1802 }; -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r274817 r275490 1128 1128 while (m_checkpointSideState.size() && bounds.contains(m_checkpointSideState.last()->associatedCallFrame)) 1129 1129 m_checkpointSideState.takeLast(); 1130 m_checkpointSideState.shrinkToFit(); 1130 1131 } 1131 1132 -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
r274609 r275490 85 85 visitor.append(thisObject->m_moduleRecord); 86 86 visitor.append(thisObject->m_memory); 87 for ( unsigned i = 0; i < thisObject->instance().module().moduleInformation().tableCount(); ++i)88 visitor.append(t hisObject->m_tables[i]);87 for (auto& table : thisObject->m_tables) 88 visitor.append(table); 89 89 visitor.reportExtraMemoryVisited(thisObject->m_instance->extraMemoryAllocated()); 90 90 for (unsigned i = 0; i < thisObject->instance().numImportFunctions(); ++i) -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
r273138 r275490 36 36 #include "WasmInstance.h" 37 37 #include <wtf/Ref.h> 38 #include <wtf/RefCountedArray.h> 38 39 39 40 namespace JSC { … … 116 117 WriteBarrier<WebAssemblyModuleRecord> m_moduleRecord; 117 118 WriteBarrier<JSWebAssemblyMemory> m_memory; 118 Vector<WriteBarrier<JSWebAssemblyTable>> m_tables;119 RefCountedArray<WriteBarrier<JSWebAssemblyTable>> m_tables; 119 120 }; 120 121 -
trunk/Source/WTF/ChangeLog
r275484 r275490 1 2021-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 1 20 2021-04-05 Alex Christensen <achristensen@webkit.org> 2 21 -
trunk/Source/WTF/wtf/RefCountedArray.h
r268993 r275490 51 51 52 52 public: 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 53 58 RefCountedArray() = default; 54 59 … … 170 175 171 176 T* data() { return PtrTraits::unwrap(m_data); } 172 T*begin() { return data(); }173 T*end()177 iterator begin() { return data(); } 178 iterator end() 174 179 { 175 180 if (!m_data) … … 180 185 181 186 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()); } 184 194 185 195 T& at(size_t i)
Note: See TracChangeset
for help on using the changeset viewer.