Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (275541 => 275542)
--- trunk/Source/_javascript_Core/ChangeLog 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-04-06 19:47:47 UTC (rev 275542)
@@ -1,3 +1,68 @@
+2021-04-06 Yusuke Suzuki <[email protected]>
+
+ [WTF] Introduce FixedVector and use it for FixedOperands
+ https://bugs.webkit.org/show_bug.cgi?id=224171
+
+ Reviewed by Mark Lam.
+
+ Define FixedOperands<T> which uses FixedVector for its storage. We use FixedOperands in FTL::OSRExitDescriptor.
+ We also replace RefCountedArray<T> with FixedVector<T> if they are not requiring RefCountedArray<T>'s ref-counting
+ semantics.
+
+ * bytecode/BytecodeGeneratorification.cpp:
+ (JSC::BytecodeGeneratorification::run):
+ * bytecode/CodeBlock.cpp:
+ (JSC::CodeBlock::finishCreation):
+ (JSC::CodeBlock::setConstantRegisters):
+ (JSC::CodeBlock::setNumParameters):
+ (JSC::CodeBlock::setRareCaseProfiles):
+ (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler):
+ * bytecode/CodeBlock.h:
+ * bytecode/Operands.h:
+ (JSC::Operands::Operands):
+ * bytecode/OperandsInlines.h:
+ (JSC::U>::dumpInContext const):
+ (JSC::U>::dump const):
+ (JSC::Operands<T>::dumpInContext const): Deleted.
+ (JSC::Operands<T>::dump const): Deleted.
+ * bytecode/PolyProtoAccessChain.h:
+ * bytecode/PolymorphicAccess.cpp:
+ (JSC::PolymorphicAccess::regenerate):
+ * bytecode/PolymorphicAccess.h:
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo):
+ (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const):
+ * bytecode/UnlinkedCodeBlock.h:
+ (JSC::UnlinkedCodeBlock::expressionInfo):
+ (JSC::UnlinkedCodeBlock::identifiers const):
+ (JSC::UnlinkedCodeBlock::constantRegisters):
+ (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation):
+ (JSC::UnlinkedCodeBlock::constantIdentifierSets):
+ (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const):
+ * bytecode/UnlinkedFunctionExecutable.h:
+ * bytecompiler/BytecodeGenerator.cpp:
+ (JSC::prepareJumpTableForSwitch):
+ * dfg/DFGJITCode.h:
+ * dfg/DFGPlan.h:
+ (JSC::DFG::Plan::tierUpInLoopHierarchy):
+ * ftl/FTLOSRExit.h:
+ * jit/GCAwareJITStubRoutine.h:
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompileSlowCases):
+ * jit/PolymorphicCallStubRoutine.h:
+ * llint/LLIntOffsetsExtractor.cpp:
+ * llint/LowLevelInterpreter.asm:
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parseInner):
+ (JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements):
+ * parser/Parser.h:
+ (JSC::Parser<LexerType>::parse):
+ (JSC::parse):
+ * runtime/CachedTypes.cpp:
+ (JSC::CachedVector::encode):
+ (JSC::CachedVector::decode const):
+ * wasm/js/JSWebAssemblyInstance.h:
+
2021-04-05 Yusuke Suzuki <[email protected]>
[JSC] Shrink some of Vectors in JSC
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeGeneratorification.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/BytecodeGeneratorification.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeGeneratorification.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -220,7 +220,7 @@
VirtualRegister state = virtualRegisterForArgumentIncludingThis(static_cast<int32_t>(JSGenerator::Argument::State));
auto& jumpTable = m_codeBlock->addSwitchJumpTable();
jumpTable.min = 0;
- jumpTable.branchOffsets = RefCountedArray<int32_t>(m_yields.size() + 1);
+ jumpTable.branchOffsets = FixedVector<int32_t>(m_yields.size() + 1);
std::fill(jumpTable.branchOffsets.begin(), jumpTable.branchOffsets.end(), 0);
jumpTable.add(0, nextToEnterPoint.offset());
for (unsigned i = 0; i < m_yields.size(); ++i)
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -403,7 +403,7 @@
}
bool shouldUpdateFunctionHasExecutedCache = m_unlinkedCode->wasCompiledWithTypeProfilerOpcodes() || m_unlinkedCode->wasCompiledWithControlFlowProfilerOpcodes();
- m_functionDecls = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionDecls());
+ m_functionDecls = FixedVector<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionDecls());
for (size_t count = unlinkedCodeBlock->numberOfFunctionDecls(), i = 0; i < count; ++i) {
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
if (shouldUpdateFunctionHasExecutedCache)
@@ -411,7 +411,7 @@
m_functionDecls[i].set(vm, this, unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source(), WTF::nullopt, NoIntrinsic, ownerExecutable->isInsideOrdinaryFunction()));
}
- m_functionExprs = RefCountedArray<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionExprs());
+ m_functionExprs = FixedVector<WriteBarrier<FunctionExecutable>>(unlinkedCodeBlock->numberOfFunctionExprs());
for (size_t count = unlinkedCodeBlock->numberOfFunctionExprs(), i = 0; i < count; ++i) {
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionExpr(i);
if (shouldUpdateFunctionHasExecutedCache)
@@ -887,7 +887,7 @@
#endif // ENABLE(JIT)
}
-void CodeBlock::setConstantRegisters(const RefCountedArray<WriteBarrier<Unknown>>& constants, const RefCountedArray<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable)
+void CodeBlock::setConstantRegisters(const FixedVector<WriteBarrier<Unknown>>& constants, const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable)
{
VM& vm = *m_vm;
auto scope = DECLARE_THROW_SCOPE(vm);
@@ -949,7 +949,7 @@
{
m_numParameters = newValue;
- m_argumentValueProfiles = RefCountedArray<ValueProfile>(Options::useJIT() ? newValue : 0);
+ m_argumentValueProfiles = FixedVector<ValueProfile>(Options::useJIT() ? newValue : 0);
}
CodeBlock* CodeBlock::specialOSREntryBlockOrNull()
@@ -1754,7 +1754,7 @@
return nullptr;
}
-void CodeBlock::setRareCaseProfiles(RefCountedArray<RareCaseProfile>&& rareCaseProfiles)
+void CodeBlock::setRareCaseProfiles(FixedVector<RareCaseProfile>&& rareCaseProfiles)
{
ConcurrentJSLocker locker(m_lock);
ensureJITData(locker).m_rareCaseProfiles = WTFMove(rareCaseProfiles);
@@ -3381,7 +3381,7 @@
{
if (!unlinkedCodeBlock()->hasOpProfileControlFlowBytecodeOffsets())
return;
- const RefCountedArray<InstructionStream::Offset>& bytecodeOffsets = unlinkedCodeBlock()->opProfileControlFlowBytecodeOffsets();
+ const FixedVector<InstructionStream::Offset>& bytecodeOffsets = unlinkedCodeBlock()->opProfileControlFlowBytecodeOffsets();
for (size_t i = 0, offsetsLength = bytecodeOffsets.size(); i < offsetsLength; i++) {
// Because op_profile_control_flow is emitted at the beginning of every basic block, finding
// the next op_profile_control_flow will give us the text range of a single basic block.
Modified: trunk/Source/_javascript_Core/bytecode/CodeBlock.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlock.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -69,7 +69,7 @@
#include "Watchpoint.h"
#include <wtf/Bag.h>
#include <wtf/FastMalloc.h>
-#include <wtf/RefCountedArray.h>
+#include <wtf/FixedVector.h>
#include <wtf/RefPtr.h>
#include <wtf/SegmentedVector.h>
#include <wtf/Vector.h>
@@ -277,7 +277,7 @@
Bag<CallLinkInfo> m_callLinkInfos;
SentinelLinkedList<CallLinkInfo, PackedRawSentinelNode<CallLinkInfo>> m_incomingCalls;
SentinelLinkedList<PolymorphicCallNode, PackedRawSentinelNode<PolymorphicCallNode>> m_incomingPolymorphicCalls;
- RefCountedArray<RareCaseProfile> m_rareCaseProfiles;
+ FixedVector<RareCaseProfile> m_rareCaseProfiles;
std::unique_ptr<PCToCodeOriginMap> m_pcToCodeOriginMap;
std::unique_ptr<RegisterAtOffsetList> m_calleeSaveRegisters;
JITCodeMap m_jitCodeMap;
@@ -341,7 +341,7 @@
void setCalleeSaveRegisters(RegisterSet);
void setCalleeSaveRegisters(std::unique_ptr<RegisterAtOffsetList>);
- void setRareCaseProfiles(RefCountedArray<RareCaseProfile>&&);
+ void setRareCaseProfiles(FixedVector<RareCaseProfile>&&);
RareCaseProfile* rareCaseProfileForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex);
unsigned rareCaseProfileCountForBytecodeIndex(const ConcurrentJSLocker&, BytecodeIndex);
@@ -956,7 +956,7 @@
void updateAllValueProfilePredictionsAndCountLiveness(unsigned& numberOfLiveNonArgumentValueProfiles, unsigned& numberOfSamplesInProfiles);
- void setConstantRegisters(const RefCountedArray<WriteBarrier<Unknown>>& constants, const RefCountedArray<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable);
+ void setConstantRegisters(const FixedVector<WriteBarrier<Unknown>>& constants, const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation, ScriptExecutable* topLevelExecutable);
void replaceConstant(VirtualRegister reg, JSValue value)
{
@@ -1032,7 +1032,7 @@
// for DFG code blocks.
CompressedLazyOperandValueProfileHolder m_lazyOperandValueProfiles;
#endif
- RefCountedArray<ValueProfile> m_argumentValueProfiles;
+ FixedVector<ValueProfile> m_argumentValueProfiles;
// Constant Pool
COMPILE_ASSERT(sizeof(Register) == sizeof(WriteBarrier<Unknown>), Register_must_be_same_size_as_WriteBarrier_Unknown);
@@ -1040,8 +1040,8 @@
// it, so we're stuck with it for now.
Vector<WriteBarrier<Unknown>> m_constantRegisters;
Vector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation;
- RefCountedArray<WriteBarrier<FunctionExecutable>> m_functionDecls;
- RefCountedArray<WriteBarrier<FunctionExecutable>> m_functionExprs;
+ FixedVector<WriteBarrier<FunctionExecutable>> m_functionDecls;
+ FixedVector<WriteBarrier<FunctionExecutable>> m_functionExprs;
WriteBarrier<CodeBlock> m_alternative;
Modified: trunk/Source/_javascript_Core/bytecode/Operands.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/Operands.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/Operands.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -28,6 +28,7 @@
#include "CallFrame.h"
#include "VirtualRegister.h"
+#include <wtf/FixedVector.h>
#include <wtf/PrintStream.h>
#include <wtf/Vector.h>
@@ -134,10 +135,10 @@
enum OperandsLikeTag { OperandsLike };
-template<typename T>
+template<typename T, typename StorageArg = std::conditional_t<std::is_same_v<T, bool>, FastBitVector, Vector<T, 0, UnsafeVectorOverflow>>>
class Operands {
public:
- using Storage = std::conditional_t<std::is_same_v<T, bool>, FastBitVector, Vector<T, 0, UnsafeVectorOverflow>>;
+ using Storage = StorageArg;
using RefType = std::conditional_t<std::is_same_v<T, bool>, FastBitReference, T&>;
using ConstRefType = std::conditional_t<std::is_same_v<T, bool>, bool, const T&>;
@@ -144,29 +145,28 @@
Operands() = default;
explicit Operands(size_t numArguments, size_t numLocals, size_t numTmps)
- : m_numArguments(numArguments)
+ : m_values(numArguments + numLocals + numTmps)
+ , m_numArguments(numArguments)
, m_numLocals(numLocals)
{
- size_t size = numArguments + numLocals + numTmps;
- m_values.grow(size);
if (!WTF::VectorTraits<T>::needsInitialization)
m_values.fill(T());
}
explicit Operands(size_t numArguments, size_t numLocals, size_t numTmps, const T& initialValue)
- : m_numArguments(numArguments)
+ : m_values(numArguments + numLocals + numTmps)
+ , m_numArguments(numArguments)
, m_numLocals(numLocals)
{
- m_values.grow(numArguments + numLocals + numTmps);
m_values.fill(initialValue);
}
- template<typename U>
- explicit Operands(OperandsLikeTag, const Operands<U>& other, const T& initialValue = T())
- : m_numArguments(other.numberOfArguments())
+ template<typename U, typename V>
+ explicit Operands(OperandsLikeTag, const Operands<U, V>& other, const T& initialValue = T())
+ : m_values(other.size())
+ , m_numArguments(other.numberOfArguments())
, m_numLocals(other.numberOfLocals())
{
- m_values.grow(other.size());
m_values.fill(initialValue);
}
@@ -399,4 +399,7 @@
unsigned m_numLocals { 0 };
};
+template<typename T>
+using FixedOperands = Operands<T, std::conditional_t<std::is_same_v<T, bool>, FastBitVector, FixedVector<T>>>;
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/bytecode/OperandsInlines.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/OperandsInlines.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/OperandsInlines.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -38,8 +38,8 @@
out.print(virtualRegister());
}
-template<typename T>
-void Operands<T>::dumpInContext(PrintStream& out, DumpContext* context) const
+template<typename T, typename U>
+void Operands<T, U>::dumpInContext(PrintStream& out, DumpContext* context) const
{
CommaPrinter comma(" ");
for (size_t argumentIndex = numberOfArguments(); argumentIndex--;) {
@@ -59,8 +59,8 @@
}
}
-template<typename T>
-void Operands<T>::dump(PrintStream& out) const
+template<typename T, typename U>
+void Operands<T, U>::dump(PrintStream& out) const
{
CommaPrinter comma(" ");
for (size_t argumentIndex = numberOfArguments(); argumentIndex--;) {
Modified: trunk/Source/_javascript_Core/bytecode/PolyProtoAccessChain.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/PolyProtoAccessChain.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/PolyProtoAccessChain.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -27,7 +27,7 @@
#include "StructureIDTable.h"
#include "VM.h"
-#include <wtf/RefCountedArray.h>
+#include <wtf/FixedVector.h>
#include <wtf/Vector.h>
namespace JSC {
@@ -44,7 +44,7 @@
static RefPtr<PolyProtoAccessChain> tryCreate(JSGlobalObject*, JSCell* base, const PropertySlot&);
static RefPtr<PolyProtoAccessChain> tryCreate(JSGlobalObject*, JSCell* base, JSObject* target);
- const RefCountedArray<StructureID>& chain() const { return m_chain; }
+ const FixedVector<StructureID>& chain() const { return m_chain; }
void dump(Structure* baseStructure, PrintStream& out) const;
@@ -82,7 +82,7 @@
// This does not include the base. We rely on AccessCase providing it for us. That said, this data
// structure is tied to the base that it was created with.
- RefCountedArray<StructureID> m_chain;
+ FixedVector<StructureID> m_chain;
};
}
Modified: trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -748,7 +748,7 @@
m_stubRoutine = createJITStubRoutine(code, vm, codeBlock, doesCalls, cellsToMark, WTFMove(state.m_callLinkInfos), codeBlockThatOwnsExceptionHandlers, callSiteIndexForExceptionHandling);
m_watchpoints = WTFMove(state.watchpoints);
if (!state.weakReferences.isEmpty())
- m_weakReferences = RefCountedArray<WriteBarrier<JSCell>>(WTFMove(state.weakReferences));
+ m_weakReferences = FixedVector<WriteBarrier<JSCell>>(WTFMove(state.weakReferences));
if (PolymorphicAccessInternal::verbose)
dataLog("Returning: ", code.code(), "\n");
Modified: trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/PolymorphicAccess.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -32,7 +32,7 @@
#include "JSFunctionInlines.h"
#include "MacroAssembler.h"
#include "ScratchRegisterAllocator.h"
-#include <wtf/RefCountedArray.h>
+#include <wtf/FixedVector.h>
#include <wtf/Vector.h>
namespace JSC {
@@ -188,7 +188,7 @@
ListType m_list;
RefPtr<JITStubRoutine> m_stubRoutine;
std::unique_ptr<WatchpointsOnStructureStubInfo> m_watchpoints;
- RefCountedArray<WriteBarrier<JSCell>> m_weakReferences;
+ FixedVector<WriteBarrier<JSCell>> m_weakReferences;
};
struct AccessGenerationState {
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -159,7 +159,7 @@
void UnlinkedCodeBlock::dumpExpressionRangeInfo()
{
- RefCountedArray<ExpressionRangeInfo>& expressionInfo = m_expressionInfo;
+ FixedVector<ExpressionRangeInfo>& expressionInfo = m_expressionInfo;
size_t size = m_expressionInfo.size();
dataLogF("UnlinkedCodeBlock %p expressionRangeInfo[%zu] {\n", this, size);
@@ -188,7 +188,7 @@
return;
}
- const RefCountedArray<ExpressionRangeInfo>& expressionInfo = m_expressionInfo;
+ const FixedVector<ExpressionRangeInfo>& expressionInfo = m_expressionInfo;
int low = 0;
int high = expressionInfo.size();
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedCodeBlock.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -42,7 +42,7 @@
#include "VirtualRegister.h"
#include <algorithm>
#include <wtf/BitVector.h>
-#include <wtf/RefCountedArray.h>
+#include <wtf/FixedVector.h>
#include <wtf/RobinHoodHashMap.h>
#include <wtf/TriState.h>
#include <wtf/Vector.h>
@@ -95,7 +95,7 @@
};
struct UnlinkedSimpleJumpTable {
- RefCountedArray<int32_t> branchOffsets;
+ FixedVector<int32_t> branchOffsets;
int32_t min;
int32_t offsetForValue(int32_t value, int32_t defaultOffset);
@@ -135,7 +135,7 @@
bool allowDirectEvalCache() const { return !(m_features & NoEvalCacheFeature); }
bool hasExpressionInfo() { return m_expressionInfo.size(); }
- const RefCountedArray<ExpressionRangeInfo>& expressionInfo() { return m_expressionInfo; }
+ const FixedVector<ExpressionRangeInfo>& expressionInfo() { return m_expressionInfo; }
bool hasCheckpoints() const { return m_hasCheckpoints; }
void setHasCheckpoints() { m_hasCheckpoints = true; }
@@ -152,17 +152,17 @@
size_t numberOfIdentifiers() const { return m_identifiers.size(); }
const Identifier& identifier(int index) const { return m_identifiers[index]; }
- const RefCountedArray<Identifier>& identifiers() const { return m_identifiers; }
+ const FixedVector<Identifier>& identifiers() const { return m_identifiers; }
BitVector& bitVector(size_t i) { ASSERT(m_rareData); return m_rareData->m_bitVectors[i]; }
- const RefCountedArray<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; }
+ const FixedVector<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; }
const WriteBarrier<Unknown>& constantRegister(VirtualRegister reg) const { return m_constantRegisters[reg.toConstantIndex()]; }
ALWAYS_INLINE JSValue getConstant(VirtualRegister reg) const { return m_constantRegisters[reg.toConstantIndex()].get(); }
- const RefCountedArray<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }
+ const FixedVector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; }
unsigned numberOfConstantIdentifierSets() const { return m_rareData ? m_rareData->m_constantIdentifierSets.size() : 0; }
- const RefCountedArray<IdentifierSet>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; }
+ const FixedVector<IdentifierSet>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; }
// Jumps
size_t numberOfJumpTargets() const { return m_jumpTargets.size(); }
@@ -234,7 +234,7 @@
ALWAYS_INLINE unsigned startColumn() const { return 0; }
unsigned endColumn() const { return m_endColumn; }
- const RefCountedArray<InstructionStream::Offset>& opProfileControlFlowBytecodeOffsets() const
+ const FixedVector<InstructionStream::Offset>& opProfileControlFlowBytecodeOffsets() const
{
ASSERT(m_rareData);
return m_rareData->m_opProfileControlFlowBytecodeOffsets;
@@ -374,7 +374,7 @@
PackedRefPtr<StringImpl> m_sourceURLDirective;
PackedRefPtr<StringImpl> m_sourceMappingURLDirective;
- RefCountedArray<InstructionStream::Offset> m_jumpTargets;
+ FixedVector<InstructionStream::Offset> m_jumpTargets;
Ref<UnlinkedMetadataTable> m_metadata;
std::unique_ptr<InstructionStream> m_instructions;
std::unique_ptr<BytecodeLivenessAnalysis> m_liveness;
@@ -385,10 +385,10 @@
#endif
// Constant Pools
- RefCountedArray<Identifier> m_identifiers;
- RefCountedArray<WriteBarrier<Unknown>> m_constantRegisters;
- RefCountedArray<SourceCodeRepresentation> m_constantsSourceCodeRepresentation;
- using FunctionExpressionVector = RefCountedArray<WriteBarrier<UnlinkedFunctionExecutable>>;
+ FixedVector<Identifier> m_identifiers;
+ FixedVector<WriteBarrier<Unknown>> m_constantRegisters;
+ FixedVector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation;
+ using FunctionExpressionVector = FixedVector<WriteBarrier<UnlinkedFunctionExecutable>>;
FunctionExpressionVector m_functionDecls;
FunctionExpressionVector m_functionExprs;
@@ -396,13 +396,13 @@
struct RareData {
WTF_MAKE_STRUCT_FAST_ALLOCATED;
- RefCountedArray<UnlinkedHandlerInfo> m_exceptionHandlers;
+ FixedVector<UnlinkedHandlerInfo> m_exceptionHandlers;
// Jump Tables
- RefCountedArray<UnlinkedSimpleJumpTable> m_switchJumpTables;
- RefCountedArray<UnlinkedStringJumpTable> m_stringSwitchJumpTables;
+ FixedVector<UnlinkedSimpleJumpTable> m_switchJumpTables;
+ FixedVector<UnlinkedStringJumpTable> m_stringSwitchJumpTables;
- RefCountedArray<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions;
+ FixedVector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions;
struct TypeProfilerExpressionRange {
unsigned m_startDivot;
@@ -409,9 +409,9 @@
unsigned m_endDivot;
};
HashMap<unsigned, TypeProfilerExpressionRange> m_typeProfilerInfoMap;
- RefCountedArray<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;
- RefCountedArray<BitVector> m_bitVectors;
- RefCountedArray<IdentifierSet> m_constantIdentifierSets;
+ FixedVector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets;
+ FixedVector<BitVector> m_bitVectors;
+ FixedVector<IdentifierSet> m_constantIdentifierSets;
unsigned m_needsClassFieldInitializer : 1;
unsigned m_privateBrandRequirement : 1;
@@ -428,7 +428,7 @@
OutOfLineJumpTargets m_outOfLineJumpTargets;
std::unique_ptr<RareData> m_rareData;
- RefCountedArray<ExpressionRangeInfo> m_expressionInfo;
+ FixedVector<ExpressionRangeInfo> m_expressionInfo;
protected:
DECLARE_VISIT_CHILDREN;
Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -38,8 +38,8 @@
#include "RegExp.h"
#include "SourceCode.h"
#include "VariableEnvironment.h"
+#include <wtf/FixedVector.h>
#include <wtf/Optional.h>
-#include <wtf/RefCountedArray.h>
namespace JSC {
@@ -219,13 +219,13 @@
String m_sourceURLDirective;
String m_sourceMappingURLDirective;
RefPtr<TDZEnvironmentLink> m_parentScopeTDZVariables;
- RefCountedArray<JSTextPosition> m_classFieldLocations;
+ FixedVector<JSTextPosition> m_classFieldLocations;
PrivateNameEnvironment m_parentPrivateNameEnvironment;
};
NeedsClassFieldInitializer needsClassFieldInitializer() const { return static_cast<NeedsClassFieldInitializer>(m_needsClassFieldInitializer); }
- RefCountedArray<JSTextPosition>* classFieldLocations() const
+ const FixedVector<JSTextPosition>* classFieldLocations() const
{
if (m_rareData)
return &m_rareData->m_classFieldLocations;
@@ -236,7 +236,7 @@
{
if (classFieldLocations.isEmpty())
return;
- ensureRareData().m_classFieldLocations = RefCountedArray<JSTextPosition>(WTFMove(classFieldLocations));
+ ensureRareData().m_classFieldLocations = FixedVector<JSTextPosition>(WTFMove(classFieldLocations));
}
private:
Modified: trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/bytecompiler/BytecodeGenerator.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -4092,7 +4092,7 @@
int32_t (*keyGetter)(ExpressionNode*, int32_t min, int32_t max))
{
jumpTable.min = min;
- jumpTable.branchOffsets = RefCountedArray<int32_t>(max - min + 1);
+ jumpTable.branchOffsets = FixedVector<int32_t>(max - min + 1);
std::fill(jumpTable.branchOffsets.begin(), jumpTable.branchOffsets.end(), 0);
for (uint32_t i = 0; i < clauseCount; ++i) {
// We're emitting this after the clause labels should have been fixed, so
Modified: trunk/Source/_javascript_Core/dfg/DFGJITCode.h (275541 => 275542)
--- trunk/Source/_javascript_Core/dfg/DFGJITCode.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/dfg/DFGJITCode.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -151,7 +151,7 @@
//
// The key may not always be a target for OSR Entry but the list in the value is guaranteed
// to be usable for OSR Entry.
- HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>> tierUpInLoopHierarchy;
+ HashMap<BytecodeIndex, FixedVector<BytecodeIndex>> tierUpInLoopHierarchy;
// Map each bytecode of CheckTierUpAndOSREnter to its stream index.
HashMap<BytecodeIndex, unsigned> bytecodeIndexToStreamIndex;
Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.h (275541 => 275542)
--- trunk/Source/_javascript_Core/dfg/DFGPlan.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -106,7 +106,7 @@
bool willTryToTierUp() const { return m_willTryToTierUp; }
void setWillTryToTierUp(bool willTryToTierUp) { m_willTryToTierUp = willTryToTierUp; }
- HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; }
+ HashMap<BytecodeIndex, FixedVector<BytecodeIndex>>& tierUpInLoopHierarchy() { return m_tierUpInLoopHierarchy; }
Vector<BytecodeIndex>& tierUpAndOSREnterBytecodes() { return m_tierUpAndOSREnterBytecodes; }
enum Stage { Preparing, Compiling, Ready, Cancelled };
@@ -159,7 +159,7 @@
DesiredGlobalProperties m_globalProperties;
RecordedStatuses m_recordedStatuses;
- HashMap<BytecodeIndex, RefCountedArray<BytecodeIndex>> m_tierUpInLoopHierarchy;
+ HashMap<BytecodeIndex, FixedVector<BytecodeIndex>> m_tierUpInLoopHierarchy;
Vector<BytecodeIndex> m_tierUpAndOSREnterBytecodes;
Stage m_stage;
Modified: trunk/Source/_javascript_Core/ftl/FTLOSRExit.h (275541 => 275542)
--- trunk/Source/_javascript_Core/ftl/FTLOSRExit.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/ftl/FTLOSRExit.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -67,6 +67,9 @@
struct OSRExitHandle;
struct OSRExitDescriptor {
+private:
+ WTF_MAKE_NONCOPYABLE(OSRExitDescriptor);
+public:
OSRExitDescriptor(
DataFormat profileDataFormat, MethodOfGettingAValueProfile,
unsigned numberOfArguments, unsigned numberOfLocals, unsigned numberOfTmps);
@@ -79,7 +82,7 @@
DataFormat m_profileDataFormat;
MethodOfGettingAValueProfile m_valueProfile;
- Operands<ExitValue> m_values;
+ FixedOperands<ExitValue> m_values;
Bag<ExitTimeObjectMaterialization> m_materializations;
void validateReferences(const TrackedReferences&);
Modified: trunk/Source/_javascript_Core/jit/GCAwareJITStubRoutine.h (275541 => 275542)
--- trunk/Source/_javascript_Core/jit/GCAwareJITStubRoutine.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/jit/GCAwareJITStubRoutine.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -30,7 +30,7 @@
#include "JITStubRoutine.h"
#include "JSObject.h"
#include "WriteBarrier.h"
-#include <wtf/RefCountedArray.h>
+#include <wtf/FixedVector.h>
#include <wtf/Vector.h>
namespace JSC {
@@ -97,7 +97,7 @@
void markRequiredObjectsInternal(SlotVisitor&) final;
private:
- RefCountedArray<WriteBarrier<JSCell>> m_cells;
+ FixedVector<WriteBarrier<JSCell>> m_cells;
Bag<CallLinkInfo> m_callLinkInfos;
};
Modified: trunk/Source/_javascript_Core/jit/JIT.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/jit/JIT.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/jit/JIT.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -520,9 +520,9 @@
m_byValInstructionIndex = 0;
m_callLinkInfoIndex = 0;
- RefCountedArray<RareCaseProfile> rareCaseProfiles;
+ FixedVector<RareCaseProfile> rareCaseProfiles;
if (shouldEmitProfiling())
- rareCaseProfiles = RefCountedArray<RareCaseProfile>(m_bytecodeCountHavingSlowCase);
+ rareCaseProfiles = FixedVector<RareCaseProfile>(m_bytecodeCountHavingSlowCase);
unsigned bytecodeCountHavingSlowCase = 0;
for (Vector<SlowCaseEntry>::iterator iter = m_slowCases.begin(); iter != m_slowCases.end();) {
Modified: trunk/Source/_javascript_Core/jit/PolymorphicCallStubRoutine.h (275541 => 275542)
--- trunk/Source/_javascript_Core/jit/PolymorphicCallStubRoutine.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/jit/PolymorphicCallStubRoutine.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -109,7 +109,7 @@
void markRequiredObjectsInternal(AbstractSlotVisitor&) final;
void markRequiredObjectsInternal(SlotVisitor&) final;
- RefCountedArray<WriteBarrier<JSCell>> m_variants;
+ FixedVector<WriteBarrier<JSCell>> m_variants;
UniqueArray<uint32_t> m_fastCounts;
Bag<PolymorphicCallNode> m_callNodes;
};
Modified: trunk/Source/_javascript_Core/llint/LLIntOffsetsExtractor.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/llint/LLIntOffsetsExtractor.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/llint/LLIntOffsetsExtractor.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -86,6 +86,7 @@
// These types are useful since we can't use '<...>' syntax in LLInt offsets extraction. e.g. Vector<int>::m_data
using Vector = WTF::Vector<int>;
using JSInternalFieldObjectImpl = JSC::JSInternalFieldObjectImpl<>;
+ using FixedVector = WTF::FixedVector<int>;
using RefCountedArray = WTF::RefCountedArray<int>;
public:
Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (275541 => 275542)
--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2021-04-06 19:47:47 UTC (rev 275542)
@@ -1550,7 +1550,7 @@
addp -profileArgSkip, t0 # Use addi because that's what has the peephole
assert(macro (ok) bpgteq t0, 0, ok end)
btpz t0, .argumentProfileDone
- loadp CodeBlock::m_argumentValueProfiles + RefCountedArray::m_data[t1], t3
+ loadp CodeBlock::m_argumentValueProfiles + FixedVector::m_storage + RefCountedArray::m_data[t1], t3
btpz t3, .argumentProfileDone # When we can't JIT, we don't allocate any argument value profiles.
mulp sizeof ValueProfile, t0, t2 # Aaaaahhhh! Need strength reduction!
lshiftp 3, t0 # offset of last JSValue arguments on the stack.
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -215,7 +215,7 @@
}
template <typename LexerType>
-Expected<typename Parser<LexerType>::ParseInnerResult, String> Parser<LexerType>::parseInner(const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const RefCountedArray<JSTextPosition>* classFieldLocations, const PrivateNameEnvironment* parentScopePrivateNames)
+Expected<typename Parser<LexerType>::ParseInnerResult, String> Parser<LexerType>::parseInner(const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const FixedVector<JSTextPosition>* classFieldLocations, const PrivateNameEnvironment* parentScopePrivateNames)
{
ASTBuilder context(const_cast<VM&>(m_vm), m_parserArena, const_cast<SourceCode*>(m_source));
SourceParseMode parseMode = sourceParseMode();
@@ -3180,7 +3180,7 @@
}
template <typename LexerType>
-template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const RefCountedArray<JSTextPosition>& classFieldLocations)
+template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFieldInitializerSourceElements(TreeBuilder& context, const FixedVector<JSTextPosition>& classFieldLocations)
{
TreeSourceElements sourceElements = context.createSourceElements();
currentScope()->setIsClassScope();
Modified: trunk/Source/_javascript_Core/parser/Parser.h (275541 => 275542)
--- trunk/Source/_javascript_Core/parser/Parser.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/parser/Parser.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -35,9 +35,9 @@
#include "SourceProviderCache.h"
#include "SourceProviderCacheItem.h"
#include "VariableEnvironment.h"
+#include <wtf/FixedVector.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
-#include <wtf/RefCountedArray.h>
#include <wtf/RefPtr.h>
namespace JSC {
@@ -992,7 +992,7 @@
~Parser();
template <class ParsedNode>
- std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const RefCountedArray<JSTextPosition>* = nullptr);
+ std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition = WTF::nullopt, const PrivateNameEnvironment* = nullptr, const FixedVector<JSTextPosition>* = nullptr);
JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
JSTokenLocation locationBeforeLastToken() const { return m_lexer->lastTokenLocation(); }
@@ -1512,7 +1512,7 @@
CodeFeatures features;
int numConstants;
};
- Expected<ParseInnerResult, String> parseInner(const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition, const RefCountedArray<JSTextPosition>*, const PrivateNameEnvironment* parentScopePrivateNames);
+ Expected<ParseInnerResult, String> parseInner(const Identifier&, ParsingContext, Optional<int> functionConstructorParametersEndPosition, const FixedVector<JSTextPosition>*, const PrivateNameEnvironment* parentScopePrivateNames);
// Used to determine type of error to report.
bool isFunctionMetadataNode(ScopeNode*) { return false; }
@@ -1743,7 +1743,7 @@
template <class TreeBuilder> TreeSourceElements parseAsyncFunctionSourceElements(TreeBuilder&, bool isArrowFunctionBodyExpression, SourceElementsMode);
template <class TreeBuilder> TreeSourceElements parseAsyncGeneratorFunctionSourceElements(TreeBuilder&, bool isArrowFunctionBodyExpression, SourceElementsMode);
template <class TreeBuilder> TreeSourceElements parseSingleFunction(TreeBuilder&, Optional<int> functionConstructorParametersEndPosition);
- template <class TreeBuilder> TreeSourceElements parseClassFieldInitializerSourceElements(TreeBuilder&, const RefCountedArray<JSTextPosition>&);
+ template <class TreeBuilder> TreeSourceElements parseClassFieldInitializerSourceElements(TreeBuilder&, const FixedVector<JSTextPosition>&);
template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength);
template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = nullptr);
enum class ExportType { Exported, NotExported };
@@ -2128,7 +2128,7 @@
template <typename LexerType>
template <class ParsedNode>
-std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const RefCountedArray<JSTextPosition>* classFieldLocations)
+std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, ParsingContext parsingContext, Optional<int> functionConstructorParametersEndPosition, const PrivateNameEnvironment* parentScopePrivateNames, const FixedVector<JSTextPosition>* classFieldLocations)
{
int errLine;
String errMsg;
@@ -2229,7 +2229,7 @@
EvalContextType evalContextType = EvalContextType::None,
DebuggerParseData* debuggerParseData = nullptr,
const PrivateNameEnvironment* parentScopePrivateNames = nullptr,
- const RefCountedArray<JSTextPosition>* classFieldLocations = nullptr,
+ const FixedVector<JSTextPosition>* classFieldLocations = nullptr,
bool isInsideOrdinaryFunction = false)
{
ASSERT(!source.provider()->source().isNull());
Modified: trunk/Source/_javascript_Core/runtime/CachedTypes.cpp (275541 => 275542)
--- trunk/Source/_javascript_Core/runtime/CachedTypes.cpp 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/runtime/CachedTypes.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -603,7 +603,8 @@
template<typename T, size_t InlineCapacity = 0, typename OverflowHandler = CrashOnOverflow, typename Malloc = WTF::VectorMalloc>
class CachedVector : public VariableLengthObject<Vector<SourceType<T>, InlineCapacity, OverflowHandler, 16, Malloc>> {
public:
- void encode(Encoder& encoder, const Vector<SourceType<T>, InlineCapacity, OverflowHandler, 16, Malloc>& vector)
+ template<typename VectorContainer>
+ void encode(Encoder& encoder, const VectorContainer& vector)
{
m_size = vector.size();
if (!m_size)
@@ -613,39 +614,17 @@
::JSC::encode(encoder, buffer[i], vector[i]);
}
- void encode(Encoder& encoder, const RefCountedArray<SourceType<T>>& vector)
+ template<typename... Args, typename VectorContainer>
+ void decode(Decoder& decoder, VectorContainer& vector, Args... args) const
{
- m_size = vector.size();
if (!m_size)
return;
- T* buffer = this->template allocate<T>(encoder, m_size);
- for (unsigned i = 0; i < m_size; ++i)
- ::JSC::encode(encoder, buffer[i], vector[i]);
- }
-
- template<typename... Args>
- void decode(Decoder& decoder, Vector<SourceType<T>, InlineCapacity, OverflowHandler, 16, Malloc>& vector, Args... args) const
- {
- if (!m_size)
- return;
- vector.resizeToFit(m_size);
+ vector = VectorContainer(m_size);
const T* buffer = this->template buffer<T>();
for (unsigned i = 0; i < m_size; ++i)
::JSC::decode(decoder, buffer[i], vector[i], args...);
}
- template<typename... Args>
- void decode(Decoder& decoder, RefCountedArray<SourceType<T>>& vector, Args... args) const
- {
- if (!m_size)
- return;
- vector = RefCountedArray<SourceType<T>>(m_size);
- const T* buffer = this->template buffer<T>();
- for (unsigned i = 0; i < m_size; ++i)
- ::JSC::decode(decoder, buffer[i], vector[i], args...);
- }
-
-
private:
unsigned m_size;
};
Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.h (275541 => 275542)
--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -34,8 +34,8 @@
#include "JSWebAssemblyTable.h"
#include "WasmCreationMode.h"
#include "WasmInstance.h"
+#include <wtf/FixedVector.h>
#include <wtf/Ref.h>
-#include <wtf/RefCountedArray.h>
namespace JSC {
@@ -116,7 +116,7 @@
WriteBarrier<JSWebAssemblyCodeBlock> m_codeBlock;
WriteBarrier<WebAssemblyModuleRecord> m_moduleRecord;
WriteBarrier<JSWebAssemblyMemory> m_memory;
- RefCountedArray<WriteBarrier<JSWebAssemblyTable>> m_tables;
+ FixedVector<WriteBarrier<JSWebAssemblyTable>> m_tables;
};
} // namespace JSC
Modified: trunk/Source/WTF/ChangeLog (275541 => 275542)
--- trunk/Source/WTF/ChangeLog 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/WTF/ChangeLog 2021-04-06 19:47:47 UTC (rev 275542)
@@ -1,3 +1,52 @@
+2021-04-06 Yusuke Suzuki <[email protected]>
+
+ [WTF] Introduce FixedVector and use it for FixedOperands
+ https://bugs.webkit.org/show_bug.cgi?id=224171
+
+ Reviewed by Mark Lam.
+
+ This FixedVector<T> is a wrapper around RefCountedArray<T>, but this offers Vector-like copy / move semantics,
+ so that we can use this FixedVector<T> as a drop-in-replacement for fixed-sized Vector fields. The purpose
+ of that is saving memory by removing unnecessary storage (FixedVector is fixed-sized allocated) and putting size
+ into the allocated memory.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ * wtf/FastBitVector.h:
+ (WTF::FastBitVector::FastBitVector):
+ * wtf/FixedVector.h: Added.
+ (WTF::FixedVector::FixedVector):
+ (WTF::FixedVector::operator=):
+ (WTF::FixedVector::size const):
+ (WTF::FixedVector::isEmpty const):
+ (WTF::FixedVector::byteSize const):
+ (WTF::FixedVector::data):
+ (WTF::FixedVector::begin):
+ (WTF::FixedVector::end):
+ (WTF::FixedVector::data const):
+ (WTF::FixedVector::begin const):
+ (WTF::FixedVector::end const):
+ (WTF::FixedVector::rbegin):
+ (WTF::FixedVector::rend):
+ (WTF::FixedVector::rbegin const):
+ (WTF::FixedVector::rend const):
+ (WTF::FixedVector::at):
+ (WTF::FixedVector::at const):
+ (WTF::FixedVector::operator[]):
+ (WTF::FixedVector::operator[] const):
+ (WTF::FixedVector::first):
+ (WTF::FixedVector::first const):
+ (WTF::FixedVector::last):
+ (WTF::FixedVector::last const):
+ (WTF::FixedVector::fill):
+ (WTF::FixedVector::operator== const):
+ (WTF::FixedVector::swap):
+ (WTF::swap):
+ * wtf/RefCountedArray.h:
+ (WTF::RefCountedArray::RefCountedArray):
+ (WTF::RefCountedArray::fill):
+ (WTF::RefCountedArray::swap):
+
2021-04-06 Youenn Fablet <[email protected]>
Enable NSURLSession WebSocket code path by default
Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (275541 => 275542)
--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj 2021-04-06 19:47:47 UTC (rev 275542)
@@ -742,6 +742,7 @@
E3BE09A624A58545009DF2B4 /* ICUHelpers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ICUHelpers.cpp; sourceTree = "<group>"; };
E3C583C826127ADD00C57568 /* RobinHoodHashMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RobinHoodHashMap.h; sourceTree = "<group>"; };
E3CF76902115D6BA0091DE48 /* CompactPointerTuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompactPointerTuple.h; sourceTree = "<group>"; };
+ E3E0F04F26197157004640FC /* FixedVector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FixedVector.h; sourceTree = "<group>"; };
E3E158251EADA53C004A079D /* SystemFree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemFree.h; sourceTree = "<group>"; };
E3E64F0B22813428001E55B4 /* Nonmovable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Nonmovable.h; sourceTree = "<group>"; };
E419F2E623AB9E2300B26129 /* VectorHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VectorHash.h; sourceTree = "<group>"; };
@@ -1038,6 +1039,7 @@
0F9D335C165DBA73005AD387 /* FilePrintStream.h */,
A331D95A21F24992009F02AA /* FileSystem.cpp */,
A331D95921F24992009F02AA /* FileSystem.h */,
+ E3E0F04F26197157004640FC /* FixedVector.h */,
0F2B66A517B6B4F700A7AE3F /* FlipBytes.h */,
FE86A8741E59440200111BBF /* ForbidHeapAllocation.h */,
A8A472A6151A825A004123FF /* Forward.h */,
Modified: trunk/Source/WTF/wtf/CMakeLists.txt (275541 => 275542)
--- trunk/Source/WTF/wtf/CMakeLists.txt 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/WTF/wtf/CMakeLists.txt 2021-04-06 19:47:47 UTC (rev 275542)
@@ -69,6 +69,7 @@
FileMetadata.h
FilePrintStream.h
FileSystem.h
+ FixedVector.h
FlipBytes.h
ForbidHeapAllocation.h
Forward.h
Modified: trunk/Source/WTF/wtf/FastBitVector.h (275541 => 275542)
--- trunk/Source/WTF/wtf/FastBitVector.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/WTF/wtf/FastBitVector.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -479,6 +479,10 @@
class FastBitVector : public FastBitVectorImpl<FastBitVectorWordOwner> {
public:
FastBitVector() { }
+ explicit FastBitVector(size_t numBits)
+ {
+ grow(numBits);
+ }
FastBitVector(const FastBitVector&) = default;
FastBitVector& operator=(const FastBitVector&) = default;
Added: trunk/Source/WTF/wtf/FixedVector.h (0 => 275542)
--- trunk/Source/WTF/wtf/FixedVector.h (rev 0)
+++ trunk/Source/WTF/wtf/FixedVector.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/RefCountedArray.h>
+
+namespace WTF {
+
+// Wrapper around RefCountedArray, fixed-sized, memory compact Vector.
+// Copy constructor / assignment operator work differently from RefCountedArray: works as like a Vector.
+template<typename T>
+class FixedVector {
+public:
+ using iterator = T*;
+ using const_iterator = const T*;
+ using reverse_iterator = std::reverse_iterator<iterator>;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+
+ FixedVector() = default;
+ FixedVector(const FixedVector& other)
+ : m_storage(other.m_storage.clone())
+ { }
+ FixedVector(FixedVector&& other) = default;
+
+ FixedVector& operator=(const FixedVector& other)
+ {
+ FixedVector tmp(other);
+ swap(tmp);
+ return *this;
+ }
+
+ FixedVector& operator=(FixedVector&& other)
+ {
+ FixedVector tmp(WTFMove(other));
+ swap(tmp);
+ return *this;
+ }
+
+ explicit FixedVector(size_t size)
+ : m_storage(size)
+ { }
+
+ template<size_t inlineCapacity, typename OverflowHandler>
+ explicit FixedVector(const Vector<T, inlineCapacity, OverflowHandler>& other)
+ : m_storage(other)
+ { }
+
+ template<size_t inlineCapacity, typename OverflowHandler>
+ FixedVector& operator=(const Vector<T, inlineCapacity, OverflowHandler>& other)
+ {
+ m_storage = other;
+ return *this;
+ }
+
+ size_t size() const { return m_storage.size(); }
+ bool isEmpty() const { return m_storage.isEmpty(); }
+ size_t byteSize() const { return m_storage.byteSize(); }
+
+ T* data() { return m_storage.data(); }
+ iterator begin() { return m_storage.begin(); }
+ iterator end() { return m_storage.end(); }
+
+ const T* data() const { return const_cast<FixedVector*>(this)->data(); }
+ const_iterator begin() const { return const_cast<FixedVector*>(this)->begin(); }
+ const_iterator end() const { return const_cast<FixedVector*>(this)->end(); }
+
+ reverse_iterator rbegin() { return m_storage.rbegin(); }
+ reverse_iterator rend() { return m_storage.rend(); }
+ const_reverse_iterator rbegin() const { return m_storage.rbegin(); }
+ const_reverse_iterator rend() const { return m_storage.rend(); }
+
+ T& at(size_t i) { return m_storage.at(i); }
+ const T& at(size_t i) const { return m_storage.at(i); }
+
+ T& operator[](size_t i) { return at(i); }
+ const T& operator[](size_t i) const { return at(i); }
+
+ T& first() { return (*this)[0]; }
+ const T& first() const { return (*this)[0]; }
+ T& last() { return (*this)[size() - 1]; }
+ const T& last() const { return (*this)[size() - 1]; }
+
+ void fill(const T& val) { m_storage.fill(val); }
+
+ bool operator==(const FixedVector<T>& other) const { return m_storage == other.m_storage; }
+
+ void swap(FixedVector<T>& other)
+ {
+ m_storage.swap(other.m_storage);
+ }
+
+private:
+ friend class JSC::LLIntOffsetsExtractor;
+
+ RefCountedArray<T> m_storage;
+};
+static_assert(sizeof(FixedVector<int>) == sizeof(int*));
+
+template<typename T>
+inline void swap(FixedVector<T>& a, FixedVector<T>& b)
+{
+ a.swap(b);
+}
+
+} // namespace WTF
+
+using WTF::FixedVector;
Modified: trunk/Source/WTF/wtf/RefCountedArray.h (275541 => 275542)
--- trunk/Source/WTF/wtf/RefCountedArray.h 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Source/WTF/wtf/RefCountedArray.h 2021-04-06 19:47:47 UTC (rev 275542)
@@ -66,6 +66,10 @@
: RefCountedArray(CommonCopyConstructor, other)
{ }
+ RefCountedArray(RefCountedArray&& other)
+ : m_data(PtrTraits::exchange(other.m_data, nullptr))
+ { }
+
explicit RefCountedArray(size_t size)
{
if (!size) {
@@ -212,6 +216,16 @@
T& last() { return (*this)[size() - 1]; }
const T& last() const { return (*this)[size() - 1]; }
+ void fill(const T& val)
+ {
+ std::fill(begin(), end(), val);
+ }
+
+ void swap(RefCountedArray& other)
+ {
+ PtrTraits::swap(m_data, other.m_data);
+ }
+
template<typename OtherTraits = PtrTraits>
bool operator==(const RefCountedArray<T, OtherTraits>& other) const
{
Modified: trunk/Tools/ChangeLog (275541 => 275542)
--- trunk/Tools/ChangeLog 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Tools/ChangeLog 2021-04-06 19:47:47 UTC (rev 275542)
@@ -1,3 +1,18 @@
+2021-04-06 Yusuke Suzuki <[email protected]>
+
+ [WTF] Introduce FixedVector and use it for FixedOperands
+ https://bugs.webkit.org/show_bug.cgi?id=224171
+
+ Reviewed by Mark Lam.
+
+ * TestWebKitAPI/CMakeLists.txt:
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WTF/FixedVector.cpp: Added.
+ (TestWebKitAPI::TEST):
+ (TestWebKitAPI::DestructorObserver::DestructorObserver):
+ (TestWebKitAPI::DestructorObserver::~DestructorObserver):
+ (TestWebKitAPI::DestructorObserver::operator=):
+
2021-04-06 Eric Carlson <[email protected]>
[macOS] Add MediaSessionCoordinator API test
Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (275541 => 275542)
--- trunk/Tools/TestWebKitAPI/CMakeLists.txt 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt 2021-04-06 19:47:47 UTC (rev 275542)
@@ -44,6 +44,7 @@
Tests/WTF/EnumTraits.cpp
Tests/WTF/Expected.cpp
Tests/WTF/FileSystem.cpp
+ Tests/WTF/FixedVector.cpp
Tests/WTF/Function.cpp
Tests/WTF/HashCountedSet.cpp
Tests/WTF/HashMap.cpp
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (275541 => 275542)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-04-06 19:42:57 UTC (rev 275541)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2021-04-06 19:47:47 UTC (rev 275542)
@@ -1110,6 +1110,7 @@
E1220DCA155B28AA0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E1220DC9155B287D0013E2FC /* MemoryCacheDisableWithinResourceLoadDelegate.html */; };
E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
E302BDAA2404B92400865277 /* CompactRefPtrTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E302BDA92404B92300865277 /* CompactRefPtrTuple.cpp */; };
+ E3210519261979F300157C67 /* FixedVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3210518261979F300157C67 /* FixedVector.cpp */; };
E324A6F02041C82000A76593 /* UniqueArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398BC0F2041C76300387136 /* UniqueArray.cpp */; };
E325C90723E3870200BC7D3B /* PictureInPictureSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */; };
E32B549222810AC4008AD702 /* Packed.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E32B549122810AC0008AD702 /* Packed.cpp */; };
@@ -2904,6 +2905,7 @@
E194E1BA177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidReceiveResponse.mm; sourceTree = "<group>"; };
E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = StopLoadingFromDidReceiveResponse.html; sourceTree = "<group>"; };
E302BDA92404B92300865277 /* CompactRefPtrTuple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CompactRefPtrTuple.cpp; sourceTree = "<group>"; };
+ E3210518261979F300157C67 /* FixedVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FixedVector.cpp; sourceTree = "<group>"; };
E325C90623E3870200BC7D3B /* PictureInPictureSupport.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureInPictureSupport.mm; sourceTree = "<group>"; };
E32B549122810AC0008AD702 /* Packed.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Packed.cpp; sourceTree = "<group>"; };
E34A6D182412DE390012AB6E /* GrantAccessToPreferencesService.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GrantAccessToPreferencesService.mm; sourceTree = "<group>"; };
@@ -4373,6 +4375,7 @@
1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */,
AD7C434C1DD2A5470026888B /* Expected.cpp */,
A310827121F296EC00C28B97 /* FileSystem.cpp */,
+ E3210518261979F300157C67 /* FixedVector.cpp */,
9310CD361EF708FB0050FFE0 /* Function.cpp */,
83DB79671EF63B3C00BFA5E5 /* Function.cpp */,
7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */,
@@ -5124,6 +5127,7 @@
1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */,
AD7C434D1DD2A54E0026888B /* Expected.cpp in Sources */,
A310827221F296FF00C28B97 /* FileSystem.cpp in Sources */,
+ E3210519261979F300157C67 /* FixedVector.cpp in Sources */,
9310CD381EF708FB0050FFE0 /* Function.cpp in Sources */,
6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */,
933D631D1FCB76200032ECD6 /* Hasher.cpp in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp (0 => 275542)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FixedVector.cpp 2021-04-06 19:47:47 UTC (rev 275542)
@@ -0,0 +1,265 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "MoveOnly.h"
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/ListHashSet.h>
+#include <wtf/FixedVector.h>
+#include <wtf/VectorHash.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTF_FixedVector, Empty)
+{
+ FixedVector<unsigned> intVector;
+ EXPECT_TRUE(intVector.isEmpty());
+ EXPECT_EQ(0U, intVector.size());
+}
+
+TEST(WTF_FixedVector, Iterator)
+{
+ FixedVector<unsigned> intVector(4);
+ intVector[0] = 10;
+ intVector[1] = 11;
+ intVector[2] = 12;
+ intVector[3] = 13;
+
+ FixedVector<unsigned>::iterator it = intVector.begin();
+ FixedVector<unsigned>::iterator end = intVector.end();
+ EXPECT_TRUE(end != it);
+
+ EXPECT_EQ(10U, *it);
+ ++it;
+ EXPECT_EQ(11U, *it);
+ ++it;
+ EXPECT_EQ(12U, *it);
+ ++it;
+ EXPECT_EQ(13U, *it);
+ ++it;
+
+ EXPECT_TRUE(end == it);
+}
+
+TEST(WTF_FixedVector, OverloadedOperatorAmpersand)
+{
+ struct Test {
+ private:
+ Test* operator&() = delete;
+ };
+
+ FixedVector<Test> vector(1);
+ vector[0] = Test();
+}
+
+TEST(WTF_FixedVector, Copy)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ FixedVector<unsigned> vec2(vec1);
+ EXPECT_EQ(vec1.size(), 3U);
+ EXPECT_EQ(vec2.size(), 3U);
+ for (unsigned i = 0; i < vec1.size(); ++i) {
+ EXPECT_EQ(vec1[i], i);
+ EXPECT_EQ(vec2[i], i);
+ }
+ vec1[2] = 42;
+ EXPECT_EQ(vec1[2], 42U);
+ EXPECT_EQ(vec2[2], 2U);
+}
+
+TEST(WTF_FixedVector, CopyAssign)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ FixedVector<unsigned> vec2;
+ vec2 = vec1;
+ EXPECT_EQ(vec1.size(), 3U);
+ EXPECT_EQ(vec2.size(), 3U);
+ for (unsigned i = 0; i < vec1.size(); ++i) {
+ EXPECT_EQ(vec1[i], i);
+ EXPECT_EQ(vec2[i], i);
+ }
+ vec1[2] = 42;
+ EXPECT_EQ(vec1[2], 42U);
+ EXPECT_EQ(vec2[2], 2U);
+}
+
+TEST(WTF_FixedVector, Move)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ FixedVector<unsigned> vec2(WTFMove(vec1));
+ EXPECT_EQ(vec1.size(), 0U);
+ EXPECT_EQ(vec2.size(), 3U);
+ for (unsigned i = 0; i < vec2.size(); ++i)
+ EXPECT_EQ(vec2[i], i);
+}
+
+TEST(WTF_FixedVector, MoveAssign)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ FixedVector<unsigned> vec2;
+ vec2 = WTFMove(vec1);
+ EXPECT_EQ(vec1.size(), 0U);
+ EXPECT_EQ(vec2.size(), 3U);
+ for (unsigned i = 0; i < vec2.size(); ++i)
+ EXPECT_EQ(vec2[i], i);
+}
+
+TEST(WTF_FixedVector, Swap)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ FixedVector<unsigned> vec2;
+ vec2.swap(vec1);
+ EXPECT_EQ(vec1.size(), 0U);
+ EXPECT_EQ(vec2.size(), 3U);
+ for (unsigned i = 0; i < vec2.size(); ++i)
+ EXPECT_EQ(vec2[i], i);
+}
+
+TEST(WTF_FixedVector, IteratorFor)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ unsigned index = 0;
+ for (auto iter = vec1.begin(); iter != vec1.end(); ++iter) {
+ EXPECT_EQ(*iter, index);
+ ++index;
+ }
+}
+
+TEST(WTF_FixedVector, Reverse)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1[0] = 0;
+ vec1[1] = 1;
+ vec1[2] = 2;
+
+ unsigned index = 0;
+ for (auto iter = vec1.rbegin(); iter != vec1.rend(); ++iter) {
+ ++index;
+ EXPECT_EQ(*iter, 3U - index);
+ }
+}
+
+TEST(WTF_FixedVector, Fill)
+{
+ FixedVector<unsigned> vec1(3);
+ vec1.fill(42);
+
+ for (auto& value : vec1)
+ EXPECT_EQ(value, 42U);
+}
+
+struct DestructorObserver {
+ DestructorObserver() = default;
+
+ DestructorObserver(bool* destructed)
+ : destructed(destructed)
+ {
+ }
+
+ ~DestructorObserver()
+ {
+ if (destructed)
+ *destructed = true;
+ }
+
+ DestructorObserver(DestructorObserver&& other)
+ : destructed(other.destructed)
+ {
+ other.destructed = nullptr;
+ }
+
+ DestructorObserver& operator=(DestructorObserver&& other)
+ {
+ destructed = other.destructed;
+ other.destructed = nullptr;
+ return *this;
+ }
+
+ bool* destructed { nullptr };
+};
+
+TEST(WTF_FixedVector, Destructor)
+{
+ Vector<bool> flags(3, false);
+ {
+ FixedVector<DestructorObserver> vector(flags.size());
+ for (unsigned i = 0; i < flags.size(); ++i)
+ vector[i] = DestructorObserver(&flags[i]);
+ for (unsigned i = 0; i < flags.size(); ++i)
+ EXPECT_FALSE(flags[i]);
+ }
+ for (unsigned i = 0; i < flags.size(); ++i)
+ EXPECT_TRUE(flags[i]);
+}
+
+TEST(WTF_FixedVector, DestructorAfterMove)
+{
+ Vector<bool> flags(3, false);
+ {
+ FixedVector<DestructorObserver> outerVector;
+ {
+ FixedVector<DestructorObserver> vector(flags.size());
+ for (unsigned i = 0; i < flags.size(); ++i)
+ vector[i] = DestructorObserver(&flags[i]);
+ for (unsigned i = 0; i < flags.size(); ++i)
+ EXPECT_FALSE(flags[i]);
+ outerVector = WTFMove(vector);
+ }
+ for (unsigned i = 0; i < flags.size(); ++i)
+ EXPECT_FALSE(flags[i]);
+ }
+ for (unsigned i = 0; i < flags.size(); ++i)
+ EXPECT_TRUE(flags[i]);
+}
+
+} // namespace TestWebKitAPI