[pypy-svn] r7247 - in pypy/trunk/src: goal pypy/interpreter
hpk at codespeak.net
hpk at codespeak.net
Mon Nov 15 16:58:43 CET 2004
Author: hpk
Date: Mon Nov 15 16:58:42 2004
New Revision: 7247
Added:
pypy/trunk/src/goal/testcachebuild.py
Modified:
pypy/trunk/src/pypy/interpreter/baseobjspace.py
pypy/trunk/src/pypy/interpreter/gateway.py
Log:
the beginnings of filling caches and controling
it via "allowbuildcache" as a flag on an objectspace
Added: pypy/trunk/src/goal/testcachebuild.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/goal/testcachebuild.py Mon Nov 15 16:58:42 2004
@@ -0,0 +1,23 @@
+from pypy.tool import option, autopath, testit
+from pypy.interpreter import gateway
+
+#######################################################
+def app_triggergenerator():
+ def gen():
+ yield 42
+ for x in gen():
+ pass
+
+gateway.importall(globals()) # app_xxx() -> xxx()
+
+#######################################################
+
+def triggercachebuild(space):
+ triggergenerator(space)
+
+if __name__ == '__main__':
+ space = option.objspace('std')
+ #triggercachebuild(space)
+ testit.main(autopath.pypydir)
+ space.allowbuildcache = False
+ testit.main(autopath.pypydir)
Modified: pypy/trunk/src/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/baseobjspace.py (original)
+++ pypy/trunk/src/pypy/interpreter/baseobjspace.py Mon Nov 15 16:58:42 2004
@@ -33,6 +33,7 @@
def __init__(self):
"Basic initialization of objects."
self.generalcache = {}
+ self.allowbuildcache = True
# sets all the internal descriptors
self.initialize()
@@ -40,7 +41,10 @@
try:
return self.generalcache[key]
except KeyError:
- return self.generalcache.setdefault(key, builder(key, self))
+ if self.allowbuildcache:
+ #print "building for key %r" % key
+ return self.generalcache.setdefault(key, builder(key, self))
+ raise
loadfromcache.translated_version = lambda s, k, b: s.generalcache[k]
def make_builtins(self, for_builtins):
Modified: pypy/trunk/src/pypy/interpreter/gateway.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/gateway.py (original)
+++ pypy/trunk/src/pypy/interpreter/gateway.py Mon Nov 15 16:58:42 2004
@@ -210,12 +210,11 @@
return self.build_function(space, w_globals)
def build_function(self, space, w_globals):
- if self in space.generalcache:
- fn = space.generalcache[self]
- else:
- defs = self.getdefaults(space) # needs to be implemented by subclass
- fn = Function(space, self.code, w_globals, defs, forcename = self.name)
- space.generalcache[self] = fn
+ if not space.allowbuildcache:
+ return space.generalcache[self]
+ defs = self.getdefaults(space) # needs to be implemented by subclass
+ fn = Function(space, self.code, w_globals, defs, forcename = self.name)
+ space.generalcache[self] = fn
return fn
def get_method(self, obj):
More information about the Pypy-commit
mailing list