haikuwebkit/Source/WTF/wtf/RefCountedArray.h

363 lines
12 KiB
C
Raw Permalink Normal View History

Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
/*
* Copyright (C) 2011-2019 Apple Inc. All rights reserved.
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
*
* 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.
*/
Use pragma once in WTF https://bugs.webkit.org/show_bug.cgi?id=190527 Reviewed by Chris Dumez. Source/WTF: We also need to consistently include wtf headers from within wtf so we can build wtf without symbol redefinition errors from including the copy in Source and the copy in the build directory. * wtf/ASCIICType.h: * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/Atomics.h: * wtf/AutomaticThread.cpp: * wtf/AutomaticThread.h: * wtf/BackwardsGraph.h: * wtf/Bag.h: * wtf/BagToHashMap.h: * wtf/BitVector.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Box.h: * wtf/BubbleSort.h: * wtf/BumpPointerAllocator.h: * wtf/ByteOrder.h: * wtf/CPUTime.cpp: * wtf/CallbackAggregator.h: * wtf/CheckedArithmetic.h: * wtf/CheckedBoolean.h: * wtf/ClockType.cpp: * wtf/ClockType.h: * wtf/CommaPrinter.h: * wtf/CompilationThread.cpp: * wtf/CompilationThread.h: * wtf/Compiler.h: * wtf/ConcurrentPtrHashSet.cpp: * wtf/ConcurrentVector.h: * wtf/Condition.h: * wtf/CountingLock.cpp: * wtf/CrossThreadTaskHandler.cpp: * wtf/CryptographicUtilities.cpp: * wtf/CryptographicUtilities.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/CryptographicallyRandomNumber.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DataLog.h: * wtf/DateMath.cpp: * wtf/DateMath.h: * wtf/DecimalNumber.cpp: * wtf/DecimalNumber.h: * wtf/Deque.h: * wtf/DisallowCType.h: * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/FastBitVector.cpp: * wtf/FastMalloc.cpp: * wtf/FastMalloc.h: * wtf/FeatureDefines.h: * wtf/FilePrintStream.cpp: * wtf/FilePrintStream.h: * wtf/FlipBytes.h: * wtf/FunctionDispatcher.cpp: * wtf/FunctionDispatcher.h: * wtf/GetPtr.h: * wtf/Gigacage.cpp: * wtf/GlobalVersion.cpp: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.cpp: * wtf/GregorianDateTime.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashMethod.h: * wtf/HashSet.h: * wtf/HashTable.cpp: * wtf/HashTraits.h: * wtf/Indenter.h: * wtf/IndexSparseSet.h: * wtf/InlineASM.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/JSONValues.cpp: * wtf/JSValueMalloc.cpp: * wtf/LEBDecoder.h: * wtf/Language.cpp: * wtf/ListDump.h: * wtf/Lock.cpp: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockedPrintStream.cpp: * wtf/Locker.h: * wtf/MD5.cpp: * wtf/MD5.h: * wtf/MainThread.cpp: * wtf/MainThread.h: * wtf/MallocPtr.h: * wtf/MathExtras.h: * wtf/MediaTime.cpp: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.cpp: * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: * wtf/MetaAllocator.h: * wtf/MetaAllocatorHandle.h: * wtf/MonotonicTime.cpp: * wtf/MonotonicTime.h: * wtf/NakedPtr.h: * wtf/NoLock.h: * wtf/NoTailCalls.h: * wtf/Noncopyable.h: * wtf/NumberOfCores.cpp: * wtf/NumberOfCores.h: * wtf/OSAllocator.h: * wtf/OSAllocatorPosix.cpp: * wtf/OSRandomSource.cpp: * wtf/OSRandomSource.h: * wtf/ObjcRuntimeExtras.h: * wtf/OrderMaker.h: * wtf/PackedIntVector.h: * wtf/PageAllocation.h: * wtf/PageBlock.cpp: * wtf/PageBlock.h: * wtf/PageReservation.h: * wtf/ParallelHelperPool.cpp: * wtf/ParallelHelperPool.h: * wtf/ParallelJobs.h: * wtf/ParallelJobsLibdispatch.h: * wtf/ParallelVectorIterator.h: * wtf/ParkingLot.cpp: * wtf/ParkingLot.h: * wtf/Platform.h: * wtf/PointerComparison.h: * wtf/Poisoned.cpp: * wtf/PrintStream.cpp: * wtf/PrintStream.h: * wtf/ProcessID.h: * wtf/ProcessPrivilege.cpp: * wtf/RAMSize.cpp: * wtf/RAMSize.h: * wtf/RandomDevice.cpp: * wtf/RandomNumber.cpp: * wtf/RandomNumber.h: * wtf/RandomNumberSeed.h: * wtf/RangeSet.h: * wtf/RawPointer.h: * wtf/ReadWriteLock.cpp: * wtf/RedBlackTree.h: * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefCountedLeakCounter.cpp: * wtf/RefCountedLeakCounter.h: * wtf/RefCounter.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/RunLoop.cpp: * wtf/RunLoop.h: * wtf/RunLoopTimer.h: * wtf/RunLoopTimerCF.cpp: * wtf/SHA1.cpp: * wtf/SHA1.h: * wtf/SaturatedArithmetic.h: (saturatedSubtraction): * wtf/SchedulePair.h: * wtf/SchedulePairCF.cpp: * wtf/SchedulePairMac.mm: * wtf/ScopedLambda.h: * wtf/Seconds.cpp: * wtf/Seconds.h: * wtf/SegmentedVector.h: * wtf/SentinelLinkedList.h: * wtf/SharedTask.h: * wtf/SimpleStats.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SixCharacterHash.cpp: * wtf/SixCharacterHash.h: * wtf/SmallPtrSet.h: * wtf/Spectrum.h: * wtf/StackBounds.cpp: * wtf/StackBounds.h: * wtf/StackStats.cpp: * wtf/StackStats.h: * wtf/StackTrace.cpp: * wtf/StdLibExtras.h: * wtf/StreamBuffer.h: * wtf/StringHashDumpContext.h: * wtf/StringPrintStream.cpp: * wtf/StringPrintStream.h: * wtf/ThreadGroup.cpp: * wtf/ThreadMessage.cpp: * wtf/ThreadSpecific.h: * wtf/Threading.cpp: * wtf/Threading.h: * wtf/ThreadingPrimitives.h: * wtf/ThreadingPthreads.cpp: * wtf/TimeWithDynamicClockType.cpp: * wtf/TimeWithDynamicClockType.h: * wtf/TimingScope.cpp: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/TriState.h: * wtf/TypeCasts.h: * wtf/UUID.cpp: * wtf/UnionFind.h: * wtf/VMTags.h: * wtf/ValueCheck.h: * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.cpp: * wtf/WallTime.h: * wtf/WeakPtr.h: * wtf/WeakRandom.h: * wtf/WordLock.cpp: * wtf/WordLock.h: * wtf/WorkQueue.cpp: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: * wtf/cf/LanguageCF.cpp: * wtf/cf/RunLoopCF.cpp: * wtf/cocoa/Entitlements.mm: * wtf/cocoa/MachSendRight.cpp: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/MemoryFootprintCocoa.cpp: * wtf/cocoa/WorkQueueCocoa.cpp: * wtf/dtoa.cpp: * wtf/dtoa.h: * wtf/ios/WebCoreThread.cpp: * wtf/ios/WebCoreThread.h: * wtf/mac/AppKitCompatibilityDeclarations.h: * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: * wtf/mbmalloc.cpp: * wtf/persistence/PersistentCoders.cpp: * wtf/persistence/PersistentDecoder.cpp: * wtf/persistence/PersistentEncoder.cpp: * wtf/spi/cf/CFBundleSPI.h: * wtf/spi/darwin/CommonCryptoSPI.h: * wtf/text/ASCIIFastPath.h: * wtf/text/ASCIILiteral.cpp: * wtf/text/AtomicString.cpp: * wtf/text/AtomicString.h: * wtf/text/AtomicStringHash.h: * wtf/text/AtomicStringImpl.cpp: * wtf/text/AtomicStringImpl.h: * wtf/text/AtomicStringTable.cpp: * wtf/text/AtomicStringTable.h: * wtf/text/Base64.cpp: * wtf/text/CString.cpp: * wtf/text/CString.h: * wtf/text/ConversionMode.h: * wtf/text/ExternalStringImpl.cpp: * wtf/text/IntegerToStringConversion.h: * wtf/text/LChar.h: * wtf/text/LineEnding.cpp: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.cpp: * wtf/text/StringBuilder.h: * wtf/text/StringBuilderJSON.cpp: * wtf/text/StringCommon.h: * wtf/text/StringConcatenate.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.cpp: * wtf/text/StringImpl.h: * wtf/text/StringOperators.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: * wtf/text/SymbolImpl.cpp: * wtf/text/SymbolRegistry.cpp: * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.cpp: * wtf/text/TextBreakIterator.h: * wtf/text/TextBreakIteratorInternalICU.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.cpp: * wtf/text/UniquedStringImpl.h: * wtf/text/WTFString.cpp: * wtf/text/WTFString.h: * wtf/text/cocoa/StringCocoa.mm: * wtf/text/cocoa/StringViewCocoa.mm: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: * wtf/text/icu/UTextProvider.cpp: * wtf/text/icu/UTextProvider.h: * wtf/text/icu/UTextProviderLatin1.cpp: * wtf/text/icu/UTextProviderLatin1.h: * wtf/text/icu/UTextProviderUTF16.cpp: * wtf/text/icu/UTextProviderUTF16.h: * wtf/threads/BinarySemaphore.cpp: * wtf/threads/BinarySemaphore.h: * wtf/threads/Signals.cpp: * wtf/unicode/CharacterNames.h: * wtf/unicode/Collator.h: * wtf/unicode/CollatorDefault.cpp: * wtf/unicode/UTF8.cpp: * wtf/unicode/UTF8.h: Tools: Put WorkQueue in namespace DRT so it does not conflict with WTF::WorkQueue. * DumpRenderTree/TestRunner.cpp: (TestRunner::queueLoadHTMLString): (TestRunner::queueLoadAlternateHTMLString): (TestRunner::queueBackNavigation): (TestRunner::queueForwardNavigation): (TestRunner::queueLoadingScript): (TestRunner::queueNonLoadingScript): (TestRunner::queueReload): * DumpRenderTree/WorkQueue.cpp: (WorkQueue::singleton): Deleted. (WorkQueue::WorkQueue): Deleted. (WorkQueue::queue): Deleted. (WorkQueue::dequeue): Deleted. (WorkQueue::count): Deleted. (WorkQueue::clear): Deleted. (WorkQueue::processWork): Deleted. * DumpRenderTree/WorkQueue.h: (WorkQueue::setFrozen): Deleted. * DumpRenderTree/WorkQueueItem.h: * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): * DumpRenderTree/mac/FrameLoadDelegate.mm: (-[FrameLoadDelegate processWork:]): (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]): * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): * DumpRenderTree/win/DumpRenderTree.cpp: (runTest): * DumpRenderTree/win/FrameLoadDelegate.cpp: (FrameLoadDelegate::processWork): (FrameLoadDelegate::locationChangeDone): * DumpRenderTree/win/TestRunnerWin.cpp: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): Canonical link: https://commits.webkit.org/205473@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237099 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-15 14:24:49 +00:00
#pragma once
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
#include <wtf/FastMalloc.h>
Inclusive software: Remove instances of "dumb" from the code https://bugs.webkit.org/show_bug.cgi?id=217778 Reviewed by Simon Fraser. Source/JavaScriptCore: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::unboxBoolean): * heap/SlotVisitor.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitVirtualCall): (JSC::AssemblyHelpers::emitDumbVirtualCall): Deleted. * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEvalSlowCase): * jit/JITCall32_64.cpp: (JSC::JIT::compileCallEvalSlowCase): * runtime/CachedTypes.cpp: * runtime/JSCJSValue.h: * runtime/WriteBarrier.h: * runtime/WriteBarrierInlines.h: (JSC::RawValueTraits<Unknown>>::set): (JSC::DumbValueTraits<Unknown>>::set): Deleted. * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::addCallIndirect): * wasm/generateWasm.py: (opcodeIterator): Source/WebCore: * Modules/webaudio/AudioNode.h: * dom/GCReachableRef.h: * page/EventHandler.cpp: (WebCore::EventHandler::handleDrag): * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::addToLine): Source/WTF: * WTF.xcodeproj/project.pbxproj: * icu/unicode/caniter.h: * wtf/Bag.h: * wtf/CMakeLists.txt: * wtf/CagedPtr.h: * wtf/Forward.h: * wtf/NakedRef.h: * wtf/RawPtrTraits.h: Renamed from Source/WTF/wtf/DumbPtrTraits.h. * wtf/RawValueTraits.h: Renamed from Source/WTF/wtf/DumbValueTraits.h. * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefPtr.h: * wtf/SentinelLinkedList.h: Canonical link: https://commits.webkit.org/230896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268993 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-26 20:08:01 +00:00
#include <wtf/RawPtrTraits.h>
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
// This implements a reference counted array for POD** values, which is optimized for:
// - An empty array only uses one word.
// - A copy of the array only uses one word (i.e. assignment means aliasing).
// - The vector can't grow beyond 2^32-1 elements.
// - In all other regards this has similar space usage to a Vector.
//
// ** This could be modified to support non-POD values quite easily. It just
// hasn't been, so far, because there has been no need. Moreover, even now,
// it's used for things that aren't quite POD according to the official
// defintion, such as JSC::Instruction.
namespace WTF {
Experiment: create lots of different malloc zones for easier accounting of memory use https://bugs.webkit.org/show_bug.cgi?id=186422 Patch by Yusuke Suzuki <ysuzuki@apple.com> and Simon Fraser <simon.fraser@apple.com> on 2020-01-02 Reviewed by Saam Barati. Source/bmalloc: * bmalloc/BPlatform.h: * bmalloc/Environment.cpp: (bmalloc::Environment::computeIsDebugHeapEnabled): * bmalloc/IsoHeap.h: (bmalloc::api::IsoHeap::IsoHeap): * bmalloc/IsoHeapInlines.h: (bmalloc::api::IsoHeap<Type>::IsoHeap): * bmalloc/IsoTLSInlines.h: (bmalloc::IsoTLS::allocateSlow): (bmalloc::IsoTLS::deallocateSlow): Source/JavaScriptCore: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/AssemblerBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * assembler/AssemblerBuffer.h: (JSC::AssemblerData::AssemblerData): (JSC::AssemblerData::operator=): (JSC::AssemblerData::~AssemblerData): (JSC::AssemblerData::grow): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/BytecodeBasicBlock.cpp: * bytecode/BytecodeBasicBlock.h: * bytecode/CodeBlock.cpp: * bytecode/CodeBlock.h: * bytecode/InstructionStream.cpp: * bytecode/InstructionStream.h: * bytecode/PolymorphicAccess.cpp: * bytecode/PolymorphicAccess.h: * bytecode/UnlinkedMetadataTable.cpp: (JSC::UnlinkedMetadataTable::finalize): * bytecode/UnlinkedMetadataTable.h: * bytecode/UnlinkedMetadataTableInlines.h: (JSC::UnlinkedMetadataTable::UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::~UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::link): (JSC::UnlinkedMetadataTable::unlink): * bytecode/ValueProfile.h: (JSC::ValueProfileAndVirtualRegisterBuffer::ValueProfileAndVirtualRegisterBuffer): * bytecode/Watchpoint.cpp: * bytecode/Watchpoint.h: * dfg/DFGBasicBlock.cpp: * dfg/DFGBasicBlock.h: * dfg/DFGNode.cpp: * dfg/DFGNode.h: * dfg/DFGSpeculativeJIT.cpp: * dfg/DFGSpeculativeJIT.h: * heap/BlockDirectory.cpp: * heap/BlockDirectory.h: * heap/FastMallocAlignedMemoryAllocator.cpp: (JSC::FastMallocAlignedMemoryAllocator::FastMallocAlignedMemoryAllocator): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::freeAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateMemory): (JSC::FastMallocAlignedMemoryAllocator::freeMemory): (JSC::FastMallocAlignedMemoryAllocator::tryReallocateMemory): * heap/FastMallocAlignedMemoryAllocator.h: * heap/GCSegmentedArray.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * heap/GCSegmentedArray.h: * heap/GCSegmentedArrayInlines.h: (JSC::GCArraySegment<T>::create): (JSC::GCArraySegment<T>::destroy): * heap/GigacageAlignedMemoryAllocator.cpp: (JSC::GigacageAlignedMemoryAllocator::GigacageAlignedMemoryAllocator): (JSC::GigacageAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::freeAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::tryAllocateMemory): (JSC::GigacageAlignedMemoryAllocator::freeMemory): (JSC::GigacageAlignedMemoryAllocator::tryReallocateMemory): * heap/GigacageAlignedMemoryAllocator.h: * heap/IsoAlignedMemoryAllocator.cpp: (JSC::IsoAlignedMemoryAllocator::IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::IsoAlignedMemoryAllocator::freeAlignedMemory): (JSC::IsoAlignedMemoryAllocator::tryAllocateMemory): (JSC::IsoAlignedMemoryAllocator::freeMemory): * heap/IsoAlignedMemoryAllocator.h: * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: * heap/WeakBlock.cpp: (JSC::WeakBlock::create): (JSC::WeakBlock::destroy): * heap/WeakBlock.h: * jit/JITCode.cpp: * jit/JITCode.h: * jit/RegisterAtOffsetList.cpp: * jit/RegisterAtOffsetList.h: * parser/Nodes.cpp: * parser/Nodes.h: * parser/ParserArena.cpp: (JSC::ParserArena::deallocateObjects): (JSC::ParserArena::allocateFreeablePool): * parser/ParserArena.h: * parser/SourceProvider.cpp: * parser/SourceProvider.h: * parser/SourceProviderCache.cpp: * parser/SourceProviderCache.h: * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::create): * runtime/CachePayload.cpp: (JSC::CachePayload::makeMallocPayload): * runtime/CachePayload.h: * runtime/CachedBytecode.h: (JSC::CachedBytecode::create): * runtime/CachedTypes.cpp: (JSC::Encoder::release): (JSC::Encoder::Page::Page): (JSC::CachedVector::encode): (JSC::CachedVector::decode const): (JSC::CachedInstructionStream::decode const): * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::rehash): * runtime/PropertyTable.cpp: (JSC::PropertyTable::PropertyTable): (JSC::PropertyTable::~PropertyTable): * runtime/SymbolTable.cpp: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::~VM): * runtime/VM.h: (JSC::ScratchBuffer::create): (JSC::VM::exceptionFuzzingBuffer): * wasm/WasmInstance.cpp: (JSC::Wasm::Instance::Instance): * wasm/WasmInstance.h: * wasm/WasmTable.cpp: (JSC::Wasm::Table::Table): (JSC::Wasm::FuncRefTable::FuncRefTable): * wasm/WasmTable.h: Source/WebCore: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/SerializedScriptValue.cpp: * bindings/js/SerializedScriptValue.h: * css/CSSFontFace.cpp: * css/CSSFontFace.h: * css/CSSSelector.cpp: * css/CSSSelector.h: * css/CSSValue.cpp: * css/CSSValue.h: * css/StyleProperties.cpp: (WebCore::ImmutableStyleProperties::create): * css/StyleProperties.h: * css/StyleRule.cpp: * css/StyleRule.h: * dom/ElementData.cpp: (WebCore::ShareableElementData::createWithAttributes): (WebCore::UniqueElementData::makeShareableCopy const): * dom/ElementData.h: * dom/NodeRareData.cpp: * dom/NodeRareData.h: * dom/QualifiedName.cpp: * dom/QualifiedName.h: * html/parser/HTMLDocumentParser.cpp: * html/parser/HTMLDocumentParser.h: * loader/DocumentLoader.cpp: * loader/DocumentLoader.h: * loader/ResourceLoader.cpp: * loader/ResourceLoader.h: * loader/cache/CachedResource.cpp: * loader/cache/CachedResource.h: * page/PerformanceEntry.cpp: * page/PerformanceEntry.h: * platform/graphics/Font.cpp: * platform/graphics/Font.h: * platform/graphics/FontCascadeFonts.cpp: * platform/graphics/FontCascadeFonts.h: * platform/graphics/Region.cpp: * platform/graphics/Region.h: * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::releaseUint8Vector): * platform/graphics/cg/ImageBufferCG.cpp: (WebCore::ImageBuffer::ImageBuffer): * platform/graphics/nicosia/NicosiaBuffer.cpp: (Nicosia::Buffer::Buffer): * platform/network/ResourceHandle.cpp: * platform/network/ResourceHandleInternal.h: * platform/network/cf/FormDataStreamCFNet.cpp: (WebCore::closeCurrentStream): (WebCore::advanceCurrentStream): * rendering/RenderLayer.cpp: * rendering/RenderLayer.h: * rendering/TableLayout.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * rendering/TableLayout.h: * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: * rendering/style/SVGRenderStyle.cpp: * rendering/style/SVGRenderStyle.h: * rendering/style/SVGRenderStyleDefs.cpp: * rendering/style/SVGRenderStyleDefs.h: * rendering/style/StyleBoxData.cpp: * rendering/style/StyleBoxData.h: * rendering/style/StyleInheritedData.cpp: * rendering/style/StyleInheritedData.h: * rendering/style/StyleRareInheritedData.cpp: * rendering/style/StyleRareInheritedData.h: * rendering/style/StyleRareNonInheritedData.cpp: * rendering/style/StyleRareNonInheritedData.h: * rendering/style/StyleSurroundData.cpp: * rendering/style/StyleSurroundData.h: * rendering/style/StyleTransformData.cpp: * rendering/style/StyleTransformData.h: * style/StyleTreeResolver.cpp: * style/StyleTreeResolver.h: * svg/animation/SMILTimeContainer.cpp: * svg/animation/SMILTimeContainer.h: Source/WebKit: * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::create): (WebKit::ShareableBitmap::~ShareableBitmap): * UIProcess/mac/LegacySessionStateCoding.cpp: (WebKit::HistoryEntryDataEncoder::HistoryEntryDataEncoder): (WebKit::HistoryEntryDataEncoder::finishEncoding): (WebKit::encodeSessionHistoryEntryData): (WebKit::encodeLegacySessionState): Source/WTF: This patch introduces ENABLE(MALLOC_HEAP_BREAKDOWN). If this is enabled, we allocate malloc_zone per malloc kind. This offers the way to investigate the usage of memory per kind by using vmmap, like the following. VIRTUAL RESIDENT DIRTY SWAPPED ALLOCATION BYTES DIRTY+SWAP REGION MALLOC ZONE SIZE SIZE SIZE SIZE COUNT ALLOCATED FRAG SIZE % FRAG COUNT =========== ======= ========= ========= ========= ========= ========= ========= ====== ====== StringImpl_0x116efd000 188.0M 69.3M 30.9M 0K 139456 18.0M 12.9M 42% 34 DefaultMallocZone_0x10f487000 176.0M 53.9M 14.1M 0K 115956 9955K 4497K 32% 22 Vector_0x116eff000 162.0M 56.3M 55.3M 0K 140715 17.3M 37.9M 69% 36 MetadataTable_0x11843b000 152.0M 17.5M 17.5M 0K 14200 2353K 15.2M 87% 26 WebKit Using System Malloc_0x114cbe000 150.0M 31.6M 21.8M 0K 87422 16.7M 5278K 24% 23 InstructionStream_0x118469000 150.0M 5764K 5764K 0K 14470 4688K 1076K 19% 24 AssemblerData_0x117ee6000 150.0M 1928K 1928K 0K 1 16 1928K 100% 24 To achieve this goal without making very large change, we put a template type in various containers. For example, Vector will take Malloc parameter (the default one is FastMalloc allocator). If ENABLE(MALLOC_HEAP_BREAKDOWN) is enabled, we change this to specific VectorMalloc allocator, and vmmap can show memory usage of this allocator. This patch also supports malloc_zone per IsoHeap. So we can see memory allocation per IsoHeap in vmmap. To use this feature, we need to flip two compile time flags, ENABLE(MALLOC_HEAP_BREAKDOWN) in WTF and BENABLE_MALLOC_HEAP_BREAKDOWN in bmalloc. And use `vmmap $PID` to dump malloc zones. To allocate objects of a class with a specific malloc-zone, use WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(HeapIdentifier) for the class, and define allocator by DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HeapIdentifier) in a header and DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HeapIdentifier) in a cpp file. This patch also introduce callstack collector for malloc. Vector, HashMap etc. are used to allocate various things, but the above malloc_zone feature only tells thing like "Vector takes XXX MB memory". But what we want to know in this case is what Vector is consuming memory. We collect StackShot for each malloc call, and combine these information to tell which callsite is consuming much memory, which tell us that what Vector is consuming memory. * WTF.xcodeproj/project.pbxproj: * wtf/Bag.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): Deleted. * wtf/BitVector.cpp: (WTF::BitVector::OutOfLineBits::create): (WTF::BitVector::OutOfLineBits::destroy): * wtf/CMakeLists.txt: * wtf/ConcurrentBuffer.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * wtf/ConcurrentBuffer.h: * wtf/DebugHeap.cpp: Copied from Source/JavaScriptCore/runtime/CachePayload.cpp. (WTF::DebugHeap::DebugHeap): (WTF::DebugHeap::malloc): (WTF::DebugHeap::calloc): (WTF::DebugHeap::memalign): (WTF::DebugHeap::realloc): (WTF::DebugHeap::free): * wtf/DebugHeap.h: Added. * wtf/FastBitVector.cpp: (WTF::FastBitVectorWordOwner::setEqualsSlow): (WTF::FastBitVectorWordOwner::resizeSlow): * wtf/FastBitVector.h: (WTF::FastBitVectorWordOwner::~FastBitVectorWordOwner): * wtf/FastMalloc.cpp: (WTF::fastMallocDumpMallocStats): (WTF::AvoidRecordingScope::AvoidRecordingScope): (WTF::AvoidRecordingScope::~AvoidRecordingScope): (WTF::MallocCallTracker::MallocSiteData::MallocSiteData): (WTF::MallocCallTracker::singleton): (WTF::MallocCallTracker::MallocCallTracker): (WTF::MallocCallTracker::recordMalloc): (WTF::MallocCallTracker::recordRealloc): (WTF::MallocCallTracker::recordFree): (WTF::MallocCallTracker::dumpStats): (WTF::fastMalloc): (WTF::fastRealloc): (WTF::fastFree): (WTF::fastAlignedMalloc): (WTF::tryFastAlignedMalloc): (WTF::fastAlignedFree): * wtf/FastMalloc.h: (WTF::FastMalloc::zeroedMalloc): (WTF::FastMalloc::tryZeroedMalloc): * wtf/Forward.h: * wtf/HashTable.cpp: * wtf/HashTable.h: (WTF::KeyTraits>::allocateTable): (WTF::KeyTraits>::deallocateTable): (WTF::KeyTraits>::rehash): * wtf/MallocPtr.h: (WTF::MallocPtr::MallocPtr): (WTF::MallocPtr::malloc): (WTF::MallocPtr::zeroedMalloc): (WTF::MallocPtr::tryMalloc): (WTF::MallocPtr::tryZeroedMalloc): (WTF::adoptMallocPtr): * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::allocFreeSpaceNode): (WTF::MetaAllocator::freeFreeSpaceNode): * wtf/MetaAllocatorHandle.h: * wtf/Platform.h: * wtf/RefCountedArray.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::assign): * wtf/SegmentedVector.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/SegmentedVector.h: * wtf/SmallPtrSet.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/SmallPtrSet.h: (WTF::SmallPtrSet::~SmallPtrSet): (WTF::SmallPtrSet::grow): * wtf/UniqueArray.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/UniqueArray.h: (WTF::UniqueArrayFree::operator() const): (WTF::UniqueArrayFree<T::operator() const): * wtf/Vector.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/Vector.h: (WTF::VectorBufferBase::allocateBuffer): (WTF::VectorBufferBase::tryAllocateBuffer): (WTF::VectorBufferBase::reallocateBuffer): (WTF::VectorBufferBase::deallocateBuffer): (WTF::VectorBufferBase::releaseBuffer): (WTF::VectorBuffer::releaseBuffer): (WTF::Vector::swap): (WTF::Malloc>::Vector): (WTF::=): (WTF::Malloc>::contains const): (WTF::Malloc>::findMatching const): (WTF::Malloc>::find const): (WTF::Malloc>::reverseFind const): (WTF::Malloc>::appendIfNotContains): (WTF::Malloc>::fill): (WTF::Malloc>::appendRange): (WTF::Malloc>::expandCapacity): (WTF::Malloc>::tryExpandCapacity): (WTF::Malloc>::resize): (WTF::Malloc>::resizeToFit): (WTF::Malloc>::shrink): (WTF::Malloc>::grow): (WTF::Malloc>::asanSetInitialBufferSizeTo): (WTF::Malloc>::asanSetBufferSizeToFullCapacity): (WTF::Malloc>::asanBufferSizeWillChangeTo): (WTF::Malloc>::reserveCapacity): (WTF::Malloc>::tryReserveCapacity): (WTF::Malloc>::reserveInitialCapacity): (WTF::Malloc>::shrinkCapacity): (WTF::Malloc>::append): (WTF::Malloc>::tryAppend): (WTF::Malloc>::constructAndAppend): (WTF::Malloc>::tryConstructAndAppend): (WTF::Malloc>::appendSlowCase): (WTF::Malloc>::constructAndAppendSlowCase): (WTF::Malloc>::tryConstructAndAppendSlowCase): (WTF::Malloc>::uncheckedAppend): (WTF::Malloc>::uncheckedConstructAndAppend): (WTF::Malloc>::appendVector): (WTF::Malloc>::insert): (WTF::Malloc>::insertVector): (WTF::Malloc>::remove): (WTF::Malloc>::removeFirst): (WTF::Malloc>::removeFirstMatching): (WTF::Malloc>::removeAll): (WTF::Malloc>::removeAllMatching): (WTF::Malloc>::reverse): (WTF::Malloc>::map const): (WTF::Malloc>::releaseBuffer): (WTF::Malloc>::checkConsistency): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::Malloc>::isolatedCopy const): (WTF::removeRepeatedElements): (WTF::minCapacity>::Vector): Deleted. (WTF::minCapacity>::contains const): Deleted. (WTF::minCapacity>::findMatching const): Deleted. (WTF::minCapacity>::find const): Deleted. (WTF::minCapacity>::reverseFind const): Deleted. (WTF::minCapacity>::appendIfNotContains): Deleted. (WTF::minCapacity>::fill): Deleted. (WTF::minCapacity>::appendRange): Deleted. (WTF::minCapacity>::expandCapacity): Deleted. (WTF::minCapacity>::tryExpandCapacity): Deleted. (WTF::minCapacity>::resize): Deleted. (WTF::minCapacity>::resizeToFit): Deleted. (WTF::minCapacity>::shrink): Deleted. (WTF::minCapacity>::grow): Deleted. (WTF::minCapacity>::asanSetInitialBufferSizeTo): Deleted. (WTF::minCapacity>::asanSetBufferSizeToFullCapacity): Deleted. (WTF::minCapacity>::asanBufferSizeWillChangeTo): Deleted. (WTF::minCapacity>::reserveCapacity): Deleted. (WTF::minCapacity>::tryReserveCapacity): Deleted. (WTF::minCapacity>::reserveInitialCapacity): Deleted. (WTF::minCapacity>::shrinkCapacity): Deleted. (WTF::minCapacity>::append): Deleted. (WTF::minCapacity>::tryAppend): Deleted. (WTF::minCapacity>::constructAndAppend): Deleted. (WTF::minCapacity>::tryConstructAndAppend): Deleted. (WTF::minCapacity>::appendSlowCase): Deleted. (WTF::minCapacity>::constructAndAppendSlowCase): Deleted. (WTF::minCapacity>::tryConstructAndAppendSlowCase): Deleted. (WTF::minCapacity>::uncheckedAppend): Deleted. (WTF::minCapacity>::uncheckedConstructAndAppend): Deleted. (WTF::minCapacity>::appendVector): Deleted. (WTF::minCapacity>::insert): Deleted. (WTF::minCapacity>::insertVector): Deleted. (WTF::minCapacity>::remove): Deleted. (WTF::minCapacity>::removeFirst): Deleted. (WTF::minCapacity>::removeFirstMatching): Deleted. (WTF::minCapacity>::removeAll): Deleted. (WTF::minCapacity>::removeAllMatching): Deleted. (WTF::minCapacity>::reverse): Deleted. (WTF::minCapacity>::map const): Deleted. (WTF::minCapacity>::releaseBuffer): Deleted. (WTF::minCapacity>::checkConsistency): Deleted. (WTF::minCapacity>::isolatedCopy const): Deleted. * wtf/text/CString.cpp: (WTF::CStringBuffer::createUninitialized): * wtf/text/CString.h: * wtf/text/StringBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/text/StringBuffer.h: (WTF::StringBuffer::StringBuffer): (WTF::StringBuffer::~StringBuffer): (WTF::StringBuffer::resize): (WTF::StringBuffer::release): * wtf/text/StringImpl.cpp: (WTF::StringImpl::~StringImpl): (WTF::StringImpl::destroy): (WTF::StringImpl::createUninitializedInternalNonEmpty): (WTF::StringImpl::reallocateInternal): * wtf/text/StringImpl.h: (WTF::StringImpl::StringImpl): (WTF::StringImpl::createSubstringSharingImpl): (WTF::StringImpl::tryCreateUninitialized): (WTF::StringImpl::adopt): * wtf/text/cf/StringImplCF.cpp: (WTF::StringWrapperCFAllocator::allocate): (WTF::StringWrapperCFAllocator::reallocate): (WTF::StringWrapperCFAllocator::deallocate): Canonical link: https://commits.webkit.org/218863@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-03 02:36:43 +00:00
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(RefCountedArray);
Inclusive software: Remove instances of "dumb" from the code https://bugs.webkit.org/show_bug.cgi?id=217778 Reviewed by Simon Fraser. Source/JavaScriptCore: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitCall): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::unboxBoolean): * heap/SlotVisitor.h: * jit/AssemblyHelpers.cpp: (JSC::AssemblyHelpers::emitVirtualCall): (JSC::AssemblyHelpers::emitDumbVirtualCall): Deleted. * jit/AssemblyHelpers.h: * jit/JITCall.cpp: (JSC::JIT::compileCallEvalSlowCase): * jit/JITCall32_64.cpp: (JSC::JIT::compileCallEvalSlowCase): * runtime/CachedTypes.cpp: * runtime/JSCJSValue.h: * runtime/WriteBarrier.h: * runtime/WriteBarrierInlines.h: (JSC::RawValueTraits<Unknown>>::set): (JSC::DumbValueTraits<Unknown>>::set): Deleted. * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::addCallIndirect): * wasm/generateWasm.py: (opcodeIterator): Source/WebCore: * Modules/webaudio/AudioNode.h: * dom/GCReachableRef.h: * page/EventHandler.cpp: (WebCore::EventHandler::handleDrag): * rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::addToLine): Source/WTF: * WTF.xcodeproj/project.pbxproj: * icu/unicode/caniter.h: * wtf/Bag.h: * wtf/CMakeLists.txt: * wtf/CagedPtr.h: * wtf/Forward.h: * wtf/NakedRef.h: * wtf/RawPtrTraits.h: Renamed from Source/WTF/wtf/DumbPtrTraits.h. * wtf/RawValueTraits.h: Renamed from Source/WTF/wtf/DumbValueTraits.h. * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefPtr.h: * wtf/SentinelLinkedList.h: Canonical link: https://commits.webkit.org/230896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268993 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-26 20:08:01 +00:00
template<typename T, typename PtrTraits = RawPtrTraits<T>>
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
class RefCountedArray {
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
enum CommonCopyConstructorTag { CommonCopyConstructor };
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
public:
[JSC] Shrink some of Vectors in JSC https://bugs.webkit.org/show_bug.cgi?id=224162 Reviewed by Simon Fraser. Source/JavaScriptCore: 1. Add XXXStatus::shrinkToFit to shrink underlying dynamic Vectors. 2. Replace tierUpInLoopHierarchy's Vector with RefCountedArray since it is constructed-once-lookup-only data. 3. Use MemoryCompactLookupOnlyRobinHoodHashSet for StringTables since this is constructed-once-lookup-only data. We also add MemoryCompactLookupOnlyRobinHoodHashSet support for CachedTypes. 4. Use resizeToFit for StringSwitchJumpTables and SwitchJumpTables. 5. JITStubRoutineSet's Vector should be shrunk. 6. BlockDirectoryBits's Vector's initial size should be small. 7. Make PolyProtoAccessChain RefCounted, and use RefCountedArray for its Vector<StructureID>. And remove PolyProtoAccessChain::clone. Just having Ref is enough since this is immutable data. 8. Use RefCountedArray for UnlinkedFunctionExecutable's m_classFieldLocations. 9. Use RefCountedArray for JSWebAssemblyInstance. * bytecode/AccessCase.cpp: (JSC::AccessCase::AccessCase): (JSC::AccessCase::create): (JSC::AccessCase::createTransition): * bytecode/AccessCase.h: (JSC::AccessCase::AccessCase): Deleted. * bytecode/CallLinkInfo.cpp: (JSC::CallLinkInfo::setFrameShuffleData): * bytecode/CheckPrivateBrandStatus.cpp: (JSC::CheckPrivateBrandStatus::shrinkToFit): (JSC::CheckPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::CheckPrivateBrandStatus::merge): * bytecode/CheckPrivateBrandStatus.h: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/DeleteByStatus.cpp: (JSC::DeleteByStatus::shrinkToFit): (JSC::DeleteByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::DeleteByStatus::merge): * bytecode/DeleteByStatus.h: * bytecode/GetByStatus.cpp: (JSC::GetByStatus::shrinkToFit): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::computeFor): (JSC::GetByStatus::merge): * bytecode/GetByStatus.h: * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::GetterSetterAccessCase): (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * bytecode/InByIdStatus.cpp: (JSC::InByIdStatus::shrinkToFit): (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::InByIdStatus::merge): * bytecode/InByIdStatus.h: * bytecode/InstanceOfStatus.cpp: (JSC::InstanceOfStatus::shrinkToFit): (JSC::InstanceOfStatus::computeForStubInfo): * bytecode/InstanceOfStatus.h: * bytecode/IntrinsicGetterAccessCase.cpp: (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase): (JSC::IntrinsicGetterAccessCase::create): * bytecode/IntrinsicGetterAccessCase.h: * bytecode/JumpTable.h: * bytecode/PolyProtoAccessChain.cpp: (JSC::PolyProtoAccessChain::tryCreate): (JSC::PolyProtoAccessChain::create): Deleted. * bytecode/PolyProtoAccessChain.h: (JSC::PolyProtoAccessChain::clone): Deleted. (JSC::PolyProtoAccessChain::chain const): Deleted. (JSC::PolyProtoAccessChain::operator!= const): Deleted. (JSC::PolyProtoAccessChain::forEach const): Deleted. (JSC::PolyProtoAccessChain::slotBaseStructure const): Deleted. * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::visitWeak const): (JSC::PolymorphicAccess::regenerate): * bytecode/PolymorphicAccess.h: * bytecode/ProxyableAccessCase.cpp: (JSC::ProxyableAccessCase::ProxyableAccessCase): (JSC::ProxyableAccessCase::create): * bytecode/ProxyableAccessCase.h: * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::shrinkToFit): (JSC::PutByIdStatus::computeForStubInfo): (JSC::PutByIdStatus::computeFor): (JSC::PutByIdStatus::merge): * bytecode/PutByIdStatus.h: * bytecode/SetPrivateBrandStatus.cpp: (JSC::SetPrivateBrandStatus::shrinkToFit): (JSC::SetPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::SetPrivateBrandStatus::merge): * bytecode/SetPrivateBrandStatus.h: * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecode/UnlinkedFunctionExecutable.h: * dfg/DFGJITCode.h: * dfg/DFGPlan.h: (JSC::DFG::Plan::tierUpInLoopHierarchy): * dfg/DFGTierUpCheckInjectionPhase.cpp: (JSC::DFG::TierUpCheckInjectionPhase::run): * heap/BlockDirectoryBits.h: * heap/JITStubRoutineSet.cpp: (JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines): * jit/CallFrameShuffleData.h: (JSC::CallFrameShuffleData::shrinkToFit): * jit/GCAwareJITStubRoutine.h: * jit/PolymorphicCallStubRoutine.h: * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::tryCachePutByID): (JSC::tryCacheInByID): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements): * parser/Parser.h: (JSC::Parser<LexerType>::parse): (JSC::parse): * runtime/CachedTypes.cpp: (JSC::CachedFunctionExecutableRareData::encode): (JSC::CachedFunctionExecutableRareData::decode const): * runtime/VM.cpp: (JSC::VM::popAllCheckpointOSRSideStateUntil): * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::visitChildrenImpl): * wasm/js/JSWebAssemblyInstance.h: Source/WTF: Add rbegin and rend to make RefCountedArray usable for Vector clients who use these features. * wtf/RefCountedArray.h: (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::end const): (WTF::RefCountedArray::rbegin): (WTF::RefCountedArray::rend): (WTF::RefCountedArray::rbegin const): (WTF::RefCountedArray::rend const): Canonical link: https://commits.webkit.org/236147@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-06 04:25:33 +00:00
using iterator = T*;
using const_iterator = const T*;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
RefCountedArray() = default;
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
RefCountedArray(const RefCountedArray& other)
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
: RefCountedArray(CommonCopyConstructor, other)
{ }
template<typename OtherTraits>
RefCountedArray(const RefCountedArray<T, OtherTraits>& other)
: RefCountedArray(CommonCopyConstructor, other)
{ }
[WTF] Introduce FixedVector and use it for FixedOperands https://bugs.webkit.org/show_bug.cgi?id=224171 Reviewed by Mark Lam. Source/JavaScriptCore: 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: Source/WTF: 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): Tools: * 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=): Canonical link: https://commits.webkit.org/236198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275542 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-06 19:47:47 +00:00
RefCountedArray(RefCountedArray&& other)
: m_data(PtrTraits::exchange(other.m_data, nullptr))
{ }
explicit RefCountedArray(size_t size)
{
if (!size) {
// NOTE: JSC's LowLevelInterpreter relies on this being nullptr when the size is zero.
Replace all use of ConstExprPoisoned with Poisoned. https://bugs.webkit.org/show_bug.cgi?id=181542 <rdar://problem/36442138> Reviewed by JF Bastien. Source/JavaScriptCore: 1. All JSC poisons are now defined in JSCPoison.h. 2. Change all clients to use the new poison values via the POISON() macro. 3. The LLInt code has been updated to handle CodeBlock poison. Some of this code uses the t5 temp register, which is not available on the Windows port. Fortunately, we don't currently do poisoning on the Windows port yet. So, it will just work for now. When poisoning is enabled for the Windows port, this LLInt code will need a Windows specific implementation to workaround its lack of a t5 register. * API/JSAPIWrapperObject.h: * API/JSCallbackFunction.h: * API/JSCallbackObject.h: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodePtr::emptyValue): (JSC::MacroAssemblerCodePtr::deletedValue): * b3/B3LowerMacros.cpp: * b3/testb3.cpp: (JSC::B3::testInterpreter): * bytecode/CodeBlock.h: (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::makePoisonedUnique): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCheckSubClass): (JSC::DFG::SpeculativeJIT::emitSwitchIntJump): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass): * jit/JIT.h: * jit/ThunkGenerators.cpp: (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/ArrayPrototype.h: * runtime/CustomGetterSetter.h: * runtime/DateInstance.h: * runtime/InternalFunction.h: * runtime/JSArrayBuffer.h: * runtime/JSCPoison.cpp: Copied from Source/JavaScriptCore/runtime/JSCPoisonedPtr.cpp. (JSC::initializePoison): * runtime/JSCPoison.h: (): Deleted. * runtime/JSCPoisonedPtr.cpp: Removed. * runtime/JSCPoisonedPtr.h: Removed. * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::makePoisonedUnique): * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/NativeExecutable.h: * runtime/StructureTransitionTable.h: (JSC::StructureTransitionTable::map const): (JSC::StructureTransitionTable::weakImpl const): * runtime/WriteBarrier.h: (JSC::WriteBarrier::poison): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: Source/WTF: 1. Removed ConstExprPoisoned and its artifacts. 2. Consolidated Poisoned into PoisonedImpl. PoisonedImpl is not more. 3. Changed all clients of ConstExprPoisoned to use Poisoned instead. 4. Worked around the GCC and Clang compiler bug that confuses an intptr_t& template arg with intptr_t. See use of std::enable_if_t<Other::isPoisoned> in Poisoned.h. 5. Removed ENABLE(MIXED_POISON) since we now have a workaround (3) that makes it possible to use the mixed poison code. 6. Also fixed broken implementation of comparison operators in Poisoned. * wtf/Bag.h: * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::poison): * wtf/DumbValueTraits.h: (WTF::DumbValueTraits::poison): * wtf/Poisoned.h: (WTF::Poisoned::Poisoned): (WTF::Poisoned::operator== const): (WTF::Poisoned::operator!= const): (WTF::Poisoned::operator< const): (WTF::Poisoned::operator<= const): (WTF::Poisoned::operator> const): (WTF::Poisoned::operator>= const): (WTF::Poisoned::operator=): (WTF::Poisoned::swap): (WTF::swap): (WTF::PoisonedPtrTraits::poison): (WTF::PoisonedPtrTraits::swap): (WTF::PoisonedValueTraits::poison): (WTF::PoisonedValueTraits::swap): (WTF::PoisonedImpl::PoisonedImpl): Deleted. (WTF::PoisonedImpl::assertIsPoisoned const): Deleted. (WTF::PoisonedImpl::assertIsNotPoisoned const): Deleted. (WTF::PoisonedImpl::unpoisoned const): Deleted. (WTF::PoisonedImpl::clear): Deleted. (WTF::PoisonedImpl::operator* const): Deleted. (WTF::PoisonedImpl::operator-> const): Deleted. (WTF::PoisonedImpl::bits const): Deleted. (WTF::PoisonedImpl::operator! const): Deleted. (WTF::PoisonedImpl::operator bool const): Deleted. (WTF::PoisonedImpl::operator== const): Deleted. (WTF::PoisonedImpl::operator!= const): Deleted. (WTF::PoisonedImpl::operator< const): Deleted. (WTF::PoisonedImpl::operator<= const): Deleted. (WTF::PoisonedImpl::operator> const): Deleted. (WTF::PoisonedImpl::operator>= const): Deleted. (WTF::PoisonedImpl::operator=): Deleted. (WTF::PoisonedImpl::swap): Deleted. (WTF::PoisonedImpl::exchange): Deleted. (WTF::PoisonedImpl::poison): Deleted. (WTF::PoisonedImpl::unpoison): Deleted. (WTF::constExprPoisonRandom): Deleted. (WTF::makeConstExprPoison): Deleted. (WTF::ConstExprPoisonedPtrTraits::exchange): Deleted. (WTF::ConstExprPoisonedPtrTraits::swap): Deleted. (WTF::ConstExprPoisonedPtrTraits::unwrap): Deleted. (WTF::ConstExprPoisonedValueTraits::exchange): Deleted. (WTF::ConstExprPoisonedValueTraits::swap): Deleted. (WTF::ConstExprPoisonedValueTraits::unwrap): Deleted. * wtf/PoisonedUniquePtr.h: (WTF::PoisonedUniquePtr::PoisonedUniquePtr): (WTF::PoisonedUniquePtr::operator=): * wtf/Ref.h: * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): * wtf/RefPtr.h: * wtf/WTFAssertions.cpp: Tools: 1. Converted tests to using new uintptr_t& poison type. 2. Added tests for Poisoned comparison operators. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: Removed. * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::initializeTestPoison): Deleted. * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::f1): * TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::poisonedPtrFoo): * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/197492@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-14 06:11:55 +00:00
PtrTraits::exchange(m_data, nullptr);
return;
}
m_data = allocateUninitializedData(size);
VectorTypeOperations<T>::initializeIfNonPOD(begin(), end());
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
template<typename OtherTraits = PtrTraits>
RefCountedArray<T, OtherTraits> clone() const
Baseline JIT should be concurrent https://bugs.webkit.org/show_bug.cgi?id=158755 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This makes the baseline JIT concurrent. We want it to be concurrent because it takes up about 1% of PLT3 and 10% of JSBench (though the JSBench number might be down from recent optimizations). The idea is really simple: I separated the compile and link phases of JIT::privateCompile(), and arranged to call the compile phase from another thread. This doesn't reuse the old DFG::Worklist code, because that code does things we don't need (like compilation plan cancellation to allow GC to interleave with compilations) and is structured in a way that would have required more changes to the baseline JIT. Also, I think that code uses the wrong API, and as a result, clients of that API have a bad time. For example, it's never clear who has the responsibility of setting the JIT thresholds and the DFG::Worklist goes to great lengths to try to help its client set those things correctly, but since it doesn't set them directly, the client then has to have additional complex logic to combine what it learned from the Worklist and what it knows to set the thresholds. This patch takes a simpler approach: the JITWorklist takes complete control over scheduling compilations. It's like a combination of DFG::Worklist and operationOptimize(). Because the baseline JIT runs quickly, we can take some shortcuts. The JITWorklist requires that all of its plans complete before a GC begins. This ensures that we don't have to worry about interactions between the concurrent baseline JIT and the GC. I needed to do a bunch of minor changes to the JIT to handle the races that emerged. For example, I needed to do things to opcodes that read profiling both in the main path code generator and the slow path one. One trick I used was to create a copy of the instruction stream and provide that for anyone interested in the original value of the profiles. Most code still uses the CodeBlock's instruction stream because it may emit JIT code that points at the stream. This also fixes a LLInt bug in prototype caching. This bug was revealed by this change because more of our LayoutTests now run in LLInt. This looks like it might be a ~1% Octane speed-up (on command line) and a ~0.7% PLT3 speed-up. This also looks like a ~2% JSBench speed-up. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * debugger/Debugger.cpp: (JSC::Debugger::setSteppingMode): (JSC::Debugger::toggleBreakpoint): (JSC::Debugger::clearBreakpoints): (JSC::Debugger::clearDebuggerRequests): * dfg/DFGOSRExitPreparation.cpp: (JSC::DFG::prepareCodeOriginForOSRExit): * heap/Heap.cpp: (JSC::Heap::didFinishIterating): (JSC::Heap::completeAllJITPlans): (JSC::Heap::deleteAllCodeBlocks): (JSC::Heap::collectImpl): (JSC::Heap::completeAllDFGPlans): Deleted. * heap/Heap.h: * heap/HeapInlines.h: (JSC::Heap::forEachCodeBlock): * jit/JIT.cpp: (JSC::JIT::emitNotifyWrite): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::compileWithoutLinking): (JSC::JIT::link): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileExceptionHandlers): * jit/JIT.h: (JSC::JIT::compile): (JSC::JIT::getSlowCase): (JSC::JIT::linkSlowCase): (JSC::JIT::linkDummySlowCase): * jit/JITInlines.h: (JSC::JIT::emitTagBool): (JSC::JIT::originalInstruction): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_to_scope): * jit/JITPropertyAccess.cpp: (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emit_op_resolve_scope): (JSC::JIT::emitSlow_op_resolve_scope): (JSC::JIT::emit_op_get_from_scope): (JSC::JIT::emitSlow_op_get_from_scope): (JSC::JIT::emit_op_put_to_scope): (JSC::JIT::emitSlow_op_put_to_scope): * jit/JITWorklist.cpp: Added. (JSC::JITWorklist::Plan::Plan): (JSC::JITWorklist::Plan::compileInThread): (JSC::JITWorklist::Plan::finalize): (JSC::JITWorklist::Plan::codeBlock): (JSC::JITWorklist::Plan::vm): (JSC::JITWorklist::Plan::isFinishedCompiling): (JSC::JITWorklist::Plan::isFinalized): (JSC::JITWorklist::JITWorklist): (JSC::JITWorklist::~JITWorklist): (JSC::JITWorklist::completeAllForVM): (JSC::JITWorklist::poll): (JSC::JITWorklist::compileLater): (JSC::JITWorklist::compileNow): (JSC::JITWorklist::runThread): (JSC::JITWorklist::finalizePlans): (JSC::JITWorklist::instance): * jit/JITWorklist.h: Added. * llint/LLIntSlowPaths.cpp: (JSC::LLInt::jitCompileAndSetHeuristics): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/VM.cpp: (JSC::VM::~VM): Source/WTF: The concurrent baseline JIT needs to be able to clone bytecode to get a consistent snapshot. So, this adds such a method. * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone): Tools: Need to disable concurrent JIT when running profiler tests. We should have been doing this all along. * Scripts/run-jsc-stress-tests: LayoutTests: This change revealed a latent bug in the LLInt. The non-llint version of this new test would usually fail because it was still in LLInt. This new test always fails. * js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint.html: Added. * js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint-expected.txt: Added. * js/dom/script-tests/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint.js: Added. Canonical link: https://commits.webkit.org/176935@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202157 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-17 04:48:47 +00:00
{
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
RefCountedArray<T, OtherTraits> result(size());
const T* data = this->data();
T* resultData = result.data();
Baseline JIT should be concurrent https://bugs.webkit.org/show_bug.cgi?id=158755 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This makes the baseline JIT concurrent. We want it to be concurrent because it takes up about 1% of PLT3 and 10% of JSBench (though the JSBench number might be down from recent optimizations). The idea is really simple: I separated the compile and link phases of JIT::privateCompile(), and arranged to call the compile phase from another thread. This doesn't reuse the old DFG::Worklist code, because that code does things we don't need (like compilation plan cancellation to allow GC to interleave with compilations) and is structured in a way that would have required more changes to the baseline JIT. Also, I think that code uses the wrong API, and as a result, clients of that API have a bad time. For example, it's never clear who has the responsibility of setting the JIT thresholds and the DFG::Worklist goes to great lengths to try to help its client set those things correctly, but since it doesn't set them directly, the client then has to have additional complex logic to combine what it learned from the Worklist and what it knows to set the thresholds. This patch takes a simpler approach: the JITWorklist takes complete control over scheduling compilations. It's like a combination of DFG::Worklist and operationOptimize(). Because the baseline JIT runs quickly, we can take some shortcuts. The JITWorklist requires that all of its plans complete before a GC begins. This ensures that we don't have to worry about interactions between the concurrent baseline JIT and the GC. I needed to do a bunch of minor changes to the JIT to handle the races that emerged. For example, I needed to do things to opcodes that read profiling both in the main path code generator and the slow path one. One trick I used was to create a copy of the instruction stream and provide that for anyone interested in the original value of the profiles. Most code still uses the CodeBlock's instruction stream because it may emit JIT code that points at the stream. This also fixes a LLInt bug in prototype caching. This bug was revealed by this change because more of our LayoutTests now run in LLInt. This looks like it might be a ~1% Octane speed-up (on command line) and a ~0.7% PLT3 speed-up. This also looks like a ~2% JSBench speed-up. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * debugger/Debugger.cpp: (JSC::Debugger::setSteppingMode): (JSC::Debugger::toggleBreakpoint): (JSC::Debugger::clearBreakpoints): (JSC::Debugger::clearDebuggerRequests): * dfg/DFGOSRExitPreparation.cpp: (JSC::DFG::prepareCodeOriginForOSRExit): * heap/Heap.cpp: (JSC::Heap::didFinishIterating): (JSC::Heap::completeAllJITPlans): (JSC::Heap::deleteAllCodeBlocks): (JSC::Heap::collectImpl): (JSC::Heap::completeAllDFGPlans): Deleted. * heap/Heap.h: * heap/HeapInlines.h: (JSC::Heap::forEachCodeBlock): * jit/JIT.cpp: (JSC::JIT::emitNotifyWrite): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::compileWithoutLinking): (JSC::JIT::link): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileExceptionHandlers): * jit/JIT.h: (JSC::JIT::compile): (JSC::JIT::getSlowCase): (JSC::JIT::linkSlowCase): (JSC::JIT::linkDummySlowCase): * jit/JITInlines.h: (JSC::JIT::emitTagBool): (JSC::JIT::originalInstruction): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_to_scope): * jit/JITPropertyAccess.cpp: (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emit_op_resolve_scope): (JSC::JIT::emitSlow_op_resolve_scope): (JSC::JIT::emit_op_get_from_scope): (JSC::JIT::emitSlow_op_get_from_scope): (JSC::JIT::emit_op_put_to_scope): (JSC::JIT::emitSlow_op_put_to_scope): * jit/JITWorklist.cpp: Added. (JSC::JITWorklist::Plan::Plan): (JSC::JITWorklist::Plan::compileInThread): (JSC::JITWorklist::Plan::finalize): (JSC::JITWorklist::Plan::codeBlock): (JSC::JITWorklist::Plan::vm): (JSC::JITWorklist::Plan::isFinishedCompiling): (JSC::JITWorklist::Plan::isFinalized): (JSC::JITWorklist::JITWorklist): (JSC::JITWorklist::~JITWorklist): (JSC::JITWorklist::completeAllForVM): (JSC::JITWorklist::poll): (JSC::JITWorklist::compileLater): (JSC::JITWorklist::compileNow): (JSC::JITWorklist::runThread): (JSC::JITWorklist::finalizePlans): (JSC::JITWorklist::instance): * jit/JITWorklist.h: Added. * llint/LLIntSlowPaths.cpp: (JSC::LLInt::jitCompileAndSetHeuristics): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/VM.cpp: (JSC::VM::~VM): Source/WTF: The concurrent baseline JIT needs to be able to clone bytecode to get a consistent snapshot. So, this adds such a method. * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone): Tools: Need to disable concurrent JIT when running profiler tests. We should have been doing this all along. * Scripts/run-jsc-stress-tests: LayoutTests: This change revealed a latent bug in the LLInt. The non-llint version of this new test would usually fail because it was still in LLInt. This new test always fails. * js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint.html: Added. * js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint-expected.txt: Added. * js/dom/script-tests/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint.js: Added. Canonical link: https://commits.webkit.org/176935@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202157 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-17 04:48:47 +00:00
for (unsigned i = size(); i--;)
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
resultData[i] = data[i];
Baseline JIT should be concurrent https://bugs.webkit.org/show_bug.cgi?id=158755 Reviewed by Geoffrey Garen. Source/JavaScriptCore: This makes the baseline JIT concurrent. We want it to be concurrent because it takes up about 1% of PLT3 and 10% of JSBench (though the JSBench number might be down from recent optimizations). The idea is really simple: I separated the compile and link phases of JIT::privateCompile(), and arranged to call the compile phase from another thread. This doesn't reuse the old DFG::Worklist code, because that code does things we don't need (like compilation plan cancellation to allow GC to interleave with compilations) and is structured in a way that would have required more changes to the baseline JIT. Also, I think that code uses the wrong API, and as a result, clients of that API have a bad time. For example, it's never clear who has the responsibility of setting the JIT thresholds and the DFG::Worklist goes to great lengths to try to help its client set those things correctly, but since it doesn't set them directly, the client then has to have additional complex logic to combine what it learned from the Worklist and what it knows to set the thresholds. This patch takes a simpler approach: the JITWorklist takes complete control over scheduling compilations. It's like a combination of DFG::Worklist and operationOptimize(). Because the baseline JIT runs quickly, we can take some shortcuts. The JITWorklist requires that all of its plans complete before a GC begins. This ensures that we don't have to worry about interactions between the concurrent baseline JIT and the GC. I needed to do a bunch of minor changes to the JIT to handle the races that emerged. For example, I needed to do things to opcodes that read profiling both in the main path code generator and the slow path one. One trick I used was to create a copy of the instruction stream and provide that for anyone interested in the original value of the profiles. Most code still uses the CodeBlock's instruction stream because it may emit JIT code that points at the stream. This also fixes a LLInt bug in prototype caching. This bug was revealed by this change because more of our LayoutTests now run in LLInt. This looks like it might be a ~1% Octane speed-up (on command line) and a ~0.7% PLT3 speed-up. This also looks like a ~2% JSBench speed-up. * CMakeLists.txt: * JavaScriptCore.xcodeproj/project.pbxproj: * debugger/Debugger.cpp: (JSC::Debugger::setSteppingMode): (JSC::Debugger::toggleBreakpoint): (JSC::Debugger::clearBreakpoints): (JSC::Debugger::clearDebuggerRequests): * dfg/DFGOSRExitPreparation.cpp: (JSC::DFG::prepareCodeOriginForOSRExit): * heap/Heap.cpp: (JSC::Heap::didFinishIterating): (JSC::Heap::completeAllJITPlans): (JSC::Heap::deleteAllCodeBlocks): (JSC::Heap::collectImpl): (JSC::Heap::completeAllDFGPlans): Deleted. * heap/Heap.h: * heap/HeapInlines.h: (JSC::Heap::forEachCodeBlock): * jit/JIT.cpp: (JSC::JIT::emitNotifyWrite): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::compileWithoutLinking): (JSC::JIT::link): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileExceptionHandlers): * jit/JIT.h: (JSC::JIT::compile): (JSC::JIT::getSlowCase): (JSC::JIT::linkSlowCase): (JSC::JIT::linkDummySlowCase): * jit/JITInlines.h: (JSC::JIT::emitTagBool): (JSC::JIT::originalInstruction): * jit/JITPropertyAccess32_64.cpp: (JSC::JIT::emitSlow_op_put_to_scope): * jit/JITPropertyAccess.cpp: (JSC::JIT::emitSlow_op_put_by_val): (JSC::JIT::emit_op_resolve_scope): (JSC::JIT::emitSlow_op_resolve_scope): (JSC::JIT::emit_op_get_from_scope): (JSC::JIT::emitSlow_op_get_from_scope): (JSC::JIT::emit_op_put_to_scope): (JSC::JIT::emitSlow_op_put_to_scope): * jit/JITWorklist.cpp: Added. (JSC::JITWorklist::Plan::Plan): (JSC::JITWorklist::Plan::compileInThread): (JSC::JITWorklist::Plan::finalize): (JSC::JITWorklist::Plan::codeBlock): (JSC::JITWorklist::Plan::vm): (JSC::JITWorklist::Plan::isFinishedCompiling): (JSC::JITWorklist::Plan::isFinalized): (JSC::JITWorklist::JITWorklist): (JSC::JITWorklist::~JITWorklist): (JSC::JITWorklist::completeAllForVM): (JSC::JITWorklist::poll): (JSC::JITWorklist::compileLater): (JSC::JITWorklist::compileNow): (JSC::JITWorklist::runThread): (JSC::JITWorklist::finalizePlans): (JSC::JITWorklist::instance): * jit/JITWorklist.h: Added. * llint/LLIntSlowPaths.cpp: (JSC::LLInt::jitCompileAndSetHeuristics): * runtime/CommonSlowPaths.cpp: (JSC::SLOW_PATH_DECL): * runtime/CommonSlowPaths.h: (JSC::CommonSlowPaths::tryCachePutToScopeGlobal): (JSC::CommonSlowPaths::tryCacheGetFromScopeGlobal): * runtime/VM.cpp: (JSC::VM::~VM): Source/WTF: The concurrent baseline JIT needs to be able to clone bytecode to get a consistent snapshot. So, this adds such a method. * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone): Tools: Need to disable concurrent JIT when running profiler tests. We should have been doing this all along. * Scripts/run-jsc-stress-tests: LayoutTests: This change revealed a latent bug in the LLInt. The non-llint version of this new test would usually fail because it was still in LLInt. This new test always fails. * js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint.html: Added. * js/dom/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint-expected.txt: Added. * js/dom/script-tests/prototype-chain-caching-with-impure-get-own-property-slot-traps-llint.js: Added. Canonical link: https://commits.webkit.org/176935@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202157 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-17 04:48:47 +00:00
return result;
}
Make Vector(const Vector<T, otherCapacity, otherOverflowBehaviour>&) constructor explicit https://bugs.webkit.org/show_bug.cgi?id=143970 Reviewed by Darin Adler. Make Vector(const Vector<T, otherCapacity, otherOverflowBehaviour>&) constructor explicit as it copies the vector and it is easy to call it by mistake. Source/JavaScriptCore: * bytecode/UnlinkedInstructionStream.cpp: (JSC::UnlinkedInstructionStream::UnlinkedInstructionStream): * bytecode/UnlinkedInstructionStream.h: * ftl/FTLLowerDFGToLLVM.cpp: (JSC::FTL::LowerDFGToLLVM::lower): Source/WebCore: * Modules/indexeddb/IDBDatabaseBackend.cpp: (WebCore::IDBDatabaseBackend::setIndexKeys): (WebCore::IDBDatabaseBackend::setIndexesReady): * Modules/indexeddb/IDBDatabaseBackend.h: * Modules/indexeddb/IDBServerConnection.h: * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::minimumRegisterRequirements): (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementHasClasses): * cssjit/StackAllocator.h: (WebCore::StackAllocator::push): (WebCore::StackAllocator::pop): * rendering/RenderGrid.cpp: (WebCore::RenderGrid::GridIterator::nextGridItem): (WebCore::RenderGrid::GridIterator::isEmptyAreaEnough): * rendering/style/SVGRenderStyle.cpp: (WebCore::SVGRenderStyle::paintTypesForPaintOrder): * rendering/style/SVGRenderStyle.h: * rendering/svg/RenderSVGShape.cpp: (WebCore::RenderSVGShape::fillStrokeMarkers): * rendering/svg/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::paint): * svg/SVGToOTFFontConversion.cpp: (WebCore::SVGToOTFFontConverter::appendLigatureGlyphs): (WebCore::SVGToOTFFontConverter::SVGToOTFFontConverter): Source/WebKit2: * WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp: (WebKit::WebIDBServerConnection::setIndexKeys): * WebProcess/Databases/IndexedDB/WebIDBServerConnection.h: Source/WTF: * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): * wtf/Vector.h: Canonical link: https://commits.webkit.org/161968@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-04-21 16:18:22 +00:00
template<size_t inlineCapacity, typename OverflowHandler>
explicit RefCountedArray(const Vector<T, inlineCapacity, OverflowHandler>& other)
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
{
if (other.isEmpty()) {
Replace all use of ConstExprPoisoned with Poisoned. https://bugs.webkit.org/show_bug.cgi?id=181542 <rdar://problem/36442138> Reviewed by JF Bastien. Source/JavaScriptCore: 1. All JSC poisons are now defined in JSCPoison.h. 2. Change all clients to use the new poison values via the POISON() macro. 3. The LLInt code has been updated to handle CodeBlock poison. Some of this code uses the t5 temp register, which is not available on the Windows port. Fortunately, we don't currently do poisoning on the Windows port yet. So, it will just work for now. When poisoning is enabled for the Windows port, this LLInt code will need a Windows specific implementation to workaround its lack of a t5 register. * API/JSAPIWrapperObject.h: * API/JSCallbackFunction.h: * API/JSCallbackObject.h: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/MacroAssemblerCodeRef.h: (JSC::MacroAssemblerCodePtr::emptyValue): (JSC::MacroAssemblerCodePtr::deletedValue): * b3/B3LowerMacros.cpp: * b3/testb3.cpp: (JSC::B3::testInterpreter): * bytecode/CodeBlock.h: (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::makePoisonedUnique): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileCheckSubClass): (JSC::DFG::SpeculativeJIT::emitSwitchIntJump): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCheckSubClass): * jit/JIT.h: * jit/ThunkGenerators.cpp: (JSC::virtualThunkFor): (JSC::nativeForGenerator): (JSC::boundThisNoArgsFunctionCallGenerator): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/ArrayPrototype.h: * runtime/CustomGetterSetter.h: * runtime/DateInstance.h: * runtime/InternalFunction.h: * runtime/JSArrayBuffer.h: * runtime/JSCPoison.cpp: Copied from Source/JavaScriptCore/runtime/JSCPoisonedPtr.cpp. (JSC::initializePoison): * runtime/JSCPoison.h: (): Deleted. * runtime/JSCPoisonedPtr.cpp: Removed. * runtime/JSCPoisonedPtr.h: Removed. * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::makePoisonedUnique): * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/NativeExecutable.h: * runtime/StructureTransitionTable.h: (JSC::StructureTransitionTable::map const): (JSC::StructureTransitionTable::weakImpl const): * runtime/WriteBarrier.h: (JSC::WriteBarrier::poison): * wasm/js/JSToWasm.cpp: (JSC::Wasm::createJSToWasmWrapper): * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/JSWebAssemblyInstance.h: * wasm/js/JSWebAssemblyMemory.h: * wasm/js/JSWebAssemblyModule.h: * wasm/js/JSWebAssemblyTable.h: * wasm/js/WasmToJS.cpp: (JSC::Wasm::handleBadI64Use): (JSC::Wasm::wasmToJS): * wasm/js/WebAssemblyFunctionBase.h: * wasm/js/WebAssemblyModuleRecord.h: * wasm/js/WebAssemblyToJSCallee.h: * wasm/js/WebAssemblyWrapperFunction.h: Source/WTF: 1. Removed ConstExprPoisoned and its artifacts. 2. Consolidated Poisoned into PoisonedImpl. PoisonedImpl is not more. 3. Changed all clients of ConstExprPoisoned to use Poisoned instead. 4. Worked around the GCC and Clang compiler bug that confuses an intptr_t& template arg with intptr_t. See use of std::enable_if_t<Other::isPoisoned> in Poisoned.h. 5. Removed ENABLE(MIXED_POISON) since we now have a workaround (3) that makes it possible to use the mixed poison code. 6. Also fixed broken implementation of comparison operators in Poisoned. * wtf/Bag.h: * wtf/DumbPtrTraits.h: (WTF::DumbPtrTraits::poison): * wtf/DumbValueTraits.h: (WTF::DumbValueTraits::poison): * wtf/Poisoned.h: (WTF::Poisoned::Poisoned): (WTF::Poisoned::operator== const): (WTF::Poisoned::operator!= const): (WTF::Poisoned::operator< const): (WTF::Poisoned::operator<= const): (WTF::Poisoned::operator> const): (WTF::Poisoned::operator>= const): (WTF::Poisoned::operator=): (WTF::Poisoned::swap): (WTF::swap): (WTF::PoisonedPtrTraits::poison): (WTF::PoisonedPtrTraits::swap): (WTF::PoisonedValueTraits::poison): (WTF::PoisonedValueTraits::swap): (WTF::PoisonedImpl::PoisonedImpl): Deleted. (WTF::PoisonedImpl::assertIsPoisoned const): Deleted. (WTF::PoisonedImpl::assertIsNotPoisoned const): Deleted. (WTF::PoisonedImpl::unpoisoned const): Deleted. (WTF::PoisonedImpl::clear): Deleted. (WTF::PoisonedImpl::operator* const): Deleted. (WTF::PoisonedImpl::operator-> const): Deleted. (WTF::PoisonedImpl::bits const): Deleted. (WTF::PoisonedImpl::operator! const): Deleted. (WTF::PoisonedImpl::operator bool const): Deleted. (WTF::PoisonedImpl::operator== const): Deleted. (WTF::PoisonedImpl::operator!= const): Deleted. (WTF::PoisonedImpl::operator< const): Deleted. (WTF::PoisonedImpl::operator<= const): Deleted. (WTF::PoisonedImpl::operator> const): Deleted. (WTF::PoisonedImpl::operator>= const): Deleted. (WTF::PoisonedImpl::operator=): Deleted. (WTF::PoisonedImpl::swap): Deleted. (WTF::PoisonedImpl::exchange): Deleted. (WTF::PoisonedImpl::poison): Deleted. (WTF::PoisonedImpl::unpoison): Deleted. (WTF::constExprPoisonRandom): Deleted. (WTF::makeConstExprPoison): Deleted. (WTF::ConstExprPoisonedPtrTraits::exchange): Deleted. (WTF::ConstExprPoisonedPtrTraits::swap): Deleted. (WTF::ConstExprPoisonedPtrTraits::unwrap): Deleted. (WTF::ConstExprPoisonedValueTraits::exchange): Deleted. (WTF::ConstExprPoisonedValueTraits::swap): Deleted. (WTF::ConstExprPoisonedValueTraits::unwrap): Deleted. * wtf/PoisonedUniquePtr.h: (WTF::PoisonedUniquePtr::PoisonedUniquePtr): (WTF::PoisonedUniquePtr::operator=): * wtf/Ref.h: * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): * wtf/RefPtr.h: * wtf/WTFAssertions.cpp: Tools: 1. Converted tests to using new uintptr_t& poison type. 2. Added tests for Poisoned comparison operators. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/ConstExprPoisoned.cpp: Removed. * TestWebKitAPI/Tests/WTF/Poisoned.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::initializeTestPoison): Deleted. * TestWebKitAPI/Tests/WTF/PoisonedRef.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::passWithRef): * TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::f1): * TestWebKitAPI/Tests/WTF/PoisonedUniquePtr.cpp: (TestWebKitAPI::TEST): (TestWebKitAPI::poisonedPtrFoo): * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForNonTriviallyDestructibleArrays.cpp: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/PoisonedUniquePtrForTriviallyDestructibleArrays.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/197492@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226940 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-14 06:11:55 +00:00
PtrTraits::exchange(m_data, nullptr);
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
return;
}
T* data = allocateUninitializedData(other.size());
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
m_data = data;
VectorTypeOperations<T>::uninitializedCopy(other.begin(), other.end(), data);
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
template<size_t inlineCapacity, typename OverflowHandler>
explicit RefCountedArray(Vector<T, inlineCapacity, OverflowHandler>&& other)
{
Vector<T, inlineCapacity, OverflowHandler> vector(WTFMove(other));
if (vector.isEmpty()) {
PtrTraits::exchange(m_data, nullptr);
return;
}
T* data = allocateUninitializedData(vector.size());
m_data = data;
for (unsigned index = 0; index < vector.size(); ++index)
new (data + index) T(WTFMove(vector[index]));
}
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
template<typename OtherTraits = PtrTraits>
RefCountedArray& operator=(const RefCountedArray<T, OtherTraits>& other)
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
{
return assign<OtherTraits>(other);
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
RefCountedArray& operator=(const RefCountedArray& other)
{
return assign<PtrTraits>(other);
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. Source/JavaScriptCore: While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase<Traits>::newRegister): (JSC::BytecodeGeneratorBase<Traits>::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): Source/WTF: Add more useful methods for RefCountedArray. * wtf/RefCountedArray.h: (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::isEmpty const): (WTF::RefCountedArray::front): (WTF::RefCountedArray::front const): (WTF::RefCountedArray::last): (WTF::RefCountedArray::last const): Canonical link: https://commits.webkit.org/220203@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-04 19:05:17 +00:00
template<size_t inlineCapacity, typename OverflowHandler>
RefCountedArray& operator=(const Vector<T, inlineCapacity, OverflowHandler>& other)
{
T* oldData = data();
if (other.isEmpty())
PtrTraits::exchange(m_data, nullptr);
else {
T* data = allocateUninitializedData(other.size());
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. Source/JavaScriptCore: While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase<Traits>::newRegister): (JSC::BytecodeGeneratorBase<Traits>::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): Source/WTF: Add more useful methods for RefCountedArray. * wtf/RefCountedArray.h: (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::isEmpty const): (WTF::RefCountedArray::front): (WTF::RefCountedArray::front const): (WTF::RefCountedArray::last): (WTF::RefCountedArray::last const): Canonical link: https://commits.webkit.org/220203@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-04 19:05:17 +00:00
m_data = data;
VectorTypeOperations<T>::uninitializedCopy(other.begin(), other.end(), data);
}
if (!oldData)
return *this;
unsigned refCount = Header::fromPayload(oldData)->refCount - 1;
if (refCount) {
Header::fromPayload(oldData)->refCount = refCount;
return *this;
}
VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
RefCountedArrayMalloc::free(Header::fromPayload(oldData));
return *this;
}
template<size_t inlineCapacity, typename OverflowHandler>
RefCountedArray& operator=(Vector<T, inlineCapacity, OverflowHandler>&& other)
{
Vector<T, inlineCapacity, OverflowHandler> vector(WTFMove(other));
T* oldData = data();
if (vector.isEmpty())
PtrTraits::exchange(m_data, nullptr);
else {
T* data = allocateUninitializedData(vector.size());
m_data = data;
for (unsigned index = 0; index < vector.size(); ++index)
new (data + index) T(WTFMove(vector[index]));
}
if (!oldData)
return *this;
unsigned refCount = Header::fromPayload(oldData)->refCount - 1;
if (refCount) {
Header::fromPayload(oldData)->refCount = refCount;
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. Source/JavaScriptCore: While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase<Traits>::newRegister): (JSC::BytecodeGeneratorBase<Traits>::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): Source/WTF: Add more useful methods for RefCountedArray. * wtf/RefCountedArray.h: (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::isEmpty const): (WTF::RefCountedArray::front): (WTF::RefCountedArray::front const): (WTF::RefCountedArray::last): (WTF::RefCountedArray::last const): Canonical link: https://commits.webkit.org/220203@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-04 19:05:17 +00:00
return *this;
}
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. Source/JavaScriptCore: While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase<Traits>::newRegister): (JSC::BytecodeGeneratorBase<Traits>::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): Source/WTF: Add more useful methods for RefCountedArray. * wtf/RefCountedArray.h: (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::isEmpty const): (WTF::RefCountedArray::front): (WTF::RefCountedArray::front const): (WTF::RefCountedArray::last): (WTF::RefCountedArray::last const): Canonical link: https://commits.webkit.org/220203@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-04 19:05:17 +00:00
VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
RefCountedArrayMalloc::free(Header::fromPayload(oldData));
return *this;
}
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
~RefCountedArray()
{
if (!m_data)
return;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
T* data = this->data();
unsigned refCount = Header::fromPayload(data)->refCount - 1;
if (refCount) {
Header::fromPayload(data)->refCount = refCount;
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
return;
}
VectorTypeOperations<T>::destruct(begin(), end());
Experiment: create lots of different malloc zones for easier accounting of memory use https://bugs.webkit.org/show_bug.cgi?id=186422 Patch by Yusuke Suzuki <ysuzuki@apple.com> and Simon Fraser <simon.fraser@apple.com> on 2020-01-02 Reviewed by Saam Barati. Source/bmalloc: * bmalloc/BPlatform.h: * bmalloc/Environment.cpp: (bmalloc::Environment::computeIsDebugHeapEnabled): * bmalloc/IsoHeap.h: (bmalloc::api::IsoHeap::IsoHeap): * bmalloc/IsoHeapInlines.h: (bmalloc::api::IsoHeap<Type>::IsoHeap): * bmalloc/IsoTLSInlines.h: (bmalloc::IsoTLS::allocateSlow): (bmalloc::IsoTLS::deallocateSlow): Source/JavaScriptCore: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/AssemblerBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * assembler/AssemblerBuffer.h: (JSC::AssemblerData::AssemblerData): (JSC::AssemblerData::operator=): (JSC::AssemblerData::~AssemblerData): (JSC::AssemblerData::grow): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/BytecodeBasicBlock.cpp: * bytecode/BytecodeBasicBlock.h: * bytecode/CodeBlock.cpp: * bytecode/CodeBlock.h: * bytecode/InstructionStream.cpp: * bytecode/InstructionStream.h: * bytecode/PolymorphicAccess.cpp: * bytecode/PolymorphicAccess.h: * bytecode/UnlinkedMetadataTable.cpp: (JSC::UnlinkedMetadataTable::finalize): * bytecode/UnlinkedMetadataTable.h: * bytecode/UnlinkedMetadataTableInlines.h: (JSC::UnlinkedMetadataTable::UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::~UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::link): (JSC::UnlinkedMetadataTable::unlink): * bytecode/ValueProfile.h: (JSC::ValueProfileAndVirtualRegisterBuffer::ValueProfileAndVirtualRegisterBuffer): * bytecode/Watchpoint.cpp: * bytecode/Watchpoint.h: * dfg/DFGBasicBlock.cpp: * dfg/DFGBasicBlock.h: * dfg/DFGNode.cpp: * dfg/DFGNode.h: * dfg/DFGSpeculativeJIT.cpp: * dfg/DFGSpeculativeJIT.h: * heap/BlockDirectory.cpp: * heap/BlockDirectory.h: * heap/FastMallocAlignedMemoryAllocator.cpp: (JSC::FastMallocAlignedMemoryAllocator::FastMallocAlignedMemoryAllocator): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::freeAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateMemory): (JSC::FastMallocAlignedMemoryAllocator::freeMemory): (JSC::FastMallocAlignedMemoryAllocator::tryReallocateMemory): * heap/FastMallocAlignedMemoryAllocator.h: * heap/GCSegmentedArray.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * heap/GCSegmentedArray.h: * heap/GCSegmentedArrayInlines.h: (JSC::GCArraySegment<T>::create): (JSC::GCArraySegment<T>::destroy): * heap/GigacageAlignedMemoryAllocator.cpp: (JSC::GigacageAlignedMemoryAllocator::GigacageAlignedMemoryAllocator): (JSC::GigacageAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::freeAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::tryAllocateMemory): (JSC::GigacageAlignedMemoryAllocator::freeMemory): (JSC::GigacageAlignedMemoryAllocator::tryReallocateMemory): * heap/GigacageAlignedMemoryAllocator.h: * heap/IsoAlignedMemoryAllocator.cpp: (JSC::IsoAlignedMemoryAllocator::IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::IsoAlignedMemoryAllocator::freeAlignedMemory): (JSC::IsoAlignedMemoryAllocator::tryAllocateMemory): (JSC::IsoAlignedMemoryAllocator::freeMemory): * heap/IsoAlignedMemoryAllocator.h: * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: * heap/WeakBlock.cpp: (JSC::WeakBlock::create): (JSC::WeakBlock::destroy): * heap/WeakBlock.h: * jit/JITCode.cpp: * jit/JITCode.h: * jit/RegisterAtOffsetList.cpp: * jit/RegisterAtOffsetList.h: * parser/Nodes.cpp: * parser/Nodes.h: * parser/ParserArena.cpp: (JSC::ParserArena::deallocateObjects): (JSC::ParserArena::allocateFreeablePool): * parser/ParserArena.h: * parser/SourceProvider.cpp: * parser/SourceProvider.h: * parser/SourceProviderCache.cpp: * parser/SourceProviderCache.h: * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::create): * runtime/CachePayload.cpp: (JSC::CachePayload::makeMallocPayload): * runtime/CachePayload.h: * runtime/CachedBytecode.h: (JSC::CachedBytecode::create): * runtime/CachedTypes.cpp: (JSC::Encoder::release): (JSC::Encoder::Page::Page): (JSC::CachedVector::encode): (JSC::CachedVector::decode const): (JSC::CachedInstructionStream::decode const): * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::rehash): * runtime/PropertyTable.cpp: (JSC::PropertyTable::PropertyTable): (JSC::PropertyTable::~PropertyTable): * runtime/SymbolTable.cpp: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::~VM): * runtime/VM.h: (JSC::ScratchBuffer::create): (JSC::VM::exceptionFuzzingBuffer): * wasm/WasmInstance.cpp: (JSC::Wasm::Instance::Instance): * wasm/WasmInstance.h: * wasm/WasmTable.cpp: (JSC::Wasm::Table::Table): (JSC::Wasm::FuncRefTable::FuncRefTable): * wasm/WasmTable.h: Source/WebCore: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/SerializedScriptValue.cpp: * bindings/js/SerializedScriptValue.h: * css/CSSFontFace.cpp: * css/CSSFontFace.h: * css/CSSSelector.cpp: * css/CSSSelector.h: * css/CSSValue.cpp: * css/CSSValue.h: * css/StyleProperties.cpp: (WebCore::ImmutableStyleProperties::create): * css/StyleProperties.h: * css/StyleRule.cpp: * css/StyleRule.h: * dom/ElementData.cpp: (WebCore::ShareableElementData::createWithAttributes): (WebCore::UniqueElementData::makeShareableCopy const): * dom/ElementData.h: * dom/NodeRareData.cpp: * dom/NodeRareData.h: * dom/QualifiedName.cpp: * dom/QualifiedName.h: * html/parser/HTMLDocumentParser.cpp: * html/parser/HTMLDocumentParser.h: * loader/DocumentLoader.cpp: * loader/DocumentLoader.h: * loader/ResourceLoader.cpp: * loader/ResourceLoader.h: * loader/cache/CachedResource.cpp: * loader/cache/CachedResource.h: * page/PerformanceEntry.cpp: * page/PerformanceEntry.h: * platform/graphics/Font.cpp: * platform/graphics/Font.h: * platform/graphics/FontCascadeFonts.cpp: * platform/graphics/FontCascadeFonts.h: * platform/graphics/Region.cpp: * platform/graphics/Region.h: * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::releaseUint8Vector): * platform/graphics/cg/ImageBufferCG.cpp: (WebCore::ImageBuffer::ImageBuffer): * platform/graphics/nicosia/NicosiaBuffer.cpp: (Nicosia::Buffer::Buffer): * platform/network/ResourceHandle.cpp: * platform/network/ResourceHandleInternal.h: * platform/network/cf/FormDataStreamCFNet.cpp: (WebCore::closeCurrentStream): (WebCore::advanceCurrentStream): * rendering/RenderLayer.cpp: * rendering/RenderLayer.h: * rendering/TableLayout.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * rendering/TableLayout.h: * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: * rendering/style/SVGRenderStyle.cpp: * rendering/style/SVGRenderStyle.h: * rendering/style/SVGRenderStyleDefs.cpp: * rendering/style/SVGRenderStyleDefs.h: * rendering/style/StyleBoxData.cpp: * rendering/style/StyleBoxData.h: * rendering/style/StyleInheritedData.cpp: * rendering/style/StyleInheritedData.h: * rendering/style/StyleRareInheritedData.cpp: * rendering/style/StyleRareInheritedData.h: * rendering/style/StyleRareNonInheritedData.cpp: * rendering/style/StyleRareNonInheritedData.h: * rendering/style/StyleSurroundData.cpp: * rendering/style/StyleSurroundData.h: * rendering/style/StyleTransformData.cpp: * rendering/style/StyleTransformData.h: * style/StyleTreeResolver.cpp: * style/StyleTreeResolver.h: * svg/animation/SMILTimeContainer.cpp: * svg/animation/SMILTimeContainer.h: Source/WebKit: * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::create): (WebKit::ShareableBitmap::~ShareableBitmap): * UIProcess/mac/LegacySessionStateCoding.cpp: (WebKit::HistoryEntryDataEncoder::HistoryEntryDataEncoder): (WebKit::HistoryEntryDataEncoder::finishEncoding): (WebKit::encodeSessionHistoryEntryData): (WebKit::encodeLegacySessionState): Source/WTF: This patch introduces ENABLE(MALLOC_HEAP_BREAKDOWN). If this is enabled, we allocate malloc_zone per malloc kind. This offers the way to investigate the usage of memory per kind by using vmmap, like the following. VIRTUAL RESIDENT DIRTY SWAPPED ALLOCATION BYTES DIRTY+SWAP REGION MALLOC ZONE SIZE SIZE SIZE SIZE COUNT ALLOCATED FRAG SIZE % FRAG COUNT =========== ======= ========= ========= ========= ========= ========= ========= ====== ====== StringImpl_0x116efd000 188.0M 69.3M 30.9M 0K 139456 18.0M 12.9M 42% 34 DefaultMallocZone_0x10f487000 176.0M 53.9M 14.1M 0K 115956 9955K 4497K 32% 22 Vector_0x116eff000 162.0M 56.3M 55.3M 0K 140715 17.3M 37.9M 69% 36 MetadataTable_0x11843b000 152.0M 17.5M 17.5M 0K 14200 2353K 15.2M 87% 26 WebKit Using System Malloc_0x114cbe000 150.0M 31.6M 21.8M 0K 87422 16.7M 5278K 24% 23 InstructionStream_0x118469000 150.0M 5764K 5764K 0K 14470 4688K 1076K 19% 24 AssemblerData_0x117ee6000 150.0M 1928K 1928K 0K 1 16 1928K 100% 24 To achieve this goal without making very large change, we put a template type in various containers. For example, Vector will take Malloc parameter (the default one is FastMalloc allocator). If ENABLE(MALLOC_HEAP_BREAKDOWN) is enabled, we change this to specific VectorMalloc allocator, and vmmap can show memory usage of this allocator. This patch also supports malloc_zone per IsoHeap. So we can see memory allocation per IsoHeap in vmmap. To use this feature, we need to flip two compile time flags, ENABLE(MALLOC_HEAP_BREAKDOWN) in WTF and BENABLE_MALLOC_HEAP_BREAKDOWN in bmalloc. And use `vmmap $PID` to dump malloc zones. To allocate objects of a class with a specific malloc-zone, use WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(HeapIdentifier) for the class, and define allocator by DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HeapIdentifier) in a header and DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HeapIdentifier) in a cpp file. This patch also introduce callstack collector for malloc. Vector, HashMap etc. are used to allocate various things, but the above malloc_zone feature only tells thing like "Vector takes XXX MB memory". But what we want to know in this case is what Vector is consuming memory. We collect StackShot for each malloc call, and combine these information to tell which callsite is consuming much memory, which tell us that what Vector is consuming memory. * WTF.xcodeproj/project.pbxproj: * wtf/Bag.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): Deleted. * wtf/BitVector.cpp: (WTF::BitVector::OutOfLineBits::create): (WTF::BitVector::OutOfLineBits::destroy): * wtf/CMakeLists.txt: * wtf/ConcurrentBuffer.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * wtf/ConcurrentBuffer.h: * wtf/DebugHeap.cpp: Copied from Source/JavaScriptCore/runtime/CachePayload.cpp. (WTF::DebugHeap::DebugHeap): (WTF::DebugHeap::malloc): (WTF::DebugHeap::calloc): (WTF::DebugHeap::memalign): (WTF::DebugHeap::realloc): (WTF::DebugHeap::free): * wtf/DebugHeap.h: Added. * wtf/FastBitVector.cpp: (WTF::FastBitVectorWordOwner::setEqualsSlow): (WTF::FastBitVectorWordOwner::resizeSlow): * wtf/FastBitVector.h: (WTF::FastBitVectorWordOwner::~FastBitVectorWordOwner): * wtf/FastMalloc.cpp: (WTF::fastMallocDumpMallocStats): (WTF::AvoidRecordingScope::AvoidRecordingScope): (WTF::AvoidRecordingScope::~AvoidRecordingScope): (WTF::MallocCallTracker::MallocSiteData::MallocSiteData): (WTF::MallocCallTracker::singleton): (WTF::MallocCallTracker::MallocCallTracker): (WTF::MallocCallTracker::recordMalloc): (WTF::MallocCallTracker::recordRealloc): (WTF::MallocCallTracker::recordFree): (WTF::MallocCallTracker::dumpStats): (WTF::fastMalloc): (WTF::fastRealloc): (WTF::fastFree): (WTF::fastAlignedMalloc): (WTF::tryFastAlignedMalloc): (WTF::fastAlignedFree): * wtf/FastMalloc.h: (WTF::FastMalloc::zeroedMalloc): (WTF::FastMalloc::tryZeroedMalloc): * wtf/Forward.h: * wtf/HashTable.cpp: * wtf/HashTable.h: (WTF::KeyTraits>::allocateTable): (WTF::KeyTraits>::deallocateTable): (WTF::KeyTraits>::rehash): * wtf/MallocPtr.h: (WTF::MallocPtr::MallocPtr): (WTF::MallocPtr::malloc): (WTF::MallocPtr::zeroedMalloc): (WTF::MallocPtr::tryMalloc): (WTF::MallocPtr::tryZeroedMalloc): (WTF::adoptMallocPtr): * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::allocFreeSpaceNode): (WTF::MetaAllocator::freeFreeSpaceNode): * wtf/MetaAllocatorHandle.h: * wtf/Platform.h: * wtf/RefCountedArray.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::assign): * wtf/SegmentedVector.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/SegmentedVector.h: * wtf/SmallPtrSet.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/SmallPtrSet.h: (WTF::SmallPtrSet::~SmallPtrSet): (WTF::SmallPtrSet::grow): * wtf/UniqueArray.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/UniqueArray.h: (WTF::UniqueArrayFree::operator() const): (WTF::UniqueArrayFree<T::operator() const): * wtf/Vector.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/Vector.h: (WTF::VectorBufferBase::allocateBuffer): (WTF::VectorBufferBase::tryAllocateBuffer): (WTF::VectorBufferBase::reallocateBuffer): (WTF::VectorBufferBase::deallocateBuffer): (WTF::VectorBufferBase::releaseBuffer): (WTF::VectorBuffer::releaseBuffer): (WTF::Vector::swap): (WTF::Malloc>::Vector): (WTF::=): (WTF::Malloc>::contains const): (WTF::Malloc>::findMatching const): (WTF::Malloc>::find const): (WTF::Malloc>::reverseFind const): (WTF::Malloc>::appendIfNotContains): (WTF::Malloc>::fill): (WTF::Malloc>::appendRange): (WTF::Malloc>::expandCapacity): (WTF::Malloc>::tryExpandCapacity): (WTF::Malloc>::resize): (WTF::Malloc>::resizeToFit): (WTF::Malloc>::shrink): (WTF::Malloc>::grow): (WTF::Malloc>::asanSetInitialBufferSizeTo): (WTF::Malloc>::asanSetBufferSizeToFullCapacity): (WTF::Malloc>::asanBufferSizeWillChangeTo): (WTF::Malloc>::reserveCapacity): (WTF::Malloc>::tryReserveCapacity): (WTF::Malloc>::reserveInitialCapacity): (WTF::Malloc>::shrinkCapacity): (WTF::Malloc>::append): (WTF::Malloc>::tryAppend): (WTF::Malloc>::constructAndAppend): (WTF::Malloc>::tryConstructAndAppend): (WTF::Malloc>::appendSlowCase): (WTF::Malloc>::constructAndAppendSlowCase): (WTF::Malloc>::tryConstructAndAppendSlowCase): (WTF::Malloc>::uncheckedAppend): (WTF::Malloc>::uncheckedConstructAndAppend): (WTF::Malloc>::appendVector): (WTF::Malloc>::insert): (WTF::Malloc>::insertVector): (WTF::Malloc>::remove): (WTF::Malloc>::removeFirst): (WTF::Malloc>::removeFirstMatching): (WTF::Malloc>::removeAll): (WTF::Malloc>::removeAllMatching): (WTF::Malloc>::reverse): (WTF::Malloc>::map const): (WTF::Malloc>::releaseBuffer): (WTF::Malloc>::checkConsistency): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::Malloc>::isolatedCopy const): (WTF::removeRepeatedElements): (WTF::minCapacity>::Vector): Deleted. (WTF::minCapacity>::contains const): Deleted. (WTF::minCapacity>::findMatching const): Deleted. (WTF::minCapacity>::find const): Deleted. (WTF::minCapacity>::reverseFind const): Deleted. (WTF::minCapacity>::appendIfNotContains): Deleted. (WTF::minCapacity>::fill): Deleted. (WTF::minCapacity>::appendRange): Deleted. (WTF::minCapacity>::expandCapacity): Deleted. (WTF::minCapacity>::tryExpandCapacity): Deleted. (WTF::minCapacity>::resize): Deleted. (WTF::minCapacity>::resizeToFit): Deleted. (WTF::minCapacity>::shrink): Deleted. (WTF::minCapacity>::grow): Deleted. (WTF::minCapacity>::asanSetInitialBufferSizeTo): Deleted. (WTF::minCapacity>::asanSetBufferSizeToFullCapacity): Deleted. (WTF::minCapacity>::asanBufferSizeWillChangeTo): Deleted. (WTF::minCapacity>::reserveCapacity): Deleted. (WTF::minCapacity>::tryReserveCapacity): Deleted. (WTF::minCapacity>::reserveInitialCapacity): Deleted. (WTF::minCapacity>::shrinkCapacity): Deleted. (WTF::minCapacity>::append): Deleted. (WTF::minCapacity>::tryAppend): Deleted. (WTF::minCapacity>::constructAndAppend): Deleted. (WTF::minCapacity>::tryConstructAndAppend): Deleted. (WTF::minCapacity>::appendSlowCase): Deleted. (WTF::minCapacity>::constructAndAppendSlowCase): Deleted. (WTF::minCapacity>::tryConstructAndAppendSlowCase): Deleted. (WTF::minCapacity>::uncheckedAppend): Deleted. (WTF::minCapacity>::uncheckedConstructAndAppend): Deleted. (WTF::minCapacity>::appendVector): Deleted. (WTF::minCapacity>::insert): Deleted. (WTF::minCapacity>::insertVector): Deleted. (WTF::minCapacity>::remove): Deleted. (WTF::minCapacity>::removeFirst): Deleted. (WTF::minCapacity>::removeFirstMatching): Deleted. (WTF::minCapacity>::removeAll): Deleted. (WTF::minCapacity>::removeAllMatching): Deleted. (WTF::minCapacity>::reverse): Deleted. (WTF::minCapacity>::map const): Deleted. (WTF::minCapacity>::releaseBuffer): Deleted. (WTF::minCapacity>::checkConsistency): Deleted. (WTF::minCapacity>::isolatedCopy const): Deleted. * wtf/text/CString.cpp: (WTF::CStringBuffer::createUninitialized): * wtf/text/CString.h: * wtf/text/StringBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/text/StringBuffer.h: (WTF::StringBuffer::StringBuffer): (WTF::StringBuffer::~StringBuffer): (WTF::StringBuffer::resize): (WTF::StringBuffer::release): * wtf/text/StringImpl.cpp: (WTF::StringImpl::~StringImpl): (WTF::StringImpl::destroy): (WTF::StringImpl::createUninitializedInternalNonEmpty): (WTF::StringImpl::reallocateInternal): * wtf/text/StringImpl.h: (WTF::StringImpl::StringImpl): (WTF::StringImpl::createSubstringSharingImpl): (WTF::StringImpl::tryCreateUninitialized): (WTF::StringImpl::adopt): * wtf/text/cf/StringImplCF.cpp: (WTF::StringWrapperCFAllocator::allocate): (WTF::StringWrapperCFAllocator::reallocate): (WTF::StringWrapperCFAllocator::deallocate): Canonical link: https://commits.webkit.org/218863@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-03 02:36:43 +00:00
RefCountedArrayMalloc::free(Header::fromPayload(data));
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
unsigned refCount() const
{
if (!m_data)
return 0;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
return Header::fromPayload(data())->refCount;
}
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
size_t size() const
{
if (!m_data)
return 0;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
return Header::fromPayload(data())->length;
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. Source/JavaScriptCore: While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase<Traits>::newRegister): (JSC::BytecodeGeneratorBase<Traits>::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): Source/WTF: Add more useful methods for RefCountedArray. * wtf/RefCountedArray.h: (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::isEmpty const): (WTF::RefCountedArray::front): (WTF::RefCountedArray::front const): (WTF::RefCountedArray::last): (WTF::RefCountedArray::last const): Canonical link: https://commits.webkit.org/220203@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-04 19:05:17 +00:00
bool isEmpty() const { return size() == 0; }
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
size_t byteSize() const { return size() * sizeof(T); }
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
T* data() { return PtrTraits::unwrap(m_data); }
[JSC] Shrink some of Vectors in JSC https://bugs.webkit.org/show_bug.cgi?id=224162 Reviewed by Simon Fraser. Source/JavaScriptCore: 1. Add XXXStatus::shrinkToFit to shrink underlying dynamic Vectors. 2. Replace tierUpInLoopHierarchy's Vector with RefCountedArray since it is constructed-once-lookup-only data. 3. Use MemoryCompactLookupOnlyRobinHoodHashSet for StringTables since this is constructed-once-lookup-only data. We also add MemoryCompactLookupOnlyRobinHoodHashSet support for CachedTypes. 4. Use resizeToFit for StringSwitchJumpTables and SwitchJumpTables. 5. JITStubRoutineSet's Vector should be shrunk. 6. BlockDirectoryBits's Vector's initial size should be small. 7. Make PolyProtoAccessChain RefCounted, and use RefCountedArray for its Vector<StructureID>. And remove PolyProtoAccessChain::clone. Just having Ref is enough since this is immutable data. 8. Use RefCountedArray for UnlinkedFunctionExecutable's m_classFieldLocations. 9. Use RefCountedArray for JSWebAssemblyInstance. * bytecode/AccessCase.cpp: (JSC::AccessCase::AccessCase): (JSC::AccessCase::create): (JSC::AccessCase::createTransition): * bytecode/AccessCase.h: (JSC::AccessCase::AccessCase): Deleted. * bytecode/CallLinkInfo.cpp: (JSC::CallLinkInfo::setFrameShuffleData): * bytecode/CheckPrivateBrandStatus.cpp: (JSC::CheckPrivateBrandStatus::shrinkToFit): (JSC::CheckPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::CheckPrivateBrandStatus::merge): * bytecode/CheckPrivateBrandStatus.h: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/DeleteByStatus.cpp: (JSC::DeleteByStatus::shrinkToFit): (JSC::DeleteByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::DeleteByStatus::merge): * bytecode/DeleteByStatus.h: * bytecode/GetByStatus.cpp: (JSC::GetByStatus::shrinkToFit): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::computeFor): (JSC::GetByStatus::merge): * bytecode/GetByStatus.h: * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::GetterSetterAccessCase): (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * bytecode/InByIdStatus.cpp: (JSC::InByIdStatus::shrinkToFit): (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::InByIdStatus::merge): * bytecode/InByIdStatus.h: * bytecode/InstanceOfStatus.cpp: (JSC::InstanceOfStatus::shrinkToFit): (JSC::InstanceOfStatus::computeForStubInfo): * bytecode/InstanceOfStatus.h: * bytecode/IntrinsicGetterAccessCase.cpp: (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase): (JSC::IntrinsicGetterAccessCase::create): * bytecode/IntrinsicGetterAccessCase.h: * bytecode/JumpTable.h: * bytecode/PolyProtoAccessChain.cpp: (JSC::PolyProtoAccessChain::tryCreate): (JSC::PolyProtoAccessChain::create): Deleted. * bytecode/PolyProtoAccessChain.h: (JSC::PolyProtoAccessChain::clone): Deleted. (JSC::PolyProtoAccessChain::chain const): Deleted. (JSC::PolyProtoAccessChain::operator!= const): Deleted. (JSC::PolyProtoAccessChain::forEach const): Deleted. (JSC::PolyProtoAccessChain::slotBaseStructure const): Deleted. * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::visitWeak const): (JSC::PolymorphicAccess::regenerate): * bytecode/PolymorphicAccess.h: * bytecode/ProxyableAccessCase.cpp: (JSC::ProxyableAccessCase::ProxyableAccessCase): (JSC::ProxyableAccessCase::create): * bytecode/ProxyableAccessCase.h: * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::shrinkToFit): (JSC::PutByIdStatus::computeForStubInfo): (JSC::PutByIdStatus::computeFor): (JSC::PutByIdStatus::merge): * bytecode/PutByIdStatus.h: * bytecode/SetPrivateBrandStatus.cpp: (JSC::SetPrivateBrandStatus::shrinkToFit): (JSC::SetPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::SetPrivateBrandStatus::merge): * bytecode/SetPrivateBrandStatus.h: * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecode/UnlinkedFunctionExecutable.h: * dfg/DFGJITCode.h: * dfg/DFGPlan.h: (JSC::DFG::Plan::tierUpInLoopHierarchy): * dfg/DFGTierUpCheckInjectionPhase.cpp: (JSC::DFG::TierUpCheckInjectionPhase::run): * heap/BlockDirectoryBits.h: * heap/JITStubRoutineSet.cpp: (JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines): * jit/CallFrameShuffleData.h: (JSC::CallFrameShuffleData::shrinkToFit): * jit/GCAwareJITStubRoutine.h: * jit/PolymorphicCallStubRoutine.h: * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::tryCachePutByID): (JSC::tryCacheInByID): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements): * parser/Parser.h: (JSC::Parser<LexerType>::parse): (JSC::parse): * runtime/CachedTypes.cpp: (JSC::CachedFunctionExecutableRareData::encode): (JSC::CachedFunctionExecutableRareData::decode const): * runtime/VM.cpp: (JSC::VM::popAllCheckpointOSRSideStateUntil): * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::visitChildrenImpl): * wasm/js/JSWebAssemblyInstance.h: Source/WTF: Add rbegin and rend to make RefCountedArray usable for Vector clients who use these features. * wtf/RefCountedArray.h: (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::end const): (WTF::RefCountedArray::rbegin): (WTF::RefCountedArray::rend): (WTF::RefCountedArray::rbegin const): (WTF::RefCountedArray::rend const): Canonical link: https://commits.webkit.org/236147@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-06 04:25:33 +00:00
iterator begin() { return data(); }
iterator end()
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
{
if (!m_data)
return 0;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
T* data = this->data();
return data + Header::fromPayload(data)->length;
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
const T* data() const { return const_cast<RefCountedArray*>(this)->data(); }
[JSC] Shrink some of Vectors in JSC https://bugs.webkit.org/show_bug.cgi?id=224162 Reviewed by Simon Fraser. Source/JavaScriptCore: 1. Add XXXStatus::shrinkToFit to shrink underlying dynamic Vectors. 2. Replace tierUpInLoopHierarchy's Vector with RefCountedArray since it is constructed-once-lookup-only data. 3. Use MemoryCompactLookupOnlyRobinHoodHashSet for StringTables since this is constructed-once-lookup-only data. We also add MemoryCompactLookupOnlyRobinHoodHashSet support for CachedTypes. 4. Use resizeToFit for StringSwitchJumpTables and SwitchJumpTables. 5. JITStubRoutineSet's Vector should be shrunk. 6. BlockDirectoryBits's Vector's initial size should be small. 7. Make PolyProtoAccessChain RefCounted, and use RefCountedArray for its Vector<StructureID>. And remove PolyProtoAccessChain::clone. Just having Ref is enough since this is immutable data. 8. Use RefCountedArray for UnlinkedFunctionExecutable's m_classFieldLocations. 9. Use RefCountedArray for JSWebAssemblyInstance. * bytecode/AccessCase.cpp: (JSC::AccessCase::AccessCase): (JSC::AccessCase::create): (JSC::AccessCase::createTransition): * bytecode/AccessCase.h: (JSC::AccessCase::AccessCase): Deleted. * bytecode/CallLinkInfo.cpp: (JSC::CallLinkInfo::setFrameShuffleData): * bytecode/CheckPrivateBrandStatus.cpp: (JSC::CheckPrivateBrandStatus::shrinkToFit): (JSC::CheckPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::CheckPrivateBrandStatus::merge): * bytecode/CheckPrivateBrandStatus.h: * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/DeleteByStatus.cpp: (JSC::DeleteByStatus::shrinkToFit): (JSC::DeleteByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::DeleteByStatus::merge): * bytecode/DeleteByStatus.h: * bytecode/GetByStatus.cpp: (JSC::GetByStatus::shrinkToFit): (JSC::GetByStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::GetByStatus::computeFor): (JSC::GetByStatus::merge): * bytecode/GetByStatus.h: * bytecode/GetterSetterAccessCase.cpp: (JSC::GetterSetterAccessCase::GetterSetterAccessCase): (JSC::GetterSetterAccessCase::create): * bytecode/GetterSetterAccessCase.h: * bytecode/InByIdStatus.cpp: (JSC::InByIdStatus::shrinkToFit): (JSC::InByIdStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::InByIdStatus::merge): * bytecode/InByIdStatus.h: * bytecode/InstanceOfStatus.cpp: (JSC::InstanceOfStatus::shrinkToFit): (JSC::InstanceOfStatus::computeForStubInfo): * bytecode/InstanceOfStatus.h: * bytecode/IntrinsicGetterAccessCase.cpp: (JSC::IntrinsicGetterAccessCase::IntrinsicGetterAccessCase): (JSC::IntrinsicGetterAccessCase::create): * bytecode/IntrinsicGetterAccessCase.h: * bytecode/JumpTable.h: * bytecode/PolyProtoAccessChain.cpp: (JSC::PolyProtoAccessChain::tryCreate): (JSC::PolyProtoAccessChain::create): Deleted. * bytecode/PolyProtoAccessChain.h: (JSC::PolyProtoAccessChain::clone): Deleted. (JSC::PolyProtoAccessChain::chain const): Deleted. (JSC::PolyProtoAccessChain::operator!= const): Deleted. (JSC::PolyProtoAccessChain::forEach const): Deleted. (JSC::PolyProtoAccessChain::slotBaseStructure const): Deleted. * bytecode/PolymorphicAccess.cpp: (JSC::PolymorphicAccess::visitWeak const): (JSC::PolymorphicAccess::regenerate): * bytecode/PolymorphicAccess.h: * bytecode/ProxyableAccessCase.cpp: (JSC::ProxyableAccessCase::ProxyableAccessCase): (JSC::ProxyableAccessCase::create): * bytecode/ProxyableAccessCase.h: * bytecode/PutByIdStatus.cpp: (JSC::PutByIdStatus::shrinkToFit): (JSC::PutByIdStatus::computeForStubInfo): (JSC::PutByIdStatus::computeFor): (JSC::PutByIdStatus::merge): * bytecode/PutByIdStatus.h: * bytecode/SetPrivateBrandStatus.cpp: (JSC::SetPrivateBrandStatus::shrinkToFit): (JSC::SetPrivateBrandStatus::computeForStubInfoWithoutExitSiteFeedback): (JSC::SetPrivateBrandStatus::merge): * bytecode/SetPrivateBrandStatus.h: * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * bytecode/UnlinkedFunctionExecutable.h: * dfg/DFGJITCode.h: * dfg/DFGPlan.h: (JSC::DFG::Plan::tierUpInLoopHierarchy): * dfg/DFGTierUpCheckInjectionPhase.cpp: (JSC::DFG::TierUpCheckInjectionPhase::run): * heap/BlockDirectoryBits.h: * heap/JITStubRoutineSet.cpp: (JSC::JITStubRoutineSet::deleteUnmarkedJettisonedStubRoutines): * jit/CallFrameShuffleData.h: (JSC::CallFrameShuffleData::shrinkToFit): * jit/GCAwareJITStubRoutine.h: * jit/PolymorphicCallStubRoutine.h: * jit/Repatch.cpp: (JSC::tryCacheGetBy): (JSC::tryCachePutByID): (JSC::tryCacheInByID): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseClassFieldInitializerSourceElements): * parser/Parser.h: (JSC::Parser<LexerType>::parse): (JSC::parse): * runtime/CachedTypes.cpp: (JSC::CachedFunctionExecutableRareData::encode): (JSC::CachedFunctionExecutableRareData::decode const): * runtime/VM.cpp: (JSC::VM::popAllCheckpointOSRSideStateUntil): * wasm/js/JSWebAssemblyInstance.cpp: (JSC::JSWebAssemblyInstance::visitChildrenImpl): * wasm/js/JSWebAssemblyInstance.h: Source/WTF: Add rbegin and rend to make RefCountedArray usable for Vector clients who use these features. * wtf/RefCountedArray.h: (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::end const): (WTF::RefCountedArray::rbegin): (WTF::RefCountedArray::rend): (WTF::RefCountedArray::rbegin const): (WTF::RefCountedArray::rend const): Canonical link: https://commits.webkit.org/236147@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-06 04:25:33 +00:00
const_iterator begin() const { return const_cast<RefCountedArray*>(this)->begin(); }
const_iterator end() const { return const_cast<RefCountedArray*>(this)->end(); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
T& at(size_t i)
{
Add ASSERT_WITH_SECURITY_IMPLICATION to detect out of bounds access https://bugs.webkit.org/show_bug.cgi?id=108668 Reviewed by Eric Seidel. Source/WebCore: * bindings/v8/SerializedScriptValue.cpp: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcExpressionNodeParser::parseCalc): * css/CSSImageSetValue.cpp: (WebCore::CSSImageSetValue::fillImageSet): (WebCore::CSSImageSetValue::customCssText): * css/CSSParserValues.h: (WebCore::CSSParserString::operator[]): * css/CSSValueList.h: (WebCore::CSSValueListInspector::item): * css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::ruleAt): (WebCore::StyleSheetContents::wrapperInsertRule): (WebCore::StyleSheetContents::wrapperDeleteRule): * dom/Document.cpp: (WebCore::Document::processArguments): * dom/Element.cpp: (WebCore::Element::removeAttributeInternal): * dom/ElementAttributeData.cpp: (WebCore::ElementAttributeData::removeAttribute): * dom/ElementAttributeData.h: (WebCore::ElementAttributeData::attributeItem): * dom/SpaceSplitString.h: (WebCore::SpaceSplitStringData::operator[]): (WebCore::SpaceSplitString::operator[]): * editing/TextIterator.cpp: (WebCore::TextIterator::characterAt): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::removeFormElement): * html/HTMLSelectElementWin.cpp: (WebCore::HTMLSelectElement::platformHandleKeydownEvent): * html/canvas/WebGLRenderingContext.cpp: (WebCore): * html/parser/HTMLFormattingElementList.cpp: (WebCore::HTMLFormattingElementList::swapTo): * inspector/InspectorStyleSheet.cpp: (WebCore::InspectorStyleSheet::styleSheetTextWithChangedStyle): * inspector/InspectorStyleTextEditor.cpp: (WebCore::InspectorStyleTextEditor::replaceProperty): * inspector/InspectorValues.cpp: (WebCore::InspectorArrayBase::get): * page/WindowFeatures.cpp: (WebCore::WindowFeatures::WindowFeatures): * platform/audio/AudioArray.h: (WebCore::AudioArray::at): * platform/audio/AudioFIFO.cpp: (WebCore::AudioFIFO::findWrapLengths): * platform/graphics/GlyphPage.h: (WebCore::GlyphPage::glyphDataForIndex): (WebCore::GlyphPage::glyphAt): (WebCore::GlyphPage::setGlyphDataForIndex): * platform/graphics/TextRun.h: (WebCore::TextRun::operator[]): (WebCore::TextRun::data8): (WebCore::TextRun::data16): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: (WebCore::HarfBuzzShaper::setDrawRange): * platform/graphics/openvg/TiledImageOpenVG.cpp: (WebCore::TiledImageOpenVG::setTile): (WebCore::TiledImageOpenVG::tile): * platform/image-decoders/ico/ICOImageDecoder.cpp: (WebCore::ICOImageDecoder::decodeAtIndex): (WebCore::ICOImageDecoder::imageTypeAtIndex): * platform/text/QuotedPrintable.cpp: (WebCore::lengthOfLineEndingAtIndex): * platform/text/SegmentedString.cpp: (WebCore::SegmentedString::advance): * platform/win/WebCoreTextRenderer.cpp: (WebCore::doDrawTextAtPoint): * rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::paint): (WebCore::InlineTextBox::paintSelection): Source/WebKit/chromium: * src/ContextFeaturesClientImpl.cpp: (WebKit::ContextFeaturesCache::entryFor): * src/WebFrameImpl.cpp: (WebKit::WebFrameImpl::selectFindMatch): Source/WebKit2: * Shared/mac/SandboxExtensionMac.mm: (WebKit::SandboxExtension::HandleArray::operator[]): Source/WTF: * wtf/AVLTree.h: (WTF::AVLTreeDefaultBSet::operator[]): * wtf/BitArray.h: (WTF::BitArray::set): (WTF::BitArray::get): * wtf/FastBitVector.h: (WTF::FastBitVector::set): (WTF::FastBitVector::clear): (WTF::FastBitVector::get): * wtf/FixedArray.h: (WTF::FixedArray::operator[]): * wtf/RefCountedArray.h: (WTF::RefCountedArray::at): * wtf/TypedArrayBase.h: (WTF::TypedArrayBase::item): * wtf/text/StringBuffer.h: (WTF::StringBuffer::operator[]): * wtf/text/StringBuilder.h: (WTF::StringBuilder::operator[]): * wtf/text/StringImpl.h: (WTF::StringImpl::operator[]): Canonical link: https://commits.webkit.org/127075@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141816 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-02-04 22:36:56 +00:00
ASSERT_WITH_SECURITY_IMPLICATION(i < size());
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
return begin()[i];
}
const T& at(size_t i) const
{
Add ASSERT_WITH_SECURITY_IMPLICATION to detect out of bounds access https://bugs.webkit.org/show_bug.cgi?id=108668 Reviewed by Eric Seidel. Source/WebCore: * bindings/v8/SerializedScriptValue.cpp: * css/CSSCalculationValue.cpp: (WebCore::CSSCalcExpressionNodeParser::parseCalc): * css/CSSImageSetValue.cpp: (WebCore::CSSImageSetValue::fillImageSet): (WebCore::CSSImageSetValue::customCssText): * css/CSSParserValues.h: (WebCore::CSSParserString::operator[]): * css/CSSValueList.h: (WebCore::CSSValueListInspector::item): * css/StyleSheetContents.cpp: (WebCore::StyleSheetContents::ruleAt): (WebCore::StyleSheetContents::wrapperInsertRule): (WebCore::StyleSheetContents::wrapperDeleteRule): * dom/Document.cpp: (WebCore::Document::processArguments): * dom/Element.cpp: (WebCore::Element::removeAttributeInternal): * dom/ElementAttributeData.cpp: (WebCore::ElementAttributeData::removeAttribute): * dom/ElementAttributeData.h: (WebCore::ElementAttributeData::attributeItem): * dom/SpaceSplitString.h: (WebCore::SpaceSplitStringData::operator[]): (WebCore::SpaceSplitString::operator[]): * editing/TextIterator.cpp: (WebCore::TextIterator::characterAt): * html/HTMLFormElement.cpp: (WebCore::HTMLFormElement::removeFormElement): * html/HTMLSelectElementWin.cpp: (WebCore::HTMLSelectElement::platformHandleKeydownEvent): * html/canvas/WebGLRenderingContext.cpp: (WebCore): * html/parser/HTMLFormattingElementList.cpp: (WebCore::HTMLFormattingElementList::swapTo): * inspector/InspectorStyleSheet.cpp: (WebCore::InspectorStyleSheet::styleSheetTextWithChangedStyle): * inspector/InspectorStyleTextEditor.cpp: (WebCore::InspectorStyleTextEditor::replaceProperty): * inspector/InspectorValues.cpp: (WebCore::InspectorArrayBase::get): * page/WindowFeatures.cpp: (WebCore::WindowFeatures::WindowFeatures): * platform/audio/AudioArray.h: (WebCore::AudioArray::at): * platform/audio/AudioFIFO.cpp: (WebCore::AudioFIFO::findWrapLengths): * platform/graphics/GlyphPage.h: (WebCore::GlyphPage::glyphDataForIndex): (WebCore::GlyphPage::glyphAt): (WebCore::GlyphPage::setGlyphDataForIndex): * platform/graphics/TextRun.h: (WebCore::TextRun::operator[]): (WebCore::TextRun::data8): (WebCore::TextRun::data16): * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: (WebCore::HarfBuzzShaper::setDrawRange): * platform/graphics/openvg/TiledImageOpenVG.cpp: (WebCore::TiledImageOpenVG::setTile): (WebCore::TiledImageOpenVG::tile): * platform/image-decoders/ico/ICOImageDecoder.cpp: (WebCore::ICOImageDecoder::decodeAtIndex): (WebCore::ICOImageDecoder::imageTypeAtIndex): * platform/text/QuotedPrintable.cpp: (WebCore::lengthOfLineEndingAtIndex): * platform/text/SegmentedString.cpp: (WebCore::SegmentedString::advance): * platform/win/WebCoreTextRenderer.cpp: (WebCore::doDrawTextAtPoint): * rendering/InlineTextBox.cpp: (WebCore::InlineTextBox::paint): (WebCore::InlineTextBox::paintSelection): Source/WebKit/chromium: * src/ContextFeaturesClientImpl.cpp: (WebKit::ContextFeaturesCache::entryFor): * src/WebFrameImpl.cpp: (WebKit::WebFrameImpl::selectFindMatch): Source/WebKit2: * Shared/mac/SandboxExtensionMac.mm: (WebKit::SandboxExtension::HandleArray::operator[]): Source/WTF: * wtf/AVLTree.h: (WTF::AVLTreeDefaultBSet::operator[]): * wtf/BitArray.h: (WTF::BitArray::set): (WTF::BitArray::get): * wtf/FastBitVector.h: (WTF::FastBitVector::set): (WTF::FastBitVector::clear): (WTF::FastBitVector::get): * wtf/FixedArray.h: (WTF::FixedArray::operator[]): * wtf/RefCountedArray.h: (WTF::RefCountedArray::at): * wtf/TypedArrayBase.h: (WTF::TypedArrayBase::item): * wtf/text/StringBuffer.h: (WTF::StringBuffer::operator[]): * wtf/text/StringBuilder.h: (WTF::StringBuilder::operator[]): * wtf/text/StringImpl.h: (WTF::StringImpl::operator[]): Canonical link: https://commits.webkit.org/127075@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141816 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2013-02-04 22:36:56 +00:00
ASSERT_WITH_SECURITY_IMPLICATION(i < size());
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
return begin()[i];
}
T& operator[](size_t i) { return at(i); }
const T& operator[](size_t i) const { return at(i); }
[JSC] Introduce UnlinkedCodeBlockGenerator and reduce sizeof(UnlinkedCodeBlock) https://bugs.webkit.org/show_bug.cgi?id=207087 Reviewed by Tadeu Zagallo. Source/JavaScriptCore: While UnlinkedCodeBlock is immutable once it is created from BytecodeGenerator, it has many mutable Vectors. This is because we are using UnlinkedCodeBlock as a builder of UnlinkedCodeBlock itself too in BytecodeGenerator. Since Vector takes 16 bytes to allow efficient expansions, it is nice if we can use RefCountedArray instead when we know this Vector is immutable. In this patch, we introduce UnlinkedCodeBlockGenerator wrapper. BytecodeGenerator, BytecodeRewriter, BytecodeDumper, and BytecodeGeneratorification interact with UnlinkedCodeBlockGenerator instead of UnlinkedCodeBlock. And UnlinkedCodeBlockGenerator will generate the finalized UnlinkedCodeBlock. This design allows us to use RefCountedArray for data in UnlinkedCodeBlock, which is (1) smaller and (2) doing shrinkToFit operation when creating it from Vector. This patch reduces sizeof(UnlinkedCodeBlock) from 256 to 168, 88 bytes reduction. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/BytecodeBasicBlock.cpp: (JSC::BytecodeBasicBlock::compute): * bytecode/BytecodeBasicBlock.h: * bytecode/BytecodeDumper.cpp: * bytecode/BytecodeGeneratorification.cpp: (JSC::BytecodeGeneratorification::BytecodeGeneratorification): (JSC::GeneratorLivenessAnalysis::run): (JSC::BytecodeGeneratorification::run): (JSC::performGeneratorification): * bytecode/BytecodeGeneratorification.h: * bytecode/BytecodeRewriter.h: (JSC::BytecodeRewriter::BytecodeRewriter): * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::setConstantIdentifierSetRegisters): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::handlerForIndex): (JSC::CodeBlock::insertBasicBlockBoundariesForControlFlowProfiler): * bytecode/CodeBlock.h: (JSC::CodeBlock::numberOfSwitchJumpTables const): (JSC::CodeBlock::numberOfStringSwitchJumpTables const): (JSC::CodeBlock::addSwitchJumpTable): Deleted. (JSC::CodeBlock::addStringSwitchJumpTable): Deleted. * bytecode/HandlerInfo.h: (JSC::HandlerInfoBase::handlerForIndex): * bytecode/JumpTable.h: (JSC::SimpleJumpTable::add): Deleted. * bytecode/PreciseJumpTargets.cpp: (JSC::computePreciseJumpTargets): (JSC::recomputePreciseJumpTargets): (JSC::findJumpTargetsForInstruction): * bytecode/PreciseJumpTargets.h: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): (JSC::UnlinkedCodeBlock::visitChildren): (JSC::UnlinkedCodeBlock::dumpExpressionRangeInfo): (JSC::UnlinkedCodeBlock::expressionRangeForBytecodeIndex const): (JSC::UnlinkedCodeBlock::handlerForIndex): (JSC::UnlinkedCodeBlock::addExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::addTypeProfilerExpressionInfo): Deleted. (JSC::UnlinkedCodeBlock::setInstructions): Deleted. (JSC::UnlinkedCodeBlock::applyModification): Deleted. (JSC::UnlinkedCodeBlock::shrinkToFit): Deleted. (JSC::UnlinkedCodeBlock::addOutOfLineJumpTarget): Deleted. * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::expressionInfo): (JSC::UnlinkedCodeBlock::setNumParameters): (JSC::UnlinkedCodeBlock::numberOfIdentifiers const): (JSC::UnlinkedCodeBlock::identifiers const): (JSC::UnlinkedCodeBlock::bitVector): (JSC::UnlinkedCodeBlock::constantRegisters): (JSC::UnlinkedCodeBlock::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlock::constantIdentifierSets): (JSC::UnlinkedCodeBlock::numberOfJumpTargets const): (JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlock::numberOfFunctionDecls): (JSC::UnlinkedCodeBlock::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlock::opProfileControlFlowBytecodeOffsets const): (JSC::UnlinkedCodeBlock::createRareDataIfNecessary): (JSC::UnlinkedCodeBlock::addParameter): Deleted. (JSC::UnlinkedCodeBlock::addIdentifier): Deleted. (JSC::UnlinkedCodeBlock::addBitVector): Deleted. (JSC::UnlinkedCodeBlock::addSetConstant): Deleted. (JSC::UnlinkedCodeBlock::addConstant): Deleted. (JSC::UnlinkedCodeBlock::addJumpTarget): Deleted. (JSC::UnlinkedCodeBlock::addSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addStringSwitchJumpTable): Deleted. (JSC::UnlinkedCodeBlock::addFunctionDecl): Deleted. (JSC::UnlinkedCodeBlock::addFunctionExpr): Deleted. (JSC::UnlinkedCodeBlock::addExceptionHandler): Deleted. (JSC::UnlinkedCodeBlock::addOpProfileControlFlowBytecodeOffset): Deleted. (JSC::UnlinkedCodeBlock::replaceOutOfLineJumpTargets): Deleted. * bytecode/UnlinkedCodeBlockGenerator.cpp: Added. (JSC::UnlinkedCodeBlockGenerator::getLineAndColumn const): (JSC::UnlinkedCodeBlockGenerator::addExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::addTypeProfilerExpressionInfo): (JSC::UnlinkedCodeBlockGenerator::finalize): (JSC::UnlinkedCodeBlockGenerator::handlerForBytecodeIndex): (JSC::UnlinkedCodeBlockGenerator::handlerForIndex): (JSC::UnlinkedCodeBlockGenerator::applyModification): (JSC::UnlinkedCodeBlockGenerator::addOutOfLineJumpTarget): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::dump const): * bytecode/UnlinkedCodeBlockGenerator.h: Added. (JSC::UnlinkedCodeBlockGenerator::UnlinkedCodeBlockGenerator): (JSC::UnlinkedCodeBlockGenerator::vm): (JSC::UnlinkedCodeBlockGenerator::isConstructor const): (JSC::UnlinkedCodeBlockGenerator::constructorKind const): (JSC::UnlinkedCodeBlockGenerator::superBinding const): (JSC::UnlinkedCodeBlockGenerator::scriptMode const): (JSC::UnlinkedCodeBlockGenerator::needsClassFieldInitializer const): (JSC::UnlinkedCodeBlockGenerator::isStrictMode const): (JSC::UnlinkedCodeBlockGenerator::usesEval const): (JSC::UnlinkedCodeBlockGenerator::parseMode const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunction): (JSC::UnlinkedCodeBlockGenerator::derivedContextType const): (JSC::UnlinkedCodeBlockGenerator::evalContextType const): (JSC::UnlinkedCodeBlockGenerator::isArrowFunctionContext const): (JSC::UnlinkedCodeBlockGenerator::isClassContext const): (JSC::UnlinkedCodeBlockGenerator::numCalleeLocals const): (JSC::UnlinkedCodeBlockGenerator::numVars const): (JSC::UnlinkedCodeBlockGenerator::numParameters const): (JSC::UnlinkedCodeBlockGenerator::thisRegister const): (JSC::UnlinkedCodeBlockGenerator::scopeRegister const): (JSC::UnlinkedCodeBlockGenerator::wasCompiledWithDebuggingOpcodes const): (JSC::UnlinkedCodeBlockGenerator::hasCheckpoints const): (JSC::UnlinkedCodeBlockGenerator::hasTailCalls const): (JSC::UnlinkedCodeBlockGenerator::setHasCheckpoints): (JSC::UnlinkedCodeBlockGenerator::setHasTailCalls): (JSC::UnlinkedCodeBlockGenerator::setNumCalleeLocals): (JSC::UnlinkedCodeBlockGenerator::setNumVars): (JSC::UnlinkedCodeBlockGenerator::setThisRegister): (JSC::UnlinkedCodeBlockGenerator::setScopeRegister): (JSC::UnlinkedCodeBlockGenerator::setNumParameters): (JSC::UnlinkedCodeBlockGenerator::metadata): (JSC::UnlinkedCodeBlockGenerator::addOpProfileControlFlowBytecodeOffset): (JSC::UnlinkedCodeBlockGenerator::numberOfJumpTargets const): (JSC::UnlinkedCodeBlockGenerator::addJumpTarget): (JSC::UnlinkedCodeBlockGenerator::jumpTarget const): (JSC::UnlinkedCodeBlockGenerator::lastJumpTarget const): (JSC::UnlinkedCodeBlockGenerator::numberOfSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::switchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfStringSwitchJumpTables const): (JSC::UnlinkedCodeBlockGenerator::addStringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::stringSwitchJumpTable): (JSC::UnlinkedCodeBlockGenerator::numberOfExceptionHandlers const): (JSC::UnlinkedCodeBlockGenerator::exceptionHandler): (JSC::UnlinkedCodeBlockGenerator::addExceptionHandler): (JSC::UnlinkedCodeBlockGenerator::bitVector): (JSC::UnlinkedCodeBlockGenerator::addBitVector): (JSC::UnlinkedCodeBlockGenerator::numberOfConstantIdentifierSets const): (JSC::UnlinkedCodeBlockGenerator::constantIdentifierSets): (JSC::UnlinkedCodeBlockGenerator::addSetConstant): (JSC::UnlinkedCodeBlockGenerator::constantRegister const): (JSC::UnlinkedCodeBlockGenerator::constantRegisters): (JSC::UnlinkedCodeBlockGenerator::getConstant const): (JSC::UnlinkedCodeBlockGenerator::constantsSourceCodeRepresentation): (JSC::UnlinkedCodeBlockGenerator::addConstant): (JSC::UnlinkedCodeBlockGenerator::addFunctionDecl): (JSC::UnlinkedCodeBlockGenerator::addFunctionExpr): (JSC::UnlinkedCodeBlockGenerator::numberOfIdentifiers const): (JSC::UnlinkedCodeBlockGenerator::identifier const): (JSC::UnlinkedCodeBlockGenerator::addIdentifier): (JSC::UnlinkedCodeBlockGenerator::outOfLineJumpOffset): (JSC::UnlinkedCodeBlockGenerator::replaceOutOfLineJumpTargets): (JSC::UnlinkedCodeBlockGenerator::metadataSizeInBytes): * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::BytecodeGenerator): (JSC::BytecodeGenerator::initializeNextParameter): (JSC::BytecodeGenerator::emitPushFunctionNameScope): (JSC::prepareJumpTableForSwitch): (JSC::ForInContext::finalize): (JSC::StructureForInContext::finalize): (JSC::IndexedForInContext::finalize): * bytecompiler/BytecodeGenerator.h: * bytecompiler/BytecodeGeneratorBaseInlines.h: (JSC::BytecodeGeneratorBase<Traits>::newRegister): (JSC::BytecodeGeneratorBase<Traits>::addVar): * runtime/CachedTypes.cpp: (JSC::CachedVector::encode): (JSC::CachedVector::decode const): * wasm/WasmFunctionCodeBlock.h: (JSC::Wasm::FunctionCodeBlock::setNumVars): (JSC::Wasm::FunctionCodeBlock::setNumCalleeLocals): Source/WTF: Add more useful methods for RefCountedArray. * wtf/RefCountedArray.h: (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::isEmpty const): (WTF::RefCountedArray::front): (WTF::RefCountedArray::front const): (WTF::RefCountedArray::last): (WTF::RefCountedArray::last const): Canonical link: https://commits.webkit.org/220203@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-04 19:05:17 +00:00
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]; }
[WTF] Introduce FixedVector and use it for FixedOperands https://bugs.webkit.org/show_bug.cgi?id=224171 Reviewed by Mark Lam. Source/JavaScriptCore: 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: Source/WTF: 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): Tools: * 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=): Canonical link: https://commits.webkit.org/236198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275542 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-06 19:47:47 +00:00
void fill(const T& val)
{
std::fill(begin(), end(), val);
}
void swap(RefCountedArray& other)
{
PtrTraits::swap(m_data, other.m_data);
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
template<typename OtherTraits = PtrTraits>
bool operator==(const RefCountedArray<T, OtherTraits>& other) const
{
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
T* data = const_cast<T*>(this->data());
T* otherData = const_cast<T*>(other.data());
if (data == otherData)
return true;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
if (!data || !otherData)
return false;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
unsigned length = Header::fromPayload(data)->length;
if (length != Header::fromPayload(otherData)->length)
return false;
for (unsigned i = 0; i < length; ++i) {
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
if (data[i] != otherData[i])
return false;
}
return true;
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
bool operator==(const RefCountedArray& other) const { return this->operator==<PtrTraits>(other); }
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
private:
static T* allocateUninitializedData(unsigned length)
{
T* data = (static_cast<Header*>(RefCountedArrayMalloc::malloc(Header::size() + sizeof(T) * length)))->payload();
Header::fromPayload(data)->refCount = 1;
Header::fromPayload(data)->length = length;
ASSERT(Header::fromPayload(data)->length == length);
return data;
}
template<typename OtherTraits = PtrTraits>
RefCountedArray& assign(const RefCountedArray<T, OtherTraits>& other)
{
T* oldData = data();
T* otherData = const_cast<T*>(other.data());
if (otherData)
Header::fromPayload(otherData)->refCount++;
m_data = otherData;
if (!oldData)
return *this;
unsigned refCount = Header::fromPayload(oldData)->refCount - 1;
if (refCount) {
Header::fromPayload(oldData)->refCount = refCount;
return *this;
}
VectorTypeOperations<T>::destruct(oldData, oldData + Header::fromPayload(oldData)->length);
Experiment: create lots of different malloc zones for easier accounting of memory use https://bugs.webkit.org/show_bug.cgi?id=186422 Patch by Yusuke Suzuki <ysuzuki@apple.com> and Simon Fraser <simon.fraser@apple.com> on 2020-01-02 Reviewed by Saam Barati. Source/bmalloc: * bmalloc/BPlatform.h: * bmalloc/Environment.cpp: (bmalloc::Environment::computeIsDebugHeapEnabled): * bmalloc/IsoHeap.h: (bmalloc::api::IsoHeap::IsoHeap): * bmalloc/IsoHeapInlines.h: (bmalloc::api::IsoHeap<Type>::IsoHeap): * bmalloc/IsoTLSInlines.h: (bmalloc::IsoTLS::allocateSlow): (bmalloc::IsoTLS::deallocateSlow): Source/JavaScriptCore: * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * assembler/AssemblerBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * assembler/AssemblerBuffer.h: (JSC::AssemblerData::AssemblerData): (JSC::AssemblerData::operator=): (JSC::AssemblerData::~AssemblerData): (JSC::AssemblerData::grow): * bytecode/AccessCase.cpp: * bytecode/AccessCase.h: * bytecode/BytecodeBasicBlock.cpp: * bytecode/BytecodeBasicBlock.h: * bytecode/CodeBlock.cpp: * bytecode/CodeBlock.h: * bytecode/InstructionStream.cpp: * bytecode/InstructionStream.h: * bytecode/PolymorphicAccess.cpp: * bytecode/PolymorphicAccess.h: * bytecode/UnlinkedMetadataTable.cpp: (JSC::UnlinkedMetadataTable::finalize): * bytecode/UnlinkedMetadataTable.h: * bytecode/UnlinkedMetadataTableInlines.h: (JSC::UnlinkedMetadataTable::UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::~UnlinkedMetadataTable): (JSC::UnlinkedMetadataTable::link): (JSC::UnlinkedMetadataTable::unlink): * bytecode/ValueProfile.h: (JSC::ValueProfileAndVirtualRegisterBuffer::ValueProfileAndVirtualRegisterBuffer): * bytecode/Watchpoint.cpp: * bytecode/Watchpoint.h: * dfg/DFGBasicBlock.cpp: * dfg/DFGBasicBlock.h: * dfg/DFGNode.cpp: * dfg/DFGNode.h: * dfg/DFGSpeculativeJIT.cpp: * dfg/DFGSpeculativeJIT.h: * heap/BlockDirectory.cpp: * heap/BlockDirectory.h: * heap/FastMallocAlignedMemoryAllocator.cpp: (JSC::FastMallocAlignedMemoryAllocator::FastMallocAlignedMemoryAllocator): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::freeAlignedMemory): (JSC::FastMallocAlignedMemoryAllocator::tryAllocateMemory): (JSC::FastMallocAlignedMemoryAllocator::freeMemory): (JSC::FastMallocAlignedMemoryAllocator::tryReallocateMemory): * heap/FastMallocAlignedMemoryAllocator.h: * heap/GCSegmentedArray.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * heap/GCSegmentedArray.h: * heap/GCSegmentedArrayInlines.h: (JSC::GCArraySegment<T>::create): (JSC::GCArraySegment<T>::destroy): * heap/GigacageAlignedMemoryAllocator.cpp: (JSC::GigacageAlignedMemoryAllocator::GigacageAlignedMemoryAllocator): (JSC::GigacageAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::freeAlignedMemory): (JSC::GigacageAlignedMemoryAllocator::tryAllocateMemory): (JSC::GigacageAlignedMemoryAllocator::freeMemory): (JSC::GigacageAlignedMemoryAllocator::tryReallocateMemory): * heap/GigacageAlignedMemoryAllocator.h: * heap/IsoAlignedMemoryAllocator.cpp: (JSC::IsoAlignedMemoryAllocator::IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator): (JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory): (JSC::IsoAlignedMemoryAllocator::freeAlignedMemory): (JSC::IsoAlignedMemoryAllocator::tryAllocateMemory): (JSC::IsoAlignedMemoryAllocator::freeMemory): * heap/IsoAlignedMemoryAllocator.h: * heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): * heap/MarkedBlock.cpp: * heap/MarkedBlock.h: * heap/WeakBlock.cpp: (JSC::WeakBlock::create): (JSC::WeakBlock::destroy): * heap/WeakBlock.h: * jit/JITCode.cpp: * jit/JITCode.h: * jit/RegisterAtOffsetList.cpp: * jit/RegisterAtOffsetList.h: * parser/Nodes.cpp: * parser/Nodes.h: * parser/ParserArena.cpp: (JSC::ParserArena::deallocateObjects): (JSC::ParserArena::allocateFreeablePool): * parser/ParserArena.h: * parser/SourceProvider.cpp: * parser/SourceProvider.h: * parser/SourceProviderCache.cpp: * parser/SourceProviderCache.h: * parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::create): * runtime/CachePayload.cpp: (JSC::CachePayload::makeMallocPayload): * runtime/CachePayload.h: * runtime/CachedBytecode.h: (JSC::CachedBytecode::create): * runtime/CachedTypes.cpp: (JSC::Encoder::release): (JSC::Encoder::Page::Page): (JSC::CachedVector::encode): (JSC::CachedVector::decode const): (JSC::CachedInstructionStream::decode const): * runtime/PropertyMapHashTable.h: (JSC::PropertyTable::rehash): * runtime/PropertyTable.cpp: (JSC::PropertyTable::PropertyTable): (JSC::PropertyTable::~PropertyTable): * runtime/SymbolTable.cpp: * runtime/SymbolTable.h: * runtime/VM.cpp: (JSC::VM::~VM): * runtime/VM.h: (JSC::ScratchBuffer::create): (JSC::VM::exceptionFuzzingBuffer): * wasm/WasmInstance.cpp: (JSC::Wasm::Instance::Instance): * wasm/WasmInstance.h: * wasm/WasmTable.cpp: (JSC::Wasm::Table::Table): (JSC::Wasm::FuncRefTable::FuncRefTable): * wasm/WasmTable.h: Source/WebCore: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * bindings/js/SerializedScriptValue.cpp: * bindings/js/SerializedScriptValue.h: * css/CSSFontFace.cpp: * css/CSSFontFace.h: * css/CSSSelector.cpp: * css/CSSSelector.h: * css/CSSValue.cpp: * css/CSSValue.h: * css/StyleProperties.cpp: (WebCore::ImmutableStyleProperties::create): * css/StyleProperties.h: * css/StyleRule.cpp: * css/StyleRule.h: * dom/ElementData.cpp: (WebCore::ShareableElementData::createWithAttributes): (WebCore::UniqueElementData::makeShareableCopy const): * dom/ElementData.h: * dom/NodeRareData.cpp: * dom/NodeRareData.h: * dom/QualifiedName.cpp: * dom/QualifiedName.h: * html/parser/HTMLDocumentParser.cpp: * html/parser/HTMLDocumentParser.h: * loader/DocumentLoader.cpp: * loader/DocumentLoader.h: * loader/ResourceLoader.cpp: * loader/ResourceLoader.h: * loader/cache/CachedResource.cpp: * loader/cache/CachedResource.h: * page/PerformanceEntry.cpp: * page/PerformanceEntry.h: * platform/graphics/Font.cpp: * platform/graphics/Font.h: * platform/graphics/FontCascadeFonts.cpp: * platform/graphics/FontCascadeFonts.h: * platform/graphics/Region.cpp: * platform/graphics/Region.h: * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm: (WebCore::releaseUint8Vector): * platform/graphics/cg/ImageBufferCG.cpp: (WebCore::ImageBuffer::ImageBuffer): * platform/graphics/nicosia/NicosiaBuffer.cpp: (Nicosia::Buffer::Buffer): * platform/network/ResourceHandle.cpp: * platform/network/ResourceHandleInternal.h: * platform/network/cf/FormDataStreamCFNet.cpp: (WebCore::closeCurrentStream): (WebCore::advanceCurrentStream): * rendering/RenderLayer.cpp: * rendering/RenderLayer.h: * rendering/TableLayout.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * rendering/TableLayout.h: * rendering/style/RenderStyle.cpp: * rendering/style/RenderStyle.h: * rendering/style/SVGRenderStyle.cpp: * rendering/style/SVGRenderStyle.h: * rendering/style/SVGRenderStyleDefs.cpp: * rendering/style/SVGRenderStyleDefs.h: * rendering/style/StyleBoxData.cpp: * rendering/style/StyleBoxData.h: * rendering/style/StyleInheritedData.cpp: * rendering/style/StyleInheritedData.h: * rendering/style/StyleRareInheritedData.cpp: * rendering/style/StyleRareInheritedData.h: * rendering/style/StyleRareNonInheritedData.cpp: * rendering/style/StyleRareNonInheritedData.h: * rendering/style/StyleSurroundData.cpp: * rendering/style/StyleSurroundData.h: * rendering/style/StyleTransformData.cpp: * rendering/style/StyleTransformData.h: * style/StyleTreeResolver.cpp: * style/StyleTreeResolver.h: * svg/animation/SMILTimeContainer.cpp: * svg/animation/SMILTimeContainer.h: Source/WebKit: * Shared/ShareableBitmap.cpp: (WebKit::ShareableBitmap::create): (WebKit::ShareableBitmap::~ShareableBitmap): * UIProcess/mac/LegacySessionStateCoding.cpp: (WebKit::HistoryEntryDataEncoder::HistoryEntryDataEncoder): (WebKit::HistoryEntryDataEncoder::finishEncoding): (WebKit::encodeSessionHistoryEntryData): (WebKit::encodeLegacySessionState): Source/WTF: This patch introduces ENABLE(MALLOC_HEAP_BREAKDOWN). If this is enabled, we allocate malloc_zone per malloc kind. This offers the way to investigate the usage of memory per kind by using vmmap, like the following. VIRTUAL RESIDENT DIRTY SWAPPED ALLOCATION BYTES DIRTY+SWAP REGION MALLOC ZONE SIZE SIZE SIZE SIZE COUNT ALLOCATED FRAG SIZE % FRAG COUNT =========== ======= ========= ========= ========= ========= ========= ========= ====== ====== StringImpl_0x116efd000 188.0M 69.3M 30.9M 0K 139456 18.0M 12.9M 42% 34 DefaultMallocZone_0x10f487000 176.0M 53.9M 14.1M 0K 115956 9955K 4497K 32% 22 Vector_0x116eff000 162.0M 56.3M 55.3M 0K 140715 17.3M 37.9M 69% 36 MetadataTable_0x11843b000 152.0M 17.5M 17.5M 0K 14200 2353K 15.2M 87% 26 WebKit Using System Malloc_0x114cbe000 150.0M 31.6M 21.8M 0K 87422 16.7M 5278K 24% 23 InstructionStream_0x118469000 150.0M 5764K 5764K 0K 14470 4688K 1076K 19% 24 AssemblerData_0x117ee6000 150.0M 1928K 1928K 0K 1 16 1928K 100% 24 To achieve this goal without making very large change, we put a template type in various containers. For example, Vector will take Malloc parameter (the default one is FastMalloc allocator). If ENABLE(MALLOC_HEAP_BREAKDOWN) is enabled, we change this to specific VectorMalloc allocator, and vmmap can show memory usage of this allocator. This patch also supports malloc_zone per IsoHeap. So we can see memory allocation per IsoHeap in vmmap. To use this feature, we need to flip two compile time flags, ENABLE(MALLOC_HEAP_BREAKDOWN) in WTF and BENABLE_MALLOC_HEAP_BREAKDOWN in bmalloc. And use `vmmap $PID` to dump malloc zones. To allocate objects of a class with a specific malloc-zone, use WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(HeapIdentifier) for the class, and define allocator by DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HeapIdentifier) in a header and DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(HeapIdentifier) in a cpp file. This patch also introduce callstack collector for malloc. Vector, HashMap etc. are used to allocate various things, but the above malloc_zone feature only tells thing like "Vector takes XXX MB memory". But what we want to know in this case is what Vector is consuming memory. We collect StackShot for each malloc call, and combine these information to tell which callsite is consuming much memory, which tell us that what Vector is consuming memory. * WTF.xcodeproj/project.pbxproj: * wtf/Bag.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): Deleted. * wtf/BitVector.cpp: (WTF::BitVector::OutOfLineBits::create): (WTF::BitVector::OutOfLineBits::destroy): * wtf/CMakeLists.txt: * wtf/ConcurrentBuffer.cpp: Copied from Source/JavaScriptCore/parser/SourceProviderCache.cpp. * wtf/ConcurrentBuffer.h: * wtf/DebugHeap.cpp: Copied from Source/JavaScriptCore/runtime/CachePayload.cpp. (WTF::DebugHeap::DebugHeap): (WTF::DebugHeap::malloc): (WTF::DebugHeap::calloc): (WTF::DebugHeap::memalign): (WTF::DebugHeap::realloc): (WTF::DebugHeap::free): * wtf/DebugHeap.h: Added. * wtf/FastBitVector.cpp: (WTF::FastBitVectorWordOwner::setEqualsSlow): (WTF::FastBitVectorWordOwner::resizeSlow): * wtf/FastBitVector.h: (WTF::FastBitVectorWordOwner::~FastBitVectorWordOwner): * wtf/FastMalloc.cpp: (WTF::fastMallocDumpMallocStats): (WTF::AvoidRecordingScope::AvoidRecordingScope): (WTF::AvoidRecordingScope::~AvoidRecordingScope): (WTF::MallocCallTracker::MallocSiteData::MallocSiteData): (WTF::MallocCallTracker::singleton): (WTF::MallocCallTracker::MallocCallTracker): (WTF::MallocCallTracker::recordMalloc): (WTF::MallocCallTracker::recordRealloc): (WTF::MallocCallTracker::recordFree): (WTF::MallocCallTracker::dumpStats): (WTF::fastMalloc): (WTF::fastRealloc): (WTF::fastFree): (WTF::fastAlignedMalloc): (WTF::tryFastAlignedMalloc): (WTF::fastAlignedFree): * wtf/FastMalloc.h: (WTF::FastMalloc::zeroedMalloc): (WTF::FastMalloc::tryZeroedMalloc): * wtf/Forward.h: * wtf/HashTable.cpp: * wtf/HashTable.h: (WTF::KeyTraits>::allocateTable): (WTF::KeyTraits>::deallocateTable): (WTF::KeyTraits>::rehash): * wtf/MallocPtr.h: (WTF::MallocPtr::MallocPtr): (WTF::MallocPtr::malloc): (WTF::MallocPtr::zeroedMalloc): (WTF::MallocPtr::tryMalloc): (WTF::MallocPtr::tryZeroedMalloc): (WTF::adoptMallocPtr): * wtf/MetaAllocator.cpp: (WTF::MetaAllocator::allocFreeSpaceNode): (WTF::MetaAllocator::freeFreeSpaceNode): * wtf/MetaAllocatorHandle.h: * wtf/Platform.h: * wtf/RefCountedArray.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::assign): * wtf/SegmentedVector.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/SegmentedVector.h: * wtf/SmallPtrSet.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/SmallPtrSet.h: (WTF::SmallPtrSet::~SmallPtrSet): (WTF::SmallPtrSet::grow): * wtf/UniqueArray.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/UniqueArray.h: (WTF::UniqueArrayFree::operator() const): (WTF::UniqueArrayFree<T::operator() const): * wtf/Vector.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/Vector.h: (WTF::VectorBufferBase::allocateBuffer): (WTF::VectorBufferBase::tryAllocateBuffer): (WTF::VectorBufferBase::reallocateBuffer): (WTF::VectorBufferBase::deallocateBuffer): (WTF::VectorBufferBase::releaseBuffer): (WTF::VectorBuffer::releaseBuffer): (WTF::Vector::swap): (WTF::Malloc>::Vector): (WTF::=): (WTF::Malloc>::contains const): (WTF::Malloc>::findMatching const): (WTF::Malloc>::find const): (WTF::Malloc>::reverseFind const): (WTF::Malloc>::appendIfNotContains): (WTF::Malloc>::fill): (WTF::Malloc>::appendRange): (WTF::Malloc>::expandCapacity): (WTF::Malloc>::tryExpandCapacity): (WTF::Malloc>::resize): (WTF::Malloc>::resizeToFit): (WTF::Malloc>::shrink): (WTF::Malloc>::grow): (WTF::Malloc>::asanSetInitialBufferSizeTo): (WTF::Malloc>::asanSetBufferSizeToFullCapacity): (WTF::Malloc>::asanBufferSizeWillChangeTo): (WTF::Malloc>::reserveCapacity): (WTF::Malloc>::tryReserveCapacity): (WTF::Malloc>::reserveInitialCapacity): (WTF::Malloc>::shrinkCapacity): (WTF::Malloc>::append): (WTF::Malloc>::tryAppend): (WTF::Malloc>::constructAndAppend): (WTF::Malloc>::tryConstructAndAppend): (WTF::Malloc>::appendSlowCase): (WTF::Malloc>::constructAndAppendSlowCase): (WTF::Malloc>::tryConstructAndAppendSlowCase): (WTF::Malloc>::uncheckedAppend): (WTF::Malloc>::uncheckedConstructAndAppend): (WTF::Malloc>::appendVector): (WTF::Malloc>::insert): (WTF::Malloc>::insertVector): (WTF::Malloc>::remove): (WTF::Malloc>::removeFirst): (WTF::Malloc>::removeFirstMatching): (WTF::Malloc>::removeAll): (WTF::Malloc>::removeAllMatching): (WTF::Malloc>::reverse): (WTF::Malloc>::map const): (WTF::Malloc>::releaseBuffer): (WTF::Malloc>::checkConsistency): (WTF::swap): (WTF::operator==): (WTF::operator!=): (WTF::Malloc>::isolatedCopy const): (WTF::removeRepeatedElements): (WTF::minCapacity>::Vector): Deleted. (WTF::minCapacity>::contains const): Deleted. (WTF::minCapacity>::findMatching const): Deleted. (WTF::minCapacity>::find const): Deleted. (WTF::minCapacity>::reverseFind const): Deleted. (WTF::minCapacity>::appendIfNotContains): Deleted. (WTF::minCapacity>::fill): Deleted. (WTF::minCapacity>::appendRange): Deleted. (WTF::minCapacity>::expandCapacity): Deleted. (WTF::minCapacity>::tryExpandCapacity): Deleted. (WTF::minCapacity>::resize): Deleted. (WTF::minCapacity>::resizeToFit): Deleted. (WTF::minCapacity>::shrink): Deleted. (WTF::minCapacity>::grow): Deleted. (WTF::minCapacity>::asanSetInitialBufferSizeTo): Deleted. (WTF::minCapacity>::asanSetBufferSizeToFullCapacity): Deleted. (WTF::minCapacity>::asanBufferSizeWillChangeTo): Deleted. (WTF::minCapacity>::reserveCapacity): Deleted. (WTF::minCapacity>::tryReserveCapacity): Deleted. (WTF::minCapacity>::reserveInitialCapacity): Deleted. (WTF::minCapacity>::shrinkCapacity): Deleted. (WTF::minCapacity>::append): Deleted. (WTF::minCapacity>::tryAppend): Deleted. (WTF::minCapacity>::constructAndAppend): Deleted. (WTF::minCapacity>::tryConstructAndAppend): Deleted. (WTF::minCapacity>::appendSlowCase): Deleted. (WTF::minCapacity>::constructAndAppendSlowCase): Deleted. (WTF::minCapacity>::tryConstructAndAppendSlowCase): Deleted. (WTF::minCapacity>::uncheckedAppend): Deleted. (WTF::minCapacity>::uncheckedConstructAndAppend): Deleted. (WTF::minCapacity>::appendVector): Deleted. (WTF::minCapacity>::insert): Deleted. (WTF::minCapacity>::insertVector): Deleted. (WTF::minCapacity>::remove): Deleted. (WTF::minCapacity>::removeFirst): Deleted. (WTF::minCapacity>::removeFirstMatching): Deleted. (WTF::minCapacity>::removeAll): Deleted. (WTF::minCapacity>::removeAllMatching): Deleted. (WTF::minCapacity>::reverse): Deleted. (WTF::minCapacity>::map const): Deleted. (WTF::minCapacity>::releaseBuffer): Deleted. (WTF::minCapacity>::checkConsistency): Deleted. (WTF::minCapacity>::isolatedCopy const): Deleted. * wtf/text/CString.cpp: (WTF::CStringBuffer::createUninitialized): * wtf/text/CString.h: * wtf/text/StringBuffer.cpp: Copied from Source/JavaScriptCore/bytecode/InstructionStream.cpp. * wtf/text/StringBuffer.h: (WTF::StringBuffer::StringBuffer): (WTF::StringBuffer::~StringBuffer): (WTF::StringBuffer::resize): (WTF::StringBuffer::release): * wtf/text/StringImpl.cpp: (WTF::StringImpl::~StringImpl): (WTF::StringImpl::destroy): (WTF::StringImpl::createUninitializedInternalNonEmpty): (WTF::StringImpl::reallocateInternal): * wtf/text/StringImpl.h: (WTF::StringImpl::StringImpl): (WTF::StringImpl::createSubstringSharingImpl): (WTF::StringImpl::tryCreateUninitialized): (WTF::StringImpl::adopt): * wtf/text/cf/StringImplCF.cpp: (WTF::StringWrapperCFAllocator::allocate): (WTF::StringWrapperCFAllocator::reallocate): (WTF::StringWrapperCFAllocator::deallocate): Canonical link: https://commits.webkit.org/218863@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-03 02:36:43 +00:00
RefCountedArrayMalloc::free(Header::fromPayload(oldData));
return *this;
}
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
struct Header {
unsigned refCount;
unsigned length;
[JSC] Use FixedVector more in bytecode dir and JumpTable https://bugs.webkit.org/show_bug.cgi?id=224275 Reviewed by Michael Saboff and Mark Lam. Source/JavaScriptCore: 1. Use FixedVector more in bytecode/ directory's long-living data structures. 2. Use FixedVector in SimpleJumpTable. This involves LLInt changes because we need to access FixedVector data from LLInt. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/InlineCallFrame.cpp: (JSC::InlineCallFrame::dumpInContext const): * bytecode/InlineCallFrame.h: * bytecode/JumpTable.h: (JSC::SimpleJumpTable::clear): * bytecode/ObjectPropertyConditionSet.cpp: (JSC::ObjectPropertyConditionSet::mergedWith const): (JSC::ObjectPropertyConditionSet::dumpInContext const): (JSC::ObjectPropertyConditionSet::isValidAndWatchable const): * bytecode/ObjectPropertyConditionSet.h: (JSC::ObjectPropertyConditionSet::create): (JSC::ObjectPropertyConditionSet::isValid const): (JSC::ObjectPropertyConditionSet::size const): (JSC::ObjectPropertyConditionSet::begin const): (JSC::ObjectPropertyConditionSet::end const): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::findArgumentPositionForLocal): (JSC::DFG::ByteCodeParser::flushImpl): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry): * dfg/DFGCommonData.cpp: (JSC::DFG::CommonData::validateReferences): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGGraph.h: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGStackLayoutPhase.cpp: (JSC::DFG::StackLayoutPhase::run): * ftl/FTLCompile.cpp: (JSC::FTL::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::argumentsStart): * jit/SetupVarargsFrame.cpp: (JSC::emitSetupVarargsFrameFastCase): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::createWithInlineFrame): Source/WTF: * wtf/FixedVector.h: (WTF::FixedVector::offsetOfStorage): * wtf/RefCountedArray.h: (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::offsetOfLength): Canonical link: https://commits.webkit.org/236271@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-07 21:14:57 +00:00
static constexpr size_t size()
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
{
return (sizeof(Header) + 7) & ~7;
}
[JSC] Use FixedVector more in bytecode dir and JumpTable https://bugs.webkit.org/show_bug.cgi?id=224275 Reviewed by Michael Saboff and Mark Lam. Source/JavaScriptCore: 1. Use FixedVector more in bytecode/ directory's long-living data structures. 2. Use FixedVector in SimpleJumpTable. This involves LLInt changes because we need to access FixedVector data from LLInt. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::finishCreation): * bytecode/InlineCallFrame.cpp: (JSC::InlineCallFrame::dumpInContext const): * bytecode/InlineCallFrame.h: * bytecode/JumpTable.h: (JSC::SimpleJumpTable::clear): * bytecode/ObjectPropertyConditionSet.cpp: (JSC::ObjectPropertyConditionSet::mergedWith const): (JSC::ObjectPropertyConditionSet::dumpInContext const): (JSC::ObjectPropertyConditionSet::isValidAndWatchable const): * bytecode/ObjectPropertyConditionSet.h: (JSC::ObjectPropertyConditionSet::create): (JSC::ObjectPropertyConditionSet::isValid const): (JSC::ObjectPropertyConditionSet::size const): (JSC::ObjectPropertyConditionSet::begin const): (JSC::ObjectPropertyConditionSet::end const): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::findArgumentPositionForLocal): (JSC::DFG::ByteCodeParser::flushImpl): (JSC::DFG::ByteCodeParser::parseBlock): (JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry): * dfg/DFGCommonData.cpp: (JSC::DFG::CommonData::validateReferences): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGGraph.h: * dfg/DFGPreciseLocalClobberize.h: (JSC::DFG::PreciseLocalClobberizeAdaptor::readTop): * dfg/DFGStackLayoutPhase.cpp: (JSC::DFG::StackLayoutPhase::run): * ftl/FTLCompile.cpp: (JSC::FTL::compile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileGetMyArgumentByVal): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::argumentsStart): * jit/SetupVarargsFrame.cpp: (JSC::emitSetupVarargsFrameFastCase): * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter32_64.asm: * llint/LowLevelInterpreter64.asm: * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::createWithInlineFrame): Source/WTF: * wtf/FixedVector.h: (WTF::FixedVector::offsetOfStorage): * wtf/RefCountedArray.h: (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::offsetOfLength): Canonical link: https://commits.webkit.org/236271@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-07 21:14:57 +00:00
static ptrdiff_t offsetOfLength() { return OBJECT_OFFSETOF(Header, length); }
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
T* payload()
{
char* result = reinterpret_cast<char*>(this) + size();
ASSERT(!(bitwise_cast<uintptr_t>(result) & 7));
return reinterpret_cast_ptr<T*>(result);
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
static Header* fromPayload(T* payload)
{
return reinterpret_cast_ptr<Header*>(reinterpret_cast<char*>(payload) - size());
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
}
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
static const Header* fromPayload(const T* payload)
{
return fromPayload(const_cast<T*>(payload));
}
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
};
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
template<typename OtherTraits>
RefCountedArray(CommonCopyConstructorTag, const RefCountedArray<T, OtherTraits>& other)
: m_data(const_cast<T*>(other.data()))
{
if (m_data)
Header::fromPayload(data())->refCount++;
}
friend class JSC::LLIntOffsetsExtractor;
Apply poisoning to more pointers in JSC. https://bugs.webkit.org/show_bug.cgi?id=181096 <rdar://problem/36182970> Reviewed by JF Bastien. Source/JavaScriptCore: * assembler/MacroAssembler.h: (JSC::MacroAssembler::xorPtr): * assembler/MacroAssemblerARM64.h: (JSC::MacroAssemblerARM64::xor64): * assembler/MacroAssemblerX86_64.h: (JSC::MacroAssemblerX86_64::xor64): - Add xorPtr implementation. * bytecode/CodeBlock.cpp: (JSC::CodeBlock::inferredName const): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finishCreation): (JSC::CodeBlock::~CodeBlock): (JSC::CodeBlock::setConstantRegisters): (JSC::CodeBlock::visitWeakly): (JSC::CodeBlock::visitChildren): (JSC::CodeBlock::propagateTransitions): (JSC::CodeBlock::WeakReferenceHarvester::visitWeakReferences): (JSC::CodeBlock::finalizeLLIntInlineCaches): (JSC::CodeBlock::finalizeBaselineJITInlineCaches): (JSC::CodeBlock::UnconditionalFinalizer::finalizeUnconditionally): (JSC::CodeBlock::jettison): (JSC::CodeBlock::predictedMachineCodeSize): (JSC::CodeBlock::findPC): * bytecode/CodeBlock.h: (JSC::CodeBlock::UnconditionalFinalizer::UnconditionalFinalizer): (JSC::CodeBlock::WeakReferenceHarvester::WeakReferenceHarvester): (JSC::CodeBlock::stubInfoBegin): (JSC::CodeBlock::stubInfoEnd): (JSC::CodeBlock::callLinkInfosBegin): (JSC::CodeBlock::callLinkInfosEnd): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructions const): (JSC::CodeBlock::vm const): * dfg/DFGOSRExitCompilerCommon.h: (JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk): * jit/JIT.h: * llint/LLIntOfflineAsmConfig.h: * llint/LowLevelInterpreter.asm: * llint/LowLevelInterpreter64.asm: * parser/UnlinkedSourceCode.h: * runtime/JSCPoison.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/StructureTransitionTable.h: * wasm/js/JSWebAssemblyCodeBlock.cpp: (JSC::JSWebAssemblyCodeBlock::JSWebAssemblyCodeBlock): (JSC::JSWebAssemblyCodeBlock::visitChildren): (JSC::JSWebAssemblyCodeBlock::UnconditionalFinalizer::finalizeUnconditionally): * wasm/js/JSWebAssemblyCodeBlock.h: Source/WTF: Added support for PoisonedBag and PoisonedRefCountedArray. * wtf/Bag.h: (WTF::Private::BagNode::BagNode): (WTF::Bag::Bag): (WTF::Bag::operator=): (WTF::Bag::clear): (WTF::Bag::add): (WTF::Bag::begin): (WTF::Bag::unwrappedHead): (WTF::Bag::Node::Node): Deleted. * wtf/BagToHashMap.h: (WTF::toHashMap): * wtf/Poisoned.h: (WTF::constExprPoisonRandom): (WTF::makeConstExprPoison): * wtf/RefCountedArray.h: (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::clone const): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::refCount const): (WTF::RefCountedArray::size const): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::data const): (WTF::RefCountedArray::begin const): (WTF::RefCountedArray::operator== const): (WTF::RefCountedArray::Header::fromPayload): * wtf/WTFAssertions.cpp: Canonical link: https://commits.webkit.org/197239@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-08 21:05:17 +00:00
typename PtrTraits::StorageType m_data { nullptr };
Getting the instruction stream for a code block should not require two loads https://bugs.webkit.org/show_bug.cgi?id=79608 Reviewed by Sam Weinig. Introduced the RefCountedArray class, which contains a single inline pointer to a ref-counted non-resizeable vector backing store. This satisfies the requirements of CodeBlock, which desires the ability to share instruction streams with other CodeBlocks. It also reduces the number of loads required for getting the instruction stream by one. This patch also gets rid of the bytecode discarding logic, since we don't use it anymore and it's unlikely to ever work right with DFG or LLInt. And I didn't feel like porting dead code to use RefCountedArray. * GNUmakefile.list.am: * JavaScriptCore.xcodeproj/project.pbxproj: * bytecode/CodeBlock.cpp: (JSC::instructionOffsetForNth): (JSC::CodeBlock::dump): (JSC::CodeBlock::CodeBlock): (JSC::CodeBlock::finalizeUnconditionally): (JSC::CodeBlock::handlerForBytecodeOffset): (JSC::CodeBlock::lineNumberForBytecodeOffset): (JSC::CodeBlock::expressionRangeForBytecodeOffset): (JSC::CodeBlock::shrinkToFit): * bytecode/CodeBlock.h: (CodeBlock): (JSC::CodeBlock::numberOfInstructions): (JSC::CodeBlock::instructions): (JSC::CodeBlock::instructionCount): (JSC::CodeBlock::valueProfileForBytecodeOffset): (JSC): * bytecompiler/BytecodeGenerator.cpp: (JSC::Label::setLocation): (JSC): (JSC::BytecodeGenerator::generate): (JSC::BytecodeGenerator::newLabel): * bytecompiler/BytecodeGenerator.h: (JSC): (BytecodeGenerator): (JSC::BytecodeGenerator::instructions): * bytecompiler/Label.h: (JSC::Label::Label): (Label): * dfg/DFGByteCodeCache.h: (JSC::DFG::ByteCodeCache::~ByteCodeCache): (JSC::DFG::ByteCodeCache::get): * jit/JITExceptions.cpp: (JSC::genericThrow): * llint/LowLevelInterpreter32_64.asm: * runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::codeBlockWithBytecodeFor): (JSC::FunctionExecutable::produceCodeBlockFor): * wtf/RefCountedArray.h: Added. (WTF): (RefCountedArray): (WTF::RefCountedArray::RefCountedArray): (WTF::RefCountedArray::operator=): (WTF::RefCountedArray::~RefCountedArray): (WTF::RefCountedArray::size): (WTF::RefCountedArray::data): (WTF::RefCountedArray::begin): (WTF::RefCountedArray::end): (WTF::RefCountedArray::at): (WTF::RefCountedArray::operator[]): (Header): (WTF::RefCountedArray::Header::size): (WTF::RefCountedArray::Header::payload): (WTF::RefCountedArray::Header::fromPayload): * wtf/Platform.h: Canonical link: https://commits.webkit.org/96713@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108943 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-02-27 02:07:34 +00:00
};
} // namespace WTF
using WTF::RefCountedArray;