[pypy-commit] pypy result-in-resops: fix new array

fijal noreply at buildbot.pypy.org
Tue Sep 25 13:36:37 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: result-in-resops
Changeset: r57570:05b01e80d84f
Date: 2012-09-25 13:26 +0200
http://bitbucket.org/pypy/pypy/changeset/05b01e80d84f/

Log:	fix new array

diff --git a/pypy/jit/metainterp/optimizeopt/heap.py b/pypy/jit/metainterp/optimizeopt/heap.py
--- a/pypy/jit/metainterp/optimizeopt/heap.py
+++ b/pypy/jit/metainterp/optimizeopt/heap.py
@@ -421,9 +421,10 @@
         indexvalue = self.getvalue(op.getarg(1))
         cf = None
         if indexvalue.is_constant():
-            arrayvalue.make_len_gt(MODE_ARRAY, op.getdescr(), indexvalue.box.getint())
+            arrayvalue.make_len_gt(MODE_ARRAY, op.getdescr(),
+                                   indexvalue.op.getint())
             # use the cache on (arraydescr, index), which is a constant
-            cf = self.arrayitem_cache(op.getdescr(), indexvalue.box.getint())
+            cf = self.arrayitem_cache(op.getdescr(), indexvalue.op.getint())
             fieldvalue = cf.getfield_from_cache(self, arrayvalue)
             if fieldvalue is not None:
                 self.make_equal_to(op.result, fieldvalue)
@@ -436,7 +437,7 @@
         self.emit_operation(op)
         # the remember the result of reading the array item
         if cf is not None:
-            fieldvalue = self.getvalue(op.result)
+            fieldvalue = self.getvalue(op)
             cf.remember_field_value(arrayvalue, fieldvalue, op)
     optimize_GETARRAYITEM_GC_p = optimize_GETARRAYITEM_GC_i
     optimize_GETARRAYITEM_GC_f = optimize_GETARRAYITEM_GC_i
diff --git a/pypy/jit/metainterp/optimizeopt/optimizer.py b/pypy/jit/metainterp/optimizeopt/optimizer.py
--- a/pypy/jit/metainterp/optimizeopt/optimizer.py
+++ b/pypy/jit/metainterp/optimizeopt/optimizer.py
@@ -461,9 +461,9 @@
             self.replace(op, new_op)
         return new_op
 
-    @specialize.arg(2)
-    def copy_and_change(self, op, opnum, *args, **kwds): 
-        new_op = op.copy_and_change(opnum, *args, **kwds)
+    # XXX some RPython magic needed
+    def copy_and_change(self, op, *args, **kwds): 
+        new_op = op.copy_and_change(*args, **kwds)
         if new_op is not op:
             self.replace(op, new_op)
         return new_op
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -1279,7 +1279,7 @@
         []
         p2 = new_with_vtable(ConstClass(node_vtable))
         setfield_gc(p2, 3, descr=valuedescr)
-        i1 = getfield_gc(p2, descr=valuedescr)    # i1 = const 3
+        i1 = getfield_gc_i(p2, descr=valuedescr)    # i1 = const 3
         p1 = new_array(i1, descr=arraydescr)
         escape(p1)
         i2 = arraylen_gc(p1)
diff --git a/pypy/jit/metainterp/optimizeopt/virtualize.py b/pypy/jit/metainterp/optimizeopt/virtualize.py
--- a/pypy/jit/metainterp/optimizeopt/virtualize.py
+++ b/pypy/jit/metainterp/optimizeopt/virtualize.py
@@ -482,8 +482,12 @@
             # if the original 'op' did not have a ConstInt as argument,
             # build a new one with the ConstInt argument
             if not isinstance(op.getarg(0), ConstInt):
-                op = self.optimizer.copy_and_change(op, newargs=[sizebox])
-            self.make_varray(op.getdescr(), sizebox.getint(), op)
+                new_op = op.copy_and_change(arg0=sizebox)
+            else:
+                new_op = op
+            self.make_varray(op.getdescr(), sizebox.getint(), new_op)
+            if op is not new_op:
+                self.setvalue(op, self.getvalue(new_op))
         else:
             self.getvalue(op).ensure_nonnull()
             self.emit_operation(op)


More information about the pypy-commit mailing list