Strings and Vectors shouldn't do index masking
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Mar 2018 15:55:38 +0000 (15:55 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 31 Mar 2018 15:55:38 +0000 (15:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184193

Reviewed by Mark Lam.

Source/JavaScriptCore:

* 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:

* 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::VectorBuffer::allocateBuffer):
(WTF::VectorBuffer::tryAllocateBuffer):
(WTF::VectorBuffer::swap):
(WTF::VectorBuffer::restoreInlineBufferIfNeeded):
(WTF::Vector::at):
(WTF::Vector::at const):
(WTF::VectorBufferBase::updateMask): Deleted.
* wtf/text/StringImpl.h:
(WTF::StringImpl::flagIsSymbol):
(WTF::StringImpl::length const):
(WTF::StringImplShape::StringImplShape):
(WTF::StringImpl::at const):
(WTF::StringImpl::tailOffset):
(WTF::StringImpl::maskOffset): Deleted.
(WTF::StringImpl::mask const): Deleted.
* 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::length const):
(WTF::String::mask const): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230130 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 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/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

index 6ad4ba8..91227bb 100644 (file)
@@ -1,3 +1,20 @@
+2018-03-30  Filip Pizlo  <fpizlo@apple.com>
+
+        Strings and Vectors shouldn't do index masking
+        https://bugs.webkit.org/show_bug.cgi?id=184193
+
+        Reviewed by Mark Lam.
+
+        * 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):
+
 2018-03-30  Mark Lam  <mark.lam@apple.com>
 
         Add pointer profiling support in baseline JIT and supporting files.
index ad85384..6af46e3 100644 (file)
@@ -2110,7 +2110,6 @@ void SpeculativeJIT::compileGetCharCodeAt(Node* node)
     GPRReg scratchReg = scratch.gpr();
 
     m_jit.loadPtr(MacroAssembler::Address(stringReg, JSString::offsetOfValue()), scratchReg);
-    m_jit.and32(MacroAssembler::Address(scratchReg, StringImpl::maskOffset()), indexReg);
 
     // Load the character into scratchReg
     JITCompiler::Jump is16Bit = m_jit.branchTest32(MacroAssembler::Zero, MacroAssembler::Address(scratchReg, StringImpl::flagsOffset()), TrustedImm32(StringImpl::flagIs8Bit()));
@@ -2158,7 +2157,6 @@ void SpeculativeJIT::compileGetByValOnString(Node* node)
         speculationCheck(OutOfBounds, JSValueRegs(), 0, outOfBounds);
 
     m_jit.loadPtr(MacroAssembler::Address(baseReg, JSString::offsetOfValue()), scratchReg);
-    m_jit.and32(MacroAssembler::Address(scratchReg, StringImpl::maskOffset()), propertyReg);
 
     // Load the character into scratchReg
     JITCompiler::Jump is16Bit = m_jit.branchTest32(MacroAssembler::Zero, MacroAssembler::Address(scratchReg, StringImpl::flagsOffset()), TrustedImm32(StringImpl::flagIs8Bit()));
index 179552b..fa07806 100644 (file)
@@ -112,7 +112,6 @@ namespace JSC { namespace FTL {
     macro(StringImpl_data, StringImpl::dataOffset()) \
     macro(StringImpl_hashAndFlags, StringImpl::flagsOffset()) \
     macro(StringImpl_length, StringImpl::lengthMemoryOffset()) \
-    macro(StringImpl_mask, StringImpl::maskOffset()) \
     macro(Structure_classInfo, Structure::classInfoOffset()) \
     macro(Structure_globalObject, Structure::globalObjectOffset()) \
     macro(Structure_prototype, Structure::prototypeOffset()) \
index bdd990e..ca730cf 100644 (file)
@@ -6285,7 +6285,6 @@ private:
         LBasicBlock lastNext = m_out.appendTo(fastPath, slowPath);
             
         LValue stringImpl = m_out.loadPtr(base, m_heaps.JSString_value);
-        LValue indexForAccess = m_out.bitAnd(index, m_out.load32(stringImpl, m_heaps.StringImpl_mask));
             
         LBasicBlock is8Bit = m_out.newBlock();
         LBasicBlock is16Bit = m_out.newBlock();
@@ -6304,7 +6303,7 @@ private:
         // https://bugs.webkit.org/show_bug.cgi?id=174924
         ValueFromBlock char8Bit = m_out.anchor(
             m_out.load8ZeroExt32(m_out.baseIndex(
-                m_heaps.characters8, storage, m_out.zeroExtPtr(indexForAccess),
+                m_heaps.characters8, storage, m_out.zeroExtPtr(index),
                 provenValue(m_graph.child(m_node, 1)))));
         m_out.jump(bitsContinuation);
             
@@ -6312,7 +6311,7 @@ private:
 
         LValue char16BitValue = m_out.load16ZeroExt32(
             m_out.baseIndex(
-                m_heaps.characters16, storage, m_out.zeroExtPtr(indexForAccess),
+                m_heaps.characters16, storage, m_out.zeroExtPtr(index),
                 provenValue(m_graph.child(m_node, 1))));
         ValueFromBlock char16Bit = m_out.anchor(char16BitValue);
         m_out.branch(
@@ -6394,7 +6393,6 @@ private:
                 index, m_out.load32NonNegative(base, m_heaps.JSString_length)));
         
         LValue stringImpl = m_out.loadPtr(base, m_heaps.JSString_value);
-        LValue indexForAccess = m_out.bitAnd(index, m_out.load32(stringImpl, m_heaps.StringImpl_mask));
         
         m_out.branch(
             m_out.testIsZero32(
@@ -6408,7 +6406,7 @@ private:
         // https://bugs.webkit.org/show_bug.cgi?id=174924
         ValueFromBlock char8Bit = m_out.anchor(
             m_out.load8ZeroExt32(m_out.baseIndex(
-                m_heaps.characters8, storage, m_out.zeroExtPtr(indexForAccess),
+                m_heaps.characters8, storage, m_out.zeroExtPtr(index),
                 provenValue(m_node->child2()))));
         m_out.jump(continuation);
             
@@ -6416,7 +6414,7 @@ private:
             
         ValueFromBlock char16Bit = m_out.anchor(
             m_out.load16ZeroExt32(m_out.baseIndex(
-                m_heaps.characters16, storage, m_out.zeroExtPtr(indexForAccess),
+                m_heaps.characters16, storage, m_out.zeroExtPtr(index),
                 provenValue(m_node->child2()))));
         m_out.jump(continuation);
         
index 49be95b..5f0e5c9 100644 (file)
@@ -633,7 +633,6 @@ static void stringCharLoad(SpecializedThunkJIT& jit, VM* vm)
     SpecializedThunkJIT::JumpList cont8Bit;
     // Load the string flags
     jit.loadPtr(MacroAssembler::Address(SpecializedThunkJIT::regT0, StringImpl::flagsOffset()), SpecializedThunkJIT::regT2);
-    jit.and32(MacroAssembler::Address(SpecializedThunkJIT::regT0, StringImpl::maskOffset()), SpecializedThunkJIT::regT1);
     jit.loadPtr(MacroAssembler::Address(SpecializedThunkJIT::regT0, StringImpl::dataOffset()), SpecializedThunkJIT::regT0);
     is16Bit.append(jit.branchTest32(MacroAssembler::Zero, SpecializedThunkJIT::regT2, MacroAssembler::TrustedImm32(StringImpl::flagIs8Bit())));
     jit.load8(MacroAssembler::BaseIndex(SpecializedThunkJIT::regT0, SpecializedThunkJIT::regT1, MacroAssembler::TimesOne, 0), SpecializedThunkJIT::regT0);
index 3386e99..82e81f3 100644 (file)
@@ -1,3 +1,43 @@
+2018-03-30  Filip Pizlo  <fpizlo@apple.com>
+
+        Strings and Vectors shouldn't do index masking
+        https://bugs.webkit.org/show_bug.cgi?id=184193
+
+        Reviewed by Mark Lam.
+
+        * 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::VectorBuffer::allocateBuffer):
+        (WTF::VectorBuffer::tryAllocateBuffer):
+        (WTF::VectorBuffer::swap):
+        (WTF::VectorBuffer::restoreInlineBufferIfNeeded):
+        (WTF::Vector::at):
+        (WTF::Vector::at const):
+        (WTF::VectorBufferBase::updateMask): Deleted.
+        * wtf/text/StringImpl.h:
+        (WTF::StringImpl::flagIsSymbol):
+        (WTF::StringImpl::length const):
+        (WTF::StringImplShape::StringImplShape):
+        (WTF::StringImpl::at const):
+        (WTF::StringImpl::tailOffset):
+        (WTF::StringImpl::maskOffset): Deleted.
+        (WTF::StringImpl::mask const): Deleted.
+        * 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::length const):
+        (WTF::String::mask const): Deleted.
+
 2018-03-30  Mark Lam  <mark.lam@apple.com>
 
         Add pointer profiling support in baseline JIT and supporting files.
index 8101412..b0ad140 100644 (file)
@@ -68,7 +68,6 @@ public:
     void* bufferPointer;
     unsigned capacity;
     unsigned size;
-    unsigned mask;
 };
 
 template<typename T>
index 3367559..f83af2e 100644 (file)
@@ -287,7 +287,6 @@ public:
             CRASH();
         size_t sizeToAllocate = newCapacity * sizeof(T);
         m_capacity = sizeToAllocate / sizeof(T);
-        updateMask();
         m_buffer = static_cast<T*>(Malloc::malloc(sizeToAllocate));
     }
 
@@ -302,7 +301,6 @@ public:
         if (!newBuffer)
             return false;
         m_capacity = sizeToAllocate / sizeof(T);
-        updateMask();
         m_buffer = newBuffer;
         return true;
     }
@@ -319,7 +317,6 @@ public:
             CRASH();
         size_t sizeToAllocate = newCapacity * sizeof(T);
         m_capacity = sizeToAllocate / sizeof(T);
-        updateMask();
         m_buffer = static_cast<T*>(Malloc::realloc(m_buffer, sizeToAllocate));
     }
 
@@ -331,7 +328,6 @@ public:
         if (m_buffer == bufferToDeallocate) {
             m_buffer = 0;
             m_capacity = 0;
-            m_mask = 0;
         }
 
         Malloc::free(bufferToDeallocate);
@@ -347,7 +343,6 @@ public:
         T* buffer = m_buffer;
         m_buffer = 0;
         m_capacity = 0;
-        m_mask = 0;
         return adoptMallocPtr(buffer);
     }
 
@@ -356,7 +351,6 @@ protected:
         : m_buffer(0)
         , m_capacity(0)
         , m_size(0)
-        , m_mask(0)
     {
     }
 
@@ -364,9 +358,7 @@ protected:
         : m_buffer(buffer)
         , m_capacity(capacity)
         , m_size(size)
-        , m_mask(0)
     {
-        updateMask();
     }
 
     ~VectorBufferBase()
@@ -374,15 +366,9 @@ protected:
         // FIXME: It would be nice to find a way to ASSERT that m_buffer hasn't leaked here.
     }
 
-    void updateMask()
-    {
-        m_mask = maskForSize(m_capacity);
-    }
-
     T* m_buffer;
     unsigned m_capacity;
     unsigned m_size; // Only used by the Vector subclass, but placed here to avoid padding the struct.
-    unsigned m_mask;
 };
 
 template<typename T, size_t inlineCapacity, typename Malloc>
@@ -415,7 +401,6 @@ public:
     {
         std::swap(m_buffer, other.m_buffer);
         std::swap(m_capacity, other.m_capacity);
-        std::swap(m_mask, other.m_mask);
     }
     
     void restoreInlineBufferIfNeeded() { }
@@ -440,7 +425,6 @@ public:
     using Base::releaseBuffer;
 
 protected:
-    using Base::m_mask;
     using Base::m_size;
 
 private:
@@ -479,7 +463,6 @@ public:
         else {
             m_buffer = inlineBuffer();
             m_capacity = inlineCapacity;
-            updateMask();
         }
     }
 
@@ -489,7 +472,6 @@ public:
             return Base::tryAllocateBuffer(newCapacity);
         m_buffer = inlineBuffer();
         m_capacity = inlineCapacity;
-        updateMask();
         return true;
     }
 
@@ -517,23 +499,19 @@ public:
         if (buffer() == inlineBuffer() && other.buffer() == other.inlineBuffer()) {
             swapInlineBuffer(other, mySize, otherSize);
             std::swap(m_capacity, other.m_capacity);
-            std::swap(m_mask, other.m_mask);
         } else if (buffer() == inlineBuffer()) {
             m_buffer = other.m_buffer;
             other.m_buffer = other.inlineBuffer();
             swapInlineBuffer(other, mySize, 0);
             std::swap(m_capacity, other.m_capacity);
-            std::swap(m_mask, other.m_mask);
         } else if (other.buffer() == other.inlineBuffer()) {
             other.m_buffer = m_buffer;
             m_buffer = inlineBuffer();
             swapInlineBuffer(other, 0, otherSize);
             std::swap(m_capacity, other.m_capacity);
-            std::swap(m_mask, other.m_mask);
         } else {
             std::swap(m_buffer, other.m_buffer);
             std::swap(m_capacity, other.m_capacity);
-            std::swap(m_mask, other.m_mask);
         }
     }
 
@@ -543,7 +521,6 @@ public:
             return;
         m_buffer = inlineBuffer();
         m_capacity = inlineCapacity;
-        updateMask();
     }
 
 #if ASAN_ENABLED
@@ -571,13 +548,11 @@ public:
     }
 
 protected:
-    using Base::m_mask;
     using Base::m_size;
 
 private:
     using Base::m_buffer;
     using Base::m_capacity;
-    using Base::updateMask;
     
     void swapInlineBuffer(VectorBuffer& other, size_t mySize, size_t otherSize)
     {
@@ -713,23 +688,23 @@ public:
     {
         if (UNLIKELY(i >= size()))
             OverflowHandler::overflowed();
-        return Base::buffer()[i & m_mask];
+        return Base::buffer()[i];
     }
     const T& at(size_t i) const 
     {
         if (UNLIKELY(i >= size()))
             OverflowHandler::overflowed();
-        return Base::buffer()[i & m_mask];
+        return Base::buffer()[i];
     }
     T& at(Checked<size_t> i)
     {
         RELEASE_ASSERT(i < size());
-        return Base::buffer()[i & m_mask];
+        return Base::buffer()[i];
     }
     const T& at(Checked<size_t> i) const
     {
         RELEASE_ASSERT(i < size());
-        return Base::buffer()[i & m_mask];
+        return Base::buffer()[i];
     }
 
     T& operator[](size_t i) { return at(i); }
@@ -873,7 +848,6 @@ private:
 
     void asanBufferSizeWillChangeTo(size_t);
 
-    using Base::m_mask;
     using Base::m_size;
     using Base::buffer;
     using Base::capacity;
index f8348d5..774876b 100644 (file)
@@ -48,7 +48,7 @@ namespace WTF {
 
 using namespace Unicode;
 
-static_assert(sizeof(StringImpl) == 2 * sizeof(int) + sizeof(void*) + 2 * sizeof(int), "StringImpl should stay small");
+static_assert(sizeof(StringImpl) == 2 * sizeof(int) + 2 * sizeof(void*), "StringImpl should stay small");
 
 #if STRING_STATS
 StringStats StringImpl::m_stringStats;
index 53a2158..616da25 100644 (file)
@@ -148,7 +148,6 @@ protected:
         const char16_t* m_data16Char;
     };
     mutable unsigned m_hashAndFlags;
-    unsigned m_mask;
 };
 
 // FIXME: Use of StringImpl and const is rather confused.
@@ -254,7 +253,6 @@ public:
     static unsigned flagIs8Bit() { return s_hashFlag8BitBuffer; }
     static unsigned flagIsAtomic() { return s_hashFlagStringKindIsAtomic; }
     static unsigned flagIsSymbol() { return s_hashFlagStringKindIsSymbol; }
-    static unsigned maskOffset() { return OBJECT_OFFSETOF(StringImpl, m_mask); }
     static unsigned maskStringKind() { return s_hashMaskStringKind; }
     static unsigned dataOffset() { return OBJECT_OFFSETOF(StringImpl, m_data8); }
 
@@ -265,7 +263,6 @@ public:
     WTF_EXPORT_PRIVATE static Ref<StringImpl> adopt(StringBuffer<LChar>&&);
 
     unsigned length() const { return m_length; }
-    unsigned mask() const { return m_mask; }
     static ptrdiff_t lengthMemoryOffset() { return OBJECT_OFFSETOF(StringImpl, m_length); }
     bool isEmpty() const { return !m_length; }
 
@@ -758,7 +755,6 @@ inline StringImplShape::StringImplShape(unsigned refCount, unsigned length, cons
     , m_length(length)
     , m_data8(data8)
     , m_hashAndFlags(hashAndFlags)
-    , m_mask(maskForSize(length))
 {
 }
 
@@ -767,7 +763,6 @@ inline StringImplShape::StringImplShape(unsigned refCount, unsigned length, cons
     , m_length(length)
     , m_data16(data16)
     , m_hashAndFlags(hashAndFlags)
-    , m_mask(maskForSize(length))
 {
 }
 
@@ -776,7 +771,6 @@ template<unsigned characterCount> inline constexpr StringImplShape::StringImplSh
     , m_length(length)
     , m_data8Char(characters)
     , m_hashAndFlags(hashAndFlags)
-    , m_mask(maskForSize(length))
 {
 }
 
@@ -785,7 +779,6 @@ template<unsigned characterCount> inline constexpr StringImplShape::StringImplSh
     , m_length(length)
     , m_data16Char(characters)
     , m_hashAndFlags(hashAndFlags)
-    , m_mask(maskForSize(length))
 {
 }
 
@@ -1078,7 +1071,7 @@ ALWAYS_INLINE void StringImpl::copyCharacters(UChar* destination, const LChar* s
 inline UChar StringImpl::at(unsigned i) const
 {
     ASSERT_WITH_SECURITY_IMPLICATION(i < m_length);
-    return is8Bit() ? m_data8[i & m_mask] : m_data16[i & m_mask];
+    return is8Bit() ? m_data8[i] : m_data16[i];
 }
 
 inline void StringImpl::assertCaged() const
@@ -1122,7 +1115,7 @@ template<typename T> inline size_t StringImpl::tailOffset()
     // MSVC doesn't support alignof yet.
     return roundUpToMultipleOf<sizeof(T)>(sizeof(StringImpl));
 #else
-    return roundUpToMultipleOf<alignof(T)>(offsetof(StringImpl, m_mask) + sizeof(StringImpl::m_mask));
+    return roundUpToMultipleOf<alignof(T)>(offsetof(StringImpl, m_hashAndFlags) + sizeof(StringImpl::m_hashAndFlags));
 #endif
 }
 
index f2601d5..822c65a 100644 (file)
@@ -159,8 +159,6 @@ private:
 
     void initialize(const LChar*, unsigned length);
     void initialize(const UChar*, unsigned length);
-    void initialize(const LChar*, unsigned length, unsigned mask);
-    void initialize(const UChar*, unsigned length, unsigned mask);
 
     template<typename CharacterType, typename MatchedCharacterPredicate>
     StringView stripLeadingAndTrailingMatchedCharacters(const CharacterType*, const MatchedCharacterPredicate&);
@@ -178,7 +176,6 @@ private:
 
     const void* m_characters { nullptr };
     unsigned m_length { 0 };
-    unsigned m_mask { 0 };
     bool m_is8Bit { true };
 
 #if CHECK_STRINGVIEW_LIFETIME
@@ -231,7 +228,6 @@ inline StringView::~StringView()
 inline StringView::StringView(StringView&& other)
     : m_characters(other.m_characters)
     , m_length(other.m_length)
-    , m_mask(other.m_mask)
     , m_is8Bit(other.m_is8Bit)
 {
     ASSERT(other.underlyingStringIsValid());
@@ -245,7 +241,6 @@ inline StringView::StringView(StringView&& other)
 inline StringView::StringView(const StringView& other)
     : m_characters(other.m_characters)
     , m_length(other.m_length)
-    , m_mask(other.m_mask)
     , m_is8Bit(other.m_is8Bit)
 {
     ASSERT(other.underlyingStringIsValid());
@@ -259,7 +254,6 @@ inline StringView& StringView::operator=(StringView&& other)
 
     m_characters = other.m_characters;
     m_length = other.m_length;
-    m_mask = other.m_mask;
     m_is8Bit = other.m_is8Bit;
 
     other.clear();
@@ -276,7 +270,6 @@ inline StringView& StringView::operator=(const StringView& other)
 
     m_characters = other.m_characters;
     m_length = other.m_length;
-    m_mask = other.m_mask;
     m_is8Bit = other.m_is8Bit;
 
     setUnderlyingString(other);
@@ -287,27 +280,15 @@ inline StringView& StringView::operator=(const StringView& other)
 
 inline void StringView::initialize(const LChar* characters, unsigned length)
 {
-    initialize(characters, length, maskForSize(length));
-}
-
-inline void StringView::initialize(const UChar* characters, unsigned length)
-{
-    initialize(characters, length, maskForSize(length));
-}
-
-inline void StringView::initialize(const LChar* characters, unsigned length, unsigned mask)
-{
     m_characters = characters;
     m_length = length;
-    m_mask = mask;
     m_is8Bit = true;
 }
 
-inline void StringView::initialize(const UChar* characters, unsigned length, unsigned mask)
+inline void StringView::initialize(const UChar* characters, unsigned length)
 {
     m_characters = characters;
     m_length = length;
-    m_mask = mask;
     m_is8Bit = false;
 }
 
@@ -330,9 +311,9 @@ inline StringView::StringView(const StringImpl& string)
 {
     setUnderlyingString(&string);
     if (string.is8Bit())
-        initialize(string.characters8(), string.length(), string.mask());
+        initialize(string.characters8(), string.length());
     else
-        initialize(string.characters16(), string.length(), string.mask());
+        initialize(string.characters16(), string.length());
 }
 
 inline StringView::StringView(const StringImpl* string)
@@ -342,9 +323,9 @@ inline StringView::StringView(const StringImpl* string)
 
     setUnderlyingString(string);
     if (string->is8Bit())
-        initialize(string->characters8(), string->length(), string->mask());
+        initialize(string->characters8(), string->length());
     else
-        initialize(string->characters16(), string->length(), string->mask());
+        initialize(string->characters16(), string->length());
 }
 
 inline StringView::StringView(const String& string)
@@ -355,10 +336,10 @@ inline StringView::StringView(const String& string)
         return;
     }
     if (string.is8Bit()) {
-        initialize(string.characters8(), string.length(), string.mask());
+        initialize(string.characters8(), string.length());
         return;
     }
-    initialize(string.characters16(), string.length(), string.mask());
+    initialize(string.characters16(), string.length());
 }
 
 inline StringView::StringView(const AtomicString& atomicString)
@@ -370,7 +351,6 @@ inline void StringView::clear()
 {
     m_characters = nullptr;
     m_length = 0;
-    m_mask = 0;
     m_is8Bit = true;
 }
 
@@ -459,8 +439,8 @@ inline UChar StringView::operator[](unsigned index) const
 {
     ASSERT(index < length());
     if (is8Bit())
-        return characters8()[index & m_mask];
-    return characters16()[index & m_mask];
+        return characters8()[index];
+    return characters16()[index];
 }
 
 inline bool StringView::contains(UChar character) const
index e11d2cb..b726608 100644 (file)
@@ -149,7 +149,6 @@ public:
     RefPtr<StringImpl> releaseImpl() { return WTFMove(m_impl); }
 
     unsigned length() const { return m_impl ? m_impl->length() : 0; }
-    unsigned mask() const { return m_impl ? m_impl->mask() : 0; }
     const LChar* characters8() const { return m_impl ? m_impl->characters8() : nullptr; }
     const UChar* characters16() const { return m_impl ? m_impl->characters16() : nullptr; }