[pypy-commit] pypy result-in-resops: (agaynor, fijal) in-progress

fijal noreply at buildbot.pypy.org
Sat Oct 27 20:17:10 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r58512:9967bfdae13e
Date: 2012-10-27 20:14 +0200
http://bitbucket.org/pypy/pypy/changeset/9967bfdae13e/

Log:	(agaynor, fijal) in-progress

diff --git a/pypy/jit/metainterp/optmodel.py b/pypy/jit/metainterp/optmodel.py
--- a/pypy/jit/metainterp/optmodel.py
+++ b/pypy/jit/metainterp/optmodel.py
@@ -7,6 +7,7 @@
      INT, REF, ConstInt, Const
 from pypy.jit.metainterp.optimizeopt.intutils import ImmutableIntUnbounded,\
      ConstantIntBound, IntBound
+from pypy.jit.metainterp.virtualmodel import declare_virtual
 
 class __extend__(ConstInt):
     def getintbound(self):
@@ -73,19 +74,12 @@
                 is_mutable = True
                 attributes_to_copy = []
 
-                if cls.getopnum() in (rop.NEW_WITH_VTABLE, rop.NEW):
-                    def force(self, optimizer):
-                        if not self._isforced:
-                            optimizer.emit_operation(self)
-                            self._isforced = True
-                        return self
-                    def is_virtual(self):
-                        return not self._isforced
-                else:
-                    def force(self, _):
-                        return self
-                    def is_virtual(self):
-                        return False
+                def force(self, _):
+                    return self
+                def is_virtual(self):
+                    return False
+            if op.getopnum() == rop.NEW_WITH_VTABLE:
+                Mutable = declare_virtual(Mutable)
             if cls.is_guard() or cls.getopnum() == rop.FINISH:
                 addattr(Mutable, 'failargs')
             if cls.is_guard():
diff --git a/pypy/jit/metainterp/virtualmodel.py b/pypy/jit/metainterp/virtualmodel.py
new file mode 100644
--- /dev/null
+++ b/pypy/jit/metainterp/virtualmodel.py
@@ -0,0 +1,12 @@
+
+def declare_virtual(cls):
+    class Virtual(cls):
+        def force(self, optimizer):
+            if not self._isforced:
+                optimizer.emit_operation(self)
+                self._isforced = True
+            return self
+        
+        def is_virtual(self):
+            return not self._isforced
+    return Virtual


More information about the pypy-commit mailing list