[pypy-svn] r76319 - pypy/branch/fast-ctypes/pypy/rlib

getxsick at codespeak.net getxsick at codespeak.net
Thu Jul 22 21:43:20 CEST 2010


Author: getxsick
Date: Thu Jul 22 21:43:18 2010
New Revision: 76319

Modified:
   pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
Log:
use cache per instance of _Get instead of global one


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	Thu Jul 22 21:43:18 2010
@@ -7,8 +7,6 @@
 from pypy.jit.metainterp.resoperation import ResOperation, rop
 from pypy.jit.metainterp.typesystem import deref
 
-cache = {} # XXX global!
-
 class CDLL(object):
     def __init__(self, name, load=True):
         if load:
@@ -41,6 +39,7 @@
         self.cpu = cpu
         lib = lib.handler
         bargs = []
+        self._cache = {}
 
         try:
             self.funcaddr = rffi.cast(lltype.Signed, rdynload.dlsym(lib, func))
@@ -49,8 +48,10 @@
         bargs.append(BoxInt())
 
         # grab from the cache if possible
+        arg_classes = ''.join(self.args_type)
+        key = (self.res_type, arg_classes)
         try:
-            self.looptoken = cache[self.res_type][tuple(self.args_type)]
+            self.looptoken = self._cache[key]
         except KeyError:
             args = []
             for arg in self.args_type:
@@ -89,7 +90,7 @@
             self.cpu.compile_loop(bargs, oplist, self.looptoken)
 
             # add to the cache
-            cache[self.res_type] = { tuple(self.args_type) : self.looptoken }
+            self._cache[key] = self.looptoken
         self.setup_stack()
 
     def gen_calldescr(self):
@@ -153,4 +154,3 @@
     _clsname = 'SignedCallDescr'
     def get_result_size(self, translate_support_code):
         return symbolic.get_size(lltype.Signed, translate_support_code)
-



More information about the Pypy-commit mailing list