Author: fijal
Branch: jit-leaner-frontend
Changeset: r82772:1d9927b12845
Date: 2016-03-04 18:46 +0200
http://bitbucket.org/pypy/pypy/changeset/1d9927b12845/

Log:    kill special casing of ESCAPE and FORCE_SPILL and make them normal
        classes, pass most of test_optimizebasic

diff --git a/rpython/jit/metainterp/executor.py 
b/rpython/jit/metainterp/executor.py
--- a/rpython/jit/metainterp/executor.py
+++ b/rpython/jit/metainterp/executor.py
@@ -385,6 +385,11 @@
                          rop.CALL_MALLOC_NURSERY_VARSIZE_FRAME,
                          rop.NURSERY_PTR_INCREMENT,
                          rop.LABEL,
+                         rop.ESCAPE_I,
+                         rop.ESCAPE_N,
+                         rop.ESCAPE_R,
+                         rop.ESCAPE_F,
+                         rop.FORCE_SPILL,
                          rop.SAVE_EXC_CLASS,
                          rop.SAVE_EXCEPTION,
                          rop.RESTORE_EXCEPTION,
diff --git a/rpython/jit/metainterp/opencoder.py 
b/rpython/jit/metainterp/opencoder.py
--- a/rpython/jit/metainterp/opencoder.py
+++ b/rpython/jit/metainterp/opencoder.py
@@ -134,7 +134,9 @@
 
     def _encode(self, box):
         if isinstance(box, Const):
-            if isinstance(box, ConstInt) and 0 <= box.getint() < MAXINT:
+            if (isinstance(box, ConstInt) and
+                isinstance(box.getint(), int) and # symbolics
+                0 <= box.getint() < MAXINT):
                 return tag(TAGINT, box.getint())
             else:
                 self._consts.append(box)
@@ -189,6 +191,7 @@
     def record_op(self, opnum, argboxes, descr=None):
         # return an ResOperation instance, ideally die in hell
         pos = self._record_op(opnum, argboxes, descr)
+        assert opnum >= 0
         return ResOperation(opnum, argboxes, pos, descr)
 
     def record_op_tag(self, opnum, tagged_args, descr=None):
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -56,13 +56,13 @@
         arg0 = op.getarg(0)
         arg1 = op.getarg(1)
         if oldopnum != -1:
-            top = ResOperation(oldopnum, [arg0, arg1], None)
+            top = ResOperation(oldopnum, [arg0, arg1], -1)
             if self.try_boolinvers(op, top):
                 return True
 
         oldopnum = op.boolreflex # FIXME: add INT_ADD, INT_MUL
         if oldopnum != -1:
-            top = ResOperation(oldopnum, [arg1, arg0], None)
+            top = ResOperation(oldopnum, [arg1, arg0], -1)
             oldop = self.get_pure_result(top)
             if oldop is not None:
                 self.optimizer.make_equal_to(op, oldop)
@@ -72,7 +72,7 @@
             return False
         oldopnum = opclasses[op.boolreflex].boolinverse
         if oldopnum != -1:
-            top = ResOperation(oldopnum, [arg1, arg0], None)
+            top = ResOperation(oldopnum, [arg1, arg0], -1)
             if self.try_boolinvers(op, top):
                 return True
 
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_util.py 
b/rpython/jit/metainterp/optimizeopt/test/test_util.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_util.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_util.py
@@ -557,7 +557,7 @@
         from rpython.jit.metainterp.opencoder import Trace
         trace = Trace(loop.inputargs)
         for op in loop.operations:
-            newop = trace.record_op(op.getopnum(), op.getarglist())
+            newop = trace.record_op(op.getopnum(), op.getarglist(), 
op.getdescr())
             if rop.is_guard(op.getopnum()):
                 frame = FakeFrame(op.getfailargs())
                 resume.capture_resumedata([frame], None, [], trace)
diff --git a/rpython/jit/metainterp/resoperation.py 
b/rpython/jit/metainterp/resoperation.py
--- a/rpython/jit/metainterp/resoperation.py
+++ b/rpython/jit/metainterp/resoperation.py
@@ -81,7 +81,7 @@
         return False
 
 
-def ResOperation(opnum, args, position, descr=None):
+def ResOperation(opnum, args, position=-1, descr=None):
     cls = opclasses[opnum]
     op = cls()
     op.initarglist(args)
@@ -1153,8 +1153,6 @@
     'STRLEN/1/i',
     'STRGETITEM/2/i',
     'GETARRAYITEM_GC_PURE/2d/rfi',
-    #'GETFIELD_RAW_PURE/1d/rfi',     these two operations not useful and
-    #'GETARRAYITEM_RAW_PURE/2d/fi',  dangerous when unrolling speculatively
     'UNICODELEN/1/i',
     'UNICODEGETITEM/2/i',
     #
@@ -1235,6 +1233,8 @@
     'LEAVE_PORTAL_FRAME/1/n',     # debugging only
     'JIT_DEBUG/*/n',              # debugging only
     '_JIT_DEBUG_LAST',
+    'ESCAPE/*/rfin',              # tests only
+    'FORCE_SPILL/1/n',            # tests only
     'VIRTUAL_REF_FINISH/2/n',   # removed before it's passed to the backend
     'COPYSTRCONTENT/5/n',       # src, dst, srcstart, dststart, length
     'COPYUNICODECONTENT/5/n',
diff --git a/rpython/jit/tool/oparser.py b/rpython/jit/tool/oparser.py
--- a/rpython/jit/tool/oparser.py
+++ b/rpython/jit/tool/oparser.py
@@ -15,67 +15,6 @@
 class ParseError(Exception):
     pass
 
-class ESCAPE_OP(N_aryOp, ResOpWithDescr):
-
-    is_source_op = True
-
-    def getopnum(self):
-        return self.OPNUM
-
-    def getopname(self):
-        return 'escape'
-
-    def copy_and_change(self, opnum, args=None, descr=None):
-        assert opnum == self.OPNUM
-        op = self.__class__()
-        if args is not None:
-            op.initarglist(args)
-        else:
-            op.initarglist(self._args[:])
-        assert descr is None
-        return op
-
-
-class ESCAPE_OP_I(ESCAPE_OP):
-    type = 'i'
-    OPNUM = -123
-
-class ESCAPE_OP_F(ESCAPE_OP):
-    type = 'f'
-    OPNUM = -124
-
-class ESCAPE_OP_N(ESCAPE_OP):
-    type = 'v'
-    OPNUM = -125
-
-class ESCAPE_OP_R(ESCAPE_OP):
-    type = 'r'
-    OPNUM = -126
-
-ALL_ESCAPE_OPS = {
-    ESCAPE_OP_I.OPNUM: ESCAPE_OP_I,
-    ESCAPE_OP_F.OPNUM: ESCAPE_OP_F,
-    ESCAPE_OP_N.OPNUM: ESCAPE_OP_N,
-    ESCAPE_OP_R.OPNUM: ESCAPE_OP_R
-}
-
-class FORCE_SPILL(UnaryOp, PlainResOp):
-
-    OPNUM = -127
-    is_source_op = True
-
-    def getopnum(self):
-        return self.OPNUM
-
-    def getopname(self):
-        return 'force_spill'
-
-    def copy_and_change(self, opnum, args=None, descr=None):
-        assert opnum == self.OPNUM
-        newop = FORCE_SPILL()
-        newop.initarglist(args or self.getarglist())
-        return newop
-
 
 def default_fail_descr(model, opnum, fail_args=None):
     if opnum == rop.FINISH:
@@ -313,23 +252,12 @@
         return opnum, args, descr, fail_args
 
     def create_op(self, opnum, args, res, descr, fail_args):
-        if opnum in ALL_ESCAPE_OPS:
-            op = ALL_ESCAPE_OPS[opnum]()
-            op.initarglist(args)
-            assert descr is None
-            return op
-        if opnum == FORCE_SPILL.OPNUM:
-            op = FORCE_SPILL()
-            op.initarglist(args)
-            assert descr is None
-            return op
-        else:
-            res = ResOperation(opnum, args, -1, descr)
-            if fail_args is not None:
-                res.setfailargs(fail_args)
-            if self._postproces:
-                self._postproces(res)
-            return res
+        res = ResOperation(opnum, args, -1, descr)
+        if fail_args is not None:
+            res.setfailargs(fail_args)
+        if self._postproces:
+            self._postproces(res)
+        return res
 
     def parse_result_op(self, line):
         res, op = line.split("=", 1)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to