DFG::DesiredWatchpoints should accept WatchpointSetType's that aren't necessarily...
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jul 2015 06:41:25 +0000 (06:41 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Jul 2015 06:41:25 +0000 (06:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146875

Reviewed by Dan Bernstein.

In the future we'll want to add a desired watchpoint set that's something like "please
watch property 'Foo' for 'deletion' on structure 'S1'", so that the "set type" is struct
like "struct MySet { StringImpl* property; Mode mode; Structure* structure };".

This is a very mechanical change for now - all of the current users happen to use sets
that are pointer typed, so it's just a matter of moving some "*"'s around.

* dfg/DFGDesiredWatchpoints.h:
(JSC::DFG::GenericSetAdaptor::add):
(JSC::DFG::GenericSetAdaptor::hasBeenInvalidated):
(JSC::DFG::GenericDesiredWatchpoints::GenericDesiredWatchpoints):
(JSC::DFG::GenericDesiredWatchpoints::addLazily):
(JSC::DFG::GenericDesiredWatchpoints::reallyAdd):
(JSC::DFG::GenericDesiredWatchpoints::areStillValid):
(JSC::DFG::GenericDesiredWatchpoints::isWatched):
(JSC::DFG::DesiredWatchpoints::isWatched):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGDesiredWatchpoints.h

index d54f2d4..eada298 100644 (file)
@@ -1,5 +1,29 @@
 2015-07-10  Filip Pizlo  <fpizlo@apple.com>
 
+        DFG::DesiredWatchpoints should accept WatchpointSetType's that aren't necessarily pointers
+        https://bugs.webkit.org/show_bug.cgi?id=146875
+
+        Reviewed by Dan Bernstein.
+        
+        In the future we'll want to add a desired watchpoint set that's something like "please
+        watch property 'Foo' for 'deletion' on structure 'S1'", so that the "set type" is struct
+        like "struct MySet { StringImpl* property; Mode mode; Structure* structure };".
+        
+        This is a very mechanical change for now - all of the current users happen to use sets
+        that are pointer typed, so it's just a matter of moving some "*"'s around.
+
+        * dfg/DFGDesiredWatchpoints.h:
+        (JSC::DFG::GenericSetAdaptor::add):
+        (JSC::DFG::GenericSetAdaptor::hasBeenInvalidated):
+        (JSC::DFG::GenericDesiredWatchpoints::GenericDesiredWatchpoints):
+        (JSC::DFG::GenericDesiredWatchpoints::addLazily):
+        (JSC::DFG::GenericDesiredWatchpoints::reallyAdd):
+        (JSC::DFG::GenericDesiredWatchpoints::areStillValid):
+        (JSC::DFG::GenericDesiredWatchpoints::isWatched):
+        (JSC::DFG::DesiredWatchpoints::isWatched):
+
+2015-07-10  Filip Pizlo  <fpizlo@apple.com>
+
         Watchpoints should be allocated with FastMalloc
         https://bugs.webkit.org/show_bug.cgi?id=146874
 
index bbd63bc..e970526 100644 (file)
 #include "InferredValue.h"
 #include "JSArrayBufferView.h"
 #include "Watchpoint.h"
-#include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
 
 namespace JSC { namespace DFG {
 
@@ -44,11 +41,11 @@ class Graph;
 
 template<typename T>
 struct GenericSetAdaptor {
-    static void add(CodeBlock*, T* set, Watchpoint* watchpoint)
+    static void add(CodeBlock*, T set, Watchpoint* watchpoint)
     {
         return set->add(watchpoint);
     }
-    static bool hasBeenInvalidated(T* set) { return set->hasBeenInvalidated(); }
+    static bool hasBeenInvalidated(T set) { return set->hasBeenInvalidated(); }
 };
 
 struct InferredValueAdaptor {
@@ -72,7 +69,7 @@ struct ArrayBufferViewWatchpointAdaptor {
 template<typename WatchpointSetType, typename Adaptor = GenericSetAdaptor<WatchpointSetType>>
 class GenericDesiredWatchpoints {
 #if !ASSERT_DISABLED
-    typedef HashMap<WatchpointSetType*, bool> StateMap;
+    typedef HashMap<WatchpointSetType, bool> StateMap;
 #endif
 public:
     GenericDesiredWatchpoints()
@@ -80,7 +77,7 @@ public:
     {
     }
     
-    void addLazily(WatchpointSetType* set)
+    void addLazily(const WatchpointSetType& set)
     {
         m_sets.add(set);
     }
@@ -89,33 +86,29 @@ public:
     {
         RELEASE_ASSERT(!m_reallyAdded);
         
-        typename HashSet<WatchpointSetType*>::iterator iter = m_sets.begin();
-        typename HashSet<WatchpointSetType*>::iterator end = m_sets.end();
-        for (; iter != end; ++iter)
-            Adaptor::add(codeBlock, *iter, common.watchpoints.add(codeBlock));
+        for (auto& set : m_sets)
+            Adaptor::add(codeBlock, set, common.watchpoints.add(codeBlock));
         
         m_reallyAdded = true;
     }
     
     bool areStillValid() const
     {
-        typename HashSet<WatchpointSetType*>::iterator iter = m_sets.begin();
-        typename HashSet<WatchpointSetType*>::iterator end = m_sets.end();
-        for (; iter != end; ++iter) {
-            if (Adaptor::hasBeenInvalidated(*iter))
+        for (auto& set : m_sets) {
+            if (Adaptor::hasBeenInvalidated(set))
                 return false;
         }
         
         return true;
     }
     
-    bool isWatched(WatchpointSetType* set) const
+    bool isWatched(const WatchpointSetType& set) const
     {
         return m_sets.contains(set);
     }
 
 private:
-    HashSet<WatchpointSetType*> m_sets;
+    HashSet<WatchpointSetType> m_sets;
     bool m_reallyAdded;
 };
 
@@ -153,10 +146,10 @@ public:
     }
     
 private:
-    GenericDesiredWatchpoints<WatchpointSet> m_sets;
-    GenericDesiredWatchpoints<InlineWatchpointSet> m_inlineSets;
-    GenericDesiredWatchpoints<InferredValue, InferredValueAdaptor> m_inferredValues;
-    GenericDesiredWatchpoints<JSArrayBufferView, ArrayBufferViewWatchpointAdaptor> m_bufferViews;
+    GenericDesiredWatchpoints<WatchpointSet*> m_sets;
+    GenericDesiredWatchpoints<InlineWatchpointSet*> m_inlineSets;
+    GenericDesiredWatchpoints<InferredValue*, InferredValueAdaptor> m_inferredValues;
+    GenericDesiredWatchpoints<JSArrayBufferView*, ArrayBufferViewWatchpointAdaptor> m_bufferViews;
 };
 
 } } // namespace JSC::DFG