[pypy-svn] r75942 - in pypy/branch/fast-ctypes/pypy/rlib: . test

getxsick at codespeak.net getxsick at codespeak.net
Tue Jul 6 19:59:03 CEST 2010


Author: getxsick
Date: Tue Jul  6 19:59:01 2010
New Revision: 75942

Modified:
   pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
   pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
Log:
roll back r75939


Modified: pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py	Tue Jul  6 19:59:01 2010
@@ -54,10 +54,10 @@
             raise ValueError(self.res_type)
 
         try:
-            self.funcaddr = rffi.cast(lltype.Signed, rdynload.dlsym(self.lib, func))
+            addr = rffi.cast(lltype.Signed, rdynload.dlsym(self.lib, func))
         except KeyError:
             raise ValueError("Cannot find symbol %s", func)
-        self.bfuncaddr = BoxInt(self.funcaddr)
+        self.bfuncaddr = BoxInt(addr)
 
         args = []
         for arg in self.args_type:
@@ -74,25 +74,19 @@
         FUNC = deref(FPTR)
         self.calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT)
 
-        self.looptoken = LoopToken()
-        self.inputargs = [ BoxInt(), BoxInt(), BoxInt() ]
-
-        self.oplist = [ResOperation(rop.CALL, self.inputargs, self.bres,
-                                    descr=self.calldescr),
-                       ResOperation(rop.FINISH, [self.bres], None,
-                                    descr=BasicFailDescr(0))]
-        self.cpu.compile_loop(self.inputargs, self.oplist, self.looptoken)
-
     def call(self):
-        self.inputargs[0].value = self.funcaddr
-        self.cpu.set_future_value_int(0, self.funcaddr)
-        self.inputargs[1].value = 1
-        self.cpu.set_future_value_int(1, 1)
-        self.inputargs[2].value = 2
-        self.cpu.set_future_value_int(2, 2)
+        inputargs = [self.bfuncaddr] + self.bargs
+
+        oplist = [ResOperation(rop.CALL, inputargs, self.bres,
+                               descr=self.calldescr),
+                  ResOperation(rop.FINISH, [self.bres], None,
+                               descr=BasicFailDescr(0))]
+        looptoken = LoopToken()
+        self.cpu.compile_loop(inputargs, oplist, looptoken)
+        self.cpu.set_future_value_int(0, self.bfuncaddr.getint())
 
-        res = self.cpu.execute_token(self.looptoken)
-        if res is self.oplist[-1].descr:
+        res = self.cpu.execute_token(looptoken)
+        if res is oplist[-1].descr:
             self.guard_failed = False
         else:
             self.guard_failed = True
@@ -113,12 +107,7 @@
 
     def setup_stack(self):
         self.bargs = []
-        self.esp = 0
-
-    def push_funcaddr(self, value):
-        self.cpu.set_future_value_int(self.esp, value)
-        self.bargs.append(BoxInt(value)) # insert(0, )? 
-        self.esp += 1
+        self.esp = 1 # 0 is a func addr
 
     def push_int(self, value):
         self.cpu.set_future_value_int(self.esp, value)

Modified: pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py	(original)
+++ pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py	Tue Jul  6 19:59:01 2010
@@ -69,30 +69,30 @@
         lib = rjitffi.CDLL(self.lib_name)
 
         func = lib.get('add_integers', ['i', 'i'], 'i')
-        #func.push_int(1)
-        #func.push_int(2)
+        func.push_int(1)
+        func.push_int(2)
         assert func.call() == 3
 
-        #func = lib.get('add_integers', ['i', 'i'], 'i')
-        #func.push_int(-1)
-        #func.push_int(2)
-        #assert func.call() == 1
-
-        #func = lib.get('add_integers', ['i', 'i'], 'i')
-        #func.push_int(0)
-        #func.push_int(0)
-        #assert func.call() == 0
-
-        #func = lib.get('max3', ['i', 'i', 'i'], 'i')
-        #func.push_int(2)
-        #func.push_int(8)
-        #func.push_int(3)
-        #assert func.call() == 8
-
-        #func = lib.get('add_floats', ['f', 'f'], 'f')
-        #func.push_float(1.2)
-        #func.push_float(1.5)
-        #assert func.call() == 2.7
+        func = lib.get('add_integers', ['i', 'i'], 'i')
+        func.push_int(-1)
+        func.push_int(2)
+        assert func.call() == 1
+
+        func = lib.get('add_integers', ['i', 'i'], 'i')
+        func.push_int(0)
+        func.push_int(0)
+        assert func.call() == 0
+
+        func = lib.get('max3', ['i', 'i', 'i'], 'i')
+        func.push_int(2)
+        func.push_int(8)
+        func.push_int(3)
+        assert func.call() == 8
+
+        func = lib.get('add_floats', ['f', 'f'], 'f')
+        func.push_float(1.2)
+        func.push_float(1.5)
+        assert func.call() == 2.7
 
     def test_get_void(self):
         lib = rjitffi.CDLL(self.lib_name)



More information about the Pypy-commit mailing list