[pypy-svn] r62299 - in pypy/branch/pyjitpl5/pypy/jit/backend/x86: . test

fijal at codespeak.net fijal at codespeak.net
Sun Mar 1 16:33:44 CET 2009


Author: fijal
Date: Sun Mar  1 16:33:42 2009
New Revision: 62299

Modified:
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
   pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py
Log:
progress, be able to run some tests


Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/assembler.py	Sun Mar  1 16:33:42 2009
@@ -7,11 +7,13 @@
 from pypy.annotation import model as annmodel
 from pypy.tool.uid import fixid
 from pypy.jit.backend.x86.regalloc import (RegAlloc, FRAMESIZE, WORD, REGS,
-                                      arg_pos, lower_byte, stack_pos, Perform)
+                                      arg_pos, lower_byte, stack_pos, Perform,
+                                           MALLOC_VARSIZE)
 from pypy.rlib.objectmodel import we_are_translated, specialize
 from pypy.jit.backend.x86 import codebuf
 from pypy.jit.backend.x86.support import gc_malloc_fnaddr
 from pypy.jit.backend.x86.ri386 import *
+from pypy.jit.metainterp.resoperation import rop
 
 # our calling convention - we pass three first args as edx, ecx and eax
 # and the rest stays on stack
@@ -164,10 +166,10 @@
     def regalloc_perform(self, op):
         assert isinstance(op, Perform)
         resloc = op.result_loc
-        genop_dict[op.op.opname](self, op.op, op.arglocs, resloc)
+        genop_list[op.op.opnum](self, op.op, op.arglocs, resloc)
 
     def regalloc_perform_discard(self, op):
-        genop_discard_dict[op.op.opname](self, op.op, op.arglocs)
+        genop_discard_list[op.op.opnum](self, op.op, op.arglocs)
 
     def regalloc_store_to_arg(self, op):
         self.mc.MOV(arg_pos(op.pos), op.from_loc)
@@ -219,7 +221,7 @@
     genop_uint_add = genop_int_add
     genop_uint_sub = genop_int_sub
     genop_uint_mul = genop_int_mul
-    genop_uint_and = genop_int_and
+    xxx_genop_uint_and = genop_int_and
 
     genop_int_mul_ovf = _binaryop_ovf("IMUL", True)
     genop_int_sub_ovf = _binaryop_ovf("SUB")
@@ -239,7 +241,7 @@
 
     # for now all chars are being considered ints, although we should make
     # a difference at some point
-    genop_char_eq = genop_int_eq
+    xxx_genop_char_eq = genop_int_eq
 
     def genop_bool_not(self, op, arglocs, resloc):
         self.mc.XOR(arglocs[0], imm8(1))
@@ -300,12 +302,12 @@
         # xxx ignore NULL returns for now
         self.mc.POP(mem(eax, 0))
 
-    def genop_new(self, op, arglocs, result_loc):
-        assert result_loc is eax
+    def genop_malloc_varsize(self, op, arglocs, result_loc):
         loc_size = arglocs[0]
         self.call(self.malloc_func_addr, [loc_size], eax)
 
-    def genop_malloc_varsize(self, op, arglocs, result_loc):
+    def genop_new(self, op, arglocs, result_loc):
+        assert result_loc is eax
         loc_size = arglocs[0]
         self.call(self.malloc_func_addr, [loc_size], eax)
 
@@ -377,7 +379,6 @@
 
     def genop_jump(self, op, locs):
         targetmp = op.jump_target
-        assert isinstance(targetmp, MergePoint)
         self.mc.JMP(rel32(targetmp.position))
 
     def genop_guard_true(self, op, locs):
@@ -406,38 +407,6 @@
         self.mc.TEST(loc, loc)
         self.implement_guard(op, self.mc.JNZ, locs[1:])
 
-    genop_guard_nonzero = genop_guard_true
-    genop_guard_iszero  = genop_guard_false
-    genop_guard_nonnull = genop_guard_true
-    genop_guard_isnull  = genop_guard_false
-
-    def genop_guard_lt(self, op, locs):
-        self.mc.CMP(locs[0], locs[1])
-        self.implement_guard(op, self.mc.JGE, locs[2:])
-
-    def genop_guard_le(self, op, locs):
-        self.mc.CMP(locs[0], locs[1])
-        self.implement_guard(op, self.mc.JG, locs[2:])
-
-    def genop_guard_eq(self, op, locs):
-        self.mc.CMP(locs[0], locs[1])
-        self.implement_guard(op, self.mc.JNE, locs[2:])
-
-    def genop_guard_ne(self, op, locs):
-        self.mc.CMP(locs[0], locs[1])
-        self.implement_guard(op, self.mc.JE, locs[2:])
-
-    def genop_guard_gt(self, op, locs):
-        self.mc.CMP(locs[0], locs[1])
-        self.implement_guard(op, self.mc.JLE, locs[2:])
-
-    def genop_guard_ge(self, op, locs):
-        self.mc.CMP(locs[0], locs[1])
-        self.implement_guard(op, self.mc.JL, locs[2:])
-
-    genop_guard_is = genop_guard_eq
-    genop_guard_isnot = genop_guard_ne
-
     def genop_guard_value(self, op, locs):
         arg0 = locs[0]
         arg1 = locs[1]
@@ -449,9 +418,6 @@
         self.mc.CMP(mem(locs[0], offset), locs[1])
         self.implement_guard(op, self.mc.JNE, locs[2:])
 
-    def genop_guard_pause(self, op, locs):
-        self.implement_guard(op, self.mc.JMP, locs)
-
     #def genop_guard_nonvirtualized(self, op):
     #    STRUCT = op.args[0].concretetype.TO
     #    offset, size = symbolic.get_field_token(STRUCT, 'vable_rti')
@@ -508,11 +474,11 @@
     genop_call__4 = _new_gen_call()
     gen_call = _new_gen_call()
     genop_call_ptr = gen_call
-    genop_getitem = _new_gen_call()    
-    genop_len = _new_gen_call()
-    genop_pop = _new_gen_call()
-    genop_newlist = _new_gen_call()
-    genop_listnonzero = _new_gen_call()
+    xxx_genop_getitem = _new_gen_call()    
+    xxx_genop_len = _new_gen_call()
+    xxx_genop_pop = _new_gen_call()
+    xxx_genop_newlist = _new_gen_call()
+    xxx_genop_listnonzero = _new_gen_call()
 
     def genop_call_void(self, op, arglocs):
         extra_on_stack = 0
@@ -533,9 +499,9 @@
         self.mc.CALL(x)
         self.mc.ADD(esp, imm(WORD * extra_on_stack))
 
-    genop_append = genop_call_void
-    genop_setitem = genop_call_void
-    genop_insert = genop_call_void
+    xxx_genop_append = genop_call_void
+    xxx_genop_setitem = genop_call_void
+    xxx_genop_insert = genop_call_void
 
     def genop_call__1(self, op, arglocs, resloc):
         self.gen_call(op, arglocs, resloc)
@@ -546,18 +512,22 @@
         self.gen_call(op, arglocs, resloc)
         self.mc.MOVZX(eax, eax)
 
-genop_discard_dict = {}
-genop_dict = {}
+genop_discard_list = [None] * (MALLOC_VARSIZE + 1)
+genop_list = [None] * (MALLOC_VARSIZE + 1)
 
 for name, value in Assembler386.__dict__.iteritems():
     if name.startswith('genop_'):
         opname = name[len('genop_'):]
+        if opname == 'malloc_varsize':
+            num = MALLOC_VARSIZE
+        else:
+            num = getattr(rop, opname.upper())
         if value.func_code.co_argcount == 3:
-            genop_discard_dict[opname] = value
+            genop_discard_list[num] = value
         else:
-            genop_dict[opname] = value
+            genop_list[num] = value
 
-genop_discard_dict['call_void'] = Assembler386.genop_call_void
+genop_discard_list[rop.CALL_VOID] = Assembler386.genop_call_void
 
 def addr_add(reg_or_imm1, reg_or_imm2, offset=0, scale=0):
     if isinstance(reg_or_imm1, IMM32):

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/regalloc.py	Sun Mar  1 16:33:42 2009
@@ -11,6 +11,9 @@
 from pypy.jit.backend.x86 import symbolic
 from pypy.jit.metainterp.resoperation import rop, opname
 
+
+MALLOC_VARSIZE = rop._CANRAISE_LAST + 1
+
 # esi edi and ebp can be added to this list, provided they're correctly
 # saved and restored
 REGS = [eax, ecx, edx]
@@ -656,6 +659,9 @@
     consider_int_ne = _consider_compop
     consider_int_eq = _consider_compop
     consider_uint_gt = _consider_compop
+    consider_uint_lt = _consider_compop
+    consider_uint_le = _consider_compop
+    consider_uint_ge = _consider_compop
 
     def sync_var(self, v):
         ops = []
@@ -717,21 +723,21 @@
             ops0 += self.sync_var(v)
             if size != 0:
                 # XXX lshift?
-                ops0.append(Perform(ResOperation('int_mul', [], []),
+                ops0.append(Perform(ResOperation(rop.INT_MUL, [], None),
                                 [loc, imm(1 << size)], loc))
-            ops0.append(Perform(ResOperation('int_add', [], []),
+            ops0.append(Perform(ResOperation(rop.INT_ADD, [], None),
                                 [loc, imm(ofs + ofs_items)], loc))
         else:
             ops0 = []
             loc = imm(ofs + ofs_items + (v.getint() << size))
-        ops = self._call(ResOperation('malloc_varsize', [v], [res_v])
+        ops = self._call(ResOperation(MALLOC_VARSIZE, [v], res_v)
                          , [loc], [v])
         loc, ops1 = self.make_sure_var_in_reg(v, [res_v])
         assert self.loc(res_v) == eax
         # now we have to reload length to some reasonable place
         self.eventually_free_var(v)
         res = (ops0 + ops + ops1 +
-               [PerformDiscard(ResOperation('setfield_gc', [], []),
+               [PerformDiscard(ResOperation(rop.SETFIELD_GC, [], None),
                                [eax, imm(ofs + ofs_length), imm(WORD), loc])])
         return res
 
@@ -886,7 +892,7 @@
             res = mp.arglocs[i]
             if not (isinstance(arg, Const) or (arg in self.loop_consts
                                                and self.loop_consts[arg] == i)):
-                assert isinstance(mp, MergePoint)
+                assert mp.opnum == rop.MERGE_POINT
                 if arg in self.reg_bindings:
                     if not isinstance(res, REG):
                         ops.append(Store(arg, self.loc(arg), self.stack_bindings[arg]))

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/runner.py	Sun Mar  1 16:33:42 2009
@@ -14,6 +14,7 @@
      ConstInt, ConstPtr, BoxInt, BoxPtr, ConstAddr)
 from pypy.jit.backend.x86.assembler import Assembler386
 from pypy.jit.backend.x86 import symbolic
+from pypy.jit.metainterp.resoperation import rop, opname
 
 class CPU386(object):
     debug = True
@@ -137,19 +138,18 @@
     def get_exc_value(self, frame):
         return self.cast_int_to_gcref(self.assembler._exception_data[1])
 
-    def execute_operation(self, opname, valueboxes, result_type):
+    def execute_operation(self, opnum, valueboxes, result_type):
         # mostly a hack: fall back to compiling and executing the single
         # operation.
-        if opname.startswith('#'):
-            return None
-        key = [opname, result_type]
+        key = [opnum, result_type]
         for valuebox in valueboxes:
             if isinstance(valuebox, Box):
                 key.append(valuebox.type)
             else:
                 key.append(repr(valuebox)) # XXX not RPython
         mp = self.get_compiled_single_operation(key, valueboxes)
-        res = self.execute_operations_in_new_frame(opname, mp, valueboxes,
+        res = self.execute_operations_in_new_frame(opname[opnum], mp,
+                                                   valueboxes,
                                                    result_type)
         if self.assembler._exception_data[0] != 0:
             TP = lltype.Ptr(rclass.OBJECT_VTABLE)
@@ -168,7 +168,7 @@
         try:
             return self._compiled_ops[real_key]
         except KeyError:
-            opname = key[0]
+            opnum = key[0]
             result_type = key[1]
             livevarlist = []
             i = 0
@@ -185,19 +185,23 @@
                     raise ValueError(type)
                 livevarlist.append(box)
                 i += 1
-            mp = MergePoint('merge_point', livevarlist, [])
+            mp = ResOperation(rop.MERGE_POINT, livevarlist, None)
             if result_type == 'void':
-                results = []
+                result = None
             elif result_type == 'int':
-                results = [history.BoxInt()]
+                result = history.BoxInt()
             elif result_type == 'ptr':
-                results = [history.BoxPtr()]
+                result = history.BoxPtr()
             else:
                 raise ValueError(result_type)
+            if result is None:
+                results = []
+            else:
+                results = [result]
             operations = [mp,
-                          ResOperation(opname, livevarlist, results),
-                          ResOperation('return', results, [])]
-            if opname.startswith('guard_'):
+                          ResOperation(opnum, livevarlist, result),
+                          ResOperation(rop.RETURN, results, None)]
+            if operations[1].is_guard():
                 operations[1].liveboxes = []
             self.compile_operations(operations, verbose=False)
             self._compiled_ops[real_key] = mp

Modified: pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/x86/test/test_runner.py	Sun Mar  1 16:33:42 2009
@@ -65,9 +65,13 @@
             result = BoxPtr()
         else:
             raise ValueError(result_type)
+        if result is None:
+            results = []
+        else:
+            results = [result]
         operations = [mp,
                       ResOperation(opnum, livevarlist, result),
-                      ResOperation(rop.RETURN, [result], None)]
+                      ResOperation(rop.RETURN, results, None)]
         if operations[1].is_guard():
             operations[1].liveboxes = []
         self.cpu.compile_operations(operations, verbose=False)
@@ -85,17 +89,17 @@
 
     def test_int_unary_ops(self):
         for op, args, res in [
-            ('int_neg', [BoxInt(42)], -42),
+            (rop.INT_NEG, [BoxInt(42)], -42),
             ]:
             assert self.execute_operation(op, args, 'int').value == res
 
     def test_int_comp_ops(self):
         for op, args, res in [
-            ('int_lt', [BoxInt(40), BoxInt(39)], 0),
-            ('int_lt', [BoxInt(40), ConstInt(41)], 1),
-            ('int_lt', [ConstInt(41), BoxInt(40)], 0),
-            ('int_le', [ConstInt(42), BoxInt(42)], 1),
-            ('int_gt', [BoxInt(40), ConstInt(-100)], 1),
+            (rop.INT_LT, [BoxInt(40), BoxInt(39)], 0),
+            (rop.INT_LT, [BoxInt(40), ConstInt(41)], 1),
+            (rop.INT_LT, [ConstInt(41), BoxInt(40)], 0),
+            (rop.INT_LE, [ConstInt(42), BoxInt(42)], 1),
+            (rop.INT_GT, [BoxInt(40), ConstInt(-100)], 1),
             ]:
             assert self.execute_operation(op, args, 'int').value == res
 
@@ -104,11 +108,12 @@
         u = lltype.malloc(U)
         u_box = BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, u))
         ofs_box = ConstInt(cpu.fielddescrof(S, 'value'))
-        assert self.execute_operation('setfield_gc', [u_box, ofs_box, BoxInt(3)],
+        assert self.execute_operation(rop.SETFIELD_GC,
+                                      [u_box, ofs_box, BoxInt(3)],
                                      'void') == None
         assert u.parent.parent.value == 3
         u.parent.parent.value += 100
-        assert (self.execute_operation('getfield_gc', [u_box, ofs_box], 'int')
+        assert (self.execute_operation(rop.GETFIELD_GC, [u_box, ofs_box], 'int')
                 .value == 103)
 
     def test_execute_operations_in_env(self):
@@ -120,12 +125,12 @@
         t = BoxInt(455)
         u = BoxInt(0)    # False
         operations = [
-            ResOperation(rop.MERGE_POINT, [x, y], []),
-            ResOperation(rop.INT_ADD, [x, y], [z]),
-            ResOperation(rop.INT_SUB, [y, ConstInt(1)], [t]),
-            ResOperation('int_eq', [t, ConstInt(0)], [u]),
-            ResOperation('guard_false', [u], []),
-            ResOperation('jump', [z, t], []),
+            ResOperation(rop.MERGE_POINT, [x, y], None),
+            ResOperation(rop.INT_ADD, [x, y], z),
+            ResOperation(rop.INT_SUB, [y, ConstInt(1)], t),
+            ResOperation(rop.INT_EQ, [t, ConstInt(0)], u),
+            ResOperation(rop.GUARD_FALSE, [u], None),
+            ResOperation(rop.JUMP, [z, t], None),
             ]
         startmp = operations[0]
         operations[-1].jump_target = startmp
@@ -143,16 +148,16 @@
         vtable_for_T = lltype.malloc(MY_VTABLE, immortal=True)
         cpu = self.cpu
         cpu._cache_gcstruct2vtable = {T: vtable_for_T}
-        for (opname, args) in [('guard_true', [BoxInt(1)]),
-                               ('guard_false', [BoxInt(0)]),
-                               ('guard_value', [BoxInt(42), BoxInt(42)])]:
+        for (opname, args) in [(rop.GUARD_TRUE, [BoxInt(1)]),
+                               (rop.GUARD_FALSE, [BoxInt(0)]),
+                               (rop.GUARD_VALUE, [BoxInt(42), BoxInt(42)])]:
                 assert self.execute_operation(opname, args, 'void') == None
         t = lltype.malloc(T)
         t.parent.typeptr = vtable_for_T
         t_box = BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, t))
         T_box = ConstInt(rffi.cast(lltype.Signed, vtable_for_T))
         null_box = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, lltype.nullptr(T)))
-        assert self.execute_operation('guard_class', [t_box, T_box], 'void') == None
+        assert self.execute_operation(rop.GUARD_CLASS, [t_box, T_box], 'void') == None
 
     def test_failing_guards(self):
         vtable_for_T = lltype.malloc(MY_VTABLE, immortal=True)
@@ -169,11 +174,11 @@
         u_box = BoxPtr(lltype.cast_opaque_ptr(llmemory.GCREF, u))
         U_box = ConstInt(rffi.cast(lltype.Signed, vtable_for_U))
         null_box = ConstPtr(lltype.cast_opaque_ptr(llmemory.GCREF, lltype.nullptr(T)))
-        for opname, args in [('guard_true', [BoxInt(0)]),
-                             ('guard_false', [BoxInt(1)]),
-                             ('guard_value', [BoxInt(42), BoxInt(41)]),
-                             ('guard_class', [t_box, U_box]),
-                             ('guard_class', [u_box, T_box]),
+        for opname, args in [(rop.GUARD_TRUE, [BoxInt(0)]),
+                             (rop.GUARD_FALSE, [BoxInt(1)]),
+                             (rop.GUARD_VALUE, [BoxInt(42), BoxInt(41)]),
+                             (rop.GUARD_CLASS, [t_box, U_box]),
+                             (rop.GUARD_CLASS, [u_box, T_box]),
                              ]:
             cpu.metainterp.gf = None
             assert self.execute_operation(opname, args, 'void') == None
@@ -181,15 +186,15 @@
 
     def test_misc_int_ops(self):
         for op, args, res in [
-            ('int_mod', [BoxInt(7), BoxInt(3)], 1),
-            ('int_mod', [ConstInt(0), BoxInt(7)], 0),
-            ('int_mod', [BoxInt(13), ConstInt(5)], 3),
-            ('int_mod', [ConstInt(33), ConstInt(10)], 3),
-            ('int_floordiv', [BoxInt(13), BoxInt(3)], 4),
-            ('int_floordiv', [BoxInt(42), ConstInt(10)], 4),
-            ('int_floordiv', [ConstInt(42), BoxInt(10)], 4),
-            ('int_rshift', [ConstInt(3), BoxInt(4)], 3>>4),
-            ('int_rshift', [BoxInt(3), ConstInt(10)], 3>>10),
+            (rop.INT_MOD, [BoxInt(7), BoxInt(3)], 1),
+            (rop.INT_MOD, [ConstInt(0), BoxInt(7)], 0),
+            (rop.INT_MOD, [BoxInt(13), ConstInt(5)], 3),
+            (rop.INT_MOD, [ConstInt(33), ConstInt(10)], 3),
+            (rop.INT_FLOORDIV, [BoxInt(13), BoxInt(3)], 4),
+            (rop.INT_FLOORDIV, [BoxInt(42), ConstInt(10)], 4),
+            (rop.INT_FLOORDIV, [ConstInt(42), BoxInt(10)], 4),
+            (rop.INT_RSHIFT, [ConstInt(3), BoxInt(4)], 3>>4),
+            (rop.INT_RSHIFT, [BoxInt(3), ConstInt(10)], 3>>10),
             ]:
             assert self.execute_operation(op, args, 'int').value == res
 
@@ -223,14 +228,14 @@
             self.cpu.assembler.malloc_func_addr = addr
             ofs = symbolic.get_field_token(rstr.STR, 'chars')[0]
             
-            res = self.execute_operation('newstr', [ConstInt(7)], 'ptr')
+            res = self.execute_operation(rop.NEWSTR, [ConstInt(7)], 'ptr')
             assert allocs[0] == 7 + ofs + WORD
             resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_int))
             assert resbuf[ofs/WORD] == 7
             
             # ------------------------------------------------------------
 
-            res = self.execute_operation('newstr', [BoxInt(7)], 'ptr')
+            res = self.execute_operation(rop.NEWSTR, [BoxInt(7)], 'ptr')
             assert allocs[0] == 7 + ofs + WORD
             resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_int))
             assert resbuf[ofs/WORD] == 7
@@ -241,7 +246,7 @@
             ofs = symbolic.get_field_token(TP, 'length')[0]
             descr = ConstInt(self.cpu.arraydescrof(TP))
 
-            res = self.execute_operation('new_array', [descr, ConstInt(10)],
+            res = self.execute_operation(rop.NEW_ARRAY, [descr, ConstInt(10)],
                                              'ptr')
             assert allocs[0] == 10*WORD + ofs + WORD
             resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_int))
@@ -249,7 +254,7 @@
 
             # ------------------------------------------------------------
 
-            res = self.execute_operation('new_array', [descr, BoxInt(10)],
+            res = self.execute_operation(rop.NEW_ARRAY, [descr, BoxInt(10)],
                                              'ptr')
             assert allocs[0] == 10*WORD + ofs + WORD
             resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_int))
@@ -263,13 +268,13 @@
         ofs = symbolic.get_field_token(STR, 'chars')[0]
         ofs_items = symbolic.get_field_token(STR.chars, 'items')[0]
 
-        res = self.execute_operation('newstr', [ConstInt(10)], 'ptr')
-        self.execute_operation('strsetitem', [res, ConstInt(2), ConstInt(ord('d'))], 'void')
+        res = self.execute_operation(rop.NEWSTR, [ConstInt(10)], 'ptr')
+        self.execute_operation(rop.STRSETITEM, [res, ConstInt(2), ConstInt(ord('d'))], 'void')
         resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_char))
         assert resbuf[ofs + ofs_items + 2] == 'd'
-        self.execute_operation('strsetitem', [res, BoxInt(2), ConstInt(ord('z'))], 'void')
+        self.execute_operation(rop.STRSETITEM, [res, BoxInt(2), ConstInt(ord('z'))], 'void')
         assert resbuf[ofs + ofs_items + 2] == 'z'
-        r = self.execute_operation('strgetitem', [res, BoxInt(2)], 'int')
+        r = self.execute_operation(rop.STRGETITEM, [res, BoxInt(2)], 'int')
         assert r.value == ord('z')
 
     def test_arrayitems(self):
@@ -277,25 +282,25 @@
         ofs = symbolic.get_field_token(TP, 'length')[0]
         itemsofs = symbolic.get_field_token(TP, 'items')[0]
         descr = ConstInt(self.cpu.arraydescrof(TP))
-        res = self.execute_operation('new_array', [descr, ConstInt(10)],
+        res = self.execute_operation(rop.NEW_ARRAY, [descr, ConstInt(10)],
                                      'ptr')
         resbuf = ctypes.cast(res.value.intval, ctypes.POINTER(ctypes.c_int))
         assert resbuf[ofs/WORD] == 10
-        self.execute_operation('setarrayitem_gc', [res, descr,
-                                                   ConstInt(2), BoxInt(38)],
+        self.execute_operation(rop.SETARRAYITEM_GC, [res, descr,
+                                                     ConstInt(2), BoxInt(38)],
                                'void')
         assert resbuf[itemsofs/WORD + 2] == 38
         
-        self.execute_operation('setarrayitem_gc', [res, descr,
-                                                   BoxInt(3), BoxInt(42)],
+        self.execute_operation(rop.SETARRAYITEM_GC, [res, descr,
+                                                     BoxInt(3), BoxInt(42)],
                                'void')
         assert resbuf[itemsofs/WORD + 3] == 42
 
-        r = self.execute_operation('getarrayitem_gc', [res, descr,
-                                                       ConstInt(2)], 'int')
+        r = self.execute_operation(rop.GETARRAYITEM_GC, [res, descr,
+                                                         ConstInt(2)], 'int')
         assert r.value == 38
-        r = self.execute_operation('getarrayitem_gc', [res, descr,
-                                                       BoxInt(3)], 'int')
+        r = self.execute_operation(rop.GETARRAYITEM_GC, [res, descr,
+                                                         BoxInt(3)], 'int')
         assert r.value == 42
 
     def test_getfield_setfield(self):
@@ -305,7 +310,7 @@
                              ('c1', lltype.Char),
                              ('c2', lltype.Char),
                              ('c3', lltype.Char))
-        res = self.execute_operation('new', [ConstInt(self.cpu.sizeof(TP))],
+        res = self.execute_operation(rop.NEW, [ConstInt(self.cpu.sizeof(TP))],
                                      'ptr')
         ofs_s = ConstInt(self.cpu.fielddescrof(TP, 's'))
         ofs_f = ConstInt(self.cpu.fielddescrof(TP, 'f'))
@@ -313,36 +318,36 @@
         ofsc1 = ConstInt(self.cpu.fielddescrof(TP, 'c1'))
         ofsc2 = ConstInt(self.cpu.fielddescrof(TP, 'c2'))
         ofsc3 = ConstInt(self.cpu.fielddescrof(TP, 'c3'))
-        self.execute_operation('setfield_gc', [res, ofs_s, ConstInt(3)], 'void')
+        self.execute_operation(rop.SETFIELD_GC, [res, ofs_s, ConstInt(3)], 'void')
         # XXX ConstFloat
-        #self.execute_operation('setfield_gc', [res, ofs_f, 1e100], 'void')
+        #self.execute_operation(rop.SETFIELD_GC, [res, ofs_f, 1e100], 'void')
         # XXX we don't support shorts (at all)
-        #self.execute_operation('setfield_gc', [res, ofs_u, ConstInt(5)], 'void')
-        s = self.execute_operation('getfield_gc', [res, ofs_s], 'int')
+        #self.execute_operation(rop.SETFIELD_GC, [res, ofs_u, ConstInt(5)], 'void')
+        s = self.execute_operation(rop.GETFIELD_GC, [res, ofs_s], 'int')
         assert s.value == 3
-        self.execute_operation('setfield_gc', [res, ofs_s, BoxInt(3)], 'void')
-        s = self.execute_operation('getfield_gc', [res, ofs_s], 'int')
+        self.execute_operation(rop.SETFIELD_GC, [res, ofs_s, BoxInt(3)], 'void')
+        s = self.execute_operation(rop.GETFIELD_GC, [res, ofs_s], 'int')
         assert s.value == 3
-        #u = self.execute_operation('getfield_gc', [res, ofs_u], 'int')
+        #u = self.execute_operation(rop.GETFIELD_GC, [res, ofs_u], 'int')
         #assert u.value == 5
-        self.execute_operation('setfield_gc', [res, ofsc1, ConstInt(1)], 'void')
-        self.execute_operation('setfield_gc', [res, ofsc2, ConstInt(2)], 'void')
-        self.execute_operation('setfield_gc', [res, ofsc3, ConstInt(3)], 'void')
-        c = self.execute_operation('getfield_gc', [res, ofsc1], 'int')
+        self.execute_operation(rop.SETFIELD_GC, [res, ofsc1, ConstInt(1)], 'void')
+        self.execute_operation(rop.SETFIELD_GC, [res, ofsc2, ConstInt(2)], 'void')
+        self.execute_operation(rop.SETFIELD_GC, [res, ofsc3, ConstInt(3)], 'void')
+        c = self.execute_operation(rop.GETFIELD_GC, [res, ofsc1], 'int')
         assert c.value == 1
-        c = self.execute_operation('getfield_gc', [res, ofsc2], 'int')
+        c = self.execute_operation(rop.GETFIELD_GC, [res, ofsc2], 'int')
         assert c.value == 2
-        c = self.execute_operation('getfield_gc', [res, ofsc3], 'int')
+        c = self.execute_operation(rop.GETFIELD_GC, [res, ofsc3], 'int')
         assert c.value == 3
         
     def test_ovf_ops(self):
         arg0 = BoxInt(12)
         arg1 = BoxInt(13)
-        res = self.execute_operation('int_mul_ovf', [arg0, arg1], 'int')
+        res = self.execute_operation(rop.INT_MUL_OVF, [arg0, arg1], 'int')
         assert res.value == 12*13
         arg0 = BoxInt(sys.maxint/2)
         arg1 = BoxInt(2222)
-        self.execute_operation('int_mul_ovf', [arg0, arg1], 'int')
+        self.execute_operation(rop.INT_MUL_OVF, [arg0, arg1], 'int')
         assert self.cpu.assembler._exception_data[0] == 1
         self.cpu.assembler._exception_data[0] = 0
 
@@ -351,16 +356,16 @@
 
         arg0 = BoxInt(intmask(r_uint(sys.maxint + 3)))
         arg1 = BoxInt(intmask(r_uint(4)))
-        res = self.execute_operation('uint_add', [arg0, arg1], 'int')
+        res = self.execute_operation(rop.UINT_ADD, [arg0, arg1], 'int')
         assert res.value == intmask(r_uint(sys.maxint + 3) + r_uint(4))
 
         arg0 = BoxInt(intmask(sys.maxint + 10))
         arg1 = BoxInt(10)
-        res = self.execute_operation('uint_mul', [arg0, arg1], 'int')
+        res = self.execute_operation(rop.UINT_MUL, [arg0, arg1], 'int')
         assert res.value == intmask((sys.maxint + 10) * 10)
 
         arg0 = BoxInt(intmask(r_uint(sys.maxint + 3)))
         arg1 = BoxInt(intmask(r_uint(4)))
 
-        res = self.execute_operation('uint_gt', [arg0, arg1], 'int')
+        res = self.execute_operation(rop.UINT_GT, [arg0, arg1], 'int')
         assert res.value == 1



More information about the Pypy-commit mailing list