[pypy-commit] pypy stmgc-c7: Move the jit-less logic into a separate function, so that the codewriter doesn't see at all the stm_ignored block
arigo
noreply at buildbot.pypy.org
Tue May 6 12:29:06 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r71326:44d4ecbdbe2e
Date: 2014-05-06 11:32 +0200
http://bitbucket.org/pypy/pypy/changeset/44d4ecbdbe2e/
Log: Move the jit-less logic into a separate function, so that the
codewriter doesn't see at all the stm_ignored block
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -132,6 +132,18 @@
def size_estimate(self):
return self._size_estimate >> NUM_DIGITS
+ @jit.dont_look_inside
+ def _update_size_estimate(self, new_size_estimate):
+ size_est = (self._size_estimate + new_size_estimate
+ - self.size_estimate())
+ assert size_est >= (self.length() * NUM_DIGITS_POW2)
+ # This write is "stm ignored", which means that we're doing
+ # a best-effort attempt at updating the value, but other threads
+ # may or may not see the update. The benefit is that it will
+ # never create conflicts.
+ with objectmodel.stm_ignored:
+ self._size_estimate = size_est
+
def search(self, attrtype):
return None
@@ -156,15 +168,7 @@
attr = self._get_new_attr(selector[0], selector[1])
oldattr = obj._get_mapdict_map()
if not jit.we_are_jitted():
- size_est = (oldattr._size_estimate + attr.size_estimate()
- - oldattr.size_estimate())
- assert size_est >= (oldattr.length() * NUM_DIGITS_POW2)
- # This write is "stm ignored", which means that we're doing
- # a best-effort attempt at updating the value, but other threads
- # may or may not see the update. The benefit is that it will
- # never create conflicts.
- with objectmodel.stm_ignored:
- oldattr._size_estimate = size_est
+ oldattr._update_size_estimate(attr.size_estimate())
if attr.length() > obj._mapdict_storage_length():
# note that attr.size_estimate() is always at least attr.length()
new_storage = [None] * attr.size_estimate()
More information about the pypy-commit
mailing list