Author: Armin Rigo <[email protected]>
Branch: stm-gc
Changeset: r54809:2906eb0e0980
Date: 2012-04-29 14:41 +0200
http://bitbucket.org/pypy/pypy/changeset/2906eb0e0980/
Log: Re-enable the methodcache optimization. Found another trick that
should be "kind of good enough for now".
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -366,8 +366,7 @@
if level in ['2', '3', 'jit']:
config.objspace.opcodes.suggest(CALL_METHOD=True)
config.objspace.std.suggest(withrangelist=True)
- if not config.translation.stm: # XXX temporary
- config.objspace.std.suggest(withmethodcache=True)
+ config.objspace.std.suggest(withmethodcache=True)
config.objspace.std.suggest(withprebuiltchar=True)
config.objspace.std.suggest(builtinshortcut=True)
config.objspace.std.suggest(optimized_list_getitem=True)
diff --git a/pypy/module/transaction/interp_transaction.py
b/pypy/module/transaction/interp_transaction.py
--- a/pypy/module/transaction/interp_transaction.py
+++ b/pypy/module/transaction/interp_transaction.py
@@ -127,8 +127,17 @@
ec = self.space.getexecutioncontext() # create it if needed
assert len(ec._transaction_pending) == 0
#
+ if self.space.config.translation.stm:
+ from pypy.objspace.std.typeobject import MethodCache
+ ec._methodcache = MethodCache(self.space)
+ #
self.space.call_args(self.w_callback, self.args)
#
+ if self.space.config.translation.stm:
+ # remove the method cache again now, to prevent it from being
+ # promoted to a GLOBAL
+ ec._methodcache = None
+ #
result = ec._transaction_pending
ec._transaction_pending = []
return result
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -409,6 +409,9 @@
if space.config.translation.stm:
# with stm, it's important to use one method cache per thread;
# otherwise, we get all the time spurious transaction conflicts.
+ # For now we have one per transaction: the following field is
+ # set when we start a transaction, and cleared just before
+ # committing.
cache = space.getexecutioncontext()._methodcache
else:
cache = space.fromcache(MethodCache)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit