Changeset 176592 in webkit
- Timestamp:
- Dec 1, 2014, 9:50:35 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 29 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp (modified) (1 diff)
-
JavaScriptCore/bytecompiler/BytecodeGenerator.cpp (modified) (2 diffs)
-
JavaScriptCore/dfg/DFGSpeculativeJIT.cpp (modified) (1 diff)
-
JavaScriptCore/ftl/FTLAbbreviations.h (modified) (2 diffs)
-
JavaScriptCore/llint/LLIntData.cpp (modified) (1 diff)
-
JavaScriptCore/parser/Parser.h (modified) (1 diff)
-
JavaScriptCore/runtime/JSArray.cpp (modified) (2 diffs)
-
JavaScriptCore/tools/ProfileTreeNode.h (modified) (1 diff)
-
JavaScriptCore/yarr/YarrJIT.cpp (modified) (1 diff)
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/WTF.vcxproj/WTF.vcxproj (modified) (1 diff)
-
WTF/WTF.vcxproj/WTF.vcxproj.filters (modified) (1 diff)
-
WTF/WTF.xcodeproj/project.pbxproj (modified) (4 diffs)
-
WTF/wtf/IndexedIterator.h (added)
-
WTF/wtf/RefCountedArray.h (modified) (1 diff)
-
WTF/wtf/Vector.h (modified) (31 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/bindings/js/SerializedScriptValue.cpp (modified) (1 diff)
-
WebCore/editing/TextIterator.cpp (modified) (1 diff)
-
WebCore/page/mac/ServicesOverlayController.mm (modified) (1 diff)
-
WebCore/platform/graphics/SegmentedFontData.cpp (modified) (3 diffs)
-
WebCore/platform/graphics/WOFFFileFormat.cpp (modified) (1 diff)
-
WebCore/platform/graphics/cairo/GradientCairo.cpp (modified) (1 diff)
-
WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp (modified) (3 diffs)
-
WebCore/rendering/RenderBox.cpp (modified) (1 diff)
-
WebCore/rendering/style/GridResolvedPosition.cpp (modified) (2 diffs)
-
WebCore/svg/SVGFontElement.cpp (modified) (2 diffs)
-
WebCore/svg/SVGPathByteStream.h (modified) (1 diff)
-
WebCore/xml/XPathNodeSet.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r176583 r176592 1 2014-11-17 Oliver Hunt <oliver@apple.com> 2 3 Make sure range based iteration of Vector<> still receives bounds checking 4 https://bugs.webkit.org/show_bug.cgi?id=138821 5 6 Reviewed by Mark Lam. 7 8 There are a few uses of begin()/end() that explicitly require pointers, 9 so we use getPtr() to extract the underlying pointer generically. 10 11 * bytecode/UnlinkedCodeBlock.cpp: 12 (JSC::UnlinkedCodeBlock::visitChildren): 13 * bytecompiler/BytecodeGenerator.cpp: 14 (JSC::BytecodeGenerator::emitComplexPopScopes): 15 * dfg/DFGSpeculativeJIT.cpp: 16 (JSC::DFG::SpeculativeJIT::emitSwitchIntJump): 17 * ftl/FTLAbbreviations.h: 18 (JSC::FTL::mdNode): 19 (JSC::FTL::buildCall): 20 * llint/LLIntData.cpp: 21 (JSC::LLInt::Data::performAssertions): 22 * parser/Parser.h: 23 (JSC::Scope::Scope): 24 * profiler/ProfileNode.cpp: 25 (JSC::ProfileNode::debugPrintRecursively): 26 * runtime/JSArray.cpp: 27 (JSC::JSArray::setLengthWithArrayStorage): 28 (JSC::JSArray::sortCompactedVector): 29 * tools/ProfileTreeNode.h: 30 (JSC::ProfileTreeNode::dumpInternal): 31 * yarr/YarrJIT.cpp: 32 (JSC::Yarr::YarrGenerator::matchCharacterClass): 33 1 34 2014-11-29 Andreas Kling <akling@apple.com> 2 35 -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r172820 r176592 235 235 visitor.append(&thisObject->m_symbolTable); 236 236 for (FunctionExpressionVector::iterator ptr = thisObject->m_functionDecls.begin(), end = thisObject->m_functionDecls.end(); ptr != end; ++ptr) 237 visitor.append( ptr);237 visitor.append(WTF::getPtr(ptr)); 238 238 for (FunctionExpressionVector::iterator ptr = thisObject->m_functionExprs.begin(), end = thisObject->m_functionExprs.end(); ptr != end; ++ptr) 239 visitor.append( ptr);239 visitor.append(WTF::getPtr(ptr)); 240 240 visitor.appendValues(thisObject->m_constantRegisters.data(), thisObject->m_constantRegisters.size()); 241 241 if (thisObject->m_rareData) { -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r176479 r176592 2272 2272 int bottomScopeIndex = -1; 2273 2273 if (flipScopes) { 2274 topScopeIndex = topScope - m_scopeContextStack. begin();2275 bottomScopeIndex = bottomScope - m_scopeContextStack. begin();2274 topScopeIndex = topScope - m_scopeContextStack.data(); 2275 bottomScopeIndex = bottomScope - m_scopeContextStack.data(); 2276 2276 savedScopeContextStack = m_scopeContextStack; 2277 2277 m_scopeContextStack.shrink(finallyContext.scopeContextStackSize); … … 2317 2317 m_scopeContextStack = savedScopeContextStack; 2318 2318 topScope = &m_scopeContextStack[topScopeIndex]; // assert it's within bounds 2319 bottomScope = m_scopeContextStack. begin() + bottomScopeIndex; // don't assert, since it the index might be -1.2319 bottomScope = m_scopeContextStack.data() + bottomScopeIndex; // don't assert, since it the index might be -1. 2320 2320 } 2321 2321 if (flipSwitches) -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
r176109 r176592 4911 4911 m_jit.branch32(JITCompiler::AboveOrEqual, value, Imm32(table.ctiOffsets.size())), 4912 4912 data->fallThrough.block); 4913 m_jit.move(TrustedImmPtr(table.ctiOffsets. begin()), scratch);4913 m_jit.move(TrustedImmPtr(table.ctiOffsets.data()), scratch); 4914 4914 m_jit.loadPtr(JITCompiler::BaseIndex(scratch, value, JITCompiler::timesPtr()), scratch); 4915 4915 m_jit.jump(scratch); -
trunk/Source/JavaScriptCore/ftl/FTLAbbreviations.h
r172648 r176592 121 121 static inline LValue mdNode(LContext context, LValue* args, unsigned numArgs) { return llvm->MDNodeInContext(context, args, numArgs); } 122 122 template<typename VectorType> 123 static inline LValue mdNode(LContext context, const VectorType& vector) { return mdNode(context, const_cast<LValue*>(vector. begin()), vector.size()); }123 static inline LValue mdNode(LContext context, const VectorType& vector) { return mdNode(context, const_cast<LValue*>(vector.data()), vector.size()); } 124 124 static inline LValue mdNode(LContext context) { return mdNode(context, 0, 0); } 125 125 static inline LValue mdNode(LContext context, LValue arg1) { return mdNode(context, &arg1, 1); } … … 289 289 inline LValue buildCall(LBuilder builder, LValue function, const VectorType& vector) 290 290 { 291 return buildCall(builder, function, vector. begin(), vector.size());291 return buildCall(builder, function, vector.data(), vector.size()); 292 292 } 293 293 static inline LValue buildCall(LBuilder builder, LValue function) -
trunk/Source/JavaScriptCore/llint/LLIntData.cpp
r174226 r176592 162 162 testVector.resize(42); 163 163 ASSERT(bitwise_cast<uint32_t*>(&testVector)[sizeof(void*)/sizeof(uint32_t) + 1] == 42); 164 ASSERT(bitwise_cast<int**>(&testVector)[0] == testVector. begin());164 ASSERT(bitwise_cast<int**>(&testVector)[0] == testVector.data()); 165 165 #endif 166 166 -
trunk/Source/JavaScriptCore/parser/Parser.h
r175396 r176592 131 131 if (rhs.m_labels) { 132 132 m_labels = adoptPtr(new LabelStack); 133 134 typedef LabelStack::const_iterator iterator; 135 iterator end = rhs.m_labels->end(); 136 for (iterator it = rhs.m_labels->begin(); it != end; ++it) 137 m_labels->append(ScopeLabelInfo(it->m_ident, it->m_isLoop)); 133 for (auto label : *rhs.m_labels) 134 m_labels->append(ScopeLabelInfo(label.m_ident, label.m_isLoop)); 138 135 } 139 136 } -
trunk/Source/JavaScriptCore/runtime/JSArray.cpp
r173370 r176592 353 353 // delete values in any order. 354 354 if (map->sparseMode()) { 355 qsort(keys. begin(), keys.size(), sizeof(unsigned), compareKeysForQSort);355 qsort(keys.data(), keys.size(), sizeof(unsigned), compareKeysForQSort); 356 356 unsigned i = keys.size(); 357 357 while (i) { … … 1192 1192 #if HAVE(MERGESORT) 1193 1193 if (isSortingPrimitiveValues) 1194 qsort(values. begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort);1194 qsort(values.data(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort); 1195 1195 else 1196 mergesort(values. begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort);1196 mergesort(values.data(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort); 1197 1197 #else 1198 1198 // FIXME: The qsort library function is likely to not be a stable sort. 1199 1199 // ECMAScript-262 does not specify a stable sort, but in practice, browsers perform a stable sort. 1200 qsort(values. begin(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort);1200 qsort(values.data(), values.size(), sizeof(ValueStringPair), compareByStringPairForQSort); 1201 1201 #endif 1202 1202 -
trunk/Source/JavaScriptCore/tools/ProfileTreeNode.h
r156438 r176592 87 87 for (Map::iterator it = m_children->begin(); it != m_children->end(); ++it) 88 88 entries.append(&*it); 89 qsort(entries. begin(), entries.size(), sizeof(MapEntry*), compareEntries);89 qsort(entries.data(), entries.size(), sizeof(MapEntry*), compareEntries); 90 90 91 91 // Iterate over the children in sample-frequency order. -
trunk/Source/JavaScriptCore/yarr/YarrJIT.cpp
r170876 r176592 224 224 unsigned matchIndex = 0; 225 225 JumpList failures; 226 matchCharacterClassRange(character, failures, matchDest, charClass->m_ranges. begin(), charClass->m_ranges.size(), &matchIndex, charClass->m_matches.begin(), charClass->m_matches.size());226 matchCharacterClassRange(character, failures, matchDest, charClass->m_ranges.data(), charClass->m_ranges.size(), &matchIndex, charClass->m_matches.data(), charClass->m_matches.size()); 227 227 while (matchIndex < charClass->m_matches.size()) 228 228 matchDest.append(branch32(Equal, character, Imm32((unsigned short)charClass->m_matches[matchIndex++]))); -
trunk/Source/WTF/ChangeLog
r176589 r176592 1 2014-11-17 Oliver Hunt <oliver@apple.com> 2 3 Make sure range based iteration of Vector<> still receives bounds checking 4 https://bugs.webkit.org/show_bug.cgi?id=138821 5 6 Reviewed by Mark Lam. 7 8 Add a new IndexedIterator struct to WTF that wraps a 9 Vector type and index to provide pointer like semantics 10 while still performing runtime bounds checking, even in 11 release builds. We store a simple index into the vector 12 which means that this iterator allows vector resizing 13 during iteration. If the vector is resized such that the 14 iterator is out of bounds, then any attempt to dereference 15 the iterator will crash safely. Any other errors, including 16 overflows, and over extending the iterator will likewise 17 crash. 18 19 For the purpose of retaining semantically equivalent 20 behaviour, the iterator can be moved to m_index == size() 21 as that is the standard "end" terminator for these types. 22 Attempting to dereference at that point will still crash 23 rather than perform an unsafe memory operation. 24 25 In order to maintain the validity of all the bounds checking, 26 we perform full integer range checking prior to any mutation 27 of the iterator location. If we detect an arithmetic overflow 28 we will crash rather than attempting to carry on. 29 30 By necessity there are many overrides for operator + and - as 31 we otherwise hit many different type promotion ambiguities when 32 performing arithmetic with iterators. These ambiguities are also 33 different for 32- vs. 64-bit, so duplicating the functions 34 and then forwarding to the core implementations that performed 35 the bounds checking and mutation seemed like the right call. 36 37 * WTF.xcodeproj/project.pbxproj: 38 * wtf/IndexedIterator.h: Added. 39 (WTF::IndexedIterator::IndexedIterator): 40 (WTF::IndexedIterator::operator->): 41 (WTF::IndexedIterator::operator*): 42 (WTF::IndexedIterator::get): 43 (WTF::IndexedIterator::operator++): 44 (WTF::IndexedIterator::operator--): 45 (WTF::IndexedIterator::operator UnspecifiedBoolType): 46 (WTF::IndexedIterator::operator+=): 47 (WTF::IndexedIterator::operator-=): 48 (WTF::IndexedIterator::operator+): 49 (WTF::IndexedIterator::operator-): 50 (WTF::IndexedIterator::operator=): 51 (WTF::IndexedIterator::operator==): 52 (WTF::IndexedIterator::operator!=): 53 (WTF::IndexedIterator::operator<): 54 (WTF::IndexedIterator::operator<=): 55 (WTF::IndexedIterator::operator>): 56 (WTF::IndexedIterator::operator>=): 57 (WTF::IndexedIterator::operator const_iterator): 58 (WTF::IndexedIterator::isSafeToCompare): 59 (WTF::IndexedIterator::unsafeGet): 60 (WTF::getPtr): 61 (WTF::operator-): 62 (WTF::operator==): 63 (WTF::operator!=): 64 (WTF::operator<=): 65 (WTF::operator>=): 66 (WTF::operator<): 67 (WTF::operator>): 68 (WTF::IndexedIteratorSelector::makeIterator): 69 (WTF::IndexedIteratorSelector::makeConstIterator): 70 * wtf/RefCountedArray.h: 71 (WTF::RefCountedArray::RefCountedArray): 72 * wtf/Vector.h: 73 (WTF::Vector::Vector): 74 (WTF::Vector::begin): 75 (WTF::Vector::end): 76 (WTF::OverflowHandler>::Vector): 77 (WTF::=): 78 (WTF::OverflowHandler>::fill): 79 (WTF::OverflowHandler>::expandCapacity): 80 (WTF::OverflowHandler>::tryExpandCapacity): 81 (WTF::OverflowHandler>::resize): 82 (WTF::OverflowHandler>::shrink): 83 (WTF::OverflowHandler>::grow): 84 (WTF::OverflowHandler>::reserveCapacity): 85 (WTF::OverflowHandler>::tryReserveCapacity): 86 (WTF::OverflowHandler>::shrinkCapacity): 87 (WTF::OverflowHandler>::append): 88 (WTF::OverflowHandler>::tryAppend): 89 (WTF::OverflowHandler>::appendSlowCase): 90 (WTF::OverflowHandler>::uncheckedAppend): 91 (WTF::OverflowHandler>::appendVector): 92 (WTF::OverflowHandler>::insert): 93 (WTF::OverflowHandler>::insertVector): 94 (WTF::OverflowHandler>::remove): 95 1 96 2014-11-30 Ryuan Choi <ryuan.choi@navercorp.com> 2 97 -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj
r175203 r176592 219 219 <ClInclude Include="..\wtf\HashTraits.h" /> 220 220 <ClInclude Include="..\wtf\HexNumber.h" /> 221 <ClInclude Include="..\wtf\IndexedIterator.h" /> 221 222 <ClInclude Include="..\wtf\IteratorAdaptors.h" /> 222 223 <ClInclude Include="..\wtf\IteratorRange.h" /> -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
r175203 r176592 466 466 </ClInclude> 467 467 <ClInclude Include="..\wtf\HexNumber.h"> 468 <Filter>wtf</Filter> 469 </ClInclude> 470 <ClInclude Include="..\wtf\IndexedIterator.h"> 468 471 <Filter>wtf</Filter> 469 472 </ClInclude> -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r175203 r176592 99 99 A748745317A0BDAE00FA04CB /* SixCharacterHash.h in Headers */ = {isa = PBXBuildFile; fileRef = A748745017A0BDAE00FA04CB /* SixCharacterHash.h */; }; 100 100 A748745417A0BDAE00FA04CB /* StringHashDumpContext.h in Headers */ = {isa = PBXBuildFile; fileRef = A748745117A0BDAE00FA04CB /* StringHashDumpContext.h */; }; 101 A7DC2F041A09A22D0072F4E3 /* IndexedIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = A7DC2F031A099DE30072F4E3 /* IndexedIterator.h */; }; 101 102 A7E643C617C5423B003BB16B /* Compression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E643C417C5423B003BB16B /* Compression.cpp */; }; 102 103 A7E643C717C5423B003BB16B /* Compression.h in Headers */ = {isa = PBXBuildFile; fileRef = A7E643C517C5423B003BB16B /* Compression.h */; }; … … 390 391 A748745017A0BDAE00FA04CB /* SixCharacterHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SixCharacterHash.h; sourceTree = "<group>"; }; 391 392 A748745117A0BDAE00FA04CB /* StringHashDumpContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringHashDumpContext.h; sourceTree = "<group>"; }; 393 A7DC2F031A099DE30072F4E3 /* IndexedIterator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IndexedIterator.h; sourceTree = "<group>"; }; 392 394 A7E643C417C5423B003BB16B /* Compression.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Compression.cpp; sourceTree = "<group>"; }; 393 395 A7E643C517C5423B003BB16B /* Compression.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Compression.h; sourceTree = "<group>"; }; … … 893 895 A8A4737A151A825B004123FF /* WTFThreadData.cpp */, 894 896 A8A4737B151A825B004123FF /* WTFThreadData.h */, 897 A7DC2F031A099DE30072F4E3 /* IndexedIterator.h */, 895 898 ); 896 899 path = wtf; … … 1066 1069 A8A4745E151A825B004123FF /* CharacterNames.h in Headers */, 1067 1070 A8A47394151A825B004123FF /* CheckedArithmetic.h in Headers */, 1071 A7DC2F041A09A22D0072F4E3 /* IndexedIterator.h in Headers */, 1068 1072 A8A47395151A825B004123FF /* CheckedBoolean.h in Headers */, 1069 1073 A8A4745F151A825B004123FF /* Collator.h in Headers */, -
trunk/Source/WTF/wtf/RefCountedArray.h
r159279 r176592 84 84 Header::fromPayload(m_data)->length = other.size(); 85 85 ASSERT(Header::fromPayload(m_data)->length == other.size()); 86 VectorTypeOperations<T>::uninitializedCopy( other.begin(), other.end(), m_data);86 VectorTypeOperations<T>::uninitializedCopy(getPtr(other.begin()), getPtr(other.end()), m_data); 87 87 } 88 88 -
trunk/Source/WTF/wtf/Vector.h
r176293 r176592 29 29 #include <wtf/CheckedArithmetic.h> 30 30 #include <wtf/FastMalloc.h> 31 #include <wtf/GetPtr.h> 32 #include <wtf/IndexedIterator.h> 31 33 #include <wtf/MallocPtr.h> 32 34 #include <wtf/Noncopyable.h> … … 555 557 WTF_MAKE_FAST_ALLOCATED; 556 558 private: 559 557 560 typedef VectorBuffer<T, inlineCapacity> Base; 558 561 typedef VectorTypeOperations<T> TypeOperations; 562 typedef IndexedIteratorSelector<Vector, OverflowHandler> IteratorSelector; 559 563 560 564 public: 561 565 typedef T ValueType; 562 566 563 typedef T* iterator; 564 typedef const T* const_iterator; 567 typedef typename IteratorSelector::iterator iterator; 568 typedef typename IteratorSelector::const_iterator const_iterator; 569 565 570 typedef std::reverse_iterator<iterator> reverse_iterator; 566 571 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; … … 575 580 { 576 581 if (begin()) 577 TypeOperations::initialize( begin(), end());582 TypeOperations::initialize(getPtr(begin()), getPtr(end())); 578 583 } 579 584 … … 582 587 { 583 588 if (begin()) 584 TypeOperations::uninitializedFill( begin(), end(), val);589 TypeOperations::uninitializedFill(getPtr(begin()), getPtr(end()), val); 585 590 } 586 591 … … 646 651 static ptrdiff_t dataMemoryOffset() { return Base::bufferMemoryOffset(); } 647 652 648 iterator begin() { return data(); }649 iterator end() { return begin() + m_size; }650 const_iterator begin() const { return data(); }651 const_iterator end() const { return begin() + m_size; }653 iterator begin() { return IteratorSelector::makeIterator(*this, data()); } 654 iterator end() { return begin() + size(); } 655 const_iterator begin() const { return IteratorSelector::makeConstIterator(*this, data()); } 656 const_iterator end() const { return begin() + size(); } 652 657 653 658 reverse_iterator rbegin() { return reverse_iterator(end()); } … … 684 689 void clear() { shrinkCapacity(0); } 685 690 691 void append(const_iterator, unsigned); 686 692 template<typename U> void append(const U*, unsigned); 687 693 template<typename U> void append(U&&); … … 747 753 { 748 754 if (begin()) 749 TypeOperations::uninitializedCopy( other.begin(), other.end(), begin());755 TypeOperations::uninitializedCopy(getPtr(other.begin()), getPtr(other.end()), getPtr(begin())); 750 756 } 751 757 … … 756 762 { 757 763 if (begin()) 758 TypeOperations::uninitializedCopy( other.begin(), other.end(), begin());764 TypeOperations::uninitializedCopy(getPtr(other.begin()), getPtr(other.end()), getPtr(begin())); 759 765 } 760 766 … … 773 779 } 774 780 775 std::copy( other.begin(), other.begin() + size(), begin());776 TypeOperations::uninitializedCopy( other.begin() + size(), other.end(), end());781 std::copy(getPtr(other.begin()), getPtr(other.begin() + size()), getPtr(begin())); 782 TypeOperations::uninitializedCopy(getPtr(other.begin() + size()), getPtr(other.end()), getPtr(end())); 777 783 m_size = other.size(); 778 784 … … 798 804 ASSERT(begin()); 799 805 } 800 801 std::copy( other.begin(), other.begin() + size(), begin());802 TypeOperations::uninitializedCopy( other.begin() + size(), other.end(), end());806 807 std::copy(getPtr(other.begin()), getPtr(other.begin() + size()), getPtr(begin())); 808 TypeOperations::uninitializedCopy(getPtr(other.begin() + size()), getPtr(other.end()), getPtr(end())); 803 809 m_size = other.size(); 804 810 … … 860 866 } 861 867 862 std::fill( begin(), end(), val);863 TypeOperations::uninitializedFill( end(), begin() + newSize, val);868 std::fill(getPtr(begin()), getPtr(end()), val); 869 TypeOperations::uninitializedFill(getPtr(end()), getPtr(begin()) + newSize, val); 864 870 m_size = newSize; 865 871 } … … 882 888 T* Vector<T, inlineCapacity, OverflowHandler>::expandCapacity(unsigned newMinCapacity, T* ptr) 883 889 { 884 if (ptr < begin() || ptr >= end()) {890 if (ptr < getPtr(begin()) || ptr >= getPtr(end())) { 885 891 expandCapacity(newMinCapacity); 886 892 return ptr; 887 893 } 888 unsigned index = ptr - begin();894 unsigned index = ptr - getPtr(begin()); 889 895 expandCapacity(newMinCapacity); 890 return begin() + index;896 return getPtr(begin()) + index; 891 897 } 892 898 … … 900 906 const T* Vector<T, inlineCapacity, OverflowHandler>::tryExpandCapacity(unsigned newMinCapacity, const T* ptr) 901 907 { 902 if (ptr < begin() || ptr >= end()) {908 if (ptr < getPtr(begin()) || ptr >= getPtr(end())) { 903 909 if (!tryExpandCapacity(newMinCapacity)) 904 910 return 0; 905 911 return ptr; 906 912 } 907 unsigned index = ptr - begin();913 unsigned index = ptr - getPtr(begin()); 908 914 if (!tryExpandCapacity(newMinCapacity)) 909 915 return 0; 910 return begin() + index;916 return getPtr(begin()) + index; 911 917 } 912 918 … … 922 928 { 923 929 if (size <= m_size) 924 TypeOperations::destruct( begin() + size, end());930 TypeOperations::destruct(getPtr(begin()) + size, getPtr(end())); 925 931 else { 926 932 if (size > capacity()) 927 933 expandCapacity(size); 928 934 if (begin()) 929 TypeOperations::initialize( end(), begin() + size);935 TypeOperations::initialize(getPtr(end()), getPtr(begin()) + size); 930 936 } 931 937 … … 944 950 { 945 951 ASSERT(size <= m_size); 946 TypeOperations::destruct( begin() + size, end());952 TypeOperations::destruct(getPtr(begin()) + size, getPtr(end())); 947 953 m_size = size; 948 954 } … … 955 961 expandCapacity(size); 956 962 if (begin()) 957 TypeOperations::initialize( end(), begin() + size);963 TypeOperations::initialize(getPtr(end()), getPtr(begin()) + size); 958 964 m_size = size; 959 965 } … … 964 970 if (newCapacity <= capacity()) 965 971 return; 966 T* oldBuffer = begin();967 T* oldEnd = end();972 T* oldBuffer = getPtr(begin()); 973 T* oldEnd = getPtr(end()); 968 974 Base::allocateBuffer(newCapacity); 969 975 ASSERT(begin()); 970 TypeOperations::move(oldBuffer, oldEnd, begin());976 TypeOperations::move(oldBuffer, oldEnd, getPtr(begin())); 971 977 Base::deallocateBuffer(oldBuffer); 972 978 } … … 977 983 if (newCapacity <= capacity()) 978 984 return true; 979 T* oldBuffer = begin();980 T* oldEnd = end();985 T* oldBuffer = getPtr(begin()); 986 T* oldEnd = getPtr(end()); 981 987 if (!Base::tryAllocateBuffer(newCapacity)) 982 988 return false; 983 989 ASSERT(begin()); 984 TypeOperations::move(oldBuffer, oldEnd, begin());990 TypeOperations::move(oldBuffer, oldEnd, getPtr(begin())); 985 991 Base::deallocateBuffer(oldBuffer); 986 992 return true; … … 1005 1011 shrink(newCapacity); 1006 1012 1007 T* oldBuffer = begin();1013 T* oldBuffer = getPtr(begin()); 1008 1014 if (newCapacity > 0) { 1009 1015 if (Base::shouldReallocateBuffer(newCapacity)) { … … 1012 1018 } 1013 1019 1014 T* oldEnd = end();1020 T* oldEnd = getPtr(end()); 1015 1021 Base::allocateBuffer(newCapacity); 1016 if ( begin() != oldBuffer)1017 TypeOperations::move(oldBuffer, oldEnd, begin());1022 if (getPtr(begin()) != oldBuffer) 1023 TypeOperations::move(oldBuffer, oldEnd, getPtr(begin())); 1018 1024 } 1019 1025 … … 1035 1041 if (newSize < m_size) 1036 1042 CRASH(); 1037 T* dest = end();1043 T* dest = getPtr(end()); 1038 1044 VectorCopier<std::is_trivial<T>::value, U>::uninitializedCopy(data, &data[dataSize], dest); 1039 1045 m_size = newSize; 1046 } 1047 1048 template<typename T, unsigned inlineCapacity, typename OverflowHandler> 1049 void Vector<T, inlineCapacity, OverflowHandler>::append(const_iterator data, unsigned dataSize) 1050 { 1051 append(getPtr(data), dataSize); 1040 1052 } 1041 1053 … … 1052 1064 if (newSize < m_size) 1053 1065 return false; 1054 T* dest = end();1066 T* dest = getPtr(end()); 1055 1067 VectorCopier<std::is_trivial<T>::value, U>::uninitializedCopy(data, &data[dataSize], dest); 1056 1068 m_size = newSize; … … 1062 1074 { 1063 1075 if (size() != capacity()) { 1064 new (NotNull, end()) T(std::forward<U>(value));1076 new (NotNull, getPtr(end())) T(std::forward<U>(value)); 1065 1077 ++m_size; 1066 1078 return; … … 1079 1091 ASSERT(begin()); 1080 1092 1081 new (NotNull, end()) T(std::forward<U>(*ptr));1093 new (NotNull, getPtr(end())) T(std::forward<U>(*ptr)); 1082 1094 ++m_size; 1083 1095 } … … 1092 1104 1093 1105 auto ptr = std::addressof(value); 1094 new (NotNull, end()) T(std::forward<U>(*ptr));1106 new (NotNull, getPtr(end())) T(std::forward<U>(*ptr)); 1095 1107 ++m_size; 1096 1108 } … … 1099 1111 inline void Vector<T, inlineCapacity, OverflowHandler>::appendVector(const Vector<U, otherCapacity>& val) 1100 1112 { 1101 append( val.begin(), val.size());1113 append(getPtr(val.begin()), val.size()); 1102 1114 } 1103 1115 … … 1113 1125 if (newSize < m_size) 1114 1126 CRASH(); 1115 T* spot = begin() + position;1116 TypeOperations::moveOverlapping(spot, end(), spot + dataSize);1127 T* spot = getPtr(begin()) + position; 1128 TypeOperations::moveOverlapping(spot, getPtr(end()), spot + dataSize); 1117 1129 VectorCopier<std::is_trivial<T>::value, U>::uninitializedCopy(data, &data[dataSize], spot); 1118 1130 m_size = newSize; … … 1130 1142 } 1131 1143 1132 T* spot = begin() + position;1133 TypeOperations::moveOverlapping(spot, end(), spot + 1);1144 T* spot = getPtr(begin()) + position; 1145 TypeOperations::moveOverlapping(spot, getPtr(end()), spot + 1); 1134 1146 new (NotNull, spot) T(std::forward<U>(*ptr)); 1135 1147 ++m_size; … … 1139 1151 inline void Vector<T, inlineCapacity, OverflowHandler>::insertVector(unsigned position, const Vector<U, c>& val) 1140 1152 { 1141 insert(position, val.begin(), val.size());1153 insert(position, getPtr(val.begin()), val.size()); 1142 1154 } 1143 1155 … … 1146 1158 { 1147 1159 ASSERT_WITH_SECURITY_IMPLICATION(position < size()); 1148 T* spot = begin() + position;1160 T* spot = getPtr(begin()) + position; 1149 1161 spot->~T(); 1150 TypeOperations::moveOverlapping(spot + 1, end(), spot);1162 TypeOperations::moveOverlapping(spot + 1, getPtr(end()), spot); 1151 1163 --m_size; 1152 1164 } … … 1157 1169 ASSERT_WITH_SECURITY_IMPLICATION(position <= size()); 1158 1170 ASSERT_WITH_SECURITY_IMPLICATION(position + length <= size()); 1159 T* beginSpot = begin() + position;1171 T* beginSpot = getPtr(begin()) + position; 1160 1172 T* endSpot = beginSpot + length; 1161 1173 TypeOperations::destruct(beginSpot, endSpot); 1162 TypeOperations::moveOverlapping(endSpot, end(), beginSpot);1174 TypeOperations::moveOverlapping(endSpot, getPtr(end()), beginSpot); 1163 1175 m_size -= length; 1164 1176 } -
trunk/Source/WebCore/ChangeLog
r176585 r176592 1 2014-11-17 Oliver Hunt <oliver@apple.com> 2 3 Make sure range based iteration of Vector<> still receives bounds checking 4 https://bugs.webkit.org/show_bug.cgi?id=138821 5 6 Reviewed by Mark Lam. 7 8 There are a few uses of begin()/end() that explicitly require pointers, 9 so we use getPtr() to extract the underlying pointer generically. 10 11 * bindings/js/SerializedScriptValue.cpp: 12 (WebCore::CloneDeserializer::deserializeString): 13 * editing/TextIterator.cpp: 14 (WebCore::SearchBuffer::isBadMatch): 15 * page/mac/ServicesOverlayController.mm: 16 (WebCore::ServicesOverlayController::buildSelectionHighlight): 17 * platform/graphics/SegmentedFontData.cpp: 18 (WebCore::SegmentedFontData::fontDataForCharacter): 19 (WebCore::SegmentedFontData::containsCharacter): 20 (WebCore::SegmentedFontData::isLoading): 21 * platform/graphics/WOFFFileFormat.cpp: 22 (WebCore::convertWOFFToSfnt): 23 * rendering/RenderBox.cpp: 24 (WebCore::RenderBox::paintFillLayers): 25 * rendering/style/GridResolvedPosition.cpp: 26 (WebCore::firstNamedGridLineBeforePosition): 27 (WebCore::GridResolvedPosition::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition): 28 * svg/SVGFontElement.cpp: 29 (WebCore::kerningForPairOfStringsAndGlyphs): 30 * svg/SVGPathByteStream.h: 31 (WebCore::SVGPathByteStream::append): 32 * xml/XPathNodeSet.h: 33 (WebCore::XPath::NodeSet::begin): 34 (WebCore::XPath::NodeSet::end): 35 1 36 2014-11-29 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 37 -
trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp
r174857 r176592 1438 1438 if (buffer.isEmpty()) 1439 1439 return String(); 1440 const uint8_t* ptr = buffer.begin();1441 const uint8_t* end = buffer.end();1440 const uint8_t* ptr = getPtr(buffer.begin()); 1441 const uint8_t* end = getPtr(buffer.end()); 1442 1442 uint32_t version; 1443 1443 if (!readLittleEndian(ptr, end, version) || version > CurrentVersion) -
trunk/Source/WebCore/editing/TextIterator.cpp
r176293 r176592 2074 2074 normalizeCharacters(match, matchLength, m_normalizedMatch); 2075 2075 2076 const UChar* a = m_normalizedTarget.begin();2077 const UChar* aEnd = m_normalizedTarget.end();2078 2079 const UChar* b = m_normalizedMatch.begin();2080 const UChar* bEnd = m_normalizedMatch.end();2076 const UChar* a = getPtr(m_normalizedTarget.begin()); 2077 const UChar* aEnd = getPtr(m_normalizedTarget.end()); 2078 2079 const UChar* b = getPtr(m_normalizedMatch.begin()); 2080 const UChar* bEnd = getPtr(m_normalizedMatch.end()); 2081 2081 2082 2082 while (true) { -
trunk/Source/WebCore/page/mac/ServicesOverlayController.mm
r176459 r176592 556 556 if (!cgRects.isEmpty()) { 557 557 CGRect visibleRect = mainFrameView->visibleContentRect(); 558 RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects. begin(), cgRects.size(), visibleRect, DDHighlightNoOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES));558 RetainPtr<DDHighlightRef> ddHighlight = adoptCF(DDHighlightCreateWithRectsInVisibleRectWithStyleAndDirection(nullptr, cgRects.data(), cgRects.size(), visibleRect, DDHighlightNoOutlineWithArrow, YES, NSWritingDirectionNatural, NO, YES)); 559 559 560 560 newPotentialHighlights.add(Highlight::createForSelection(*this, ddHighlight, selectionRange)); -
trunk/Source/WebCore/platform/graphics/SegmentedFontData.cpp
r165676 r176592 40 40 const SimpleFontData* SegmentedFontData::fontDataForCharacter(UChar32 c) const 41 41 { 42 Vector<FontDataRange>::const_iteratorend = m_ranges.end();43 for ( Vector<FontDataRange>::const_iteratorit = m_ranges.begin(); it != end; ++it) {42 auto end = m_ranges.end(); 43 for (auto it = m_ranges.begin(); it != end; ++it) { 44 44 if (it->from() <= c && it->to() >= c) 45 45 return it->fontData().get(); … … 50 50 bool SegmentedFontData::containsCharacter(UChar32 c) const 51 51 { 52 Vector<FontDataRange>::const_iteratorend = m_ranges.end();53 for ( Vector<FontDataRange>::const_iteratorit = m_ranges.begin(); it != end; ++it) {52 auto end = m_ranges.end(); 53 for (auto it = m_ranges.begin(); it != end; ++it) { 54 54 if (c >= it->from() && c <= it->to()) 55 55 return true; … … 77 77 bool SegmentedFontData::isLoading() const 78 78 { 79 Vector<FontDataRange>::const_iteratorend = m_ranges.end();80 for ( Vector<FontDataRange>::const_iteratorit = m_ranges.begin(); it != end; ++it) {79 auto end = m_ranges.end(); 80 for (auto it = m_ranges.begin(); it != end; ++it) { 81 81 if (it->fontData()->isLoading()) 82 82 return true; -
trunk/Source/WebCore/platform/graphics/WOFFFileFormat.cpp
r162875 r176592 201 201 if (!sfnt.tryReserveCapacity(sfnt.size() + tableOrigLength)) 202 202 return false; 203 Bytef* dest = reinterpret_cast<Bytef*>( sfnt.end());203 Bytef* dest = reinterpret_cast<Bytef*>(getPtr(sfnt.end())); 204 204 sfnt.grow(sfnt.size() + tableOrigLength); 205 205 if (uncompress(dest, &destLen, reinterpret_cast<const Bytef*>(woff->data() + tableOffset), tableCompLength) != Z_OK) -
trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp
r165676 r176592 60 60 m_gradient = cairo_pattern_create_linear(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y()); 61 61 62 Vector<ColorStop>::iteratorstopIterator = m_stops.begin();62 auto stopIterator = m_stops.begin(); 63 63 while (stopIterator != m_stops.end()) { 64 64 cairo_pattern_add_color_stop_rgba(m_gradient, stopIterator->stop, -
trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
r165676 r176592 146 146 // this case. 147 147 clearBeforeFrame = std::min(clearBeforeFrame, m_frameBufferCache.size() - 1); 148 const Vector<ImageFrame>::iterator end(m_frameBufferCache.begin() + clearBeforeFrame);148 const auto end = m_frameBufferCache.begin() + clearBeforeFrame; 149 149 150 150 // We need to preserve frames such that: … … 166 166 // has a disposal method other than DisposeOverwritePrevious, stop 167 167 // scanning, as we'll only need this frame when decoding the next one. 168 Vector<ImageFrame>::iterator i(end);168 auto i = end; 169 169 for (; (i != m_frameBufferCache.begin()) && ((i->status() == ImageFrame::FrameEmpty) || (i->disposalMethod() == ImageFrame::DisposeOverwritePrevious)); --i) { 170 170 if ((i->status() == ImageFrame::FrameComplete) && (i != end)) … … 173 173 174 174 // Now |i| holds the last frame we need to preserve; clear prior frames. 175 for ( Vector<ImageFrame>::iterator j(m_frameBufferCache.begin()); j != i; ++j) {175 for (auto j = m_frameBufferCache.begin(); j != i; ++j) { 176 176 ASSERT(j->status() != ImageFrame::FramePartial); 177 177 if (j->status() != ImageFrame::FrameEmpty) -
trunk/Source/WebCore/rendering/RenderBox.cpp
r176258 r176592 1578 1578 } 1579 1579 1580 Vector<const FillLayer*>::const_reverse_iteratortopLayer = layers.rend();1581 for ( Vector<const FillLayer*>::const_reverse_iteratorit = layers.rbegin(); it != topLayer; ++it)1580 auto topLayer = layers.rend(); 1581 for (auto it = layers.rbegin(); it != topLayer; ++it) 1582 1582 paintFillLayer(paintInfo, c, *it, rect, bleedAvoidance, op, backgroundObject, baseBgColorUsage); 1583 1583 -
trunk/Source/WebCore/rendering/style/GridResolvedPosition.cpp
r176390 r176592 296 296 // the side). 297 297 unsigned firstLineBeforePositionIndex = 0; 298 const unsigned*firstLineBeforePosition = std::lower_bound(gridLines.begin(), gridLines.end(), position);298 auto firstLineBeforePosition = std::lower_bound(gridLines.begin(), gridLines.end(), position); 299 299 if (firstLineBeforePosition != gridLines.end()) { 300 300 if (*firstLineBeforePosition > position && firstLineBeforePosition != gridLines.begin()) … … 317 317 std::unique_ptr<GridSpan> GridResolvedPosition::resolveRowEndColumnEndNamedGridLinePositionAgainstOppositePosition(const GridResolvedPosition& resolvedOppositePosition, const GridPosition& position, const Vector<unsigned>& gridLines) 318 318 { 319 ASSERT(gridLines.size());320 319 unsigned firstLineAfterOppositePositionIndex = gridLines.size() - 1; 321 const unsigned*firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition);320 auto firstLineAfterOppositePosition = std::upper_bound(gridLines.begin(), gridLines.end(), resolvedOppositePosition); 322 321 if (firstLineAfterOppositePosition != gridLines.end()) 323 322 firstLineAfterOppositePositionIndex = firstLineAfterOppositePosition - gridLines.begin(); -
trunk/Source/WebCore/svg/SVGFontElement.cpp
r173921 r176592 253 253 if (!g1.isEmpty() && kerningMap.glyphMap.contains(g1)) { 254 254 SVGKerningVector* kerningVector = kerningMap.glyphMap.get(g1); 255 SVGKerningVector::const_iterator it = kerningVector->end() - 1;256 const SVGKerningVector::const_iterator begin = kerningVector->begin() - 1;257 for (; it != begin; --it) {258 if (matches(u2, g2, *it))259 return it->kerning;255 size_t it = kerningVector->size(); 256 while (it-- > 0) { 257 auto& value = kerningVector->at(it); 258 if (matches(u2, g2, value)) 259 return value.kerning; 260 260 } 261 261 } … … 264 264 if (kerningMap.unicodeMap.contains(u1)) { 265 265 SVGKerningVector* kerningVector = kerningMap.unicodeMap.get(u1); 266 SVGKerningVector::const_iterator it = kerningVector->end() - 1;267 const SVGKerningVector::const_iterator begin = kerningVector->begin() - 1;268 for (; it != begin; --it) {269 if (matches(u2, g2, *it))270 return it->kerning;266 size_t it = kerningVector->size(); 267 while (it-- > 0) { 268 auto& value = kerningVector->at(it); 269 if (matches(u2, g2, value)) 270 return value.kerning; 271 271 } 272 272 } 273 273 274 274 if (!kerningMap.kerningUnicodeRangeMap.isEmpty()) { 275 Vector<SVGKerningPair>::const_iterator it = kerningMap.kerningUnicodeRangeMap.end() - 1;276 const Vector<SVGKerningPair>::const_iterator begin = kerningMap.kerningUnicodeRangeMap.begin() - 1;277 for (; it != begin; --it) {278 if (matches(u1, u2, g2, *it))279 return it->kerning;275 size_t it = kerningMap.kerningUnicodeRangeMap.size(); 276 while (it-- > 0) { 277 auto& value = kerningMap.kerningUnicodeRangeMap[it]; 278 if (matches(u1, u2, g2, value)) 279 return value.kerning; 280 280 } 281 281 } -
trunk/Source/WebCore/svg/SVGPathByteStream.h
r163440 r176592 61 61 void append(SVGPathByteStream* other) 62 62 { 63 for ( DataIterator it = other->begin(); it != other->end(); ++it)64 append( *it);63 for (auto& byte : *other) 64 append(byte); 65 65 } 66 66 void clear() { m_data.clear(); } -
trunk/Source/WebCore/xml/XPathNodeSet.h
r166120 r176592 65 65 bool subtreesAreDisjoint() const { return m_subtreesAreDisjoint || m_nodes.size() < 2; } 66 66 67 const RefPtr<Node>*begin() const { return m_nodes.begin(); }68 const RefPtr<Node>*end() const { return m_nodes.end(); }67 const Vector<RefPtr<Node>>::iterator begin() const { return m_nodes.begin(); } 68 const Vector<RefPtr<Node>>::iterator end() const { return m_nodes.end(); } 69 69 70 70 private:
Note:
See TracChangeset
for help on using the changeset viewer.