[pypy-commit] extradoc extradoc: Mention pointer equality.
arigo
noreply at buildbot.pypy.org
Sun Sep 2 21:48:07 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: extradoc
Changeset: r4734:f2392484a208
Date: 2012-09-02 21:47 +0200
http://bitbucket.org/pypy/extradoc/changeset/f2392484a208/
Log: Mention pointer equality.
diff --git a/talk/stm2012/stmimpl.rst b/talk/stm2012/stmimpl.rst
--- a/talk/stm2012/stmimpl.rst
+++ b/talk/stm2012/stmimpl.rst
@@ -829,3 +829,22 @@
L->h_revision->h_possibly_outdated = True
return L
+Pointer equality: a comparison ``P1 == P2`` needs special care, because
+there are several physical pointers corresponding logically to the same
+object. If ``P1`` or ``P2`` is the constant ``NULL`` then no special
+treatment is needed. Likewise if ``P1`` and ``P2`` are both known to be
+local. Otherwise, we need in general the following code (which could be
+specialized as well if needed)::
+
+ def PtrEq(P1, P2):
+ return GlobalizeForComparison(P1) == GlobalizeForComparison(P2)
+
+ def GlobalizeForComparison(P):
+ if P == NULL:
+ return NULL
+ elif P->h_global:
+ return LatestGlobalRevision(P)
+ elif P->h_revision != 1:
+ return P->h_revision # return the original global obj
+ else:
+ return P # local, allocated during this transaction
More information about the pypy-commit
mailing list