]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - runtime/BatchedTransitionOptimizer.h
JavaScriptCore-1218.34.tar.gz
[apple/javascriptcore.git] / runtime / BatchedTransitionOptimizer.h
index 13dd95c2e51293591cade73a27147b251405f7ae..76def713847dde7584839c4278cd9b6220f573f0 100644 (file)
 #ifndef BatchedTransitionOptimizer_h
 #define BatchedTransitionOptimizer_h
 
-#include <wtf/Noncopyable.h>
 #include "JSObject.h"
 
 namespace JSC {
 
-    class BatchedTransitionOptimizer : Noncopyable {
-    public:
-        BatchedTransitionOptimizer(JSObject* object)
-            : m_object(object)
-        {
-            if (!m_object->structure()->isDictionary())
-                m_object->setStructure(Structure::toDictionaryTransition(m_object->structure()));
-        }
-
-        ~BatchedTransitionOptimizer()
-        {
-            m_object->setStructure(Structure::fromDictionaryTransition(m_object->structure()));
-        }
-
-    private:
-        JSObject* m_object;
-    };
+class BatchedTransitionOptimizer {
+    WTF_MAKE_NONCOPYABLE(BatchedTransitionOptimizer);
+public:
+    BatchedTransitionOptimizer(VM& vm, JSObject* object)
+        : m_vm(&vm)
+        , m_object(object)
+    {
+    }
+
+    ~BatchedTransitionOptimizer()
+    {
+        if (m_object->structure()->isDictionary())
+            m_object->flattenDictionaryObject(*m_vm);
+    }
+
+private:
+    VM* m_vm;
+    JSObject* m_object;
+};
 
 } // namespace JSC