WebKit Bugzilla
Attachment 361163 Details for
Bug 194281
: [JSC] Shrink sizeof(UnlinkedCodeBlock)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194281-20190204232805.patch (text/plain), 35.22 KB, created by
Yusuke Suzuki
on 2019-02-04 23:28:06 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2019-02-04 23:28:06 PST
Size:
35.22 KB
patch
obsolete
>Subversion Revision: 240966 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 17fc4efc0e2b12455432f4f88187635cf22e4b81..7aa038c680c31ad40660ed0282ac812e71cf8520 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,68 @@ >+2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [JSC] Shrink sizeof(UnlinkedCodeBlock) >+ https://bugs.webkit.org/show_bug.cgi?id=194281 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch first attempts to reduce the size of UnlinkedCodeBlock in a relatively simpler way. Reordering members and >+ move rarely used members to RareData. >+ >+ This patch also makes JumpTargets from Vector<> to RefCountedArray<> to get additional size reduction in sizeof(UnlinkedCodeBlock). >+ The optimization behind this change is that GC memory is relatively high cost compared to bmalloc memory in terms of memory footprint. >+ GC pools memory for faster allocation, and which requires higher memory footprint. Reducing GC memory and moving data to bmalloc region >+ makes pooled memory less. >+ >+ This change changes sizeof(UnlinkedCodeBlock) from 312 to 256. >+ >+ Still we have several chances to reduce sizeof(UnlinkedCodeBlock). Making more Vectors to RefCountedArrays can be done with some restructuring >+ of generatorification phase. It would be possible to remove m_sourceURLDirective and m_sourceMappingURLDirective from UnlinkedCodeBlock since >+ they should be in SourceProvider and that should be enough. These changes require some intrusive modifications and we make them as a future work. >+ >+ * bytecode/CodeBlock.cpp: >+ (JSC::CodeBlock::finishCreation): >+ * bytecode/CodeBlock.h: >+ (JSC::CodeBlock::bitVectors const): Deleted. >+ * bytecode/CodeType.h: >+ * bytecode/UnlinkedCodeBlock.cpp: >+ (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): >+ (JSC::UnlinkedCodeBlock::applyModification): >+ (JSC::UnlinkedCodeBlock::shrinkToFit): >+ * bytecode/UnlinkedCodeBlock.h: >+ (JSC::UnlinkedCodeBlock::bitVector): >+ (JSC::UnlinkedCodeBlock::addBitVector): >+ (JSC::UnlinkedCodeBlock::addSetConstant): >+ (JSC::UnlinkedCodeBlock::constantRegisters): >+ (JSC::UnlinkedCodeBlock::numberOfConstantIdentifierSets const): >+ (JSC::UnlinkedCodeBlock::constantIdentifierSets): >+ (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): >+ (JSC::UnlinkedCodeBlock::jumpTarget const): >+ (JSC::UnlinkedCodeBlock::setJumpTargets): >+ (JSC::UnlinkedCodeBlock::codeType const): >+ (JSC::UnlinkedCodeBlock::didOptimize const): >+ (JSC::UnlinkedCodeBlock::setDidOptimize): >+ (JSC::UnlinkedCodeBlock::bitVectors const): Deleted. >+ (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. >+ (JSC::UnlinkedCodeBlock::lastJumpTarget const): Deleted. >+ * bytecompiler/BytecodeGenerator.cpp: >+ (JSC::BytecodeGenerator::generate): >+ (JSC::BytecodeGenerator::emitLabel): >+ (JSC::BytecodeGenerator::emitEnter): >+ (JSC::BytecodeGenerator::emitLoad): >+ * bytecompiler/BytecodeGenerator.h: >+ (JSC::BytecodeGenerator::numberOfJumpTargets const): >+ (JSC::BytecodeGenerator::addJumpTarget): >+ (JSC::BytecodeGenerator::jumpTarget const): >+ (JSC::BytecodeGenerator::lastJumpTarget const): >+ * runtime/CachedTypes.cpp: >+ (JSC::CachedCodeBlockRareData::encode): >+ (JSC::CachedCodeBlockRareData::decode const): >+ (JSC::CachedCodeBlock::jumpTargets const): >+ (JSC::CachedCodeBlock::codeType const): >+ (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): >+ (JSC::CachedCodeBlock<CodeBlockType>::decode const): >+ (JSC::CachedCodeBlock<CodeBlockType>::encode): >+ > 2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> > > Unreviewed, add missing exception checks after r240637 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 8f0f5d3405395dd3141e56f1fb82850d831ff33d..aa2783aeab7500a912885102b37fc904dbecad91 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,12 @@ >+2019-02-04 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [JSC] Shrink sizeof(UnlinkedCodeBlock) >+ https://bugs.webkit.org/show_bug.cgi?id=194281 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/TriState.h: >+ > 2019-02-04 Ms2ger <Ms2ger@igalia.com> > > [GTK][WPE] Need a function to convert internal URI to display ("pretty") URI >diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.cpp b/Source/JavaScriptCore/bytecode/CodeBlock.cpp >index 3837d11e69b7876436dafcf033d73fa5d5e80fc0..bb291e032803d2d73b008b60f148ef954af9b297 100644 >--- a/Source/JavaScriptCore/bytecode/CodeBlock.cpp >+++ b/Source/JavaScriptCore/bytecode/CodeBlock.cpp >@@ -416,9 +416,6 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink > setConstantRegisters(unlinkedCodeBlock->constantRegisters(), unlinkedCodeBlock->constantsSourceCodeRepresentation()); > RETURN_IF_EXCEPTION(throwScope, false); > >- setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock->constantIdentifierSets()); >- RETURN_IF_EXCEPTION(throwScope, false); >- > if (unlinkedCodeBlock->usesGlobalObject()) > m_constantRegisters[unlinkedCodeBlock->globalObjectRegister().toConstantIndex()].set(vm, this, m_globalObject.get()); > >@@ -458,6 +455,10 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink > > if (unlinkedCodeBlock->hasRareData()) { > createRareDataIfNecessary(); >+ >+ setConstantIdentifierSetRegisters(vm, unlinkedCodeBlock->constantIdentifierSets()); >+ RETURN_IF_EXCEPTION(throwScope, false); >+ > if (size_t count = unlinkedCodeBlock->numberOfExceptionHandlers()) { > m_rareData->m_exceptionHandlers.resizeToFit(count); > for (size_t i = 0; i < count; i++) { >diff --git a/Source/JavaScriptCore/bytecode/CodeBlock.h b/Source/JavaScriptCore/bytecode/CodeBlock.h >index d5a232b61447ad48c738c2bccd31df2dd3de2fde..2b380db2babbf5b9848f3d3157e45847fc8dbb08 100644 >--- a/Source/JavaScriptCore/bytecode/CodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/CodeBlock.h >@@ -569,7 +569,6 @@ class CodeBlock : public JSCell { > int numberOfFunctionDecls() { return m_functionDecls.size(); } > FunctionExecutable* functionExpr(int index) { return m_functionExprs[index].get(); } > >- const Vector<BitVector>& bitVectors() const { return m_unlinkedCode->bitVectors(); } > const BitVector& bitVector(size_t i) { return m_unlinkedCode->bitVector(i); } > > Heap* heap() const { return &m_vm->heap; } >diff --git a/Source/JavaScriptCore/bytecode/CodeType.h b/Source/JavaScriptCore/bytecode/CodeType.h >index 3c38ca21a9095f4b3c19fbef720cec7fe005e17e..d4bda79de7d54572c5431941ddd45b633082e030 100644 >--- a/Source/JavaScriptCore/bytecode/CodeType.h >+++ b/Source/JavaScriptCore/bytecode/CodeType.h >@@ -27,7 +27,7 @@ > > namespace JSC { > >-enum CodeType { GlobalCode, EvalCode, FunctionCode, ModuleCode }; >+enum CodeType : uint8_t { GlobalCode, EvalCode, FunctionCode, ModuleCode }; > > } // namespace JSC > >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp >index 6095d589df8495de113bb329600fb3c7f528535f..bf99bf9b0a9dfccfe6d8cec809aba3706cf94aee 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp >+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp >@@ -57,7 +57,6 @@ const ClassInfo UnlinkedCodeBlock::s_info = { "UnlinkedCodeBlock", nullptr, null > UnlinkedCodeBlock::UnlinkedCodeBlock(VM* vm, Structure* structure, CodeType codeType, const ExecutableInfo& info, DebuggerMode debuggerMode) > : Base(*vm, structure) > , m_globalObjectRegister(VirtualRegister()) >- , m_metadata(UnlinkedMetadataTable::create()) > , m_usesEval(info.usesEval()) > , m_isStrictMode(info.isStrictMode()) > , m_isConstructor(info.isConstructor()) >@@ -72,14 +71,16 @@ UnlinkedCodeBlock::UnlinkedCodeBlock(VM* vm, Structure* structure, CodeType code > , m_derivedContextType(static_cast<unsigned>(info.derivedContextType())) > , m_evalContextType(static_cast<unsigned>(info.evalContextType())) > , m_hasTailCalls(false) >- , m_features(0) >- , m_didOptimize(MixedTriState) >+ , m_codeType(static_cast<unsigned>(codeType)) >+ , m_didOptimize(static_cast<unsigned>(MixedTriState)) > , m_parseMode(info.parseMode()) >- , m_codeType(codeType) >+ , m_metadata(UnlinkedMetadataTable::create()) > { > for (auto& constantRegisterIndex : m_linkTimeConstants) > constantRegisterIndex = 0; > ASSERT(m_constructorKind == static_cast<unsigned>(info.constructorKind())); >+ ASSERT(m_codeType == static_cast<unsigned>(codeType)); >+ ASSERT(m_didOptimize == static_cast<unsigned>(MixedTriState)); > } > > void UnlinkedCodeBlock::visitChildren(JSCell* cell, SlotVisitor& visitor) >@@ -370,20 +371,18 @@ void UnlinkedCodeBlock::applyModification(BytecodeRewriter& rewriter, Instructio > rewriter.applyModification(); > > // And recompute the jump target based on the modified unlinked instructions. >- m_jumpTargets.clear(); >- recomputePreciseJumpTargets(this, instructions, m_jumpTargets); >+ Vector<InstructionStream::Offset> jumpTargets; >+ recomputePreciseJumpTargets(this, instructions, jumpTargets); >+ setJumpTargets(WTFMove(jumpTargets)); > } > > void UnlinkedCodeBlock::shrinkToFit() > { > auto locker = holdLock(cellLock()); > >- m_jumpTargets.shrinkToFit(); > m_propertyAccessInstructions.shrinkToFit(); > m_identifiers.shrinkToFit(); >- m_bitVectors.shrinkToFit(); > m_constantRegisters.shrinkToFit(); >- m_constantIdentifierSets.shrinkToFit(); > m_constantsSourceCodeRepresentation.shrinkToFit(); > m_functionDecls.shrinkToFit(); > m_functionExprs.shrinkToFit(); >@@ -395,6 +394,8 @@ void UnlinkedCodeBlock::shrinkToFit() > m_rareData->m_stringSwitchJumpTables.shrinkToFit(); > m_rareData->m_expressionInfoFatPositions.shrinkToFit(); > m_rareData->m_opProfileControlFlowBytecodeOffsets.shrinkToFit(); >+ m_rareData->m_bitVectors.shrinkToFit(); >+ m_rareData->m_constantIdentifierSets.shrinkToFit(); > } > } > >diff --git a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h >index d0bb0c7ef9994abe635ebaa3d4075a4600fbbf8f..577a0bfa6c53ec9465a6eec93f9dc2084ca6a40d 100644 >--- a/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h >+++ b/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h >@@ -44,6 +44,7 @@ > #include <algorithm> > #include <wtf/BitVector.h> > #include <wtf/HashSet.h> >+#include <wtf/RefCountedArray.h> > #include <wtf/TriState.h> > #include <wtf/Vector.h> > #include <wtf/text/UniquedStringImpl.h> >@@ -156,22 +157,23 @@ class UnlinkedCodeBlock : public JSCell { > const Identifier& identifier(int index) const { return m_identifiers[index]; } > const Vector<Identifier>& identifiers() const { return m_identifiers; } > >- const Vector<BitVector>& bitVectors() const { return m_bitVectors; } >- BitVector& bitVector(size_t i) { return m_bitVectors[i]; } >+ BitVector& bitVector(size_t i) { ASSERT(m_rareData); return m_rareData->m_bitVectors[i]; } > unsigned addBitVector(BitVector&& bitVector) > { >- m_bitVectors.append(WTFMove(bitVector)); >- return m_bitVectors.size() - 1; >+ createRareDataIfNecessary(); >+ m_rareData->m_bitVectors.append(WTFMove(bitVector)); >+ return m_rareData->m_bitVectors.size() - 1; > } > > void addSetConstant(IdentifierSet& set) > { >+ createRareDataIfNecessary(); > VM& vm = *this->vm(); > auto locker = lockDuringMarking(vm.heap, cellLock()); > unsigned result = m_constantRegisters.size(); > m_constantRegisters.append(WriteBarrier<Unknown>()); > m_constantsSourceCodeRepresentation.append(SourceCodeRepresentation::Other); >- m_constantIdentifierSets.append(ConstantIdentifierSetEntry(set, result)); >+ m_rareData->m_constantIdentifierSets.append(ConstantIdentifierSetEntry(set, result)); > } > > unsigned addConstant(JSValue v, SourceCodeRepresentation sourceCodeRepresentation = SourceCodeRepresentation::Other) >@@ -204,18 +206,19 @@ class UnlinkedCodeBlock : public JSCell { > ASSERT(index < LinkTimeConstantCount); > return m_linkTimeConstants[index]; > } >+ > const Vector<WriteBarrier<Unknown>>& constantRegisters() { return m_constantRegisters; } >- const Vector<ConstantIdentifierSetEntry>& constantIdentifierSets() { return m_constantIdentifierSets; } > const WriteBarrier<Unknown>& constantRegister(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex]; } > ALWAYS_INLINE bool isConstantRegisterIndex(int index) const { return index >= FirstConstantRegisterIndex; } > ALWAYS_INLINE JSValue getConstant(int index) const { return m_constantRegisters[index - FirstConstantRegisterIndex].get(); } > const Vector<SourceCodeRepresentation>& constantsSourceCodeRepresentation() { return m_constantsSourceCodeRepresentation; } > >+ unsigned numberOfConstantIdentifierSets() const { return m_rareData ? m_rareData->m_constantIdentifierSets.size() : 0; } >+ const Vector<ConstantIdentifierSetEntry>& constantIdentifierSets() { ASSERT(m_rareData); return m_rareData->m_constantIdentifierSets; } >+ > // Jumps > size_t numberOfJumpTargets() const { return m_jumpTargets.size(); } >- void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); } > unsigned jumpTarget(int index) const { return m_jumpTargets[index]; } >- unsigned lastJumpTarget() const { return m_jumpTargets.last(); } > > UnlinkedHandlerInfo* handlerForBytecodeOffset(unsigned bytecodeOffset, RequiredHandler = RequiredHandler::AnyHandler); > UnlinkedHandlerInfo* handlerForIndex(unsigned, RequiredHandler = RequiredHandler::AnyHandler); >@@ -228,6 +231,11 @@ class UnlinkedCodeBlock : public JSCell { > > void shrinkToFit(); > >+ void setJumpTargets(Vector<InstructionStream::Offset>&& jumpTargets) >+ { >+ m_jumpTargets = RefCountedArray<InstructionStream::Offset>(jumpTargets); >+ } >+ > void setInstructions(std::unique_ptr<InstructionStream>); > const InstructionStream& instructions() const; > >@@ -272,7 +280,7 @@ class UnlinkedCodeBlock : public JSCell { > void addExceptionHandler(const UnlinkedHandlerInfo& handler) { createRareDataIfNecessary(); return m_rareData->m_exceptionHandlers.append(handler); } > UnlinkedHandlerInfo& exceptionHandler(int index) { ASSERT(m_rareData); return m_rareData->m_exceptionHandlers[index]; } > >- CodeType codeType() const { return m_codeType; } >+ CodeType codeType() const { return static_cast<CodeType>(m_codeType); } > > VirtualRegister thisRegister() const { return m_thisRegister; } > VirtualRegister scopeRegister() const { return m_scopeRegister; } >@@ -333,8 +341,8 @@ class UnlinkedCodeBlock : public JSCell { > > bool wasCompiledWithDebuggingOpcodes() const { return m_wasCompiledWithDebuggingOpcodes; } > >- TriState didOptimize() const { return m_didOptimize; } >- void setDidOptimize(TriState didOptimize) { m_didOptimize = didOptimize; } >+ TriState didOptimize() const { return static_cast<TriState>(m_didOptimize); } >+ void setDidOptimize(TriState didOptimize) { m_didOptimize = static_cast<unsigned>(didOptimize); } > > void dump(PrintStream&) const; > >@@ -401,21 +409,10 @@ class UnlinkedCodeBlock : public JSCell { > void getLineAndColumn(const ExpressionRangeInfo&, unsigned& line, unsigned& column) const; > BytecodeLivenessAnalysis& livenessAnalysisSlow(CodeBlock*); > >- std::unique_ptr<InstructionStream> m_instructions; >- std::unique_ptr<BytecodeLivenessAnalysis> m_liveness; >- > VirtualRegister m_thisRegister; > VirtualRegister m_scopeRegister; > VirtualRegister m_globalObjectRegister; > >- String m_sourceURLDirective; >- String m_sourceMappingURLDirective; >- Ref<UnlinkedMetadataTable> m_metadata; >- >-#if ENABLE(DFG_JIT) >- DFG::ExitProfile m_exitProfile; >-#endif >- > unsigned m_usesEval : 1; > unsigned m_isStrictMode : 1; > unsigned m_isConstructor : 1; >@@ -430,6 +427,13 @@ class UnlinkedCodeBlock : public JSCell { > unsigned m_derivedContextType : 2; > unsigned m_evalContextType : 2; > unsigned m_hasTailCalls : 1; >+ unsigned m_codeType : 2; >+ unsigned m_didOptimize : 2; >+public: >+ ConcurrentJSLock m_lock; >+private: >+ CodeFeatures m_features { 0 }; >+ SourceParseMode m_parseMode; > > unsigned m_lineCount { 0 }; > unsigned m_endColumn { UINT_MAX }; >@@ -438,23 +442,25 @@ class UnlinkedCodeBlock : public JSCell { > int m_numCalleeLocals { 0 }; > int m_numParameters { 0 }; > >-public: >- ConcurrentJSLock m_lock; >-private: >- CodeFeatures m_features { 0 }; >- TriState m_didOptimize; >- SourceParseMode m_parseMode; >- CodeType m_codeType; >+ String m_sourceURLDirective; >+ String m_sourceMappingURLDirective; > >- Vector<InstructionStream::Offset> m_jumpTargets; >+ Ref<UnlinkedMetadataTable> m_metadata; >+ std::unique_ptr<InstructionStream> m_instructions; >+ std::unique_ptr<BytecodeLivenessAnalysis> m_liveness; >+ >+ >+#if ENABLE(DFG_JIT) >+ DFG::ExitProfile m_exitProfile; >+#endif >+ >+ RefCountedArray<InstructionStream::Offset> m_jumpTargets; > > Vector<InstructionStream::Offset> m_propertyAccessInstructions; > > // Constant Pools > Vector<Identifier> m_identifiers; >- Vector<BitVector> m_bitVectors; > Vector<WriteBarrier<Unknown>> m_constantRegisters; >- Vector<ConstantIdentifierSetEntry> m_constantIdentifierSets; > Vector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation; > typedef Vector<WriteBarrier<UnlinkedFunctionExecutable>> FunctionExpressionVector; > FunctionExpressionVector m_functionDecls; >@@ -463,8 +469,8 @@ class UnlinkedCodeBlock : public JSCell { > > public: > struct RareData { >- WTF_MAKE_FAST_ALLOCATED; >- public: >+ WTF_MAKE_STRUCT_FAST_ALLOCATED; >+ > Vector<UnlinkedHandlerInfo> m_exceptionHandlers; > > // Jump Tables >@@ -479,6 +485,8 @@ class UnlinkedCodeBlock : public JSCell { > }; > HashMap<unsigned, TypeProfilerExpressionRange> m_typeProfilerInfoMap; > Vector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets; >+ Vector<BitVector> m_bitVectors; >+ Vector<ConstantIdentifierSetEntry> m_constantIdentifierSets; > }; > > void addOutOfLineJumpTarget(InstructionStream::Offset, int target); >diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp >index d6e131bf81328be49511e9b920f0fe0ab575e7f3..75280f2ffbdf59244bdc66a19af2ec012c075213 100644 >--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp >+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp >@@ -249,7 +249,7 @@ ParserError BytecodeGenerator::generate() > Ref<Label> realCatchTarget = newLabel(); > OpCatch::emit(this, std::get<1>(tuple), std::get<2>(tuple)); > realCatchTarget->setLocation(*this, m_lastInstruction.offset()); >- m_codeBlock->addJumpTarget(m_lastInstruction.offset()); >+ addJumpTarget(m_lastInstruction.offset()); > > > TryData* tryData = std::get<0>(tuple); >@@ -296,6 +296,8 @@ ParserError BytecodeGenerator::generate() > > if (isGeneratorOrAsyncFunctionBodyParseMode(m_codeBlock->parseMode())) > performGeneratorification(*this, m_codeBlock.get(), m_writer, m_generatorFrameSymbolTable.get(), m_generatorFrameSymbolTableIndex); >+ else >+ m_codeBlock->setJumpTargets(WTFMove(m_jumpTargets)); > > RELEASE_ASSERT(static_cast<unsigned>(m_codeBlock->numCalleeLocals()) < static_cast<unsigned>(FirstConstantRegisterIndex)); > m_codeBlock->setInstructions(m_writer.finalize()); >@@ -1334,8 +1336,8 @@ void BytecodeGenerator::emitLabel(Label& l0) > unsigned newLabelIndex = instructions().size(); > l0.setLocation(*this, newLabelIndex); > >- if (m_codeBlock->numberOfJumpTargets()) { >- unsigned lastLabelIndex = m_codeBlock->lastJumpTarget(); >+ if (numberOfJumpTargets()) { >+ unsigned lastLabelIndex = lastJumpTarget(); > ASSERT(lastLabelIndex <= newLabelIndex); > if (newLabelIndex == lastLabelIndex) { > // Peephole optimizations have already been disabled by emitting the last label >@@ -1343,7 +1345,7 @@ void BytecodeGenerator::emitLabel(Label& l0) > } > } > >- m_codeBlock->addJumpTarget(newLabelIndex); >+ addJumpTarget(newLabelIndex); > > // This disables peephole optimizations when an instruction is a jump target > m_lastOpcodeID = op_end; >@@ -1356,7 +1358,7 @@ void BytecodeGenerator::emitEnter() > if (LIKELY(Options::optimizeRecursiveTailCalls())) { > // We must add the end of op_enter as a potential jump target, because the bytecode parser may decide to split its basic block > // to have somewhere to jump to if there is a recursive tail-call that points to this function. >- m_codeBlock->addJumpTarget(instructions().size()); >+ addJumpTarget(instructions().size()); > // This disables peephole optimizations when an instruction is a jump target > m_lastOpcodeID = op_end; > } >@@ -1869,11 +1871,13 @@ RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, JSValue v, SourceCodeRe > > RegisterID* BytecodeGenerator::emitLoad(RegisterID* dst, IdentifierSet& set) > { >- for (const auto& entry : m_codeBlock->constantIdentifierSets()) { >- if (entry.first != set) >- continue; >- >- return &m_constantPoolRegisters[entry.second]; >+ if (m_codeBlock->numberOfConstantIdentifierSets()) { >+ for (const auto& entry : m_codeBlock->constantIdentifierSets()) { >+ if (entry.first != set) >+ continue; >+ >+ return &m_constantPoolRegisters[entry.second]; >+ } > } > > unsigned index = addConstantIndex(); >diff --git a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h >index 6ad716eebd28fad7ca02affeb344026eedb94376..0cd50c21028084b1603ac38b5773c25f6515edc1 100644 >--- a/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h >+++ b/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h >@@ -1209,6 +1209,11 @@ namespace JSC { > m_lastInstruction = prevLastInstruction; > } > >+ size_t numberOfJumpTargets() const { return m_jumpTargets.size(); } >+ void addJumpTarget(unsigned jumpTarget) { m_jumpTargets.append(jumpTarget); } >+ unsigned jumpTarget(int index) const { return m_jumpTargets[index]; } >+ unsigned lastJumpTarget() const { return m_jumpTargets.last(); } >+ > private: > InstructionStreamWriter m_writer; > >@@ -1317,6 +1322,7 @@ namespace JSC { > > using CatchEntry = std::tuple<TryData*, VirtualRegister, VirtualRegister>; > Vector<CatchEntry> m_catchesToEmit; >+ Vector<InstructionStream::Offset> m_jumpTargets; > }; > > >diff --git a/Source/JavaScriptCore/runtime/CachedTypes.cpp b/Source/JavaScriptCore/runtime/CachedTypes.cpp >index c67e17df483550806ac6da26bf45346c9452f5b7..8fbc7f3cf9d7df99a8f1159868d6cceae15584c1 100644 >--- a/Source/JavaScriptCore/runtime/CachedTypes.cpp >+++ b/Source/JavaScriptCore/runtime/CachedTypes.cpp >@@ -481,6 +481,31 @@ class CachedVector : public VariableLengthObject<Vector<SourceType<T>, InlineCap > unsigned m_size; > }; > >+template<typename T> >+class CachedRefCountedArray: public VariableLengthObject<RefCountedArray<SourceType<T>>> { >+public: >+ void encode(Encoder& encoder, const RefCountedArray<SourceType<T>>& array) >+ { >+ m_size = array.size(); >+ T* buffer = this->template allocate<T>(encoder, m_size); >+ for (unsigned i = 0; i < m_size; ++i) >+ ::JSC::encode(encoder, buffer[i], array[i]); >+ } >+ >+ template<typename... Args> >+ RefCountedArray<SourceType<T>> decode(Decoder& decoder, Args... args) const >+ { >+ RefCountedArray<SourceType<T>> array(m_size); >+ const T* buffer = this->template buffer<T>(); >+ for (unsigned i = 0; i < m_size; ++i) >+ ::JSC::decode(decoder, buffer[i], array[i], args...); >+ return array; >+ } >+ >+private: >+ unsigned m_size; >+}; >+ > template<typename First, typename Second> > class CachedPair : public CachedObject<std::pair<SourceType<First>, SourceType<Second>>> { > public: >@@ -733,39 +758,6 @@ class CachedStringJumpTable : public CachedObject<UnlinkedStringJumpTable> { > CachedHashMap<CachedRefPtr<CachedStringImpl>, UnlinkedStringJumpTable:: OffsetLocation> m_offsetTable; > }; > >-class CachedCodeBlockRareData : public CachedObject<UnlinkedCodeBlock::RareData> { >-public: >- void encode(Encoder& encoder, const UnlinkedCodeBlock::RareData& rareData) >- { >- m_exceptionHandlers.encode(encoder, rareData.m_exceptionHandlers); >- m_switchJumpTables.encode(encoder, rareData.m_switchJumpTables); >- m_stringSwitchJumpTables.encode(encoder, rareData.m_stringSwitchJumpTables); >- m_expressionInfoFatPositions.encode(encoder, rareData.m_expressionInfoFatPositions); >- m_typeProfilerInfoMap.encode(encoder, rareData.m_typeProfilerInfoMap); >- m_opProfileControlFlowBytecodeOffsets.encode(encoder, rareData.m_opProfileControlFlowBytecodeOffsets); >- } >- >- UnlinkedCodeBlock::RareData* decode(Decoder& decoder) const >- { >- UnlinkedCodeBlock::RareData* rareData = new UnlinkedCodeBlock::RareData { }; >- m_exceptionHandlers.decode(decoder, rareData->m_exceptionHandlers); >- m_switchJumpTables.decode(decoder, rareData->m_switchJumpTables); >- m_stringSwitchJumpTables.decode(decoder, rareData->m_stringSwitchJumpTables); >- m_expressionInfoFatPositions.decode(decoder, rareData->m_expressionInfoFatPositions); >- m_typeProfilerInfoMap.decode(decoder, rareData->m_typeProfilerInfoMap); >- m_opProfileControlFlowBytecodeOffsets.decode(decoder, rareData->m_opProfileControlFlowBytecodeOffsets); >- return rareData; >- } >- >-private: >- CachedVector<UnlinkedHandlerInfo> m_exceptionHandlers; >- CachedVector<CachedSimpleJumpTable> m_switchJumpTables; >- CachedVector<CachedStringJumpTable> m_stringSwitchJumpTables; >- CachedVector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions; >- CachedHashMap<unsigned, UnlinkedCodeBlock::RareData::TypeProfilerExpressionRange> m_typeProfilerInfoMap; >- CachedVector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets; >-}; >- > class CachedBitVector : public VariableLengthObject<BitVector> { > public: > void encode(Encoder& encoder, const BitVector& bitVector) >@@ -828,6 +820,45 @@ class CachedConstantIdentifierSetEntry : public VariableLengthObject<ConstantIde > CachedHashSet<CachedRefPtr<CachedUniquedStringImpl>, IdentifierRepHash> m_set; > }; > >+class CachedCodeBlockRareData : public CachedObject<UnlinkedCodeBlock::RareData> { >+public: >+ void encode(Encoder& encoder, const UnlinkedCodeBlock::RareData& rareData) >+ { >+ m_exceptionHandlers.encode(encoder, rareData.m_exceptionHandlers); >+ m_switchJumpTables.encode(encoder, rareData.m_switchJumpTables); >+ m_stringSwitchJumpTables.encode(encoder, rareData.m_stringSwitchJumpTables); >+ m_expressionInfoFatPositions.encode(encoder, rareData.m_expressionInfoFatPositions); >+ m_typeProfilerInfoMap.encode(encoder, rareData.m_typeProfilerInfoMap); >+ m_opProfileControlFlowBytecodeOffsets.encode(encoder, rareData.m_opProfileControlFlowBytecodeOffsets); >+ m_bitVectors.encode(encoder, rareData.m_bitVectors); >+ m_constantIdentifierSets.encode(encoder, rareData.m_constantIdentifierSets); >+ } >+ >+ UnlinkedCodeBlock::RareData* decode(Decoder& decoder) const >+ { >+ UnlinkedCodeBlock::RareData* rareData = new UnlinkedCodeBlock::RareData { }; >+ m_exceptionHandlers.decode(decoder, rareData->m_exceptionHandlers); >+ m_switchJumpTables.decode(decoder, rareData->m_switchJumpTables); >+ m_stringSwitchJumpTables.decode(decoder, rareData->m_stringSwitchJumpTables); >+ m_expressionInfoFatPositions.decode(decoder, rareData->m_expressionInfoFatPositions); >+ m_typeProfilerInfoMap.decode(decoder, rareData->m_typeProfilerInfoMap); >+ m_opProfileControlFlowBytecodeOffsets.decode(decoder, rareData->m_opProfileControlFlowBytecodeOffsets); >+ m_bitVectors.decode(decoder, rareData->m_bitVectors); >+ m_constantIdentifierSets.decode(decoder, rareData->m_constantIdentifierSets); >+ return rareData; >+ } >+ >+private: >+ CachedVector<UnlinkedHandlerInfo> m_exceptionHandlers; >+ CachedVector<CachedSimpleJumpTable> m_switchJumpTables; >+ CachedVector<CachedStringJumpTable> m_stringSwitchJumpTables; >+ CachedVector<ExpressionRangeInfo::FatPosition> m_expressionInfoFatPositions; >+ CachedHashMap<unsigned, UnlinkedCodeBlock::RareData::TypeProfilerExpressionRange> m_typeProfilerInfoMap; >+ CachedVector<InstructionStream::Offset> m_opProfileControlFlowBytecodeOffsets; >+ CachedVector<CachedBitVector> m_bitVectors; >+ CachedVector<CachedConstantIdentifierSetEntry> m_constantIdentifierSets; >+}; >+ > class CachedVariableEnvironment : public CachedObject<VariableEnvironment> { > public: > void encode(Encoder& encoder, const VariableEnvironment& env) >@@ -1479,6 +1510,8 @@ class CachedCodeBlock : public CachedObject<CodeBlockType> { > > Ref<UnlinkedMetadataTable> metadata(Decoder& decoder) const { return m_metadata.decode(decoder); } > >+ RefCountedArray<InstructionStream::Offset> jumpTargets(Decoder& decoder) const { return m_jumpTargets.decode(decoder); } >+ > unsigned usesEval() const { return m_usesEval; } > unsigned isStrictMode() const { return m_isStrictMode; } > unsigned isConstructor() const { return m_isConstructor; } >@@ -1502,7 +1535,7 @@ class CachedCodeBlock : public CachedObject<CodeBlockType> { > > CodeFeatures features() const { return m_features; } > SourceParseMode parseMode() const { return m_parseMode; } >- CodeType codeType() const { return m_codeType; } >+ unsigned codeType() const { return m_codeType; } > > UnlinkedCodeBlock::RareData* rareData(Decoder& decoder) const { return m_rareData.decodeAsPtr(decoder); } > >@@ -1525,6 +1558,10 @@ class CachedCodeBlock : public CachedObject<CodeBlockType> { > unsigned m_derivedContextType : 2; > unsigned m_evalContextType : 2; > unsigned m_hasTailCalls : 1; >+ unsigned m_codeType : 2; >+ >+ CodeFeatures m_features; >+ SourceParseMode m_parseMode; > > unsigned m_lineCount; > unsigned m_endColumn; >@@ -1533,10 +1570,6 @@ class CachedCodeBlock : public CachedObject<CodeBlockType> { > int m_numCalleeLocals; > int m_numParameters; > >- CodeFeatures m_features; >- SourceParseMode m_parseMode; >- CodeType m_codeType; >- > std::array<unsigned, LinkTimeConstantCount> m_linkTimeConstants; > CachedMetadataTable m_metadata; > >@@ -1546,16 +1579,14 @@ class CachedCodeBlock : public CachedObject<CodeBlockType> { > CachedString m_sourceMappingURLDirective; > > CachedPtr<CachedInstructionStream> m_instructions; >- CachedVector<InstructionStream::Offset> m_jumpTargets; >+ CachedRefCountedArray<InstructionStream::Offset> m_jumpTargets; > CachedVector<InstructionStream::Offset> m_propertyAccessInstructions; > CachedVector<CachedJSValue> m_constantRegisters; > CachedVector<SourceCodeRepresentation> m_constantsSourceCodeRepresentation; > CachedVector<ExpressionRangeInfo> m_expressionInfo; > CachedHashMap<InstructionStream::Offset, int> m_outOfLineJumpTargets; > >- CachedVector<CachedConstantIdentifierSetEntry> m_constantIdentifierSets; > CachedVector<CachedIdentifier> m_identifiers; >- CachedVector<CachedBitVector> m_bitVectors; > CachedVector<CachedWriteBarrier<CachedFunctionExecutable>> m_functionDecls; > CachedVector<CachedWriteBarrier<CachedFunctionExecutable>> m_functionExprs; > }; >@@ -1691,17 +1722,10 @@ using CachedCodeBlockType = typename CachedCodeBlockTypeImpl<T>::type; > template<typename CodeBlockType> > ALWAYS_INLINE UnlinkedCodeBlock::UnlinkedCodeBlock(Decoder& decoder, Structure* structure, const CachedCodeBlock<CodeBlockType>& cachedCodeBlock) > : Base(decoder.vm(), structure) >- , m_instructions(cachedCodeBlock.instructions(decoder)) >- , m_liveness(nullptr) > , m_thisRegister(cachedCodeBlock.thisRegister()) > , m_scopeRegister(cachedCodeBlock.scopeRegister()) > , m_globalObjectRegister(cachedCodeBlock.globalObjectRegister()) > >- , m_sourceURLDirective(cachedCodeBlock.sourceURLDirective(decoder)) >- , m_sourceMappingURLDirective(cachedCodeBlock.sourceMappingURLDirective(decoder)) >- >- , m_metadata(cachedCodeBlock.metadata(decoder)) >- > , m_usesEval(cachedCodeBlock.usesEval()) > , m_isStrictMode(cachedCodeBlock.isStrictMode()) > , m_isConstructor(cachedCodeBlock.isConstructor()) >@@ -1716,14 +1740,24 @@ ALWAYS_INLINE UnlinkedCodeBlock::UnlinkedCodeBlock(Decoder& decoder, Structure* > , m_derivedContextType(cachedCodeBlock.derivedContextType()) > , m_evalContextType(cachedCodeBlock.evalContextType()) > , m_hasTailCalls(cachedCodeBlock.hasTailCalls()) >+ , m_codeType(cachedCodeBlock.codeType()) >+ >+ , m_features(cachedCodeBlock.features()) >+ , m_parseMode(cachedCodeBlock.parseMode()) >+ > , m_lineCount(cachedCodeBlock.lineCount()) > , m_endColumn(cachedCodeBlock.endColumn()) > , m_numVars(cachedCodeBlock.numVars()) > , m_numCalleeLocals(cachedCodeBlock.numCalleeLocals()) > , m_numParameters(cachedCodeBlock.numParameters()) >- , m_features(cachedCodeBlock.features()) >- , m_parseMode(cachedCodeBlock.parseMode()) >- , m_codeType(cachedCodeBlock.codeType()) >+ >+ , m_sourceURLDirective(cachedCodeBlock.sourceURLDirective(decoder)) >+ , m_sourceMappingURLDirective(cachedCodeBlock.sourceMappingURLDirective(decoder)) >+ >+ , m_metadata(cachedCodeBlock.metadata(decoder)) >+ , m_instructions(cachedCodeBlock.instructions(decoder)) >+ , m_jumpTargets(cachedCodeBlock.jumpTargets(decoder)) >+ > , m_rareData(cachedCodeBlock.rareData(decoder)) > { > } >@@ -1739,10 +1773,7 @@ ALWAYS_INLINE void CachedCodeBlock<CodeBlockType>::decode(Decoder& decoder, Unli > m_constantsSourceCodeRepresentation.decode(decoder, codeBlock.m_constantsSourceCodeRepresentation); > m_expressionInfo.decode(decoder, codeBlock.m_expressionInfo); > m_outOfLineJumpTargets.decode(decoder, codeBlock.m_outOfLineJumpTargets); >- m_jumpTargets.decode(decoder, codeBlock.m_jumpTargets); >- m_constantIdentifierSets.decode(decoder, codeBlock.m_constantIdentifierSets); > m_identifiers.decode(decoder, codeBlock.m_identifiers); >- m_bitVectors.decode(decoder, codeBlock.m_bitVectors); > m_functionDecls.decode(decoder, codeBlock.m_functionDecls, &codeBlock); > m_functionExprs.decode(decoder, codeBlock.m_functionExprs, &codeBlock); > } >@@ -1897,9 +1928,7 @@ ALWAYS_INLINE void CachedCodeBlock<CodeBlockType>::encode(Encoder& encoder, cons > m_jumpTargets.encode(encoder, codeBlock.m_jumpTargets); > m_outOfLineJumpTargets.encode(encoder, codeBlock.m_outOfLineJumpTargets); > >- m_constantIdentifierSets.encode(encoder, codeBlock.m_constantIdentifierSets); > m_identifiers.encode(encoder, codeBlock.m_identifiers); >- m_bitVectors.encode(encoder, codeBlock.m_bitVectors); > m_functionDecls.encode(encoder, codeBlock.m_functionDecls); > m_functionExprs.encode(encoder, codeBlock.m_functionExprs); > } >diff --git a/Source/WTF/wtf/TriState.h b/Source/WTF/wtf/TriState.h >index 24ace5410f8993992abbfdb825646de027953d5a..5ae785d3b9d80d83aa074fe821cd06857d661ca0 100644 >--- a/Source/WTF/wtf/TriState.h >+++ b/Source/WTF/wtf/TriState.h >@@ -27,7 +27,7 @@ > > namespace WTF { > >-enum TriState : int8_t { >+enum TriState : uint8_t { > FalseTriState, > TrueTriState, > MixedTriState
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194281
:
361163
|
361171
|
361174
|
361175
|
361177
|
361178