[pypy-commit] pypy stm-thread-2: Tweak tweak
arigo
noreply at buildbot.pypy.org
Tue Feb 19 08:39:57 CET 2013
Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r61438:cadf477fe482
Date: 2013-02-19 08:35 +0100
http://bitbucket.org/pypy/pypy/changeset/cadf477fe482/
Log: Tweak tweak
diff --git a/rpython/translator/stm/src_stm/lists.c b/rpython/translator/stm/src_stm/lists.c
--- a/rpython/translator/stm/src_stm/lists.c
+++ b/rpython/translator/stm/src_stm/lists.c
@@ -261,24 +261,20 @@
of collisions, old items are discarded. The eviction logic is a bit
too simple for now. */
-#define FX_ENTRIES 8192
-#define FX_ASSOC 1
-#define FX_SIZE (FX_ENTRIES * FX_ASSOC * sizeof(revision_t))
+#define FX_ENTRIES 8192
struct FXCache {
char *cache_start;
-#if FX_ASSOC > 1
revision_t nextadd;
-#endif
revision_t shift;
- revision_t cache[FX_ENTRIES * FX_ASSOC * 2];
+ revision_t cache[FX_ENTRIES * 2 * 2];
};
static void fxcache_clear(struct FXCache *fxcache)
{
- fxcache->shift += FX_ASSOC;
- if (fxcache->shift > (FX_ENTRIES - 1) * FX_ASSOC) {
- memset(fxcache->cache, 0, 2 * FX_SIZE);
+ fxcache->shift += 2;
+ if (fxcache->shift > FX_ENTRIES - 2) {
+ memset(fxcache->cache, 0, sizeof(fxcache->cache));
fxcache->shift = 0;
}
fxcache->cache_start = (char *)(fxcache->cache + fxcache->shift);
@@ -291,37 +287,27 @@
*/
revision_t uitem = (revision_t)item;
revision_t *entry = (revision_t *)
- (fxcache->cache_start + (uitem & (FX_SIZE-sizeof(revision_t))));
+ (fxcache->cache_start + (uitem & ((FX_ENTRIES-1) * sizeof(revision_t))));
+ revision_t current, *entry2;
- if (entry[0] == uitem
-#if FX_ASSOC >= 2
- || entry[1] == uitem
-#if FX_ASSOC >= 4
- || entry[2] == uitem || entry[3] == uitem
-#if FX_ASSOC >= 8
- || entry[4] == uitem || entry[5] == uitem
- || entry[6] == uitem || entry[7] == uitem
-#if FX_ASSOC >= 16
- || entry[8] == uitem || entry[9] == uitem
- || entry[10]== uitem || entry[11]== uitem
- || entry[12]== uitem || entry[13]== uitem
- || entry[14]== uitem || entry[15]== uitem
-#if FX_ASSOC >= 32
-#error "FX_ASSOC is too large"
-#endif /* 32 */
-#endif /* 16 */
-#endif /* 8 */
-#endif /* 4 */
-#endif /* 2 */
- )
+ current = entry[0];
+ if (current == uitem)
return 1;
-#if FX_ASSOC > 1
- entry[fxcache->nextadd] = uitem;
- fxcache->nextadd = (fxcache->nextadd + 1) & (FX_ASSOC-1);
-#else
- entry[0] = uitem;
-#endif
+ entry2 = entry + FX_ENTRIES;
+ if (entry2[0] == uitem) {
+ entry2[0] = current;
+ entry[0] = uitem;
+ return 1;
+ }
+ if (entry2[1] == uitem) {
+ entry2[1] = current;
+ entry[0] = uitem;
+ return 1;
+ }
+
+ entry2[fxcache->nextadd] = uitem;
+ fxcache->nextadd = (fxcache->nextadd + 1) & 1;
return 0;
}
More information about the pypy-commit
mailing list