Changeset 202795 in webkit
- Timestamp:
- Jul 3, 2016 2:36:48 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r202792 r202795 1 2016-07-03 Saam Barati <sbarati@apple.com> 2 3 BytecodeGenerator::getVariablesUnderTDZ is too conservative 4 https://bugs.webkit.org/show_bug.cgi?id=159387 5 6 Reviewed by Filip Pizlo. 7 8 We were too conservative in the following type of programs: 9 ``` 10 { 11 { 12 let x; 13 ... 14 } 15 let x; 16 } 17 ``` 18 We used to report "x" as under TDZ when calling getVariablesUnderTDZ at the 19 "...", even though "x" is not under TDZ. This patch removes this conservatism 20 and makes the algorithm precise. 21 22 * bytecompiler/BytecodeGenerator.cpp: 23 (JSC::BytecodeGenerator::getVariablesUnderTDZ): 24 * bytecompiler/BytecodeGenerator.h: 25 1 26 2016-07-03 Filip Pizlo <fpizlo@apple.com> 2 27 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r202778 r202795 47 47 #include "UnlinkedInstructionStream.h" 48 48 #include <wtf/CommaPrinter.h> 49 #include <wtf/SmallPtrSet.h> 49 50 #include <wtf/StdLibExtras.h> 50 51 #include <wtf/text/WTFString.h> … … 2792 2793 void BytecodeGenerator::getVariablesUnderTDZ(VariableEnvironment& result) 2793 2794 { 2794 // NOTE: This is conservative. If called at "...", it will report "x" as being under TDZ: 2795 // We keep track of variablesThatDontNeedTDZ in this algorithm to prevent 2796 // reporting that "x" is under TDZ if this function is called at "...". 2795 2797 // 2796 2798 // { … … 2802 2804 // } 2803 2805 // 2804 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=159387 2805 for (auto& map : m_TDZStack) { 2806 SmallPtrSet<UniquedStringImpl*, 16> variablesThatDontNeedTDZ; 2807 for (unsigned i = m_TDZStack.size(); i--; ) { 2808 auto& map = m_TDZStack[i]; 2806 2809 for (auto& entry : map) { 2807 if (entry.value != TDZNecessityLevel::NotNeeded) 2808 result.add(entry.key.get()); 2810 if (entry.value != TDZNecessityLevel::NotNeeded) { 2811 if (!variablesThatDontNeedTDZ.contains(entry.key.get())) 2812 result.add(entry.key.get()); 2813 } else 2814 variablesThatDontNeedTDZ.add(entry.key.get()); 2809 2815 } 2810 2816 } -
trunk/Source/WTF/ChangeLog
r202791 r202795 1 2016-07-03 Saam Barati <sbarati@apple.com> 2 3 BytecodeGenerator::getVariablesUnderTDZ is too conservative 4 https://bugs.webkit.org/show_bug.cgi?id=159387 5 6 Reviewed by Filip Pizlo. 7 8 I've templatized SmallPtrSet on its SmallArraySize instead 9 of it always being 8. 10 11 * wtf/SmallPtrSet.h: 12 (WTF::SmallPtrSet::SmallPtrSet): 13 (WTF::SmallPtrSet::add): 14 (WTF::SmallPtrSet::iterator::operator!=): 15 (WTF::SmallPtrSet::bucket): 16 1 17 2016-07-03 Filip Pizlo <fpizlo@apple.com> 2 18 -
trunk/Source/WTF/wtf/SmallPtrSet.h
r200380 r202795 34 34 namespace WTF { 35 35 36 template<typename PtrType >36 template<typename PtrType, unsigned SmallArraySize = 8> 37 37 class SmallPtrSet { 38 38 WTF_MAKE_NONCOPYABLE(SmallPtrSet); 39 39 static_assert(std::is_trivially_destructible<PtrType>::value, "We currently don't support non-trivially destructible pointer types."); 40 40 static_assert(sizeof(PtrType) == sizeof(void*), "Only support pointer sized things."); 41 static_assert(!(SmallArraySize & (SmallArraySize - 1)), "Inline size must be a power of two."); 41 42 42 43 public: … … 91 92 } 92 93 93 grow( 64);94 grow(std::max(64u, SmallArraySize * 2)); 94 95 // Fall through. We're no longer small :( 95 96 } … … 139 140 140 141 private: 141 template<typename U > friend class WTF::SmallPtrSet;142 template<typename U, unsigned S> friend class WTF::SmallPtrSet; 142 143 unsigned m_index; 143 144 unsigned m_capacity; … … 240 241 } 241 242 242 static const unsigned SmallArraySize = 8;243 244 243 unsigned m_size; 245 244 unsigned m_capacity;
Note: See TracChangeset
for help on using the changeset viewer.