[pypy-svn] r67790 - in pypy/branch/execute-star-args-jit/pypy/jit: backend/llgraph backend/test metainterp metainterp/test

arigo at codespeak.net arigo at codespeak.net
Sat Sep 19 11:55:08 CEST 2009


Author: arigo
Date: Sat Sep 19 11:55:06 2009
New Revision: 67790

Modified:
   pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/llimpl.py
   pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/runner.py
   pypy/branch/execute-star-args-jit/pypy/jit/backend/test/runner_test.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/executor.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizefindnode.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizeopt.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/resoperation.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/specnode.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_basic.py
   pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_executor.py
Log:
(arigo, pedronis around)
Refactor the do_xxx() operations in executor.py and on the CPU
to take arguments directly instead of in a list.


Modified: pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/llimpl.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/llimpl.py	Sat Sep 19 11:55:06 2009
@@ -523,7 +523,7 @@
                         else:
                             boxedargs.append(BoxPtr(x))
                     # xxx this passes the 'llimpl' module as the CPU argument
-                    resbox = impl(llimpl, boxedargs)
+                    resbox = impl(llimpl, *boxedargs)
                     return getattr(resbox, 'value', None)
                 op = _op_default_implementation
                 #

Modified: pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/backend/llgraph/runner.py	Sat Sep 19 11:55:06 2009
@@ -283,36 +283,32 @@
 
     # ---------- the backend-dependent operations ----------
 
-    def do_arraylen_gc(self, args, arraydescr):
-        array = args[0].getref_base()
+    def do_arraylen_gc(self, arraybox, arraydescr):
+        array = arraybox.getref_base()
         return history.BoxInt(llimpl.do_arraylen_gc(arraydescr, array))
 
-    def do_strlen(self, args, descr=None):
-        assert descr is None
-        string = args[0].getref_base()
+    def do_strlen(self, stringbox):
+        string = stringbox.getref_base()
         return history.BoxInt(llimpl.do_strlen(0, string))
 
-    def do_strgetitem(self, args, descr=None):
-        assert descr is None
-        string = args[0].getref_base()
-        index = args[1].getint()
+    def do_strgetitem(self, stringbox, indexbox):
+        string = stringbox.getref_base()
+        index = indexbox.getint()
         return history.BoxInt(llimpl.do_strgetitem(0, string, index))
 
-    def do_unicodelen(self, args, descr=None):
-        assert descr is None
-        string = args[0].getref_base()
+    def do_unicodelen(self, stringbox):
+        string = stringbox.getref_base()
         return history.BoxInt(llimpl.do_unicodelen(0, string))
 
-    def do_unicodegetitem(self, args, descr=None):
-        assert descr is None
-        string = args[0].getref_base()
-        index = args[1].getint()
+    def do_unicodegetitem(self, stringbox, indexbox):
+        string = stringbox.getref_base()
+        index = indexbox.getint()
         return history.BoxInt(llimpl.do_unicodegetitem(0, string, index))
 
-    def do_getarrayitem_gc(self, args, arraydescr):
+    def do_getarrayitem_gc(self, arraybox, indexbox, arraydescr):
         assert isinstance(arraydescr, Descr)
-        array = args[0].getref_base()
-        index = args[1].getint()
+        array = arraybox.getref_base()
+        index = indexbox.getint()
         if arraydescr.typeinfo == REF:
             return history.BoxPtr(llimpl.do_getarrayitem_gc_ptr(array, index))
         elif arraydescr.typeinfo == INT:
@@ -324,9 +320,9 @@
         else:
             raise NotImplementedError
 
-    def do_getfield_gc(self, args, fielddescr):
+    def do_getfield_gc(self, structbox, fielddescr):
         assert isinstance(fielddescr, Descr)
-        struct = args[0].getref_base()
+        struct = structbox.getref_base()
         if fielddescr.typeinfo == REF:
             return history.BoxPtr(llimpl.do_getfield_gc_ptr(struct,
                                                             fielddescr.ofs))
@@ -340,9 +336,9 @@
         else:
             raise NotImplementedError
 
-    def do_getfield_raw(self, args, fielddescr):
+    def do_getfield_raw(self, structbox, fielddescr):
         assert isinstance(fielddescr, Descr)
-        struct = self.cast_int_to_adr(args[0].getint())
+        struct = self.cast_int_to_adr(structbox.getint())
         if fielddescr.typeinfo == REF:
             return history.BoxPtr(llimpl.do_getfield_raw_ptr(struct,
                                                              fielddescr.ofs,
@@ -358,100 +354,95 @@
         else:
             raise NotImplementedError
 
-    def do_new(self, args, size):
+    def do_new(self, size):
         assert isinstance(size, Descr)
         return history.BoxPtr(llimpl.do_new(size.ofs))
 
-    def do_new_with_vtable(self, args, descr=None):
-        assert descr is None
-        vtable = args[0].getint()
+    def do_new_with_vtable(self, vtablebox):
+        vtable = vtablebox.getint()
         size = self.class_sizes[vtable]
         result = llimpl.do_new(size.ofs)
         llimpl.do_setfield_gc_int(result, self.fielddescrof_vtable.ofs,
                                   vtable, self.memo_cast)
         return history.BoxPtr(result)
 
-    def do_new_array(self, args, size):
+    def do_new_array(self, countbox, size):
         assert isinstance(size, Descr)
-        count = args[0].getint()
+        count = countbox.getint()
         return history.BoxPtr(llimpl.do_new_array(size.ofs, count))
 
-    def do_setarrayitem_gc(self, args, arraydescr):
+    def do_setarrayitem_gc(self, arraybox, indexbox, newvaluebox, arraydescr):
         assert isinstance(arraydescr, Descr)
-        array = args[0].getref_base()
-        index = args[1].getint()
+        array = arraybox.getref_base()
+        index = indexbox.getint()
         if arraydescr.typeinfo == REF:
-            newvalue = args[2].getref_base()
+            newvalue = newvaluebox.getref_base()
             llimpl.do_setarrayitem_gc_ptr(array, index, newvalue)
         elif arraydescr.typeinfo == INT:
-            newvalue = args[2].getint()
+            newvalue = newvaluebox.getint()
             llimpl.do_setarrayitem_gc_int(array, index, newvalue,
                                           self.memo_cast)
         elif arraydescr.typeinfo == FLOAT:
-            newvalue = args[2].getfloat()
+            newvalue = newvaluebox.getfloat()
             llimpl.do_setarrayitem_gc_float(array, index, newvalue)
         else:
             raise NotImplementedError
 
-    def do_setfield_gc(self, args, fielddescr):
+    def do_setfield_gc(self, structbox, newvaluebox, fielddescr):
         assert isinstance(fielddescr, Descr)
-        struct = args[0].getref_base()
+        struct = structbox.getref_base()
         if fielddescr.typeinfo == REF:
-            newvalue = args[1].getref_base()
+            newvalue = newvaluebox.getref_base()
             llimpl.do_setfield_gc_ptr(struct, fielddescr.ofs, newvalue)
         elif fielddescr.typeinfo == INT:
-            newvalue = args[1].getint()
+            newvalue = newvaluebox.getint()
             llimpl.do_setfield_gc_int(struct, fielddescr.ofs, newvalue,
                                       self.memo_cast)
         elif fielddescr.typeinfo == FLOAT:
-            newvalue = args[1].getfloat()
+            newvalue = newvaluebox.getfloat()
             llimpl.do_setfield_gc_float(struct, fielddescr.ofs, newvalue)
         else:
             raise NotImplementedError
 
-    def do_setfield_raw(self, args, fielddescr):
+    def do_setfield_raw(self, structbox, newvaluebox, fielddescr):
         assert isinstance(fielddescr, Descr)
-        struct = self.cast_int_to_adr(args[0].getint())
+        struct = self.cast_int_to_adr(structbox.getint())
         if fielddescr.typeinfo == REF:
-            newvalue = args[1].getref_base()
+            newvalue = newvaluebox.getref_base()
             llimpl.do_setfield_raw_ptr(struct, fielddescr.ofs, newvalue,
                                        self.memo_cast)
         elif fielddescr.typeinfo == INT:
-            newvalue = args[1].getint()
+            newvalue = newvaluebox.getint()
             llimpl.do_setfield_raw_int(struct, fielddescr.ofs, newvalue,
                                        self.memo_cast)
         elif fielddescr.typeinfo == FLOAT:
-            newvalue = args[1].getfloat()
+            newvalue = newvaluebox.getfloat()
             llimpl.do_setfield_raw_float(struct, fielddescr.ofs, newvalue,
                                          self.memo_cast)
         else:
             raise NotImplementedError
 
-    def do_same_as(self, args, descr=None):
-        return args[0].clonebox()
+    def do_same_as(self, box1):
+        return box1.clonebox()
 
-    def do_newstr(self, args, descr=None):
-        assert descr is None
-        length = args[0].getint()
+    def do_newstr(self, lengthbox):
+        length = lengthbox.getint()
         return history.BoxPtr(llimpl.do_newstr(0, length))
 
-    def do_newunicode(self, args, descr=None):
-        assert descr is None
-        length = args[0].getint()
+    def do_newunicode(self, lengthbox):
+        length = lengthbox.getint()
         return history.BoxPtr(llimpl.do_newunicode(0, length))
 
-    def do_strsetitem(self, args, descr=None):
-        assert descr is None
-        string = args[0].getref_base()
-        index = args[1].getint()
-        newvalue = args[2].getint()
+    def do_strsetitem(self, stringbox, indexbox, newvaluebox):
+        string = stringbox.getref_base()
+        index = indexbox.getint()
+        newvalue = newvaluebox.getint()
         llimpl.do_strsetitem(0, string, index, newvalue)
 
-    def do_unicodesetitem(self, args, descr=None):
-        assert descr is None
-        string = args[0].getref_base()
-        index = args[1].getint()
-        newvalue = args[2].getint()
+    def do_unicodesetitem(self, stringbox, indexbox, newvaluebox):
+        string = stringbox.getref_base()
+        index = indexbox.getint()
+        newvalue = newvaluebox.getint()
         llimpl.do_unicodesetitem(0, string, index, newvalue)
 
     def do_call(self, args, calldescr):
@@ -474,9 +465,8 @@
         else:
             raise NotImplementedError
 
-    def do_cast_ptr_to_int(self, args, descr=None):
-        assert descr is None
-        return history.BoxInt(llimpl.cast_to_int(args[0].getref_base(),
+    def do_cast_ptr_to_int(self, ptrbox):
+        return history.BoxInt(llimpl.cast_to_int(ptrbox.getref_base(),
                                                         self.memo_cast))
 
 class OOtypeCPU(BaseCPU):
@@ -537,57 +527,48 @@
         return (ootype.cast_to_object(ll_err.args[0]),
                 ootype.cast_to_object(ll_err.args[1]))
 
-    def do_new_with_vtable(self, args, descr=None):
-        assert descr is None
-        assert len(args) == 1
-        cls = args[0].getref_base()
+    def do_new_with_vtable(self, clsbox):
+        cls = clsbox.getref_base()
         typedescr = self.class_sizes[cls]
         return typedescr.create()
 
-    def do_new_array(self, args, typedescr):
+    def do_new_array(self, lengthbox, typedescr):
         assert isinstance(typedescr, TypeDescr)
-        assert len(args) == 1
-        return typedescr.create_array(args[0])
+        return typedescr.create_array(lengthbox)
 
-    def do_new(self, args, typedescr):
+    def do_new(self, typedescr):
         assert isinstance(typedescr, TypeDescr)
-        assert len(args) == 0
         return typedescr.create()
 
-    def do_runtimenew(self, args, descr):
+    def do_runtimenew(self, classbox):
         "NOT_RPYTHON"
-        classbox = args[0]
         classobj = classbox.getref(ootype.Class)
         res = ootype.runtimenew(classobj)
         return history.BoxObj(ootype.cast_to_object(res))
 
-    def do_instanceof(self, args, typedescr):
+    def do_instanceof(self, box1, typedescr):
         assert isinstance(typedescr, TypeDescr)
-        assert len(args) == 1
-        return typedescr.instanceof(args[0])
+        return typedescr.instanceof(box1)
 
-    def do_getfield_gc(self, args, fielddescr):
+    def do_getfield_gc(self, box1, fielddescr):
         assert isinstance(fielddescr, FieldDescr)
-        return fielddescr.getfield(args[0])
+        return fielddescr.getfield(box1)
 
-    def do_setfield_gc(self, args, fielddescr):
+    def do_setfield_gc(self, box1, box2, fielddescr):
         assert isinstance(fielddescr, FieldDescr)
-        return fielddescr.setfield(args[0], args[1])
+        return fielddescr.setfield(box1, box2)
 
-    def do_getarrayitem_gc(self, args, typedescr):
+    def do_getarrayitem_gc(self, box1, box2, typedescr):
         assert isinstance(typedescr, TypeDescr)
-        assert len(args) == 2
-        return typedescr.getarrayitem(*args)
+        return typedescr.getarrayitem(box1, box2)
 
-    def do_setarrayitem_gc(self, args, typedescr):
+    def do_setarrayitem_gc(self, box1, box2, box3, typedescr):
         assert isinstance(typedescr, TypeDescr)
-        assert len(args) == 3
-        return typedescr.setarrayitem(*args)
+        return typedescr.setarrayitem(box1, box2, box3)
 
-    def do_arraylen_gc(self, args, typedescr):
+    def do_arraylen_gc(self, box1, typedescr):
         assert isinstance(typedescr, TypeDescr)
-        assert len(args) == 1
-        return typedescr.getarraylength(*args)
+        return typedescr.getarraylength(box1)
 
     def do_call(self, args, descr):
         assert isinstance(descr, StaticMethDescr)

Modified: pypy/branch/execute-star-args-jit/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/backend/test/runner_test.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/backend/test/runner_test.py	Sat Sep 19 11:55:06 2009
@@ -124,14 +124,14 @@
 
     def test_executor(self):
         cpu = self.cpu
-        x = execute(cpu, rop.INT_ADD, [BoxInt(100), ConstInt(42)])
+        x = execute(cpu, rop.INT_ADD, None, BoxInt(100), ConstInt(42))
         assert x.value == 142
         if self.type_system == 'lltype':
-            s = execute(cpu, rop.NEWSTR, [BoxInt(8)])
+            s = execute(cpu, rop.NEWSTR, None, BoxInt(8))
             assert len(s.getref(lltype.Ptr(rstr.STR)).chars) == 8
 
     def test_lshift(self):
-        res = execute(self.cpu, rop.INT_LSHIFT, [BoxInt(10), ConstInt(4)])
+        res = execute(self.cpu, rop.INT_LSHIFT, None, BoxInt(10), ConstInt(4))
         assert res.value == 10 << 4
         res = self.execute_operation(rop.INT_LSHIFT, [BoxInt(10), BoxInt(4)],
                                      'int')
@@ -293,8 +293,8 @@
         fielddescr = self.cpu.fielddescrof(self.S, 'value')
         assert not fielddescr.is_pointer_field()
         #
-        self.cpu.do_setfield_gc([t_box, BoxInt(1333)], fielddescr)
-        r = self.cpu.do_getfield_gc([t_box], fielddescr)
+        self.cpu.do_setfield_gc(t_box, BoxInt(1333), fielddescr)
+        r = self.cpu.do_getfield_gc(t_box, fielddescr)
         assert r.value == 1333
         #
         res = self.execute_operation(rop.SETFIELD_GC, [t_box, BoxInt(39082)],
@@ -422,10 +422,10 @@
         arraydescr = self.cpu.arraydescrof(A)
         assert not arraydescr.is_array_of_pointers()
         #
-        r = self.cpu.do_arraylen_gc([a_box], arraydescr)
+        r = self.cpu.do_arraylen_gc(a_box, arraydescr)
         assert r.value == 342
-        self.cpu.do_setarrayitem_gc([a_box, BoxInt(311), BoxInt(170)], arraydescr)
-        r = self.cpu.do_getarrayitem_gc([a_box, BoxInt(311)], arraydescr)
+        self.cpu.do_setarrayitem_gc(a_box, BoxInt(311), BoxInt(170), arraydescr)
+        r = self.cpu.do_getarrayitem_gc(a_box, BoxInt(311), arraydescr)
         assert r.value == 170
         #
         r = self.execute_operation(rop.ARRAYLEN_GC, [a_box],
@@ -536,9 +536,9 @@
         assert r.value == 153
 
     def test_unicode_basic(self):
-        u_box = self.cpu.do_newunicode([ConstInt(5)])
-        self.cpu.do_unicodesetitem([u_box, BoxInt(4), BoxInt(123)])
-        r = self.cpu.do_unicodegetitem([u_box, BoxInt(4)])
+        u_box = self.cpu.do_newunicode(ConstInt(5))
+        self.cpu.do_unicodesetitem(u_box, BoxInt(4), BoxInt(123))
+        r = self.cpu.do_unicodegetitem(u_box, BoxInt(4))
         assert r.value == 123
         #
         u_box = self.alloc_unicode(u"hello\u1234")
@@ -696,10 +696,10 @@
         s = lltype.cast_opaque_ptr(lltype.Ptr(self.T), r1.value)
         assert s.parent.chr1 == chr(190)
         assert s.parent.chr2 == chr(150)
-        r = self.cpu.do_getfield_gc([r1], descrshort)
+        r = self.cpu.do_getfield_gc(r1, descrshort)
         assert r.value == 1313
-        self.cpu.do_setfield_gc([r1, BoxInt(1333)], descrshort)
-        r = self.cpu.do_getfield_gc([r1], descrshort)
+        self.cpu.do_setfield_gc(r1, BoxInt(1333), descrshort)
+        r = self.cpu.do_getfield_gc(r1, descrshort)
         assert r.value == 1333
         r = self.execute_operation(rop.GETFIELD_GC, [r1], 'int',
                                    descr=descrshort)
@@ -740,13 +740,13 @@
         descr_A = cpu.arraydescrof(A)
         a = lltype.malloc(A, 5)
         x = cpu.do_arraylen_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, a))],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, a)),
             descr_A)
         assert x.value == 5
         #
         a[2] = 'Y'
         x = cpu.do_getarrayitem_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, a)), BoxInt(2)],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, a)), BoxInt(2),
             descr_A)
         assert x.value == ord('Y')
         #
@@ -755,19 +755,19 @@
         b = lltype.malloc(B, 4)
         b[3] = a
         x = cpu.do_getarrayitem_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)), BoxInt(3)],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)), BoxInt(3),
             descr_B)
         assert isinstance(x, BoxPtr)
         assert x.getref(lltype.Ptr(A)) == a
         #
         s = rstr.mallocstr(6)
         x = cpu.do_strlen(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))])
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)))
         assert x.value == 6
         #
         s.chars[3] = 'X'
         x = cpu.do_strgetitem(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)), BoxInt(3)])
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)), BoxInt(3))
         assert x.value == ord('X')
         #
         S = lltype.GcStruct('S', ('x', lltype.Char), ('y', lltype.Ptr(A)))
@@ -775,27 +775,27 @@
         s = lltype.malloc(S)
         s.x = 'Z'
         x = cpu.do_getfield_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)),
             descrfld_x)
         assert x.value == ord('Z')
         #
         cpu.do_setfield_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)),
-             BoxInt(ord('4'))],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)),
+            BoxInt(ord('4')),
             descrfld_x)
         assert s.x == '4'
         #
         descrfld_y = cpu.fielddescrof(S, 'y')
         s.y = a
         x = cpu.do_getfield_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s))],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)),
             descrfld_y)
         assert isinstance(x, BoxPtr)
         assert x.getref(lltype.Ptr(A)) == a
         #
         s.y = lltype.nullptr(A)
         cpu.do_setfield_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)), x],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, s)), x,
             descrfld_y)
         assert s.y == a
         #
@@ -804,13 +804,13 @@
         rs = lltype.malloc(RS, immortal=True)
         rs.x = '?'
         x = cpu.do_getfield_raw(
-            [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs)))],
+            BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
             descrfld_rx)
         assert x.value == ord('?')
         #
         cpu.do_setfield_raw(
-            [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
-             BoxInt(ord('!'))],
+            BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
+            BoxInt(ord('!')),
             descrfld_rx)
         assert rs.x == '!'
         #
@@ -819,19 +819,19 @@
         #descrfld_ry = cpu.fielddescrof(RS, 'y')
         #rs.y = a
         #x = cpu.do_getfield_raw(
-        #    [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs)))],
+        #    BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))),
         #    descrfld_ry)
         #assert isinstance(x, BoxPtr)
         #assert x.getref(lltype.Ptr(A)) == a
         #
         #rs.y = lltype.nullptr(A)
         #cpu.do_setfield_raw(
-        #    [BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))), x],
+        #    BoxInt(cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(rs))), x,
         #    descrfld_ry)
         #assert rs.y == a
         #
         descrsize = cpu.sizeof(S)
-        x = cpu.do_new([], descrsize)
+        x = cpu.do_new(descrsize)
         assert isinstance(x, BoxPtr)
         x.getref(lltype.Ptr(S))
         #
@@ -839,35 +839,35 @@
         vtable2 = lltype.malloc(rclass.OBJECT_VTABLE, immortal=True)
         vtable2_int = cpu.cast_adr_to_int(llmemory.cast_ptr_to_adr(vtable2))
         cpu.set_class_sizes({vtable2_int: descrsize2})
-        x = cpu.do_new_with_vtable([ConstInt(vtable2_int)])
+        x = cpu.do_new_with_vtable(ConstInt(vtable2_int))
         assert isinstance(x, BoxPtr)
         # well...
         #assert x.getref(rclass.OBJECTPTR).typeptr == vtable2
         #
         arraydescr = cpu.arraydescrof(A)
-        x = cpu.do_new_array([BoxInt(7)], arraydescr)
+        x = cpu.do_new_array(BoxInt(7), arraydescr)
         assert isinstance(x, BoxPtr)
         assert len(x.getref(lltype.Ptr(A))) == 7
         #
         cpu.do_setarrayitem_gc(
-            [x, BoxInt(5), BoxInt(ord('*'))], descr_A)
+            x, BoxInt(5), BoxInt(ord('*')), descr_A)
         assert x.getref(lltype.Ptr(A))[5] == '*'
         #
         cpu.do_setarrayitem_gc(
-            [BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)),
-             BoxInt(1), x],
+            BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, b)),
+            BoxInt(1), x,
             descr_B)
         assert b[1] == x.getref(lltype.Ptr(A))
         #
-        x = cpu.do_newstr([BoxInt(5)])
+        x = cpu.do_newstr(BoxInt(5))
         assert isinstance(x, BoxPtr)
         assert len(x.getref(lltype.Ptr(rstr.STR)).chars) == 5
         #
-        cpu.do_strsetitem([x, BoxInt(4), BoxInt(ord('/'))])
+        cpu.do_strsetitem(x, BoxInt(4), BoxInt(ord('/')))
         assert x.getref(lltype.Ptr(rstr.STR)).chars[4] == '/'
         #
-        x = cpu.do_newstr([BoxInt(5)])
-        y = cpu.do_cast_ptr_to_int([x])
+        x = cpu.do_newstr(BoxInt(5))
+        y = cpu.do_cast_ptr_to_int(x)
         assert isinstance(y, BoxInt)
         assert y.value == cpu.cast_gcref_to_int(x.value)
 

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/executor.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/executor.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/executor.py	Sat Sep 19 11:55:06 2009
@@ -8,6 +8,7 @@
 from pypy.rlib.rarithmetic import ovfcheck, r_uint, intmask
 from pypy.jit.metainterp.history import BoxInt, ConstInt, check_descr
 from pypy.jit.metainterp.history import INT, REF, ConstFloat
+from pypy.jit.metainterp import resoperation
 from pypy.jit.metainterp.resoperation import rop
 
 
@@ -17,166 +18,145 @@
 
 # ____________________________________________________________
 
-def do_int_add(cpu, args, descr=None):
-    return ConstInt(intmask(args[0].getint() + args[1].getint()))
+def do_int_add(cpu, box1, box2):
+    return ConstInt(intmask(box1.getint() + box2.getint()))
 
-def do_int_sub(cpu, args, descr=None):
-    return ConstInt(intmask(args[0].getint() - args[1].getint()))
+def do_int_sub(cpu, box1, box2):
+    return ConstInt(intmask(box1.getint() - box2.getint()))
 
-def do_int_mul(cpu, args, descr=None):
-    return ConstInt(intmask(args[0].getint() * args[1].getint()))
+def do_int_mul(cpu, box1, box2):
+    return ConstInt(intmask(box1.getint() * box2.getint()))
 
-def do_int_floordiv(cpu, args, descr=None):
-    z = llop.int_floordiv(lltype.Signed, args[0].getint(), args[1].getint())
+def do_int_floordiv(cpu, box1, box2):
+    z = llop.int_floordiv(lltype.Signed, box1.getint(), box2.getint())
     return ConstInt(z)
 
-def do_int_mod(cpu, args, descr=None):
-    z = llop.int_mod(lltype.Signed, args[0].getint(), args[1].getint())
+def do_int_mod(cpu, box1, box2):
+    z = llop.int_mod(lltype.Signed, box1.getint(), box2.getint())
     return ConstInt(z)
 
-def do_int_and(cpu, args, descr=None):
-    return ConstInt(args[0].getint() & args[1].getint())
+def do_int_and(cpu, box1, box2):
+    return ConstInt(box1.getint() & box2.getint())
 
-def do_int_or(cpu, args, descr=None):
-    return ConstInt(args[0].getint() | args[1].getint())
+def do_int_or(cpu, box1, box2):
+    return ConstInt(box1.getint() | box2.getint())
 
-def do_int_xor(cpu, args, descr=None):
-    return ConstInt(args[0].getint() ^ args[1].getint())
+def do_int_xor(cpu, box1, box2):
+    return ConstInt(box1.getint() ^ box2.getint())
 
-def do_int_rshift(cpu, args, descr=None):
-    return ConstInt(args[0].getint() >> args[1].getint())
+def do_int_rshift(cpu, box1, box2):
+    return ConstInt(box1.getint() >> box2.getint())
 
-def do_int_lshift(cpu, args, descr=None):
-    return ConstInt(intmask(args[0].getint() << args[1].getint()))
+def do_int_lshift(cpu, box1, box2):
+    return ConstInt(intmask(box1.getint() << box2.getint()))
 
-def do_uint_rshift(cpu, args, descr=None):
-    v = r_uint(args[0].getint()) >> r_uint(args[1].getint())
+def do_uint_rshift(cpu, box1, box2):
+    v = r_uint(box1.getint()) >> r_uint(box2.getint())
     return ConstInt(intmask(v))
 
 # ----------
 
-def do_int_lt(cpu, args, descr=None):
-    return ConstInt(args[0].getint() < args[1].getint())
+def do_int_lt(cpu, box1, box2):
+    return ConstInt(box1.getint() < box2.getint())
 
-def do_int_le(cpu, args, descr=None):
-    return ConstInt(args[0].getint() <= args[1].getint())
+def do_int_le(cpu, box1, box2):
+    return ConstInt(box1.getint() <= box2.getint())
 
-def do_int_eq(cpu, args, descr=None):
-    return ConstInt(args[0].getint() == args[1].getint())
+def do_int_eq(cpu, box1, box2):
+    return ConstInt(box1.getint() == box2.getint())
 
-def do_int_ne(cpu, args, descr=None):
-    return ConstInt(args[0].getint() != args[1].getint())
+def do_int_ne(cpu, box1, box2):
+    return ConstInt(box1.getint() != box2.getint())
 
-def do_int_gt(cpu, args, descr=None):
-    return ConstInt(args[0].getint() > args[1].getint())
+def do_int_gt(cpu, box1, box2):
+    return ConstInt(box1.getint() > box2.getint())
 
-def do_int_ge(cpu, args, descr=None):
-    return ConstInt(args[0].getint() >= args[1].getint())
+def do_int_ge(cpu, box1, box2):
+    return ConstInt(box1.getint() >= box2.getint())
 
-def do_uint_lt(cpu, args, descr=None):
-    return ConstInt(r_uint(args[0].getint()) < r_uint(args[1].getint()))
+def do_uint_lt(cpu, box1, box2):
+    return ConstInt(r_uint(box1.getint()) < r_uint(box2.getint()))
 
-def do_uint_le(cpu, args, descr=None):
-    return ConstInt(r_uint(args[0].getint()) <= r_uint(args[1].getint()))
+def do_uint_le(cpu, box1, box2):
+    return ConstInt(r_uint(box1.getint()) <= r_uint(box2.getint()))
 
-def do_uint_gt(cpu, args, descr=None):
-    return ConstInt(r_uint(args[0].getint()) > r_uint(args[1].getint()))
+def do_uint_gt(cpu, box1, box2):
+    return ConstInt(r_uint(box1.getint()) > r_uint(box2.getint()))
 
-def do_uint_ge(cpu, args, descr=None):
-    return ConstInt(r_uint(args[0].getint()) >= r_uint(args[1].getint()))
+def do_uint_ge(cpu, box1, box2):
+    return ConstInt(r_uint(box1.getint()) >= r_uint(box2.getint()))
 
 # ----------
 
-def do_int_is_true(cpu, args, descr=None):
-    return ConstInt(bool(args[0].getint()))
+def do_int_is_true(cpu, box1):
+    return ConstInt(bool(box1.getint()))
 
-def do_int_neg(cpu, args, descr=None):
-    return ConstInt(intmask(-args[0].getint()))
+def do_int_neg(cpu, box1):
+    return ConstInt(intmask(-box1.getint()))
 
-def do_int_invert(cpu, args, descr=None):
-    return ConstInt(~args[0].getint())
+def do_int_invert(cpu, box1):
+    return ConstInt(~box1.getint())
 
-def do_bool_not(cpu, args, descr=None):
-    return ConstInt(not args[0].getint())
+def do_bool_not(cpu, box1):
+    return ConstInt(not box1.getint())
 
-def do_same_as(cpu, args, descr=None):
-    return args[0]
+def do_same_as(cpu, box1):
+    return box1
 
-def do_oononnull(cpu, args, descr=None):
-    tp = args[0].type
+def do_oononnull(cpu, box1):
+    tp = box1.type
     if tp == INT:
-        x = bool(args[0].getint())
+        x = bool(box1.getint())
     elif tp == REF:
-        x = bool(args[0].getref_base())
+        x = bool(box1.getref_base())
     else:
         assert False
     return ConstInt(x)
 
-def do_ooisnull(cpu, args, descr=None):
-    tp = args[0].type
+def do_ooisnull(cpu, box1):
+    tp = box1.type
     if tp == INT:
-        x = bool(args[0].getint())
+        x = bool(box1.getint())
     elif tp == REF:
-        x = bool(args[0].getref_base())
+        x = bool(box1.getref_base())
     else:
         assert False
     return ConstInt(not x)
 
-def do_oois(cpu, args, descr=None):
-    tp = args[0].type
-    assert tp == args[1].type
+def do_oois(cpu, box1, box2):
+    tp = box1.type
+    assert tp == box2.type
     if tp == INT:
-        x = args[0].getint() == args[1].getint()
+        x = box1.getint() == box2.getint()
     elif tp == REF:
-        x = args[0].getref_base() == args[1].getref_base()
+        x = box1.getref_base() == box2.getref_base()
     else:
         assert False
     return ConstInt(x)
 
-def do_ooisnot(cpu, args, descr=None):
-    tp = args[0].type
-    assert tp == args[1].type
+def do_ooisnot(cpu, box1, box2):
+    tp = box1.type
+    assert tp == box2.type
     if tp == INT:
-        x = args[0].getint() != args[1].getint()
+        x = box1.getint() != box2.getint()
     elif tp == REF:
-        x = args[0].getref_base() != args[1].getref_base()
+        x = box1.getref_base() != box2.getref_base()
     else:
         assert False
     return ConstInt(x)
 
-def do_ooidentityhash(cpu, args, descr=None):
-    obj = args[0].getref_base()
+def do_ooidentityhash(cpu, box1):
+    obj = box1.getref_base()
     return ConstInt(cpu.ts.ooidentityhash(obj))
 
-def do_subclassof(cpu, args, descr=None):
-    assert len(args) == 2
-    box1, box2 = args
+def do_subclassof(cpu, box1, box2):
     return ConstInt(cpu.ts.subclassOf(cpu, box1, box2))
 
 # ----------
-# the following operations just delegate to the cpu:
 
-#   do_arraylen_gc
-#   do_strlen
-#   do_strgetitem
-#   do_getarrayitem_gc
-#   do_getfield_gc
-#   do_getfield_raw
-#   do_new
-#   do_new_with_vtable
-#   do_new_array
-#   do_setarrayitem_gc
-#   do_setfield_gc
-#   do_setfield_raw
-#   do_newstr
-#   do_strsetitem
-#   do_call
-
-# ----------
-
-def do_int_add_ovf(cpu, args, descr=None):
-    x = args[0].getint()
-    y = args[1].getint()
+def do_int_add_ovf(cpu, box1, box2):
+    x = box1.getint()
+    y = box2.getint()
     try:
         z = ovfcheck(x + y)
     except OverflowError:
@@ -187,9 +167,9 @@
     cpu._overflow_flag = ovf
     return BoxInt(z)
 
-def do_int_sub_ovf(cpu, args, descr=None):
-    x = args[0].getint()
-    y = args[1].getint()
+def do_int_sub_ovf(cpu, box1, box2):
+    x = box1.getint()
+    y = box2.getint()
     try:
         z = ovfcheck(x - y)
     except OverflowError:
@@ -200,9 +180,9 @@
     cpu._overflow_flag = ovf
     return BoxInt(z)
 
-def do_int_mul_ovf(cpu, args, descr=None):
-    x = args[0].getint()
-    y = args[1].getint()
+def do_int_mul_ovf(cpu, box1, box2):
+    x = box1.getint()
+    y = box2.getint()
     try:
         z = ovfcheck(x * y)
     except OverflowError:
@@ -215,56 +195,56 @@
 
 # ----------
 
-def do_float_neg(cpu, args, descr=None):
-    return ConstFloat(-args[0].getfloat())
+def do_float_neg(cpu, box1):
+    return ConstFloat(-box1.getfloat())
 
-def do_float_abs(cpu, args, descr=None):
-    return ConstFloat(abs(args[0].getfloat()))
+def do_float_abs(cpu, box1):
+    return ConstFloat(abs(box1.getfloat()))
 
-def do_float_is_true(cpu, args, descr=None):
-    return ConstInt(bool(args[0].getfloat()))
+def do_float_is_true(cpu, box1):
+    return ConstInt(bool(box1.getfloat()))
 
-def do_float_add(cpu, args, descr=None):
-    return ConstFloat(args[0].getfloat() + args[1].getfloat())
+def do_float_add(cpu, box1, box2):
+    return ConstFloat(box1.getfloat() + box2.getfloat())
 
-def do_float_sub(cpu, args, descr=None):
-    return ConstFloat(args[0].getfloat() - args[1].getfloat())
+def do_float_sub(cpu, box1, box2):
+    return ConstFloat(box1.getfloat() - box2.getfloat())
 
-def do_float_mul(cpu, args, descr=None):
-    return ConstFloat(args[0].getfloat() * args[1].getfloat())
+def do_float_mul(cpu, box1, box2):
+    return ConstFloat(box1.getfloat() * box2.getfloat())
 
-def do_float_truediv(cpu, args, descr=None):
-    return ConstFloat(args[0].getfloat() / args[1].getfloat())
+def do_float_truediv(cpu, box1, box2):
+    return ConstFloat(box1.getfloat() / box2.getfloat())
 
-def do_float_lt(cpu, args, descr=None):
-    return ConstInt(args[0].getfloat() < args[1].getfloat())
+def do_float_lt(cpu, box1, box2):
+    return ConstInt(box1.getfloat() < box2.getfloat())
 
-def do_float_le(cpu, args, descr=None):
-    return ConstInt(args[0].getfloat() <= args[1].getfloat())
+def do_float_le(cpu, box1, box2):
+    return ConstInt(box1.getfloat() <= box2.getfloat())
 
-def do_float_eq(cpu, args, descr=None):
-    return ConstInt(args[0].getfloat() == args[1].getfloat())
+def do_float_eq(cpu, box1, box2):
+    return ConstInt(box1.getfloat() == box2.getfloat())
 
-def do_float_ne(cpu, args, descr=None):
-    return ConstInt(args[0].getfloat() != args[1].getfloat())
+def do_float_ne(cpu, box1, box2):
+    return ConstInt(box1.getfloat() != box2.getfloat())
 
-def do_float_gt(cpu, args, descr=None):
-    return ConstInt(args[0].getfloat() > args[1].getfloat())
+def do_float_gt(cpu, box1, box2):
+    return ConstInt(box1.getfloat() > box2.getfloat())
 
-def do_float_ge(cpu, args, descr=None):
-    return ConstInt(args[0].getfloat() >= args[1].getfloat())
+def do_float_ge(cpu, box1, box2):
+    return ConstInt(box1.getfloat() >= box2.getfloat())
 
-def do_cast_float_to_int(cpu, args, descr=None):
-    return ConstInt(int(args[0].getfloat()))
+def do_cast_float_to_int(cpu, box1):
+    return ConstInt(int(box1.getfloat()))
 
-def do_cast_int_to_float(cpu, args, descr=None):
-    return ConstFloat(float(args[0].getint()))
+def do_cast_int_to_float(cpu, box1):
+    return ConstFloat(float(box1.getint()))
 
 # ____________________________________________________________
 
-def do_debug_merge_point(cpu, args, descr=None):
+def do_debug_merge_point(cpu, box1):
     from pypy.jit.metainterp.warmspot import get_stats
-    loc = args[0]._get_str()
+    loc = box1._get_str()
     get_stats().locations.append(loc)
 
 # ____________________________________________________________
@@ -284,12 +264,22 @@
     else:
         def wrap(fn):
             return fn
-    execute = [None] * (rop._LAST+1)
+    #
+    execute_by_num_args = {}
     for key, value in rop.__dict__.items():
         if not key.startswith('_'):
             if (rop._FINAL_FIRST <= value <= rop._FINAL_LAST or
                 rop._GUARD_FIRST <= value <= rop._GUARD_LAST):
                 continue
+            # find which list to store the operation in, based on num_args
+            num_args = resoperation.oparity[value]
+            withdescr = resoperation.opwithdescr[value]
+            if withdescr and num_args >= 0:
+                num_args += 1
+            if num_args not in execute_by_num_args:
+                execute_by_num_args[num_args] = [None] * (rop._LAST+1)
+            execute = execute_by_num_args[num_args]
+            #
             if execute[value] is not None:
                 raise Exception("duplicate entry for op number %d" % value)
             if key.endswith('_PURE'):
@@ -301,23 +291,78 @@
                 execute[value] = wrap(globals()[name])
             else:
                 assert hasattr(AbstractCPU, name), name
-    cpuclass._execute_list = execute
+    cpuclass._execute_by_num_args = execute_by_num_args
+
 
-def get_execute_function(cpu, opnum):
+def get_execute_funclist(cpu, num_args):
+    # workaround, similar to the next one
+    return cpu._execute_by_num_args[num_args]
+get_execute_funclist._annspecialcase_ = 'specialize:memo'
+
+def get_execute_function(cpu, opnum, num_args):
     # workaround for an annotation limitation: putting this code in
     # a specialize:memo function makes sure the following line is
-    # constant-folded away.  Only works if opnum is a constant, of course.
-    return cpu._execute_list[opnum]
+    # constant-folded away.  Only works if opnum and num_args are
+    # constants, of course.
+    return cpu._execute_by_num_args[num_args][opnum]
 get_execute_function._annspecialcase_ = 'specialize:memo'
 
-def execute(cpu, opnum, argboxes, descr=None):
-    check_descr(descr)
-    func = get_execute_function(cpu, opnum)
+def has_descr(opnum):
+    # workaround, similar to the previous one
+    return resoperation.opwithdescr[opnum]
+has_descr._annspecialcase_ = 'specialize:memo'
+
+
+def execute(cpu, opnum, descr, *argboxes):
+    # only for opnums with a fixed arity
+    if has_descr(opnum):
+        check_descr(descr)
+        argboxes = argboxes + (descr,)
+    else:
+        assert descr is None
+    func = get_execute_function(cpu, opnum, len(argboxes))
     assert func is not None
-    return func(cpu, argboxes, descr)
+    return func(cpu, *argboxes)
 execute._annspecialcase_ = 'specialize:arg(1)'
 
-def _execute_nonspec(cpu, opnum, argboxes, descr=None):
+def execute_varargs(cpu, opnum, argboxes, descr):
+    # only for opnums with a variable arity (calls, typically)
     check_descr(descr)
-    func = cpu._execute_list[opnum]
+    func = get_execute_function(cpu, opnum, -1)
+    assert func is not None
     return func(cpu, argboxes, descr)
+execute_varargs._annspecialcase_ = 'specialize:arg(1)'
+
+
+def execute_nonspec(cpu, opnum, argboxes, descr=None):
+    arity = resoperation.oparity[opnum]
+    assert arity == -1 or len(argboxes) == arity
+    if resoperation.opwithdescr[opnum]:
+        check_descr(descr)
+        if arity == -1:
+            func = get_execute_funclist(cpu, -1)[opnum]
+            return func(cpu, argboxes, descr)
+        if arity == 0:
+            func = get_execute_funclist(cpu, 1)[opnum]
+            return func(cpu, descr)
+        if arity == 1:
+            func = get_execute_funclist(cpu, 2)[opnum]
+            return func(cpu, argboxes[0], descr)
+        if arity == 2:
+            func = get_execute_funclist(cpu, 3)[opnum]
+            return func(cpu, argboxes[0], argboxes[1], descr)
+        if arity == 3:
+            func = get_execute_funclist(cpu, 4)[opnum]
+            return func(cpu, argboxes[0], argboxes[1], argboxes[2], descr)
+    else:
+        assert descr is None
+        if arity == 1:
+            func = get_execute_funclist(cpu, 1)[opnum]
+            return func(cpu, argboxes[0])
+        if arity == 2:
+            func = get_execute_funclist(cpu, 2)[opnum]
+            return func(cpu, argboxes[0], argboxes[1])
+        if arity == 3:
+            func = get_execute_funclist(cpu, 3)[opnum]
+            return func(cpu, argboxes[0], argboxes[1], argboxes[2])
+    raise NotImplementedError

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizefindnode.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizefindnode.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizefindnode.py	Sat Sep 19 11:55:06 2009
@@ -6,7 +6,7 @@
 from pypy.jit.metainterp.specnode import VirtualStructSpecNode
 from pypy.jit.metainterp.history import AbstractValue, ConstInt, Const
 from pypy.jit.metainterp.resoperation import rop
-from pypy.jit.metainterp.executor import _execute_nonspec
+from pypy.jit.metainterp.executor import execute_nonspec
 from pypy.jit.metainterp.optimizeutil import av_newdict, _findall, sort_descrs
 from pypy.jit.metainterp.optimizeutil import InvalidLoop
 
@@ -159,7 +159,7 @@
             else:
                 # all constant arguments: we can constant-fold
                 argboxes = [self.get_constant_box(arg) for arg in op.args]
-                resbox = _execute_nonspec(self.cpu, op.opnum, argboxes, op.descr)
+                resbox = execute_nonspec(self.cpu, op.opnum, argboxes, op.descr)
                 self.set_constant_node(op.result, resbox.constbox())
         # default case: mark the arguments as escaping
         for box in op.args:

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizeopt.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/optimizeopt.py	Sat Sep 19 11:55:06 2009
@@ -1,7 +1,7 @@
 from pypy.jit.metainterp.history import Box, BoxInt
 from pypy.jit.metainterp.history import Const, ConstInt, ConstPtr, ConstObj, REF
 from pypy.jit.metainterp.resoperation import rop, ResOperation
-from pypy.jit.metainterp.executor import _execute_nonspec
+from pypy.jit.metainterp.executor import execute_nonspec
 from pypy.jit.metainterp.specnode import SpecNode, NotSpecNode, ConstantSpecNode
 from pypy.jit.metainterp.specnode import AbstractVirtualStructSpecNode
 from pypy.jit.metainterp.specnode import VirtualInstanceSpecNode
@@ -553,7 +553,7 @@
             else:
                 # all constant arguments: constant-fold away
                 argboxes = [self.get_constant_box(arg) for arg in op.args]
-                resbox = _execute_nonspec(self.cpu, op.opnum, argboxes, op.descr)
+                resbox = execute_nonspec(self.cpu, op.opnum, argboxes, op.descr)
                 self.make_constant(op.result, resbox.constbox())
                 return
         elif not op.has_no_side_effect() and not op.is_ovf():

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/pyjitpl.py	Sat Sep 19 11:55:06 2009
@@ -1218,7 +1218,7 @@
         # execute the operation
         profiler = self.staticdata.profiler
         profiler.count_ops(opnum)
-        resbox = executor.execute(self.cpu, opnum, list(argboxes), descr)
+        resbox = executor.execute(self.cpu, opnum, descr, *argboxes)
         if self.is_blackholing():
             return resbox
         if rop._ALWAYS_PURE_FIRST <= opnum <= rop._ALWAYS_PURE_LAST:
@@ -1239,7 +1239,7 @@
         # execute the operation
         profiler = self.staticdata.profiler
         profiler.count_ops(opnum)
-        resbox = executor.execute(self.cpu, opnum, argboxes, descr)
+        resbox = executor.execute_varargs(self.cpu, opnum, argboxes, descr)
         if not self.is_blackholing():
             if require_attention:
                 require_attention = self.after_residual_call()

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/resoperation.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/resoperation.py	Sat Sep 19 11:55:06 2009
@@ -126,97 +126,97 @@
     'OOSEND_PURE',    # ootype operation
     'CALL_PURE',
     #
-    'CAST_PTR_TO_INT',
-    'INT_ADD',
-    'INT_SUB',
-    'INT_MUL',
-    'INT_FLOORDIV',
-    'INT_MOD',
-    'INT_AND',
-    'INT_OR',
-    'INT_XOR',
-    'INT_RSHIFT',
-    'INT_LSHIFT',
-    'UINT_RSHIFT',
-    'FLOAT_ADD',
-    'FLOAT_SUB',
-    'FLOAT_MUL',
-    'FLOAT_TRUEDIV',
-    'FLOAT_NEG',
-    'FLOAT_ABS',
-    'FLOAT_IS_TRUE',
-    'CAST_FLOAT_TO_INT',
-    'CAST_INT_TO_FLOAT',
+    'CAST_PTR_TO_INT/1',
+    'INT_ADD/2',
+    'INT_SUB/2',
+    'INT_MUL/2',
+    'INT_FLOORDIV/2',
+    'INT_MOD/2',
+    'INT_AND/2',
+    'INT_OR/2',
+    'INT_XOR/2',
+    'INT_RSHIFT/2',
+    'INT_LSHIFT/2',
+    'UINT_RSHIFT/2',
+    'FLOAT_ADD/2',
+    'FLOAT_SUB/2',
+    'FLOAT_MUL/2',
+    'FLOAT_TRUEDIV/2',
+    'FLOAT_NEG/1',
+    'FLOAT_ABS/1',
+    'FLOAT_IS_TRUE/1',
+    'CAST_FLOAT_TO_INT/1',
+    'CAST_INT_TO_FLOAT/1',
     #
     '_COMPARISON_FIRST',
-    'INT_LT',
-    'INT_LE',
-    'INT_EQ',
-    'INT_NE',
-    'INT_GT',
-    'INT_GE',
-    'UINT_LT',
-    'UINT_LE',
-    'UINT_GT',
-    'UINT_GE',
+    'INT_LT/2',
+    'INT_LE/2',
+    'INT_EQ/2',
+    'INT_NE/2',
+    'INT_GT/2',
+    'INT_GE/2',
+    'UINT_LT/2',
+    'UINT_LE/2',
+    'UINT_GT/2',
+    'UINT_GE/2',
     '_COMPARISON_LAST',
-    'FLOAT_LT',          # maybe these ones should be comparisons too
-    'FLOAT_LE',
-    'FLOAT_EQ',
-    'FLOAT_NE',
-    'FLOAT_GT',
-    'FLOAT_GE',
-    #
-    'INT_IS_TRUE',
-    'INT_NEG',
-    'INT_INVERT',
-    'BOOL_NOT',
-    #
-    'SAME_AS',      # gets a Const, turns it into a Box
-    #
-    'OONONNULL',
-    'OOISNULL',
-    'OOIS',
-    'OOISNOT',
-    #
-    'ARRAYLEN_GC',
-    'STRLEN',
-    'STRGETITEM',
-    'GETFIELD_GC_PURE',
-    'GETFIELD_RAW_PURE',
-    'GETARRAYITEM_GC_PURE',
-    'UNICODELEN',
-    'UNICODEGETITEM',
+    'FLOAT_LT/2',          # maybe these ones should be comparisons too
+    'FLOAT_LE/2',
+    'FLOAT_EQ/2',
+    'FLOAT_NE/2',
+    'FLOAT_GT/2',
+    'FLOAT_GE/2',
+    #
+    'INT_IS_TRUE/1',
+    'INT_NEG/1',
+    'INT_INVERT/1',
+    'BOOL_NOT/1',
+    #
+    'SAME_AS/1',      # gets a Const, turns it into a Box
+    #
+    'OONONNULL/1',
+    'OOISNULL/1',
+    'OOIS/2',
+    'OOISNOT/2',
+    #
+    'ARRAYLEN_GC/1d',
+    'STRLEN/1',
+    'STRGETITEM/2',
+    'GETFIELD_GC_PURE/1d',
+    'GETFIELD_RAW_PURE/1d',
+    'GETARRAYITEM_GC_PURE/2d',
+    'UNICODELEN/1',
+    'UNICODEGETITEM/2',
     #
     # ootype operations
-    'OOIDENTITYHASH',
-    'INSTANCEOF',
-    'SUBCLASSOF',
+    'OOIDENTITYHASH/1',
+    'INSTANCEOF/1d',
+    'SUBCLASSOF/2',
     #
     '_ALWAYS_PURE_LAST',  # ----- end of always_pure operations -----
 
-    'GETARRAYITEM_GC',
-    'GETFIELD_GC',
-    'GETFIELD_RAW',
-    'NEW',
-    'NEW_WITH_VTABLE',
-    'NEW_ARRAY',
+    'GETARRAYITEM_GC/2d',
+    'GETFIELD_GC/1d',
+    'GETFIELD_RAW/1d',
+    'NEW/0d',
+    'NEW_WITH_VTABLE/1',
+    'NEW_ARRAY/1d',
     '_NOSIDEEFFECT_LAST', # ----- end of no_side_effect operations -----
 
-    'SETARRAYITEM_GC',
-    'SETARRAYITEM_RAW',  # only added by backend.llsupport.gc.rewrite_assembler
-    'SETFIELD_GC',
-    'SETFIELD_RAW',
-    'NEWSTR',
-    'STRSETITEM',
-    'UNICODESETITEM',
-    'NEWUNICODE',
-    'RUNTIMENEW',     # ootype operation
+    'SETARRAYITEM_GC/3d',
+    'SETARRAYITEM_RAW/3d',#only added by backend.llsupport.gc.rewrite_assembler
+    'SETFIELD_GC/2d',
+    'SETFIELD_RAW/2d',
+    'NEWSTR/1',
+    'STRSETITEM/3',
+    'UNICODESETITEM/3',
+    'NEWUNICODE/1',
+    'RUNTIMENEW/1',     # ootype operation
     'COND_CALL_GC_WB',      # [cond, imm_and, if_true_call, args_for_call...]
                             #        => no result       (for the write barrier)
     'COND_CALL_GC_MALLOC',  # [a, b, if_(a<=b)_result, if_(a>b)_call, args...]
                             #        => result          (for mallocs)
-    'DEBUG_MERGE_POINT',      # debugging only
+    'DEBUG_MERGE_POINT/1',      # debugging only
 
     '_CANRAISE_FIRST', # ----- start of can_raise operations -----
     'CALL',
@@ -224,27 +224,41 @@
     '_CANRAISE_LAST', # ----- end of can_raise operations -----
 
     '_OVF_FIRST', # ----- start of is_ovf operations -----
-    'INT_ADD_OVF',
-    'INT_SUB_OVF',
-    'INT_MUL_OVF',
+    'INT_ADD_OVF/2',
+    'INT_SUB_OVF/2',
+    'INT_MUL_OVF/2',
     '_OVF_LAST', # ----- end of is_ovf operations -----
     '_LAST',     # for the backend to add more internal operations
 ]
 
+# ____________________________________________________________
+
 class rop(object):
     pass
 
-i = 0
-for opname in _oplist:
-    if __name__ == '__main__':
-        print '%30s = %d' % (opname, i) # print out the table when run directly
-    setattr(rop, opname, i)
-    i += 1
-del _oplist
-
 opname = {}      # mapping numbers to the original names, for debugging
-for _key, _value in rop.__dict__.items():
-    if type(_value) is int and _key.isupper() and not _key.startswith('_'):
-        assert _value not in opname, "collision! %s and %s" % (
-            opname[_value], _key)
-        opname[_value] = _key
+oparity = []     # mapping numbers to the arity of the operation or -1
+opwithdescr = [] # mapping numbers to a flag "takes a descr"
+
+
+def setup(debug_print=False):
+    i = 0
+    for name in _oplist:
+        if debug_print:
+            print '%30s = %d' % (name, i)
+        if '/' in name:
+            name, arity = name.split('/')
+            withdescr = arity.endswith('d')
+            arity = int(arity.rstrip('d'))
+        else:
+            arity, withdescr = -1, True       # default
+        setattr(rop, name, i)
+        opname[i] = name
+        oparity.append(arity)
+        opwithdescr.append(withdescr)
+        i += 1
+    assert len(oparity) == i
+    assert len(opwithdescr) == i
+
+setup(__name__ == '__main__')   # print out the table when run directly
+del _oplist

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/specnode.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/specnode.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/specnode.py	Sat Sep 19 11:55:06 2009
@@ -58,7 +58,7 @@
         for ofs, subspecnode in self.fields:
             assert isinstance(ofs, history.AbstractDescr)
             fieldbox = executor.execute(cpu, resoperation.rop.GETFIELD_GC,
-                                        [valuebox], ofs)
+                                        ofs, valuebox)
             subspecnode.extract_runtime_data(cpu, fieldbox, resultlist)
 
 
@@ -96,8 +96,8 @@
         from pypy.jit.metainterp import executor, history, resoperation
         for i in range(len(self.items)):
             itembox = executor.execute(cpu, resoperation.rop.GETARRAYITEM_GC,
-                                       [valuebox, history.ConstInt(i)],
-                                       self.arraydescr)
+                                       self.arraydescr,
+                                       valuebox, history.ConstInt(i))
             subspecnode = self.items[i]
             subspecnode.extract_runtime_data(cpu, itembox, resultlist)
 

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_basic.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_basic.py	Sat Sep 19 11:55:06 2009
@@ -1001,7 +1001,7 @@
         x = lltype.malloc(TP)
         res = self.interp_operations(f, [x])
         expected = self.metainterp.cpu.do_cast_ptr_to_int(
-            [history.BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, x))]).value
+            history.BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, x))).value
         assert res == expected
 
 class TestLLtype(BaseLLtypeTests, LLJitMixin):

Modified: pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_executor.py
==============================================================================
--- pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_executor.py	(original)
+++ pypy/branch/execute-star-args-jit/pypy/jit/metainterp/test/test_executor.py	Sat Sep 19 11:55:06 2009
@@ -1,19 +1,93 @@
 import py
 from pypy.jit.metainterp.executor import make_execute_list, execute
+from pypy.jit.metainterp.executor import execute_varargs, execute_nonspec
 from pypy.jit.metainterp.resoperation import rop
 from pypy.jit.metainterp.history import BoxInt, ConstInt
 from pypy.jit.metainterp.history import BoxFloat, ConstFloat
+from pypy.jit.metainterp.history import AbstractDescr, Box
 from pypy.jit.backend.model import AbstractCPU
 
 
+class FakeDescr(AbstractDescr):
+    pass
+
+class FakeBox(Box):
+    def __init__(self, *args):
+        self.args = args
+
 class FakeCPU(AbstractCPU):
     supports_floats = True
+
+    def do_new(self, descr):
+        return FakeBox('new', descr)
+
+    def do_arraylen_gc(self, box1, descr):
+        return FakeBox('arraylen_gc', box1, descr)
+
+    def do_setfield_gc(self, box1, box2, descr):
+        return FakeBox('setfield_gc', box1, box2, descr)
+
+    def do_setarrayitem_gc(self, box1, box2, box3, descr):
+        return FakeBox('setarrayitem_gc', box1, box2, box3, descr)
+
+    def do_call(self, args, descr):
+        return FakeBox('call', args, descr)
+
+    def do_strsetitem(self, box1, box2, box3):
+        return FakeBox('strsetitem', box1, box2, box3)
+
 make_execute_list(FakeCPU)
 
 
-def test_int_ops():
-    box = execute(FakeCPU(), rop.INT_ADD, [BoxInt(40), ConstInt(2)])
+def test_execute():
+    cpu = FakeCPU()
+    descr = FakeDescr()
+    box = execute(cpu, rop.INT_ADD, None, BoxInt(40), ConstInt(2))
     assert box.value == 42
+    box = execute(cpu, rop.NEW, descr)
+    assert box.args == ('new', descr)
+
+def test_execute_varargs():
+    cpu = FakeCPU()
+    descr = FakeDescr()
+    argboxes = [BoxInt(321), ConstInt(123)]
+    box = execute_varargs(cpu, rop.CALL, argboxes, descr)
+    assert box.args == ('call', argboxes, descr)
+
+def test_execute_nonspec():
+    cpu = FakeCPU()
+    descr = FakeDescr()
+    # cases with a descr
+    # arity == -1
+    argboxes = [BoxInt(321), ConstInt(123)]
+    box = execute_nonspec(cpu, rop.CALL, argboxes, descr)
+    assert box.args == ('call', argboxes, descr)
+    # arity == 0
+    box = execute_nonspec(cpu, rop.NEW, [], descr)
+    assert box.args == ('new', descr)
+    # arity == 1
+    box1 = BoxInt(515)
+    box = execute_nonspec(cpu, rop.ARRAYLEN_GC, [box1], descr)
+    assert box.args == ('arraylen_gc', box1, descr)
+    # arity == 2
+    box2 = BoxInt(222)
+    box = execute_nonspec(cpu, rop.SETFIELD_GC, [box1, box2], descr)
+    assert box.args == ('setfield_gc', box1, box2, descr)
+    # arity == 3
+    box3 = BoxInt(-33)
+    box = execute_nonspec(cpu, rop.SETARRAYITEM_GC, [box1, box2, box3], descr)
+    assert box.args == ('setarrayitem_gc', box1, box2, box3, descr)
+    # cases without descr
+    # arity == 1
+    box = execute_nonspec(cpu, rop.INT_INVERT, [box1])
+    assert box.value == ~515
+    # arity == 2
+    box = execute_nonspec(cpu, rop.INT_LSHIFT, [box1, BoxInt(3)])
+    assert box.value == 515 << 3
+    # arity == 3
+    box = execute_nonspec(cpu, rop.STRSETITEM, [box1, box2, box3])
+    assert box.args == ('strsetitem', box1, box2, box3)
+
 
 def _float_binary_operations():
     for opnum, testcases in [
@@ -63,7 +137,7 @@
 def test_float_ops():
     cpu = FakeCPU()
     for opnum, boxargs, rettype, retvalue in get_float_tests(cpu):
-        box = execute(cpu, opnum, boxargs)
+        box = execute_nonspec(cpu, opnum, boxargs)
         if rettype == 'float':
             assert box.getfloat() == retvalue
         elif rettype == 'int':



More information about the Pypy-commit mailing list