Vector index masking
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Dec 2017 20:15:41 +0000 (20:15 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Dec 2017 20:15:41 +0000 (20:15 +0000)
commit72d2c0b852fd4648a59e7307785b956b453069b5
tree956a4481dc9e64eaa0d5c18b03521b8346b34426
parentc5af32de9b015c706b42f0e95f1fe1a69b82826f
Vector index masking
https://bugs.webkit.org/show_bug.cgi?id=180909

Reviewed by Keith Miller.

Source/JavaScriptCore:

Adopt index masking for strings.

* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileGetCharCodeAt):
(JSC::DFG::SpeculativeJIT::compileGetByValOnString):
* ftl/FTLAbstractHeapRepository.h:
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):
(JSC::FTL::DFG::LowerDFGToB3::compileStringCharCodeAt):
* jit/ThunkGenerators.cpp:
(JSC::stringCharLoad):

Source/WTF:

Adds index masking to StringImpl and Vector.

Perf:

- 0.4% slower on microbenchmarks.
- Octane totally even.
- Kraken may be 0.8% slower.
- Speedometer is 0.8% slower with p = 0.008.
- membuster is even:
    - snap2pre: 0.7% bigger w/ p = 0.26,
    - snap2post: 0.3% smaller w/ p = 0.81,
    - snap3pre: 1.2% bigger w/ p = 0.63,
    - snap3post: 0.4% smaller w/ p = 0.76.

* wtf/MathExtras.h:
(WTF::roundUpToPowerOfTwo):
(WTF::maskForSize):
* wtf/SizeLimits.cpp:
* wtf/Vector.h:
(WTF::VectorBufferBase::allocateBuffer):
(WTF::VectorBufferBase::tryAllocateBuffer):
(WTF::VectorBufferBase::reallocateBuffer):
(WTF::VectorBufferBase::deallocateBuffer):
(WTF::VectorBufferBase::releaseBuffer):
(WTF::VectorBufferBase::VectorBufferBase):
(WTF::VectorBufferBase::updateMask):
(WTF::VectorBuffer::allocateBuffer):
(WTF::VectorBuffer::tryAllocateBuffer):
(WTF::VectorBuffer::swap):
(WTF::VectorBuffer::restoreInlineBufferIfNeeded):
(WTF::Vector::at):
(WTF::Vector::at const):
* wtf/text/StringImpl.h:
(WTF::StringImpl::maskOffset):
(WTF::StringImpl::mask const):
(WTF::StringImplShape::StringImplShape):
(WTF::StringImpl::at const):
(WTF::StringImpl::tailOffset):
* wtf/text/StringView.h:
(WTF::StringView::StringView):
(WTF::StringView::operator=):
(WTF::StringView::initialize):
(WTF::StringView::clear):
(WTF::StringView::operator[] const):
* wtf/text/WTFString.h:
(WTF::String::mask const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226068 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
Source/JavaScriptCore/ftl/FTLAbstractHeapRepository.h
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Source/JavaScriptCore/jit/ThunkGenerators.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/MathExtras.h
Source/WTF/wtf/SizeLimits.cpp
Source/WTF/wtf/Vector.h
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WTF/wtf/text/StringView.h
Source/WTF/wtf/text/WTFString.h