Changeset 275542 in webkit
- Timestamp:
- Apr 6, 2021 12:47:47 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r275490 r275542 1 2021-04-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [WTF] Introduce FixedVector and use it for FixedOperands 4 https://bugs.webkit.org/show_bug.cgi?id=224171 5 6 Reviewed by Mark Lam. 7 8 Define FixedOperands<T> which uses FixedVector for its storage. We use FixedOperands in FTL::OSRExitDescriptor. 9 We also replace RefCountedArray<T> with FixedVector<T> if they are not requiring RefCountedArray<T>'s ref-counting 10 semantics. 11 12 * bytecode/BytecodeGeneratorification.cpp: 13 (JSC::BytecodeGeneratorification::run): 14 * bytecode/CodeBlock.cpp: 15 (JSC::CodeBlock::finishCreation): 16 (JSC::CodeBlock::setConstantRegisters): 17 (JSC::CodeBlock::setNumParameters): 18 (JSC::CodeBlock::setRareCaseProfiles): 19 (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): 20 * bytecode/CodeBlock.h: 21 * bytecode/Operands.h: 22 (JSC::Operands::Operands): 23 * bytecode/OperandsInlines.h: 24 (JSC::U>::dumpInContext const): 25 (JSC::U>::dump const): 26 (JSC::Operands<T>::dumpInContext const): Deleted. 27 (JSC::Operands<T>::dump const): Deleted. 28 * bytecode/PolyProtoAccessChain.h: 29 * bytecode/PolymorphicAccess.cpp: 30 (JSC::PolymorphicAccess::regenerate): 31 * bytecode/PolymorphicAccess.h: 32 * bytecode/UnlinkedCodeBlock.cpp: 33 (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): 34 (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): 35 * bytecode/UnlinkedCodeBlock.h: 36 (JSC::UnlinkedCodeBlock::expressionInfo): 37 (JSC::UnlinkedCodeBlock::identifiers const): 38 (JSC::UnlinkedCodeBlock::constantRegisters): 39 (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): 40 (JSC::UnlinkedCodeBlock::constantIdentifierSets): 41 (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): 42 * bytecode/UnlinkedFunctionExecutable.h: 43 * bytecompiler/BytecodeGenerator.cpp: 44 (JSC::prepareJumpTableForSwitch): 45 * dfg/DFGJITCode.h: 46 * dfg/DFGPlan.h: 47 (JSC::DFG::Plan::tierUpInLoopHierarchy): 48 * ftl/FTLOSRExit.h: 49 * jit/GCAwareJITStubRoutine.h: 50 * jit/JIT.cpp: 51 (JSC::JIT::privateCompileSlowCases): 52 * jit/PolymorphicCallStubRoutine.h: 53 * llint/LLIntOffsetsExtractor.cpp: 54 * llint/LowLevelInterpreter.asm: 55 * parser/Parser.cpp: 56 (JSC::Parser<LexerType>::parseInner): 57 (JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements): 58 * parser/Parser.h: 59 (JSC::Parser<LexerType>::parse): 60 (JSC::parse): 61 * runtime/CachedTypes.cpp: 62 (JSC::CachedVector::encode): 63 (JSC::CachedVector::decode const): 64 * wasm/js/JSWebAssemblyInstance.h: 65 1 66 2021-04-05 Yusuke Suzuki <ysuzuki@apple.com> 2 67 -
trunk/Source/JavaScriptCore/bytecode/BytecodeGeneratorification.cpp
r273225 r275542 221 221 auto& jumpTable = m_codeBlock->addSwitchJumpTable(); 222 222 jumpTable.min = 0; 223 jumpTable.branchOffsets = RefCountedArray<int32_t>(m_yields.size() + 1);223 jumpTable.branchOffsets = FixedVector<int32_t>(m_yields.size() + 1); 224 224 std::fill(jumpTable.branchOffsets.begin(), jumpTable.branchOffsets.end(), 0); 225 225 jumpTable.add(0, nextToEnterPoint.offset()); -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r275490 r275542 404 404 405 405 bool shouldUpdateFunctionHasExecutedCache = m_unlinkedCode->wasCompiledWithTypeProfilerOpcodes() || m_unlinkedCode->wasCompiledWithControlFlowProfilerOpcodes(); 406 m_functionDecls = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionDecls());406 m_functionDecls = FixedVector<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionDecls()); 407 407 for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) { 408 408 UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i); … … 412 412 } 413 413 414 m_functionExprs = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionExprs());414 m_functionExprs = FixedVector<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionExprs()); 415 415 for (size_t count = unlinkedCodeBlock->numberOfFunctionExprs(), i = 0; i < count; ++i) { 416 416 UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i); … … 888 888 } 889 889 890 void CodeBlock::setConstantRegisters(const RefCountedArray<WriteBarrier<Unknown>>& constants, const RefCountedArray<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable)890 void CodeBlock::setConstantRegisters(const FixedVector<WriteBarrier<Unknown>>& constants, const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable) 891 891 { 892 892 VM& vm = *m_vm; … … 950 950 m_numParameters = newValue; 951 951 952 m_argumentValueProfiles = RefCountedArray<ValueProfile>(Options::useJIT() ? newValue : 0);952 m_argumentValueProfiles = FixedVector<ValueProfile>(Options::useJIT() ? newValue : 0); 953 953 } 954 954 … … 1755 1755 } 1756 1756 1757 void CodeBlock::setRareCaseProfiles( RefCountedArray<RareCaseProfile>&& rareCaseProfiles)1757 void CodeBlock::setRareCaseProfiles(FixedVector<RareCaseProfile>&& rareCaseProfiles) 1758 1758 { 1759 1759 ConcurrentJSLocker locker(m_lock); … … 3382 3382 if (!unlinkedCodeBlock()->hasOpProfileControlFlowBytecodeOffsets()) 3383 3383 return; 3384 const RefCountedArray<InstructionStream::Offset>& bytecodeOffsets = unlinkedCodeBlock()->opProfileControlFlowBytecodeOffsets();3384 const FixedVector<InstructionStream::Offset>& bytecodeOffsets = unlinkedCodeBlock()->opProfileControlFlowBytecodeOffsets(); 3385 3385 for (size_t i = 0, offsetsLength = bytecodeOffsets.size(); i < offsetsLength; i++) { 3386 3386 // Because op_profile_control_flow is emitted at the beginning of every basic block, finding -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r273931 r275542 70 70 #include <wtf/Bag.h> 71 71 #include <wtf/FastMalloc.h> 72 #include <wtf/ RefCountedArray.h>72 #include <wtf/FixedVector.h> 73 73 #include <wtf/RefPtr.h> 74 74 #include <wtf/SegmentedVector.h> … … 278 278 SentinelLinkedList<CallLinkInfo, PackedRawSentinelNode<CallLinkInfo>> m_incomingCalls; 279 279 SentinelLinkedList<PolymorphicCallNode, PackedRawSentinelNode<PolymorphicCallNode>> m_incomingPolymorphicCalls; 280 RefCountedArray<RareCaseProfile> m_rareCaseProfiles;280 FixedVector<RareCaseProfile> m_rareCaseProfiles; 281 281 std::unique_ptr<PCToCodeOriginMap> m_pcToCodeOriginMap; 282 282 std::unique_ptr<RegisterAtOffsetList> m_calleeSaveRegisters; … … 342 342 void setCalleeSaveRegisters(std::unique_ptr<RegisterAtOffsetList>); 343 343 344 void setRareCaseProfiles( RefCountedArray<RareCaseProfile>&&);344 void setRareCaseProfiles(FixedVector<RareCaseProfile>&&); 345 345 RareCaseProfile* rareCaseProfileForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex); 346 346 unsigned rareCaseProfileCountForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex); … … 957 957 void updateAllValueProfilePredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles); 958 958 959 void setConstantRegisters(const RefCountedArray<WriteBarrier<Unknown>>& constants, const RefCountedArray<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable);959 void setConstantRegisters(const FixedVector<WriteBarrier<Unknown>>& constants, const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable); 960 960 961 961 void replaceConstant(VirtualRegister reg, JSValue value) … … 1033 1033 CompressedLazyOperandValueProfileHolder m_lazyOperandValueProfiles; 1034 1034 #endif 1035 RefCountedArray<ValueProfile> m_argumentValueProfiles;1035 FixedVector<ValueProfile> m_argumentValueProfiles; 1036 1036 1037 1037 // Constant Pool … … 1041 1041 Vector<WriteBarrier<Unknown>> m_constantRegisters; 1042 1042 Vector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation; 1043 RefCountedArray<WriteBarrier<FunctionExecutable>> m_functionDecls;1044 RefCountedArray<WriteBarrier<FunctionExecutable>> m_functionExprs;1043 FixedVector<WriteBarrier<FunctionExecutable>> m_functionDecls; 1044 FixedVector<WriteBarrier<FunctionExecutable>> m_functionExprs; 1045 1045 1046 1046 WriteBarrier<CodeBlock> m_alternative; -
trunk/Source/JavaScriptCore/bytecode/Operands.h
r254975 r275542 29 29 #include "VirtualRegister.h" 30 30 31 #include <wtf/FixedVector.h> 31 32 #include <wtf/PrintStream.h> 32 33 #include <wtf/Vector.h> … … 135 136 enum OperandsLikeTag { OperandsLike }; 136 137 137 template<typename T >138 template<typename T, typename StorageArg = std::conditional_t<std::is_same_v<T, bool>, FastBitVector, Vector<T, 0, UnsafeVectorOverflow>>> 138 139 class Operands { 139 140 public: 140 using Storage = std::conditional_t<std::is_same_v<T, bool>, FastBitVector, Vector<T, 0, UnsafeVectorOverflow>>;141 using Storage = StorageArg; 141 142 using RefType = std::conditional_t<std::is_same_v<T, bool>, FastBitReference, T&>; 142 143 using ConstRefType = std::conditional_t<std::is_same_v<T, bool>, bool, const T&>; … … 145 146 146 147 explicit Operands(size_t numArguments, size_t numLocals, size_t numTmps) 147 : m_numArguments(numArguments) 148 : m_values(numArguments + numLocals + numTmps) 149 , m_numArguments(numArguments) 148 150 , m_numLocals(numLocals) 149 151 { 150 size_t size = numArguments + numLocals + numTmps;151 m_values.grow(size);152 152 if (!WTF::VectorTraits<T>::needsInitialization) 153 153 m_values.fill(T()); … … 155 155 156 156 explicit Operands(size_t numArguments, size_t numLocals, size_t numTmps, const T& initialValue) 157 : m_numArguments(numArguments) 157 : m_values(numArguments + numLocals + numTmps) 158 , m_numArguments(numArguments) 158 159 , m_numLocals(numLocals) 159 160 { 160 m_values.grow(numArguments + numLocals + numTmps);161 161 m_values.fill(initialValue); 162 162 } 163 163 164 template<typename U> 165 explicit Operands(OperandsLikeTag, const Operands<U>& other, const T& initialValue = T()) 166 : m_numArguments(other.numberOfArguments()) 164 template<typename U, typename V> 165 explicit Operands(OperandsLikeTag, const Operands<U, V>& other, const T& initialValue = T()) 166 : m_values(other.size()) 167 , m_numArguments(other.numberOfArguments()) 167 168 , m_numLocals(other.numberOfLocals()) 168 169 { 169 m_values.grow(other.size());170 170 m_values.fill(initialValue); 171 171 } … … 400 400 }; 401 401 402 template<typename T> 403 using FixedOperands = Operands<T, std::conditional_t<std::is_same_v<T, bool>, FastBitVector, FixedVector<T>>>; 404 402 405 } // namespace JSC -
trunk/Source/JavaScriptCore/bytecode/OperandsInlines.h
r254735 r275542 39 39 } 40 40 41 template<typename T >42 void Operands<T >::dumpInContext(PrintStream& out, DumpContext* context) const41 template<typename T, typename U> 42 void Operands<T, U>::dumpInContext(PrintStream& out, DumpContext* context) const 43 43 { 44 44 CommaPrinter comma(" "); … … 60 60 } 61 61 62 template<typename T >63 void Operands<T >::dump(PrintStream& out) const62 template<typename T, typename U> 63 void Operands<T, U>::dump(PrintStream& out) const 64 64 { 65 65 CommaPrinter comma(" "); -
trunk/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h
r275490 r275542 28 28 #include "StructureIDTable.h" 29 29 #include "VM.h" 30 #include <wtf/ RefCountedArray.h>30 #include <wtf/FixedVector.h> 31 31 #include <wtf/Vector.h> 32 32 … … 45 45 static RefPtr<PolyProtoAccessChain> tryCreate(JSGlobalObject*, JSCell* base, JSObject* target); 46 46 47 const RefCountedArray<StructureID>& chain() const { return m_chain; }47 const FixedVector<StructureID>& chain() const { return m_chain; } 48 48 49 49 void dump(Structure* baseStructure, PrintStream& out) const; … … 83 83 // This does not include the base. We rely on AccessCase providing it for us. That said, this data 84 84 // structure is tied to the base that it was created with. 85 RefCountedArray<StructureID> m_chain;85 FixedVector<StructureID> m_chain; 86 86 }; 87 87 -
trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.cpp
r275490 r275542 749 749 m_watchpoints = WTFMove(state.watchpoints); 750 750 if (!state.weakReferences.isEmpty()) 751 m_weakReferences = RefCountedArray<WriteBarrier<JSCell>>(WTFMove(state.weakReferences));751 m_weakReferences = FixedVector<WriteBarrier<JSCell>>(WTFMove(state.weakReferences)); 752 752 if (PolymorphicAccessInternal::verbose) 753 753 dataLog("Returning: ", code.code(), "\n"); -
trunk/Source/JavaScriptCore/bytecode/PolymorphicAccess.h
r275490 r275542 33 33 #include "MacroAssembler.h" 34 34 #include "ScratchRegisterAllocator.h" 35 #include <wtf/ RefCountedArray.h>35 #include <wtf/FixedVector.h> 36 36 #include <wtf/Vector.h> 37 37 … … 189 189 RefPtr<JITStubRoutine> m_stubRoutine; 190 190 std::unique_ptr<WatchpointsOnStructureStubInfo> m_watchpoints; 191 RefCountedArray<WriteBarrier<JSCell>> m_weakReferences;191 FixedVector<WriteBarrier<JSCell>> m_weakReferences; 192 192 }; 193 193 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r273931 r275542 160 160 void UnlinkedCodeBlock::dumpExpressionRangeInfo() 161 161 { 162 RefCountedArray<ExpressionRangeInfo>& expressionInfo = m_expressionInfo;162 FixedVector<ExpressionRangeInfo>& expressionInfo = m_expressionInfo; 163 163 164 164 size_t size = m_expressionInfo.size(); … … 189 189 } 190 190 191 const RefCountedArray<ExpressionRangeInfo>& expressionInfo = m_expressionInfo;191 const FixedVector<ExpressionRangeInfo>& expressionInfo = m_expressionInfo; 192 192 193 193 int low = 0; -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h
r275490 r275542 43 43 #include <algorithm> 44 44 #include <wtf/BitVector.h> 45 #include <wtf/ RefCountedArray.h>45 #include <wtf/FixedVector.h> 46 46 #include <wtf/RobinHoodHashMap.h> 47 47 #include <wtf/TriState.h> … … 96 96 97 97 struct UnlinkedSimpleJumpTable { 98 RefCountedArray<int32_t> branchOffsets;98 FixedVector<int32_t> branchOffsets; 99 99 int32_t min; 100 100 … … 136 136 137 137 bool hasExpressionInfo() { return m_expressionInfo.size(); } 138 const RefCountedArray<ExpressionRangeInfo>& expressionInfo() { return m_expressionInfo; }138 const FixedVector<ExpressionRangeInfo>& expressionInfo() { return m_expressionInfo; } 139 139 140 140 bool hasCheckpoints() const { return m_hasCheckpoints; } … … 153 153 size_t numberOfIdentifiers() const { return m_identifiers.size(); } 154 154 const Identifier& identifier(int index) const { return m_identifiers[index]; } 155 const RefCountedArray<Identifier>& identifiers() const { return m_identifiers; }155 const FixedVector<Identifier>& identifiers() const { return m_identifiers; } 156 156 157 157 BitVector& bitVector(size_t i) { ASSERT(m_rareData); return m_rareData->m_bitVectors[i]; } 158 158 159 const RefCountedArray<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; }159 const FixedVector<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; } 160 160 const WriteBarrier<Unknown>& constantRegister(VirtualRegister reg) const { return m_constantRegisters[reg.toConstantIndex()]; } 161 161 ALWAYS_INLINE JSValue getConstant(VirtualRegister reg) const { return m_constantRegisters[reg.toConstantIndex()].get(); } 162 const RefCountedArray<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }162 const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; } 163 163 164 164 unsigned numberOfConstantIdentifierSets() const { return m_rareData ? m_rareData->m_constantIdentifierSets.size() : 0; } 165 const RefCountedArray<IdentifierSet>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; }165 const FixedVector<IdentifierSet>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; } 166 166 167 167 // Jumps … … 235 235 unsigned endColumn() const { return m_endColumn; } 236 236 237 const RefCountedArray<InstructionStream::Offset>& opProfileControlFlowBytecodeOffsets() const237 const FixedVector<InstructionStream::Offset>& opProfileControlFlowBytecodeOffsets() const 238 238 { 239 239 ASSERT(m_rareData); … … 375 375 PackedRefPtr<StringImpl> m_sourceMappingURLDirective; 376 376 377 RefCountedArray<InstructionStream::Offset> m_jumpTargets;377 FixedVector<InstructionStream::Offset> m_jumpTargets; 378 378 Ref<UnlinkedMetadataTable> m_metadata; 379 379 std::unique_ptr<InstructionStream> m_instructions; … … 386 386 387 387 // Constant Pools 388 RefCountedArray<Identifier> m_identifiers;389 RefCountedArray<WriteBarrier<Unknown>> m_constantRegisters;390 RefCountedArray<SourceCodeRepresentation> m_constantsSourceCodeRepresentation;391 using FunctionExpressionVector = RefCountedArray<WriteBarrier<UnlinkedFunctionExecutable>>;388 FixedVector<Identifier> m_identifiers; 389 FixedVector<WriteBarrier<Unknown>> m_constantRegisters; 390 FixedVector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation; 391 using FunctionExpressionVector = FixedVector<WriteBarrier<UnlinkedFunctionExecutable>>; 392 392 FunctionExpressionVector m_functionDecls; 393 393 FunctionExpressionVector m_functionExprs; … … 397 397 WTF_MAKE_STRUCT_FAST_ALLOCATED; 398 398 399 RefCountedArray<UnlinkedHandlerInfo> m_exceptionHandlers;399 FixedVector<UnlinkedHandlerInfo> m_exceptionHandlers; 400 400 401 401 // Jump Tables 402 RefCountedArray<UnlinkedSimpleJumpTable> m_switchJumpTables;403 RefCountedArray<UnlinkedStringJumpTable> m_stringSwitchJumpTables;404 405 RefCountedArray<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions;402 FixedVector<UnlinkedSimpleJumpTable> m_switchJumpTables; 403 FixedVector<UnlinkedStringJumpTable> m_stringSwitchJumpTables; 404 405 FixedVector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions; 406 406 407 407 struct TypeProfilerExpressionRange { … … 410 410 }; 411 411 HashMap<unsigned, TypeProfilerExpressionRange> m_typeProfilerInfoMap; 412 RefCountedArray<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;413 RefCountedArray<BitVector> m_bitVectors;414 RefCountedArray<IdentifierSet> m_constantIdentifierSets;412 FixedVector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets; 413 FixedVector<BitVector> m_bitVectors; 414 FixedVector<IdentifierSet> m_constantIdentifierSets; 415 415 416 416 unsigned m_needsClassFieldInitializer : 1; … … 429 429 OutOfLineJumpTargets m_outOfLineJumpTargets; 430 430 std::unique_ptr<RareData> m_rareData; 431 RefCountedArray<ExpressionRangeInfo> m_expressionInfo;431 FixedVector<ExpressionRangeInfo> m_expressionInfo; 432 432 433 433 protected: -
trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
r275490 r275542 39 39 #include "SourceCode.h" 40 40 #include "VariableEnvironment.h" 41 #include <wtf/FixedVector.h> 41 42 #include <wtf/Optional.h> 42 #include <wtf/RefCountedArray.h>43 43 44 44 namespace JSC { … … 220 220 String m_sourceMappingURLDirective; 221 221 RefPtr<TDZEnvironmentLink> m_parentScopeTDZVariables; 222 RefCountedArray<JSTextPosition> m_classFieldLocations;222 FixedVector<JSTextPosition> m_classFieldLocations; 223 223 PrivateNameEnvironment m_parentPrivateNameEnvironment; 224 224 }; … … 226 226 NeedsClassFieldInitializer needsClassFieldInitializer() const { return static_cast<NeedsClassFieldInitializer>(m_needsClassFieldInitializer); } 227 227 228 RefCountedArray<JSTextPosition>* classFieldLocations() const228 const FixedVector<JSTextPosition>* classFieldLocations() const 229 229 { 230 230 if (m_rareData) … … 237 237 if (classFieldLocations.isEmpty()) 238 238 return; 239 ensureRareData().m_classFieldLocations = RefCountedArray<JSTextPosition>(WTFMove(classFieldLocations));239 ensureRareData().m_classFieldLocations = FixedVector<JSTextPosition>(WTFMove(classFieldLocations)); 240 240 } 241 241 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r275439 r275542 4093 4093 { 4094 4094 jumpTable.min = min; 4095 jumpTable.branchOffsets = RefCountedArray<int32_t>(max - min + 1);4095 jumpTable.branchOffsets = FixedVector<int32_t>(max - min + 1); 4096 4096 std::fill(jumpTable.branchOffsets.begin(), jumpTable.branchOffsets.end(), 0); 4097 4097 for (uint32_t i = 0; i < clauseCount; ++i) { -
trunk/Source/JavaScriptCore/dfg/DFGJITCode.h
r275490 r275542 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, RefCountedArray<BytecodeIndex>> tierUpInLoopHierarchy;154 HashMap<BytecodeIndex, FixedVector<BytecodeIndex>> tierUpInLoopHierarchy; 155 155 156 156 // Map each bytecode of CheckTierUpAndOSREnter to its stream index. -
trunk/Source/JavaScriptCore/dfg/DFGPlan.h
r275490 r275542 107 107 void setWillTryToTierUp(bool willTryToTierUp) { m_willTryToTierUp = willTryToTierUp; } 108 108 109 HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; }109 HashMap<BytecodeIndex, FixedVector<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, RefCountedArray<BytecodeIndex>> m_tierUpInLoopHierarchy;162 HashMap<BytecodeIndex, FixedVector<BytecodeIndex>> m_tierUpInLoopHierarchy; 163 163 Vector<BytecodeIndex> m_tierUpAndOSREnterBytecodes; 164 164 -
trunk/Source/JavaScriptCore/ftl/FTLOSRExit.h
r260803 r275542 68 68 69 69 struct OSRExitDescriptor { 70 private: 71 WTF_MAKE_NONCOPYABLE(OSRExitDescriptor); 72 public: 70 73 OSRExitDescriptor( 71 74 DataFormat profileDataFormat, MethodOfGettingAValueProfile, … … 80 83 MethodOfGettingAValueProfile m_valueProfile; 81 84 82 Operands<ExitValue> m_values;85 FixedOperands<ExitValue> m_values; 83 86 Bag<ExitTimeObjectMaterialization> m_materializations; 84 87 -
trunk/Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h
r275490 r275542 31 31 #include "JSObject.h" 32 32 #include "WriteBarrier.h" 33 #include <wtf/ RefCountedArray.h>33 #include <wtf/FixedVector.h> 34 34 #include <wtf/Vector.h> 35 35 … … 98 98 99 99 private: 100 RefCountedArray<WriteBarrier<JSCell>> m_cells;100 FixedVector<WriteBarrier<JSCell>> m_cells; 101 101 Bag<CallLinkInfo> m_callLinkInfos; 102 102 }; -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r274308 r275542 521 521 m_callLinkInfoIndex = 0; 522 522 523 RefCountedArray<RareCaseProfile> rareCaseProfiles;523 FixedVector<RareCaseProfile> rareCaseProfiles; 524 524 if (shouldEmitProfiling()) 525 rareCaseProfiles = RefCountedArray<RareCaseProfile>(m_bytecodeCountHavingSlowCase);525 rareCaseProfiles = FixedVector<RareCaseProfile>(m_bytecodeCountHavingSlowCase); 526 526 527 527 unsigned bytecodeCountHavingSlowCase = 0; -
trunk/Source/JavaScriptCore/jit/PolymorphicCallStubRoutine.h
r275490 r275542 110 110 void markRequiredObjectsInternal(SlotVisitor&) final; 111 111 112 RefCountedArray<WriteBarrier<JSCell>> m_variants;112 FixedVector<WriteBarrier<JSCell>> m_variants; 113 113 UniqueArray<uint32_t> m_fastCounts; 114 114 Bag<PolymorphicCallNode> m_callNodes; -
trunk/Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp
r267489 r275542 87 87 using Vector = WTF::Vector<int>; 88 88 using JSInternalFieldObjectImpl = JSC::JSInternalFieldObjectImpl<>; 89 using FixedVector = WTF::FixedVector<int>; 89 90 using RefCountedArray = WTF::RefCountedArray<int>; 90 91 -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r275392 r275542 1551 1551 assert(macro (ok) bpgteq t0, 0, ok end) 1552 1552 btpz t0, .argumentProfileDone 1553 loadp CodeBlock::m_argumentValueProfiles + RefCountedArray::m_data[t1], t31553 loadp CodeBlock::m_argumentValueProfiles + FixedVector::m_storage + RefCountedArray::m_data[t1], t3 1554 1554 btpz t3, .argumentProfileDone # When we can't JIT, we don't allocate any argument value profiles. 1555 1555 mulp sizeof ValueProfile, t0, t2 # Aaaaahhhh! Need strength reduction! -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r275490 r275542 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 RefCountedArray<JSTextPosition>* classFieldLocations, const PrivateNameEnvironment* parentScopePrivateNames)218 Expected<typename Parser<LexerType>::ParseInnerResult, String> Parser<LexerType>::parseInner(const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const FixedVector<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 RefCountedArray<JSTextPosition>& classFieldLocations)3183 template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const FixedVector<JSTextPosition>& classFieldLocations) 3184 3184 { 3185 3185 TreeSourceElements sourceElements = context.createSourceElements(); -
trunk/Source/JavaScriptCore/parser/Parser.h
r275490 r275542 36 36 #include "SourceProviderCacheItem.h" 37 37 #include "VariableEnvironment.h" 38 #include <wtf/FixedVector.h> 38 39 #include <wtf/Forward.h> 39 40 #include <wtf/Noncopyable.h> 40 #include <wtf/RefCountedArray.h>41 41 #include <wtf/RefPtr.h> 42 42 … … 993 993 994 994 template <class ParsedNode> 995 std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const RefCountedArray<JSTextPosition>* = nullptr);995 std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const FixedVector<JSTextPosition>* = nullptr); 996 996 997 997 JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); } … … 1513 1513 int numConstants; 1514 1514 }; 1515 Expected<ParseInnerResult, String> parseInner(const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition, const RefCountedArray<JSTextPosition>*, const PrivateNameEnvironment* parentScopePrivateNames);1515 Expected<ParseInnerResult, String> parseInner(const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition, const FixedVector<JSTextPosition>*, const PrivateNameEnvironment* parentScopePrivateNames); 1516 1516 1517 1517 // Used to determine type of error to report. … … 1744 1744 template <class TreeBuilder> TreeSourceElements parseAsyncGeneratorFunctionSourceElements(TreeBuilder&, bool isArrowFunctionBodyExpression, SourceElementsMode); 1745 1745 template <class TreeBuilder> TreeSourceElements parseSingleFunction(TreeBuilder&, Optional<int> functionConstructorParametersEndPosition); 1746 template <class TreeBuilder> TreeSourceElements parseClassFieldInitializerSourceElements(TreeBuilder&, const RefCountedArray<JSTextPosition>&);1746 template <class TreeBuilder> TreeSourceElements parseClassFieldInitializerSourceElements(TreeBuilder&, const FixedVector<JSTextPosition>&); 1747 1747 template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength); 1748 1748 template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = nullptr); … … 2129 2129 template <typename LexerType> 2130 2130 template <class ParsedNode> 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 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const FixedVector<JSTextPosition>* classFieldLocations) 2132 2132 { 2133 2133 int errLine; … … 2230 2230 DebuggerParseData* debuggerParseData = nullptr, 2231 2231 const PrivateNameEnvironment* parentScopePrivateNames = nullptr, 2232 const RefCountedArray<JSTextPosition>* classFieldLocations = nullptr,2232 const FixedVector<JSTextPosition>* classFieldLocations = nullptr, 2233 2233 bool isInsideOrdinaryFunction = false) 2234 2234 { -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r275490 r275542 604 604 class CachedVector : public VariableLengthObject<Vector<SourceType<T>, InlineCapacity, OverflowHandler, 16, Malloc>> { 605 605 public: 606 void encode(Encoder& encoder, const Vector<SourceType<T>, InlineCapacity, OverflowHandler, 16, Malloc>& vector) 606 template<typename VectorContainer> 607 void encode(Encoder& encoder, const VectorContainer& vector) 607 608 { 608 609 m_size = vector.size(); … … 614 615 } 615 616 616 void encode(Encoder& encoder, const RefCountedArray<SourceType<T>>& vector)617 {618 m_size = vector.size();617 template<typename... Args, typename VectorContainer> 618 void decode(Decoder& decoder, VectorContainer& vector, Args... args) const 619 { 619 620 if (!m_size) 620 621 return; 621 T* buffer = this->template allocate<T>(encoder, m_size); 622 for (unsigned i = 0; i < m_size; ++i) 623 ::JSC::encode(encoder, buffer[i], vector[i]); 624 } 625 626 template<typename... Args> 627 void decode(Decoder& decoder, Vector<SourceType<T>, InlineCapacity, OverflowHandler, 16, Malloc>& vector, Args... args) const 628 { 629 if (!m_size) 630 return; 631 vector.resizeToFit(m_size); 622 vector = VectorContainer(m_size); 632 623 const T* buffer = this->template buffer<T>(); 633 624 for (unsigned i = 0; i < m_size; ++i) 634 625 ::JSC::decode(decoder, buffer[i], vector[i], args...); 635 626 } 636 637 template<typename... Args>638 void decode(Decoder& decoder, RefCountedArray<SourceType<T>>& vector, Args... args) const639 {640 if (!m_size)641 return;642 vector = RefCountedArray<SourceType<T>>(m_size);643 const T* buffer = this->template buffer<T>();644 for (unsigned i = 0; i < m_size; ++i)645 ::JSC::decode(decoder, buffer[i], vector[i], args...);646 }647 648 627 649 628 private: -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
r275490 r275542 35 35 #include "WasmCreationMode.h" 36 36 #include "WasmInstance.h" 37 #include <wtf/FixedVector.h> 37 38 #include <wtf/Ref.h> 38 #include <wtf/RefCountedArray.h>39 39 40 40 namespace JSC { … … 117 117 WriteBarrier<WebAssemblyModuleRecord> m_moduleRecord; 118 118 WriteBarrier<JSWebAssemblyMemory> m_memory; 119 RefCountedArray<WriteBarrier<JSWebAssemblyTable>> m_tables;119 FixedVector<WriteBarrier<JSWebAssemblyTable>> m_tables; 120 120 }; 121 121 -
trunk/Source/WTF/ChangeLog
r275496 r275542 1 2021-04-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [WTF] Introduce FixedVector and use it for FixedOperands 4 https://bugs.webkit.org/show_bug.cgi?id=224171 5 6 Reviewed by Mark Lam. 7 8 This FixedVector<T> is a wrapper around RefCountedArray<T>, but this offers Vector-like copy / move semantics, 9 so that we can use this FixedVector<T> as a drop-in-replacement for fixed-sized Vector fields. The purpose 10 of that is saving memory by removing unnecessary storage (FixedVector is fixed-sized allocated) and putting size 11 into the allocated memory. 12 13 * WTF.xcodeproj/project.pbxproj: 14 * wtf/CMakeLists.txt: 15 * wtf/FastBitVector.h: 16 (WTF::FastBitVector::FastBitVector): 17 * wtf/FixedVector.h: Added. 18 (WTF::FixedVector::FixedVector): 19 (WTF::FixedVector::operator=): 20 (WTF::FixedVector::size const): 21 (WTF::FixedVector::isEmpty const): 22 (WTF::FixedVector::byteSize const): 23 (WTF::FixedVector::data): 24 (WTF::FixedVector::begin): 25 (WTF::FixedVector::end): 26 (WTF::FixedVector::data const): 27 (WTF::FixedVector::begin const): 28 (WTF::FixedVector::end const): 29 (WTF::FixedVector::rbegin): 30 (WTF::FixedVector::rend): 31 (WTF::FixedVector::rbegin const): 32 (WTF::FixedVector::rend const): 33 (WTF::FixedVector::at): 34 (WTF::FixedVector::at const): 35 (WTF::FixedVector::operator[]): 36 (WTF::FixedVector::operator[] const): 37 (WTF::FixedVector::first): 38 (WTF::FixedVector::first const): 39 (WTF::FixedVector::last): 40 (WTF::FixedVector::last const): 41 (WTF::FixedVector::fill): 42 (WTF::FixedVector::operator== const): 43 (WTF::FixedVector::swap): 44 (WTF::swap): 45 * wtf/RefCountedArray.h: 46 (WTF::RefCountedArray::RefCountedArray): 47 (WTF::RefCountedArray::fill): 48 (WTF::RefCountedArray::swap): 49 1 50 2021-04-06 Youenn Fablet <youenn@apple.com> 2 51 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r275410 r275542 743 743 E3C583C826127ADD00C57568 /* RobinHoodHashMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RobinHoodHashMap.h; sourceTree = "<group>"; }; 744 744 E3CF76902115D6BA0091DE48 /* CompactPointerTuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactPointerTuple.h; sourceTree = "<group>"; }; 745 E3E0F04F26197157004640FC /* FixedVector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FixedVector.h; sourceTree = "<group>"; }; 745 746 E3E158251EADA53C004A079D /* SystemFree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemFree.h; sourceTree = "<group>"; }; 746 747 E3E64F0B22813428001E55B4 /* Nonmovable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Nonmovable.h; sourceTree = "<group>"; }; … … 1039 1040 A331D95A21F24992009F02AA /* FileSystem.cpp */, 1040 1041 A331D95921F24992009F02AA /* FileSystem.h */, 1042 E3E0F04F26197157004640FC /* FixedVector.h */, 1041 1043 0F2B66A517B6B4F700A7AE3F /* FlipBytes.h */, 1042 1044 FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r275410 r275542 70 70 FilePrintStream.h 71 71 FileSystem.h 72 FixedVector.h 72 73 FlipBytes.h 73 74 ForbidHeapAllocation.h -
trunk/Source/WTF/wtf/FastBitVector.h
r254735 r275542 480 480 public: 481 481 FastBitVector() { } 482 explicit FastBitVector(size_t numBits) 483 { 484 grow(numBits); 485 } 482 486 483 487 FastBitVector(const FastBitVector&) = default; -
trunk/Source/WTF/wtf/RefCountedArray.h
r275490 r275542 67 67 { } 68 68 69 RefCountedArray(RefCountedArray&& other) 70 : m_data(PtrTraits::exchange(other.m_data, nullptr)) 71 { } 72 69 73 explicit RefCountedArray(size_t size) 70 74 { … … 212 216 T& last() { return (*this)[size() - 1]; } 213 217 const T& last() const { return (*this)[size() - 1]; } 218 219 void fill(const T& val) 220 { 221 std::fill(begin(), end(), val); 222 } 223 224 void swap(RefCountedArray& other) 225 { 226 PtrTraits::swap(m_data, other.m_data); 227 } 214 228 215 229 template<typename OtherTraits = PtrTraits> -
trunk/Tools/ChangeLog
r275537 r275542 1 2021-04-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [WTF] Introduce FixedVector and use it for FixedOperands 4 https://bugs.webkit.org/show_bug.cgi?id=224171 5 6 Reviewed by Mark Lam. 7 8 * TestWebKitAPI/CMakeLists.txt: 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WTF/FixedVector.cpp: Added. 11 (TestWebKitAPI::TEST): 12 (TestWebKitAPI::DestructorObserver::DestructorObserver): 13 (TestWebKitAPI::DestructorObserver::~DestructorObserver): 14 (TestWebKitAPI::DestructorObserver::operator=): 15 1 16 2021-04-06 Eric Carlson <eric.carlson@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/CMakeLists.txt
r275410 r275542 45 45 Tests/WTF/Expected.cpp 46 46 Tests/WTF/FileSystem.cpp 47 Tests/WTF/FixedVector.cpp 47 48 Tests/WTF/Function.cpp 48 49 Tests/WTF/HashCountedSet.cpp -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r275537 r275542 1111 1111 E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; }; 1112 1112 E302BDAA2404B92400865277 /* CompactRefPtrTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E302BDA92404B92300865277 /* CompactRefPtrTuple.cpp */; }; 1113 E3210519261979F300157C67 /* FixedVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3210518261979F300157C67 /* FixedVector.cpp */; }; 1113 1114 E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398BC0F2041C76300387136 /* UniqueArray.cpp */; }; 1114 1115 E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */; }; … … 2905 2906 E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; }; 2906 2907 E302BDA92404B92300865277 /* CompactRefPtrTuple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompactRefPtrTuple.cpp; sourceTree = "<group>"; }; 2908 E3210518261979F300157C67 /* FixedVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixedVector.cpp; sourceTree = "<group>"; }; 2907 2909 E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureInPictureSupport.mm; sourceTree = "<group>"; }; 2908 2910 E32B549122810AC0008AD702 /* Packed.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Packed.cpp; sourceTree = "<group>"; }; … … 4374 4376 AD7C434C1DD2A5470026888B /* Expected.cpp */, 4375 4377 A310827121F296EC00C28B97 /* FileSystem.cpp */, 4378 E3210518261979F300157C67 /* FixedVector.cpp */, 4376 4379 9310CD361EF708FB0050FFE0 /* Function.cpp */, 4377 4380 83DB79671EF63B3C00BFA5E5 /* Function.cpp */, … … 5125 5128 AD7C434D1DD2A54E0026888B /* Expected.cpp in Sources */, 5126 5129 A310827221F296FF00C28B97 /* FileSystem.cpp in Sources */, 5130 E3210519261979F300157C67 /* FixedVector.cpp in Sources */, 5127 5131 9310CD381EF708FB0050FFE0 /* Function.cpp in Sources */, 5128 5132 6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.