Author: fijal
Branch: jit-leaner-frontend
Changeset: r82937:829e272ed683
Date: 2016-03-10 15:59 +0200
http://bitbucket.org/pypy/pypy/changeset/829e272ed683/

Log:    fix fix fix fix

diff --git a/rpython/jit/backend/llsupport/assembler.py 
b/rpython/jit/backend/llsupport/assembler.py
--- a/rpython/jit/backend/llsupport/assembler.py
+++ b/rpython/jit/backend/llsupport/assembler.py
@@ -331,7 +331,7 @@
         counter = self._register_counter(tp, number, token)
         c_adr = ConstInt(rffi.cast(lltype.Signed, counter))
         operations.append(
-            ResOperation(rop.INCREMENT_DEBUG_COUNTER, [c_adr], None))
+            ResOperation(rop.INCREMENT_DEBUG_COUNTER, [c_adr]))
 
     def _register_counter(self, tp, number, token):
         # YYY very minor leak -- we need the counters to stay alive
diff --git a/rpython/jit/backend/llsupport/rewrite.py 
b/rpython/jit/backend/llsupport/rewrite.py
--- a/rpython/jit/backend/llsupport/rewrite.py
+++ b/rpython/jit/backend/llsupport/rewrite.py
@@ -361,8 +361,8 @@
         # return True in cases where the operation and the following guard
         # should likely remain together.  Simplified version of
         # can_merge_with_next_guard() in llsupport/regalloc.py.
-        if not op.is_comparison():
-            return op.is_ovf()    # int_xxx_ovf() / guard_no_overflow()
+        if not rop.is_comparison(op.opnum):
+            return rop.is_ovf(op.opnum)    # int_xxx_ovf() / 
guard_no_overflow()
         if i + 1 >= len(operations):
             return False
         next_op = operations[i + 1]
@@ -614,8 +614,7 @@
             args = [frame, arglist[jd.index_of_virtualizable]]
         else:
             args = [frame]
-        call_asm = ResOperation(op.getopnum(), args,
-                                op.getdescr())
+        call_asm = ResOperation(op.getopnum(), args, descr=op.getdescr())
         self.replace_op_with(self.get_box_replacement(op), call_asm)
         self.emit_op(call_asm)
 
@@ -673,7 +672,7 @@
     def _gen_call_malloc_gc(self, args, v_result, descr):
         """Generate a CALL_MALLOC_GC with the given args."""
         self.emitting_an_operation_that_can_collect()
-        op = ResOperation(rop.CALL_MALLOC_GC, args, descr)
+        op = ResOperation(rop.CALL_MALLOC_GC, args, descr=descr)
         self.replace_op_with(v_result, op)
         self.emit_op(op)
         # In general, don't add v_result to write_barrier_applied:
diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -351,6 +351,7 @@
                                              metainterp.box_names_memo)
     except InvalidLoop:
         # Fall back on jumping directly to preamble
+        raise InvalidLoop
         xxxx
         jump_op = ResOperation(rop.JUMP, inputargs[:], 
descr=loop_jitcell_token)
         loop_data = UnrolledLoopData(end_label, jump_op, [jump_op], 
start_state,
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
@@ -9,7 +9,7 @@
 
 from rpython.jit.metainterp.history import ConstInt, Const
 from rpython.jit.metainterp.resoperation import AbstractResOp, 
AbstractInputArg,\
-    ResOperation, oparity, rop, opwithdescr
+    ResOperation, oparity, rop, opwithdescr, GuardResOp
 from rpython.rlib.rarithmetic import intmask
 from rpython.rlib.objectmodel import we_are_translated
 
@@ -21,6 +21,9 @@
 class Sentinel(object):
     pass
 
+class BaseTrace(object):
+    pass
+
 class SnapshotIterator(object):
     def __init__(self, main_iter, pos, end_pos):
         self.trace = main_iter.trace
@@ -69,7 +72,7 @@
             l.append(self.next())
         return l
 
-class TraceIterator(object):
+class TraceIterator(BaseTrace):
     def __init__(self, trace, start, end, force_inputargs=None):
         self.trace = trace
         self._cache = [None] * trace._count
@@ -78,10 +81,10 @@
                               arg in force_inputargs]
             self._inputargs = [None] * len(trace.inputargs)
             for i, arg in enumerate(force_inputargs):
-                if arg.position >= 0:
-                    self._cache[arg.position] = self.inputargs[i]
+                if arg.get_position() >= 0:
+                    self._cache[arg.get_position()] = self.inputargs[i]
                 else:
-                    self._inputargs[-arg.position-1] = self.inputargs[i]
+                    self._inputargs[-arg.get_position()-1] = self.inputargs[i]
         else:
             self.inputargs = [rop.inputarg_from_tp(arg.type) for
                               arg in self.trace.inputargs]
@@ -115,7 +118,7 @@
         elif tag == TAGCONST:
             return self.trace._consts[v]
         else:
-            yyyy
+            assert False
 
     def skip_resume_data(self):
         pos = self.pos
@@ -145,14 +148,12 @@
             descr = None
         res = ResOperation(opnum, args, -1, descr=descr)
         if rop.is_guard(opnum):
+            assert isinstance(res, GuardResOp)
             res.rd_resume_position = self.skip_resume_data()
         self._cache[self._count] = res
         self._count += 1
         return res
 
-class BaseTrace(object):
-    pass
-
 class CutTrace(BaseTrace):
     def __init__(self, trace, start, count, inputargs):
         self.trace = trace
@@ -172,6 +173,7 @@
         self._descrs = [None]
         self._consts = [None]
         for i, inparg in enumerate(inputargs):
+            assert isinstance(inparg, AbstractInputArg)
             inparg.position = -i - 1
         self._count = 0
         self.inputargs = inputargs
@@ -199,9 +201,9 @@
                 self._consts.append(box)
                 return tag(TAGCONST, len(self._consts) - 1)
         elif isinstance(box, AbstractResOp):
-            return tag(TAGBOX, box.position)
+            return tag(TAGBOX, box.get_position())
         elif isinstance(box, AbstractInputArg):
-            return tag(TAGBOX, box.position)
+            return tag(TAGBOX, box.get_position())
         else:
             assert False, "unreachable code"
 
diff --git a/rpython/jit/metainterp/optimizeopt/heap.py 
b/rpython/jit/metainterp/optimizeopt/heap.py
--- a/rpython/jit/metainterp/optimizeopt/heap.py
+++ b/rpython/jit/metainterp/optimizeopt/heap.py
@@ -348,7 +348,7 @@
             opnum == rop.COPYUNICODECONTENT):    # no effect on GC struct/array
             return
         if op.is_call():
-            if op.is_call_assembler():
+            if rop.is_call_assembler(op.getopnum()):
                 self._seen_guard_not_invalidated = False
             else:
                 effectinfo = op.getdescr().get_extra_info()
diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -553,7 +553,7 @@
 
     @specialize.argtype(0)
     def _emit_operation(self, op):
-        assert not op.is_call_pure()
+        assert not rop.is_call_pure(op.getopnum())
         orig_op = op
         op = self.get_box_replacement(op)
         if op.is_constant():
@@ -660,7 +660,7 @@
         return self._really_emitted_operation
 
     def is_call_pure_pure_canraise(self, op):
-        if not op.is_call_pure():
+        if not rop.is_call_pure(op.getopnum()):
             return False
         effectinfo = op.getdescr().get_extra_info()
         if effectinfo.check_can_raise(ignore_memoryerror=True):
diff --git a/rpython/jit/metainterp/pyjitpl.py 
b/rpython/jit/metainterp/pyjitpl.py
--- a/rpython/jit/metainterp/pyjitpl.py
+++ b/rpython/jit/metainterp/pyjitpl.py
@@ -1616,7 +1616,7 @@
                     resbox = None
                 else:
                     assert False
-            self.metainterp.vrefs_after_residual_call()
+            
self.metainterp.vrefs_after_residual_call(self.metainterp._last_op, cut_pos)
             vablebox = None
             if assembler_call:
                 vablebox, resbox = self.metainterp.direct_assembler_call(
@@ -1907,7 +1907,7 @@
         self.last_exc_value = lltype.nullptr(rclass.OBJECT)
         self.forced_virtualizable = None
         self.partial_trace = None
-        self.retracing_from = -1
+        self.retracing_from = (-1, -1)
         self.call_pure_results = args_dict()
         self.heapcache = HeapCache()
 
@@ -2770,7 +2770,7 @@
                                                   force_token],
                                 None, descr=vinfo.vable_token_descr)
 
-    def vrefs_after_residual_call(self):
+    def vrefs_after_residual_call(self, op, cut_pos):
         vrefinfo = self.staticdata.virtualref_info
         for i in range(0, len(self.virtualref_boxes), 2):
             vrefbox = self.virtualref_boxes[i+1]
@@ -2780,7 +2780,7 @@
                 # during this CALL_MAY_FORCE.  Mark this fact by
                 # generating a VIRTUAL_REF_FINISH on it and replacing
                 # it by ConstPtr(NULL).
-                self.stop_tracking_virtualref(i)
+                self.stop_tracking_virtualref(i, op, cut_pos)
 
     def vable_after_residual_call(self, funcbox):
         vinfo = self.jitdriver_sd.virtualizable_info
@@ -2804,15 +2804,17 @@
                 # have the eventual exception raised (this is normally done
                 # after the call to vable_after_residual_call()).
 
-    def stop_tracking_virtualref(self, i):
+    def stop_tracking_virtualref(self, i, op, cut_pos):
         virtualbox = self.virtualref_boxes[i]
         vrefbox = self.virtualref_boxes[i+1]
         # record VIRTUAL_REF_FINISH just before the current CALL_MAY_FORCE
-        call_may_force_op = self.history.operations.pop()
-        assert call_may_force_op.is_call_may_force()
-        self.history.record(rop.VIRTUAL_REF_FINISH,
+        self.history.cut(cut_pos) # pop the CALL
+        assert rop.is_call_may_force(op.getopnum())
+        self.history.record_nospec(rop.VIRTUAL_REF_FINISH,
                             [vrefbox, virtualbox], None)
-        self.history.operations.append(call_may_force_op)
+        newop = self.history.record_nospec(op.getopnum(), op.getarglist(),
+                                           op.getdescr())
+        op.position = newop.position
         # mark by replacing it with ConstPtr(NULL)
         self.virtualref_boxes[i+1] = self.cpu.ts.CONST_NULL
 
@@ -3018,7 +3020,7 @@
         patching the CALL_MAY_FORCE that occurred just now.
         """
         self.history.cut(cut_pos)
-        assert op.is_call_may_force()
+        assert rop.is_call_may_force(op.getopnum())
         num_green_args = targetjitdriver_sd.num_green_args
         arglist = op.getarglist()
         greenargs = arglist[1:num_green_args+1]
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
@@ -232,12 +232,15 @@
 
 
 class AbstractResOpOrInputArg(AbstractValue):
-    _attrs_ = ('_forwarded',)
+    _attrs_ = ('_forwarded', 'position')
     _forwarded = None # either another resop or OptInfo
 
     def get_forwarded(self):
         return self._forwarded
 
+    def get_position(self):
+        return self.position
+
     def set_forwarded(self, forwarded_to):
         assert forwarded_to is not self
         self._forwarded = forwarded_to
@@ -405,12 +408,11 @@
     def can_raise(self):
         return rop.can_raise(self.getopnum())
 
-    # XXX fix
-
     def is_foldable_guard(self):
-        return rop._GUARD_FOLDABLE_FIRST <= self.getopnum() <= 
rop._GUARD_FOLDABLE_LAST
+        return rop.is_foldable_guard(self.getopnun())
 
     def is_guard_exception(self):
+        return rop.is_guard_
         return (self.getopnum() == rop.GUARD_EXCEPTION or
                 self.getopnum() == rop.GUARD_NO_EXCEPTION)
 
@@ -451,41 +453,6 @@
                               rop.GETARRAYITEM_GC_PURE_F,
                               rop.GETARRAYITEM_GC_PURE_R)
 
-    @staticmethod
-    def is_real_call(opnum):
-        return (opnum == rop.CALL_I or
-                opnum == rop.CALL_R or
-                opnum == rop.CALL_F or
-                opnum == rop.CALL_N)
-
-    def is_call_assembler(self):
-        opnum = self.opnum
-        return (opnum == rop.CALL_ASSEMBLER_I or
-                opnum == rop.CALL_ASSEMBLER_R or
-                opnum == rop.CALL_ASSEMBLER_N or
-                opnum == rop.CALL_ASSEMBLER_F)
-
-    def is_call_may_force(self):
-        opnum = self.opnum
-        return (opnum == rop.CALL_MAY_FORCE_I or
-                opnum == rop.CALL_MAY_FORCE_R or
-                opnum == rop.CALL_MAY_FORCE_N or
-                opnum == rop.CALL_MAY_FORCE_F)
-
-    def is_call_pure(self):
-        opnum = self.opnum
-        return (opnum == rop.CALL_PURE_I or
-                opnum == rop.CALL_PURE_R or
-                opnum == rop.CALL_PURE_N or
-                opnum == rop.CALL_PURE_F)
-
-    def is_call_release_gil(self):
-        opnum = self.opnum
-        # no R returning call_release_gil
-        return (opnum == rop.CALL_RELEASE_GIL_I or
-                opnum == rop.CALL_RELEASE_GIL_F or
-                opnum == rop.CALL_RELEASE_GIL_N)
-
     def is_vector_arithmetic(self):
         return rop._VEC_ARITHMETIC_FIRST <= self.getopnum() <= 
rop._VEC_ARITHMETIC_LAST
 
@@ -1492,8 +1459,8 @@
                 opnum == rop.CALL_F or
                 opnum == rop.CALL_N)
 
-    def is_call_assembler(self):
-        opnum = self.opnum
+    @staticmethod
+    def is_call_assembler(opnum):
         return (opnum == rop.CALL_ASSEMBLER_I or
                 opnum == rop.CALL_ASSEMBLER_R or
                 opnum == rop.CALL_ASSEMBLER_N or
@@ -1513,8 +1480,8 @@
                 opnum == rop.CALL_PURE_N or
                 opnum == rop.CALL_PURE_F)
 
-    def is_call_release_gil(self):
-        opnum = self.opnum
+    @staticmethod
+    def is_call_release_gil(opnum):
         # no R returning call_release_gil
         return (opnum == rop.CALL_RELEASE_GIL_I or
                 opnum == rop.CALL_RELEASE_GIL_F or
@@ -1580,6 +1547,26 @@
                 opnum == rop.CALL_LOOPINVARIANT_N)
 
     @staticmethod
+    def get_gc_load(tp):
+        if tp == 'i':
+            return rop.GC_LOAD_I
+        elif tp == 'f':
+            return rop.GC_LOAD_F
+        else:
+            assert tp == 'r'
+        return rop.GC_LOAD_R
+
+    @staticmethod
+    def get_gc_load_indexed(tp):
+        if tp == 'i':
+            return rop.GC_LOAD_INDEXED_I
+        elif tp == 'f':
+            return rop.GC_LOAD_INDEXED_F
+        else:
+            assert tp == 'r'
+            return rop.GC_LOAD_INDEXED_R
+
+    @staticmethod
     def inputarg_from_tp(tp):
         if tp == 'i':
             return InputArgInt()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to