[pypy-commit] pypy default: Translation fix for 3777204fff8e

2014-05-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r71581:7c24973aa476
Date: 2014-05-19 10:27 +0200
http://bitbucket.org/pypy/pypy/changeset/7c24973aa476/

Log:Translation fix for 3777204fff8e

diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -209,11 +209,13 @@
 while size > 0:
 # "peeks" on the underlying stream to see how many chars
 # we can safely read without reading past an end-of-line
-peeked = stream.peek()
-pn = peeked.find("\n", 0, size)
+startindex, peeked = stream.peek()
+assert 0 <= startindex <= len(peeked)
+endindex = startindex + size
+pn = peeked.find("\n", startindex, endindex)
 if pn < 0:
-pn = min(size-1, len(peeked))
-c = stream.read(pn + 1)
+pn = min(endindex - 1, len(peeked))
+c = stream.read(pn - startindex + 1)
 if not c:
 break
 result.append(c)
diff --git a/rpython/rlib/streamio.py b/rpython/rlib/streamio.py
--- a/rpython/rlib/streamio.py
+++ b/rpython/rlib/streamio.py
@@ -554,7 +554,7 @@
 else:
 difpos = offset
 if -self.pos <= difpos <= currentsize:
-self.pos += difpos
+self.pos += intmask(difpos)
 return
 if whence == 1:
 offset -= currentsize
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: doc: update make.bat to look for Sphinx through Python

2014-05-19 Thread techtonik
Author: anatoly techtonik 
Branch: 
Changeset: r71582:d83990714816
Date: 2014-04-01 09:50 +0300
http://bitbucket.org/pypy/pypy/changeset/d83990714816/

Log:doc: update make.bat to look for Sphinx through Python

diff --git a/pypy/doc/make.bat b/pypy/doc/make.bat
--- a/pypy/doc/make.bat
+++ b/pypy/doc/make.bat
@@ -2,11 +2,15 @@
 
 REM Command file for Sphinx documentation
 
-set SPHINXBUILD=sphinx-build
+if "%SPHINXBUILD%" == "" (
+   set SPHINXBUILD=sphinx-build
+)
 set BUILDDIR=_build
 set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
 if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+   set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
 )
 
 if "%1" == "" goto help
@@ -14,16 +18,25 @@
 if "%1" == "help" (
:help
echo.Please use `make ^` where ^ is one of
-   echo.  html  to make standalone HTML files
-   echo.  dirhtml   to make HTML files named index.html in directories
-   echo.  pickleto make pickle files
-   echo.  json  to make JSON files
-   echo.  htmlhelp  to make HTML files and a HTML help project
-   echo.  qthelpto make HTML files and a qthelp project
-   echo.  latex to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter
-   echo.  changes   to make an overview over all changed/added/deprecated 
items
-   echo.  linkcheck to check all external links for integrity
-   echo.  doctest   to run all doctests embedded in the documentation if 
enabled
+   echo.  html   to make standalone HTML files
+   echo.  dirhtmlto make HTML files named index.html in directories
+   echo.  singlehtml to make a single large HTML file
+   echo.  pickle to make pickle files
+   echo.  json   to make JSON files
+   echo.  htmlhelp   to make HTML files and a HTML help project
+   echo.  qthelp to make HTML files and a qthelp project
+   echo.  devhelpto make HTML files and a Devhelp project
+   echo.  epub   to make an epub
+   echo.  latex  to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter
+   echo.  text   to make text files
+   echo.  manto make manual pages
+   echo.  texinfoto make Texinfo files
+   echo.  gettextto make PO message catalogs
+   echo.  changesto make an overview over all changed/added/deprecated 
items
+   echo.  xmlto make Docutils-native XML files
+   echo.  pseudoxml  to make pseudoxml-XML files for display purposes
+   echo.  linkcheck  to check all external links for integrity
+   echo.  doctestto run all doctests embedded in the documentation if 
enabled
goto end
 )
 
@@ -33,8 +46,34 @@
goto end
 )
 
+
+REM Check if sphinx-build is available and fallback to Python version if any
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 goto sphinx_python
+goto sphinx_ok
+
+:sphinx_python
+
+set SPHINXBUILD=python -m sphinx.__init__
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+   echo.
+   echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+   echo.installed, then set the SPHINXBUILD environment variable to point
+   echo.to the full path of the 'sphinx-build' executable. Alternatively 
you
+   echo.may add the Sphinx directory to PATH.
+   echo.
+   echo.If you don't have Sphinx installed, grab it from
+   echo.http://sphinx-doc.org/
+   exit /b 1
+)
+
+:sphinx_ok
+
+
 if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+   if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
@@ -42,13 +81,23 @@
 
 if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+   if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
 )
 
+if "%1" == "singlehtml" (
+   %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+   if errorlevel 1 exit /b 1
+   echo.
+   echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+   goto end
+)
+
 if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+   if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
@@ -56,6 +105,7 @@
 
 if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+   if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
@@ -63,6 +113,7 @@
 
 if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+   if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
 .hhp project file in %BUILDDIR%/htmlhelp.
@@

[pypy-commit] pypy default: doc: update Makefile to look for Sphinx through Python

2014-05-19 Thread techtonik
Author: anatoly techtonik 
Branch: 
Changeset: r71583:eb3a520a832f
Date: 2014-04-01 12:21 +0300
http://bitbucket.org/pypy/pypy/changeset/eb3a520a832f/

Log:doc: update Makefile to look for Sphinx through Python

diff --git a/pypy/doc/Makefile b/pypy/doc/Makefile
--- a/pypy/doc/Makefile
+++ b/pypy/doc/Makefile
@@ -7,29 +7,47 @@
 PAPER =
 BUILDDIR  = _build
 
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx 
installed, then set the SPHINXBUILD environment variable to point to the full 
path of the '$(SPHINXBUILD)' executable. Alternatively you can add the 
directory with the executable to your PATH. If you don't have Sphinx installed, 
grab it from http://sphinx-doc.org/)
+endif
+
 # Internal variables.
 PAPEROPT_a4 = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
 ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
-.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex man changes 
linkcheck doctest
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp 
epub latex latexpdf text man changes linkcheck doctest gettext
 
 help:
@echo "Please use \`make ' where  is one of"
-   @echo "  html  to make standalone HTML files"
-   @echo "  dirhtml   to make HTML files named index.html in directories"
-   @echo "  pickleto make pickle files"
-   @echo "  json  to make JSON files"
-   @echo "  htmlhelp  to make HTML files and a HTML help project"
-   @echo "  qthelpto make HTML files and a qthelp project"
-   @echo "  latex to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
-   @echo "  man   to make manual pages"
-   @echo "  changes   to make an overview of all changed/added/deprecated 
items"
-   @echo "  linkcheck to check all external links for integrity"
-   @echo "  doctest   to run all doctests embedded in the documentation 
(if enabled)"
+   @echo "  html   to make standalone HTML files"
+   @echo "  dirhtmlto make HTML files named index.html in directories"
+   @echo "  singlehtml to make a single large HTML file"
+   @echo "  pickle to make pickle files"
+   @echo "  json   to make JSON files"
+   @echo "  htmlhelp   to make HTML files and a HTML help project"
+   @echo "  qthelp to make HTML files and a qthelp project"
+   @echo "  devhelpto make HTML files and a Devhelp project"
+   @echo "  epub   to make an epub"
+   @echo "  latex  to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
+   @echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+   @echo "  latexpdfja to make LaTeX files and run them through 
platex/dvipdfmx"
+   @echo "  text   to make text files"
+   @echo "  manto make manual pages"
+   @echo "  texinfoto make Texinfo files"
+   @echo "  info   to make Texinfo files and run them through makeinfo"
+   @echo "  gettextto make PO message catalogs"
+   @echo "  changesto make an overview of all changed/added/deprecated 
items"
+   @echo "  xmlto make Docutils-native XML files"
+   @echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+   @echo "  linkcheck  to check all external links for integrity"
+   @echo "  doctestto run all doctests embedded in the documentation 
(if enabled)"
 
 clean:
-   -rm -rf $(BUILDDIR)/*
+   rm -rf $(BUILDDIR)/*
 
 html:
# python config/generate.py #readthedocs will not run this Makefile
@@ -43,6 +61,12 @@
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
 
+singlehtml:
+   # python config/generate.py #readthedocs will not run this Makefile
+   $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+   @echo
+   @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
 pickle:
# python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@@ -72,19 +96,74 @@
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PyPy.qhc"
 
+devhelp:
+   # python config/generate.py #readthedocs will not run this Makefile
+   $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+   @echo
+   @echo "Build finished."
+   @echo "To view the help file:"
+   @echo "# mkdir -p $$HOME/.local/share/devhelp/PyPy"
+   @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PyPy"
+   @echo "# devhelp"
+
+epub:
+   # python config/generate.py #readthedocs will not 

[pypy-commit] pypy default: doc: Makefile - config/generate.py call migrated to pypyconfig extension

2014-05-19 Thread techtonik
Author: anatoly techtonik 
Branch: 
Changeset: r71584:41dfdac4d6b2
Date: 2014-04-01 17:36 +0300
http://bitbucket.org/pypy/pypy/changeset/41dfdac4d6b2/

Log:doc: Makefile - config/generate.py call migrated to pypyconfig
extension

diff --git a/pypy/doc/Makefile b/pypy/doc/Makefile
--- a/pypy/doc/Makefile
+++ b/pypy/doc/Makefile
@@ -50,44 +50,37 @@
rm -rf $(BUILDDIR)/*
 
 html:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
 
 dirhtml:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
 
 singlehtml:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
 
 pickle:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
 
 json:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
 
 htmlhelp:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
  ".hhp project file in $(BUILDDIR)/htmlhelp."
 
 qthelp:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" 
\
@@ -97,7 +90,6 @@
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PyPy.qhc"
 
 devhelp:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@@ -107,13 +99,11 @@
@echo "# devhelp"
 
 epub:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
 
 latex:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@@ -121,7 +111,6 @@
  "(use \`make latexpdf' here to do that automatically)."
 
 latexpdf:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@@ -139,13 +128,11 @@
@echo "Build finished. The text files are in $(BUILDDIR)/text."
 
 man:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
 
 texinfo:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@@ -153,45 +140,38 @@
  "(use \`make info' here to do that automatically)."
 
 info:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
 
 gettext:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
 
 changes:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
 
 linkcheck:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo

[pypy-commit] pypy default: pull request #220

2014-05-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r71585:d3f93da35ed4
Date: 2014-05-19 10:37 +0200
http://bitbucket.org/pypy/pypy/changeset/d3f93da35ed4/

Log:pull request #220

diff --git a/pypy/doc/Makefile b/pypy/doc/Makefile
--- a/pypy/doc/Makefile
+++ b/pypy/doc/Makefile
@@ -7,63 +7,80 @@
 PAPER =
 BUILDDIR  = _build
 
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx 
installed, then set the SPHINXBUILD environment variable to point to the full 
path of the '$(SPHINXBUILD)' executable. Alternatively you can add the 
directory with the executable to your PATH. If you don't have Sphinx installed, 
grab it from http://sphinx-doc.org/)
+endif
+
 # Internal variables.
 PAPEROPT_a4 = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
 ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
-.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex man changes 
linkcheck doctest
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp 
epub latex latexpdf text man changes linkcheck doctest gettext
 
 help:
@echo "Please use \`make ' where  is one of"
-   @echo "  html  to make standalone HTML files"
-   @echo "  dirhtml   to make HTML files named index.html in directories"
-   @echo "  pickleto make pickle files"
-   @echo "  json  to make JSON files"
-   @echo "  htmlhelp  to make HTML files and a HTML help project"
-   @echo "  qthelpto make HTML files and a qthelp project"
-   @echo "  latex to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
-   @echo "  man   to make manual pages"
-   @echo "  changes   to make an overview of all changed/added/deprecated 
items"
-   @echo "  linkcheck to check all external links for integrity"
-   @echo "  doctest   to run all doctests embedded in the documentation 
(if enabled)"
+   @echo "  html   to make standalone HTML files"
+   @echo "  dirhtmlto make HTML files named index.html in directories"
+   @echo "  singlehtml to make a single large HTML file"
+   @echo "  pickle to make pickle files"
+   @echo "  json   to make JSON files"
+   @echo "  htmlhelp   to make HTML files and a HTML help project"
+   @echo "  qthelp to make HTML files and a qthelp project"
+   @echo "  devhelpto make HTML files and a Devhelp project"
+   @echo "  epub   to make an epub"
+   @echo "  latex  to make LaTeX files, you can set PAPER=a4 or 
PAPER=letter"
+   @echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+   @echo "  latexpdfja to make LaTeX files and run them through 
platex/dvipdfmx"
+   @echo "  text   to make text files"
+   @echo "  manto make manual pages"
+   @echo "  texinfoto make Texinfo files"
+   @echo "  info   to make Texinfo files and run them through makeinfo"
+   @echo "  gettextto make PO message catalogs"
+   @echo "  changesto make an overview of all changed/added/deprecated 
items"
+   @echo "  xmlto make Docutils-native XML files"
+   @echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+   @echo "  linkcheck  to check all external links for integrity"
+   @echo "  doctestto run all doctests embedded in the documentation 
(if enabled)"
 
 clean:
-   -rm -rf $(BUILDDIR)/*
+   rm -rf $(BUILDDIR)/*
 
 html:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
 
 dirhtml:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
 
+singlehtml:
+   $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+   @echo
+   @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
 pickle:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
 
 json:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
 
 htmlhelp:
-   # python config/generate.py #readthedocs will not run this Makefile
$(SPHINXBUILD) -b htm

[pypy-commit] pypy default: Merged in techtonik/pypy (pull request #230)

2014-05-19 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r71587:250638982fbe
Date: 2014-05-19 10:39 +0200
http://bitbucket.org/pypy/pypy/changeset/250638982fbe/

Log:Merged in techtonik/pypy (pull request #230)

docs: Use read the docs theme if available

diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -18,6 +18,24 @@
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 sys.path.append(os.path.abspath('.'))
 
+
+# -- Read The Docs theme config 

+
+# on_rtd is whether we are on readthedocs.org, this line of code grabbed from 
docs.readthedocs.org
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd:  # only import and set the theme if we're building docs locally
+  try:
+import sphinx_rtd_theme
+html_theme = 'sphinx_rtd_theme'
+html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+  except ImportError:
+print('sphinx_rtd_theme is not installed')
+html_theme = 'default'
+
+# otherwise, readthedocs.org uses their theme by default, so no need to 
specify it
+
+
 # -- General configuration 
-
 
 # Add any Sphinx extension module names here, as strings. They can be 
extensions
@@ -93,7 +111,7 @@
 
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'default'
+#html_theme = 'default'
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: docs: Use read the docs theme if available

2014-05-19 Thread techtonik
Author: anatoly techtonik 
Branch: 
Changeset: r71586:07e82d634df6
Date: 2014-04-17 17:08 +0300
http://bitbucket.org/pypy/pypy/changeset/07e82d634df6/

Log:docs: Use read the docs theme if available

diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -18,6 +18,24 @@
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 sys.path.append(os.path.abspath('.'))
 
+
+# -- Read The Docs theme config 

+
+# on_rtd is whether we are on readthedocs.org, this line of code grabbed from 
docs.readthedocs.org
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd:  # only import and set the theme if we're building docs locally
+  try:
+import sphinx_rtd_theme
+html_theme = 'sphinx_rtd_theme'
+html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+  except ImportError:
+print('sphinx_rtd_theme is not installed')
+html_theme = 'default'
+
+# otherwise, readthedocs.org uses their theme by default, so no need to 
specify it
+
+
 # -- General configuration 
-
 
 # Add any Sphinx extension module names here, as strings. They can be 
extensions
@@ -91,7 +109,7 @@
 
 # The theme to use for HTML and HTML Help pages.  Major themes that come with
 # Sphinx are currently 'default' and 'sphinxdoc'.
-html_theme = 'default'
+#html_theme = 'default'
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: this XXX is no longer needed, __debug__ works correctly nowadays, as the

2014-05-19 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r71588:91bee71be820
Date: 2014-04-25 11:14 +0200
http://bitbucket.org/pypy/pypy/changeset/91bee71be820/

Log:this XXX is no longer needed, __debug__ works correctly nowadays, as
the __pypy__ module sets

diff --git a/pypy/module/__builtin__/__init__.py 
b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -33,7 +33,7 @@
 
 interpleveldefs = {
 # constants
-'__debug__' : '(space.w_True)',  # XXX
+'__debug__' : '(space.w_True)',
 'None'  : '(space.w_None)',
 'False' : '(space.w_False)',
 'True'  : '(space.w_True)',
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add another signature to a string method to fix a random translation error

2014-05-19 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r71589:fbe93314fa42
Date: 2014-05-19 11:50 +0100
http://bitbucket.org/pypy/pypy/changeset/fbe93314fa42/

Log:add another signature to a string method to fix a random translation
error

diff --git a/rpython/rtyper/lltypesystem/rstr.py 
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -834,6 +834,7 @@
 def ll_stringslice_startonly(s1, start):
 return LLHelpers._ll_stringslice(s1, start, len(s1.chars))
 
+@signature(types.any(), types.int(), types.int(), returns=types.any())
 def ll_stringslice_startstop(s1, start, stop):
 if jit.we_are_jitted():
 if stop > len(s1.chars):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge

2014-05-19 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r71590:dca4d7417953
Date: 2014-05-19 13:39 +0100
http://bitbucket.org/pypy/pypy/changeset/dca4d7417953/

Log:merge

diff --git a/pypy/module/__builtin__/__init__.py 
b/pypy/module/__builtin__/__init__.py
--- a/pypy/module/__builtin__/__init__.py
+++ b/pypy/module/__builtin__/__init__.py
@@ -33,7 +33,7 @@
 
 interpleveldefs = {
 # constants
-'__debug__' : '(space.w_True)',  # XXX
+'__debug__' : '(space.w_True)',
 'None'  : '(space.w_None)',
 'False' : '(space.w_False)',
 'True'  : '(space.w_True)',
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc card-marking: initial sketch of API

2014-05-19 Thread Raemi
Author: Remi Meier 
Branch: card-marking
Changeset: r1211:38e68ec4f6b5
Date: 2014-05-19 15:32 +0200
http://bitbucket.org/pypy/stmgc/changeset/38e68ec4f6b5/

Log:initial sketch of API

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -40,8 +40,13 @@
 #endif
 }
 
-void _stm_write_slowpath(object_t *obj)
+void _stm_write_slowpath(object_t *obj, uintptr_t offset)
 {
+assert(IMPLY(!(obj->stm_flags & GCFLAG_HAS_CARDS),
+ offset == 0));
+if (offset)
+abort();
+
 assert(_seems_to_be_running_transaction());
 assert(!_is_young(obj));
 assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -35,6 +35,8 @@
 #define WRITELOCK_START   ((END_NURSERY_PAGE * 4096UL) >> 4)
 #define WRITELOCK_END READMARKER_END
 
+#define CARD_SIZE   _STM_CARD_SIZE
+
 enum /* stm_flags */ {
 /* This flag is set on non-nursery objects.  It forces stm_write()
to call _stm_write_slowpath().
@@ -54,6 +56,9 @@
after the object. */
 GCFLAG_HAS_SHADOW = 0x04,
 
+/* Set on objects after allocation that may use card marking */
+GCFLAG_HAS_CARDS = _STM_GCFLAG_HAS_CARDS,
+
 /* All remaining bits of the 32-bit 'stm_flags' field are taken by
the "overflow number".  This is a number that identifies the
"overflow objects" from the current transaction among all old
@@ -61,7 +66,7 @@
current transaction that have been flushed out of the nursery,
which occurs if the same transaction allocates too many objects.
 */
-GCFLAG_OVERFLOW_NUMBER_bit0 = 0x8   /* must be last */
+GCFLAG_OVERFLOW_NUMBER_bit0 = 0x10   /* must be last */
 };
 
 
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -83,6 +83,7 @@
 {
 /* Check that some values are acceptable */
 assert(NB_SEGMENTS <= NB_SEGMENTS_MAX);
+assert(CARD_SIZE > 0 && CARD_SIZE % 16 == 0);
 assert(4096 <= ((uintptr_t)STM_SEGMENT));
 assert((uintptr_t)STM_SEGMENT == (uintptr_t)STM_PSEGMENT);
 assert(((uintptr_t)STM_PSEGMENT) + sizeof(*STM_PSEGMENT) <= 8192);
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -106,7 +106,7 @@
 
 /* this should use llvm's coldcc calling convention,
but it's not exposed to C code so far */
-void _stm_write_slowpath(object_t *);
+void _stm_write_slowpath(object_t *, uintptr_t);
 object_t *_stm_allocate_slowpath(ssize_t);
 object_t *_stm_allocate_external(ssize_t);
 void _stm_become_inevitable(const char*);
@@ -143,6 +143,8 @@
 #endif
 
 #define _STM_GCFLAG_WRITE_BARRIER  0x01
+#define _STM_GCFLAG_HAS_CARDS  0x08
+#define _STM_CARD_SIZE 16 /* modulo 16 == 0! */
 #define _STM_NSE_SIGNAL_MAX _STM_TIME_N
 #define _STM_FAST_ALLOC   (66*1024)
 
@@ -210,7 +212,24 @@
 static inline void stm_write(object_t *obj)
 {
 if (UNLIKELY((obj->stm_flags & _STM_GCFLAG_WRITE_BARRIER) != 0))
-_stm_write_slowpath(obj);
+_stm_write_slowpath(obj, 0);
+}
+
+/* The following are barriers that work on the granularity of CARD_SIZE.
+   They can only be used on objects one called stm_use_cards() on. */
+__attribute__((always_inline))
+static inline void stm_read_card(object_t *obj, uintptr_t offset)
+{
+OPT_ASSERT(obj->stm_flags & _STM_GCFLAG_HAS_CARDS);
+((stm_read_marker_t *)(((uintptr_t)obj + offset) >> 4))->rm =
+STM_SEGMENT->transaction_read_version;
+}
+__attribute__((always_inline))
+static inline void stm_write_card(object_t *obj, uintptr_t offset)
+{
+OPT_ASSERT(obj->stm_flags & _STM_GCFLAG_HAS_CARDS);
+if (UNLIKELY((obj->stm_flags & _STM_GCFLAG_WRITE_BARRIER) != 0))
+_stm_write_slowpath(obj, offset);
 }
 
 /* Must be provided by the user of this library.
@@ -248,6 +267,16 @@
 return (object_t *)p;
 }
 
+/* directly after allocation one can enable card marking for any
+   kind of object with stm_use_cards(obj). This enables the use
+   of stm_write/read_card() barriers that do more fine-grained
+   conflict detection and garbage collection. */
+__attribute__((always_inline))
+static inline void stm_use_cards(object_t* o)
+{
+o->stm_flags |= _STM_GCFLAG_HAS_CARDS;
+}
+
 /* Allocate a weakref object. Weakref objects have a
reference to an object at the byte-offset
stmcb_size_rounded_up(obj) - sizeof(void*)
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -12,6 +12,8 @@
 #define STM_NB_SEGMENTS ...
 #define _STM_FAST_ALLOC ...
 #define _STM_GCFLAG_WRITE_BARRIER ...
+#define _STM_GCFLAG_HAS_CARDS ...
+#define _STM_CARD_SIZE ...
 #define STM_STACK_MARKER_NEW ...
 #define STM_STACK_MARKER_OLD ...
 
@@ -41,6 +43,11 @@
 object_t *stm_allocate_weakref(ssize_t size_rounded_up);
 object_t *_stm_allocate_old(ssize_t size_rounded_up);
 
+void stm_use_cards(object_t* o);
+void stm_read_card(object_t *obj, uintptr_t offs

[pypy-commit] stmgc card-marking: wip

2014-05-19 Thread Raemi
Author: Remi Meier 
Branch: card-marking
Changeset: r1215:cde500a7d39e
Date: 2014-05-19 17:20 +0200
http://bitbucket.org/pypy/stmgc/changeset/cde500a7d39e/

Log:wip

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -79,9 +79,7 @@
 
 void _stm_write_slowpath(object_t *obj, uintptr_t offset)
 {
-assert(IMPLY(!(obj->stm_flags & GCFLAG_HAS_CARDS),
- offset == 0));
-
+assert(IMPLY(!(obj->stm_flags & GCFLAG_HAS_CARDS), offset == 0));
 assert(_seems_to_be_running_transaction());
 assert(!_is_young(obj));
 assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
@@ -100,16 +98,18 @@
'modified_old_objects' (but, because it had GCFLAG_WRITE_BARRIER,
not in 'objects_pointing_to_nursery').  We'll detect this case
by finding that we already own the write-lock. */
-uintptr_t lock_idx = get_write_lock_idx((uintptr_t)obj);
+bool lock_whole = offset == 0;
+uintptr_t base_lock_idx = get_write_lock_idx((uintptr_t)obj);
+//uintptr_t card_lock_idx = get_write_lock_idx((uintptr_t)obj + offset);
 uint8_t lock_num = STM_PSEGMENT->write_lock_num;
-assert(lock_idx < sizeof(write_locks));
+assert(base_lock_idx < sizeof(write_locks));
  retry:
-if (write_locks[lock_idx] == 0) {
+if (write_locks[base_lock_idx] == 0) {
 /* A lock to prevent reading garbage from
lookup_other_thread_recorded_marker() */
 acquire_marker_lock(STM_SEGMENT->segment_base);
 
-if (UNLIKELY(!__sync_bool_compare_and_swap(&write_locks[lock_idx],
+if (UNLIKELY(!__sync_bool_compare_and_swap(&write_locks[base_lock_idx],
0, lock_num))) {
 release_marker_lock(STM_SEGMENT->segment_base);
 goto retry;
@@ -159,7 +159,7 @@
 }
 }
 }
-else if (write_locks[lock_idx] == lock_num) {
+else if (write_locks[base_lock_idx] == lock_num) {
 OPT_ASSERT(STM_PSEGMENT->objects_pointing_to_nursery != NULL);
 #ifdef STM_TESTS
 bool found = false;
@@ -171,33 +171,47 @@
 else {
 /* call the contention manager, and then retry (unless we were
aborted). */
-write_write_contention_management(lock_idx, obj);
+write_write_contention_management(base_lock_idx, obj);
 goto retry;
 }
 
 /* A common case for write_locks[] that was either 0 or lock_num:
-   we need to add the object to 'objects_pointing_to_nursery'
-   if there is such a list. */
-if (STM_PSEGMENT->objects_pointing_to_nursery != NULL) {
-dprintf_test(("write_slowpath %p -> old obj_to_nurs\n", obj));
-LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj);
+   we need to add the object to the appropriate list if there is one. */
+if (lock_whole) {
+if (STM_PSEGMENT->objects_pointing_to_nursery != NULL) {
+dprintf_test(("write_slowpath %p -> old obj_to_nurs\n", obj));
+LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj);
+}
+
+/* check that we really have a private page */
+assert(is_private_page(STM_SEGMENT->segment_num,
+   ((uintptr_t)obj) / 4096));
+/* check that so far all copies of the object have the flag */
+check_flag_write_barrier(obj);
+
+/* remove GCFLAG_WRITE_BARRIER if we succeeded in getting the base
+   write-lock (not for card marking). */
+assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
+obj->stm_flags &= ~GCFLAG_WRITE_BARRIER;
+
+/* for sanity, check again that all other segment copies of this
+   object still have the flag (so privatization worked) */
+check_flag_write_barrier(obj);
+
+} else { /* card marking case */
+
+if (!(obj->stm_flags & GCFLAG_CARDS_SET)) {
+/* not yet in the list (may enter here multiple times) */
+if (STM_PSEGMENT->old_objects_with_cards != NULL) {
+LIST_APPEND(STM_PSEGMENT->old_objects_with_cards, obj);
+}
+obj->stm_flags |= GCFLAG_CARDS_SET;
+}
+
+/* check that we really have a private page */
+assert(is_private_page(STM_SEGMENT->segment_num,
+   ((uintptr_t)obj + offset) / 4096));
 }
-
-/* check that we really have a private page */
-assert(is_private_page(STM_SEGMENT->segment_num,
-   ((uintptr_t)obj) / 4096));
-
-/* check that so far all copies of the object have the flag */
-check_flag_write_barrier(obj);
-
-/* remove GCFLAG_WRITE_BARRIER, but only if we succeeded in
-   getting the write-lock */
-assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
-obj->stm_flags &= ~GCFLAG_WRITE_BARRIER;
-
-/* for sanity, check again that all other segment copies of this
-   object still have the flag (so privatization worked) */
-check_flag_write_barrier(obj);
 }
 

[pypy-commit] stmgc card-marking: wip

2014-05-19 Thread Raemi
Author: Remi Meier 
Branch: card-marking
Changeset: r1213:aeafbbe2bb03
Date: 2014-05-19 16:45 +0200
http://bitbucket.org/pypy/stmgc/changeset/aeafbbe2bb03/

Log:wip

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -40,6 +40,39 @@
 #endif
 }
 
+static bool _stm_write_slowpath_overflow_objs(object_t *obj, uintptr_t offset)
+{
+/* is this an object from the same transaction, outside the nursery? */
+if ((obj->stm_flags & -GCFLAG_OVERFLOW_NUMBER_bit0)
+== STM_PSEGMENT->overflow_number) {
+
+assert(STM_PSEGMENT->objects_pointing_to_nursery != NULL);
+dprintf_test(("write_slowpath %p -> ovf obj_to_nurs\n", obj));
+
+if (!offset) {
+/* no card to be marked */
+obj->stm_flags &= ~GCFLAG_WRITE_BARRIER;
+LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj);
+} else {
+/* don't remove GCFLAG_WRITE_BARRIER because we need to be
+   here for every card to mark */
+if (!(obj->stm_flags & GCFLAG_CARDS_SET)) {
+/* not yet in the list */
+LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj);
+obj->stm_flags |= GCFLAG_CARDS_SET;
+}
+
+/* just acquire the corresponding lock for the next 
minor_collection
+   to know what may have changed. only we know about this object: 
*/
+uintptr_t lock_idx = get_write_lock_idx((uintptr_t)obj + offset);
+assert(!write_locks[lock_idx]);
+write_locks[lock_idx] = STM_PSEGMENT->write_lock_num;
+}
+return true;
+}
+return false;
+}
+
 void _stm_write_slowpath(object_t *obj, uintptr_t offset)
 {
 assert(IMPLY(!(obj->stm_flags & GCFLAG_HAS_CARDS),
@@ -49,16 +82,8 @@
 assert(!_is_young(obj));
 assert(obj->stm_flags & GCFLAG_WRITE_BARRIER);
 
-/* is this an object from the same transaction, outside the nursery? */
-if ((obj->stm_flags & -GCFLAG_OVERFLOW_NUMBER_bit0) ==
-STM_PSEGMENT->overflow_number) {
-
-dprintf_test(("write_slowpath %p -> ovf obj_to_nurs\n", obj));
-obj->stm_flags &= ~GCFLAG_WRITE_BARRIER;
-assert(STM_PSEGMENT->objects_pointing_to_nursery != NULL);
-LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj);
+if (_stm_write_slowpath_overflow_objs(obj, offset))
 return;
-}
 
 /* do a read-barrier now.  Note that this must occur before the
safepoints that may be issued in write_write_contention_management(). */
@@ -71,7 +96,7 @@
'modified_old_objects' (but, because it had GCFLAG_WRITE_BARRIER,
not in 'objects_pointing_to_nursery').  We'll detect this case
by finding that we already own the write-lock. */
-uintptr_t lock_idx = get_write_lock_idx(obj);
+uintptr_t lock_idx = get_write_lock_idx((uintptr_t)obj);
 uint8_t lock_num = STM_PSEGMENT->write_lock_num;
 assert(lock_idx < sizeof(write_locks));
  retry:
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -58,6 +58,8 @@
 
 /* Set on objects after allocation that may use card marking */
 GCFLAG_HAS_CARDS = _STM_GCFLAG_HAS_CARDS,
+/* Set on objects that have at least one card marked */
+GCFLAG_CARDS_SET = _STM_GCFLAG_CARDS_SET,
 
 /* All remaining bits of the 32-bit 'stm_flags' field are taken by
the "overflow number".  This is a number that identifies the
@@ -66,7 +68,7 @@
current transaction that have been flushed out of the nursery,
which occurs if the same transaction allocates too many objects.
 */
-GCFLAG_OVERFLOW_NUMBER_bit0 = 0x10   /* must be last */
+GCFLAG_OVERFLOW_NUMBER_bit0 = 0x20   /* must be last */
 };
 
 
@@ -220,8 +222,8 @@
 
 #define REAL_ADDRESS(segment_base, src)   ((segment_base) + (uintptr_t)(src))
 
-static inline uintptr_t get_write_lock_idx(object_t *obj) {
-return (((uintptr_t)obj) >> 4) - WRITELOCK_START;
+static inline uintptr_t get_write_lock_idx(uintptr_t obj) {
+return (obj >> 4) - WRITELOCK_START;
 }
 
 static inline char *get_segment_base(long segment_num) {
diff --git a/c7/stm/misc.c b/c7/stm/misc.c
--- a/c7/stm/misc.c
+++ b/c7/stm/misc.c
@@ -47,9 +47,9 @@
 STM_SEGMENT->transaction_read_version);
 }
 
-bool _stm_was_written_card(object_t *obj, uintptr_t offset)
+bool _stm_was_written_card(object_t *obj)
 {
-return write_locks[get_write_lock_idx((object_t*)((uintptr_t)obj + 
offset))];
+return obj->stm_flags & _STM_GCFLAG_CARDS_SET;
 }
 
 #ifdef STM_TESTS
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -84,6 +84,7 @@
 /* Check that some values are acceptable */
 assert(NB_SEGMENTS <= NB_SEGMENTS_MAX);
 assert(CARD_SIZE > 0 && CARD_SIZE % 16 == 0);
+assert(CARD_SIZE == 16);/* actually, it is hardcoded in some places 
right now.. */
 assert(4096 <= ((uintptr_t)STM_SEGMENT));
   

[pypy-commit] stmgc card-marking: expand the tests (still failing)

2014-05-19 Thread Raemi
Author: Remi Meier 
Branch: card-marking
Changeset: r1212:9759aad4236b
Date: 2014-05-19 15:58 +0200
http://bitbucket.org/pypy/stmgc/changeset/9759aad4236b/

Log:expand the tests (still failing)

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -44,8 +44,6 @@
 {
 assert(IMPLY(!(obj->stm_flags & GCFLAG_HAS_CARDS),
  offset == 0));
-if (offset)
-abort();
 
 assert(_seems_to_be_running_transaction());
 assert(!_is_young(obj));
@@ -73,7 +71,7 @@
'modified_old_objects' (but, because it had GCFLAG_WRITE_BARRIER,
not in 'objects_pointing_to_nursery').  We'll detect this case
by finding that we already own the write-lock. */
-uintptr_t lock_idx = (((uintptr_t)obj) >> 4) - WRITELOCK_START;
+uintptr_t lock_idx = get_write_lock_idx(obj);
 uint8_t lock_num = STM_PSEGMENT->write_lock_num;
 assert(lock_idx < sizeof(write_locks));
  retry:
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -220,6 +220,10 @@
 
 #define REAL_ADDRESS(segment_base, src)   ((segment_base) + (uintptr_t)(src))
 
+static inline uintptr_t get_write_lock_idx(object_t *obj) {
+return (((uintptr_t)obj) >> 4) - WRITELOCK_START;
+}
+
 static inline char *get_segment_base(long segment_num) {
 return stm_object_pages + segment_num * (NB_PAGES * 4096UL);
 }
@@ -252,6 +256,15 @@
 return rm == other_transaction_read_version;
 }
 
+static inline bool was_read_remote_card(char *base, object_t *obj, uintptr_t 
offset,
+uint8_t other_transaction_read_version)
+{
+uint8_t rm = ((struct stm_read_marker_s *)
+  (base + (((uintptr_t)obj + offset) >> 4)))->rm;
+assert(rm <= other_transaction_read_version);
+return rm == other_transaction_read_version;
+}
+
 static inline void _duck(void) {
 /* put a call to _duck() between two instructions that set 0 into
a %gs-prefixed address and that may otherwise be replaced with
diff --git a/c7/stm/misc.c b/c7/stm/misc.c
--- a/c7/stm/misc.c
+++ b/c7/stm/misc.c
@@ -40,6 +40,18 @@
 return (obj->stm_flags & _STM_GCFLAG_WRITE_BARRIER) == 0;
 }
 
+bool _stm_was_read_card(object_t *obj, uintptr_t offset)
+{
+return was_read_remote_card(
+STM_SEGMENT->segment_base, obj, offset,
+STM_SEGMENT->transaction_read_version);
+}
+
+bool _stm_was_written_card(object_t *obj, uintptr_t offset)
+{
+return write_locks[get_write_lock_idx((object_t*)((uintptr_t)obj + 
offset))];
+}
+
 #ifdef STM_TESTS
 uintptr_t _stm_get_private_page(uintptr_t pagenum)
 {
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -120,6 +120,8 @@
 #include 
 bool _stm_was_read(object_t *obj);
 bool _stm_was_written(object_t *obj);
+bool _stm_was_read_card(object_t *obj, uintptr_t offset);
+bool _stm_was_written_card(object_t *obj, uintptr_t offset);
 uintptr_t _stm_get_private_page(uintptr_t pagenum);
 bool _stm_in_transaction(stm_thread_local_t *tl);
 char *_stm_get_segment_base(long index);
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -58,7 +58,9 @@
 bool _checked_stm_write(object_t *obj);
 bool _checked_stm_write_card(object_t *obj, uintptr_t offset);
 bool _stm_was_read(object_t *obj);
+bool _stm_was_read_card(object_t *obj, uintptr_t offset);
 bool _stm_was_written(object_t *obj);
+bool _stm_was_written_card(object_t *obj, uintptr_t offset);
 char *_stm_real_address(object_t *obj);
 char *_stm_get_segment_base(long index);
 bool _stm_in_transaction(stm_thread_local_t *tl);
@@ -438,6 +440,12 @@
 def stm_was_written(o):
 return lib._stm_was_written(o)
 
+def stm_was_read_card(o, offset):
+return lib._stm_was_read_card(o, offset)
+
+def stm_was_written_card(o, offset):
+return lib._stm_was_written_card(o, offset)
+
 
 def stm_start_safe_point():
 lib._stm_start_safe_point()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc card-marking: make the 3 simple tests pass

2014-05-19 Thread Raemi
Author: Remi Meier 
Branch: card-marking
Changeset: r1216:1ce81b961157
Date: 2014-05-19 17:38 +0200
http://bitbucket.org/pypy/stmgc/changeset/1ce81b961157/

Log:make the 3 simple tests pass

diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -183,19 +183,42 @@
 minor_trace_if_young(&tl->thread_local_obj);
 }
 
+static void minor_trace_if_young_cards(object_t **pobj)
+{
+/* XXX: maybe add a specialised stmcb_trace_cards() */
+object_t *obj = *pobj;
+if (write_locks[get_write_lock_idx((uintptr_t)obj)])
+minor_trace_if_young(pobj);
+}
+
 static inline void _collect_now(object_t *obj)
 {
 assert(!_is_young(obj));
 
-/* We must not have GCFLAG_WRITE_BARRIER so far.  Add it now. */
-assert(!(obj->stm_flags & GCFLAG_WRITE_BARRIER));
-obj->stm_flags |= GCFLAG_WRITE_BARRIER;
+/* If WRITE_BARRIER: CARDS_SET */
+/* If not WRITE_BARRIER: maybe CARDS_SET */
+assert(IMPLY(obj->stm_flags & GCFLAG_WRITE_BARRIER,
+ obj->stm_flags & GCFLAG_CARDS_SET));
+if (!(obj->stm_flags & GCFLAG_WRITE_BARRIER)) {
+/* do normal full trace, even if also card-marked */
+obj->stm_flags |= GCFLAG_WRITE_BARRIER;
 
-/* Trace the 'obj' to replace pointers to nursery with pointers
-   outside the nursery, possibly forcing nursery objects out and
-   adding them to 'objects_pointing_to_nursery' as well. */
-char *realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
-stmcb_trace((struct object_s *)realobj, &minor_trace_if_young);
+/* Trace the 'obj' to replace pointers to nursery with pointers
+   outside the nursery, possibly forcing nursery objects out and
+   adding them to 'objects_pointing_to_nursery' as well. */
+char *realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
+stmcb_trace((struct object_s *)realobj, &minor_trace_if_young);
+} else {
+/* only trace cards */
+char *realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
+stmcb_trace((struct object_s *)realobj, &minor_trace_if_young_cards);
+}
+
+/* clear the CARDS_SET, but not the real cards since they are
+   still needed by STM conflict detection
+   XXX: maybe separate them since we now have to also trace all
+   these cards again in the next minor_collection */
+obj->stm_flags &= ~GCFLAG_CARDS_SET;
 }
 
 static void collect_oldrefs_to_nursery(void)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc card-marking: introduce old_objects_with_cards; 2 tests pass

2014-05-19 Thread Raemi
Author: Remi Meier 
Branch: card-marking
Changeset: r1214:e6dc7f070560
Date: 2014-05-19 16:59 +0200
http://bitbucket.org/pypy/stmgc/changeset/e6dc7f070560/

Log:introduce old_objects_with_cards; 2 tests pass

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -58,7 +58,7 @@
here for every card to mark */
 if (!(obj->stm_flags & GCFLAG_CARDS_SET)) {
 /* not yet in the list */
-LIST_APPEND(STM_PSEGMENT->objects_pointing_to_nursery, obj);
+LIST_APPEND(STM_PSEGMENT->old_objects_with_cards, obj);
 obj->stm_flags |= GCFLAG_CARDS_SET;
 }
 
@@ -68,8 +68,12 @@
 assert(!write_locks[lock_idx]);
 write_locks[lock_idx] = STM_PSEGMENT->write_lock_num;
 }
+
+/* We don't need to do anything in the STM part of the WB slowpath: */
 return true;
 }
+
+/* continue in STM part with no-overflow object */
 return false;
 }
 
@@ -512,6 +516,7 @@
 
 /* reset these lists to NULL for the next transaction */
 LIST_FREE(STM_PSEGMENT->objects_pointing_to_nursery);
+LIST_FREE(STM_PSEGMENT->old_objects_with_cards);
 LIST_FREE(STM_PSEGMENT->large_overflow_objects);
 
 timing_end_transaction(attribute_to);
@@ -690,6 +695,7 @@
 
 /* reset these lists to NULL too on abort */
 LIST_FREE(pseg->objects_pointing_to_nursery);
+LIST_FREE(pseg->old_objects_with_cards);
 LIST_FREE(pseg->large_overflow_objects);
 list_clear(pseg->young_weakrefs);
 }
diff --git a/c7/stm/core.h b/c7/stm/core.h
--- a/c7/stm/core.h
+++ b/c7/stm/core.h
@@ -103,6 +103,10 @@
understood as meaning implicitly "this is the same as
'modified_old_objects'". */
 struct list_s *objects_pointing_to_nursery;
+/* Like objects_pointing_to_nursery it holds the old objects that
+   we did a stm_write_card() on. Objects can be in both lists.
+   It is NULL iff objects_pointing_to_nursery is NULL. */
+struct list_s *old_objects_with_cards;
 
 /* List of all large, overflowed objects.  Only non-NULL after the
current transaction spanned a minor collection. */
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -332,6 +332,7 @@
 uintptr_t num_old;
 if (STM_PSEGMENT->objects_pointing_to_nursery == NULL) {
 STM_PSEGMENT->objects_pointing_to_nursery = list_create();
+STM_PSEGMENT->old_objects_with_cards = list_create();
 
 /* See the doc of 'objects_pointing_to_nursery': if it is NULL,
then it is implicitly understood to be equal to
diff --git a/c7/stm/setup.c b/c7/stm/setup.c
--- a/c7/stm/setup.c
+++ b/c7/stm/setup.c
@@ -119,6 +119,7 @@
 pr->pub.segment_num = i;
 pr->pub.segment_base = segment_base;
 pr->objects_pointing_to_nursery = NULL;
+pr->old_objects_with_cards = NULL;
 pr->large_overflow_objects = NULL;
 pr->modified_old_objects = list_create();
 pr->modified_old_objects_markers = list_create();
@@ -158,6 +159,7 @@
 for (i = 1; i <= NB_SEGMENTS; i++) {
 struct stm_priv_segment_info_s *pr = get_priv_segment(i);
 assert(pr->objects_pointing_to_nursery == NULL);
+assert(pr->old_objects_with_cards == NULL);
 assert(pr->large_overflow_objects == NULL);
 list_free(pr->modified_old_objects);
 list_free(pr->modified_old_objects_markers);
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy var-in-Some: register annotators for the base case of comparison operators

2014-05-19 Thread rlamy
Author: Ronan Lamy 
Branch: var-in-Some
Changeset: r71591:8fe91928ab37
Date: 2014-05-19 17:45 +0100
http://bitbucket.org/pypy/pypy/changeset/8fe91928ab37/

Log:register annotators for the base case of comparison operators

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -58,6 +58,18 @@
 r.set_knowntypedata(knowntypedata)
 return r
 
+def _make_cmp_annotator_default(cmp_op):
+@cmp_op.register(SomeObject, SomeObject)
+def default_annotate(obj1, obj2):
+s_1, s_2 = obj1.ann, obj2.ann
+if s_1.is_immutable_constant() and s_2.is_immutable_constant():
+return immutablevalue(cmp_op.pyfunc(s_1.const, s_2.const))
+else:
+return s_Bool
+
+for cmp_op in [op.lt, op.le, op.eq, op.ne, op.gt, op.ge]:
+_make_cmp_annotator_default(cmp_op)
+
 class __extend__(pairtype(SomeObject, SomeObject)):
 
 def union((obj1, obj2)):
@@ -86,42 +98,6 @@
 inplace_floordiv.can_only_throw = [ZeroDivisionError]
 inplace_mod.can_only_throw = [ZeroDivisionError]
 
-def lt((obj1, obj2)):
-if obj1.is_immutable_constant() and obj2.is_immutable_constant():
-return immutablevalue(obj1.const < obj2.const)
-else:
-return s_Bool
-
-def le((obj1, obj2)):
-if obj1.is_immutable_constant() and obj2.is_immutable_constant():
-return immutablevalue(obj1.const <= obj2.const)
-else:
-return s_Bool
-
-def eq((obj1, obj2)):
-if obj1.is_immutable_constant() and obj2.is_immutable_constant():
-return immutablevalue(obj1.const == obj2.const)
-else:
-return s_Bool
-
-def ne((obj1, obj2)):
-if obj1.is_immutable_constant() and obj2.is_immutable_constant():
-return immutablevalue(obj1.const != obj2.const)
-else:
-return s_Bool
-
-def gt((obj1, obj2)):
-if obj1.is_immutable_constant() and obj2.is_immutable_constant():
-return immutablevalue(obj1.const > obj2.const)
-else:
-return s_Bool
-
-def ge((obj1, obj2)):
-if obj1.is_immutable_constant() and obj2.is_immutable_constant():
-return immutablevalue(obj1.const >= obj2.const)
-else:
-return s_Bool
-
 def cmp((obj1, obj2)):
 if obj1.is_immutable_constant() and obj2.is_immutable_constant():
 return immutablevalue(cmp(obj1.const, obj2.const))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy var-in-Some: register annotators for comparisons on integers

2014-05-19 Thread rlamy
Author: Ronan Lamy 
Branch: var-in-Some
Changeset: r71592:51c01e84ed87
Date: 2014-05-19 19:26 +0100
http://bitbucket.org/pypy/pypy/changeset/51c01e84ed87/

Log:register annotators for comparisons on integers

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -3,7 +3,6 @@
 """
 
 import py
-import operator
 from rpython.tool.pairtype import pair, pairtype
 from rpython.annotator.model import (
 SomeObject, SomeInteger, SomeBool, s_Bool, SomeString, SomeChar, SomeList,
@@ -243,10 +242,14 @@
 return SomeInteger(nonneg=int1.nonneg, knowntype=int1.knowntype)
 rshift.can_only_throw = []
 
-def _compare_helper((int1, int2), opname, operation):
+
+def _make_cmp_annotator_int(cmp_op):
+@cmp_op.register(SomeInteger, SomeInteger)
+def _compare_helper(int1, int2):
 r = SomeBool()
-if int1.is_immutable_constant() and int2.is_immutable_constant():
-r.const = operation(int1.const, int2.const)
+s_int1, s_int2 = int1.ann, int2.ann
+if s_int1.is_immutable_constant() and s_int2.is_immutable_constant():
+r.const = cmp_op.pyfunc(s_int1.const, s_int2.const)
 #
 # The rest of the code propagates nonneg information between
 # the two arguments.
@@ -258,45 +261,38 @@
 # nonneg then "assert x>=y" will let the annotator know that
 # x is nonneg too, but it will not work if y is unsigned.
 #
-if not (rarithmetic.signedtype(int1.knowntype) and
-rarithmetic.signedtype(int2.knowntype)):
+if not (rarithmetic.signedtype(s_int1.knowntype) and
+rarithmetic.signedtype(s_int2.knowntype)):
 return r
 knowntypedata = {}
-op = getbookkeeper()._find_current_op(opname=opname, arity=2)
-def tointtype(int0):
-if int0.knowntype is bool:
+def tointtype(s_int0):
+if s_int0.knowntype is bool:
 return int
-return int0.knowntype
-if int1.nonneg and isinstance(op.args[1], Variable):
-case = opname in ('lt', 'le', 'eq')
-
-add_knowntypedata(knowntypedata, case, [op.args[1]],
-  SomeInteger(nonneg=True, 
knowntype=tointtype(int2)))
-if int2.nonneg and isinstance(op.args[0], Variable):
-case = opname in ('gt', 'ge', 'eq')
-add_knowntypedata(knowntypedata, case, [op.args[0]],
-  SomeInteger(nonneg=True, 
knowntype=tointtype(int1)))
+return s_int0.knowntype
+if s_int1.nonneg and isinstance(int2.value, Variable):
+case = cmp_op.opname in ('lt', 'le', 'eq')
+add_knowntypedata(knowntypedata, case, [int2.value],
+  SomeInteger(nonneg=True, 
knowntype=tointtype(s_int2)))
+if s_int2.nonneg and isinstance(int1.value, Variable):
+case = cmp_op.opname in ('gt', 'ge', 'eq')
+add_knowntypedata(knowntypedata, case, [int1.value],
+  SomeInteger(nonneg=True, 
knowntype=tointtype(s_int1)))
 r.set_knowntypedata(knowntypedata)
 # a special case for 'x < 0' or 'x >= 0',
 # where 0 is a flow graph Constant
 # (in this case we are sure that it cannot become a r_uint later)
-if (isinstance(op.args[1], Constant) and
-type(op.args[1].value) is int and# filter out Symbolics
-op.args[1].value == 0):
-if int1.nonneg:
-if opname == 'lt':
+if (isinstance(int2.value, Constant) and
+type(int2.value.value) is int and  # filter out Symbolics
+int2.value.value == 0):
+if s_int1.nonneg:
+if cmp_op.opname == 'lt':
 r.const = False
-if opname == 'ge':
+if cmp_op.opname == 'ge':
 r.const = True
 return r
 
-def lt(intint): return intint._compare_helper('lt', operator.lt)
-def le(intint): return intint._compare_helper('le', operator.le)
-def eq(intint): return intint._compare_helper('eq', operator.eq)
-def ne(intint): return intint._compare_helper('ne', operator.ne)
-def gt(intint): return intint._compare_helper('gt', operator.gt)
-def ge(intint): return intint._compare_helper('ge', operator.ge)
-
+for cmp_op in [op.lt, op.le, op.eq, op.ne, op.gt, op.ge]:
+_make_cmp_annotator_int(cmp_op)
 
 class __extend__(pairtype(SomeBool, SomeBool)):
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: kill unused SomeBuiltinMethod

2014-05-19 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r71593:583fddd89a2e
Date: 2014-05-19 20:43 +0100
http://bitbucket.org/pypy/pypy/changeset/583fddd89a2e/

Log:kill unused SomeBuiltinMethod

diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -533,12 +533,6 @@
 return False
 
 
-class SomeBuiltinMethod(SomeBuiltin):
-""" Stands for a built-in method which has got special meaning
-"""
-knowntype = MethodType
-
-
 class SomeImpossibleValue(SomeObject):
 """The empty set.  Instances are placeholders for objects that
 will never show up at run-time, e.g. elements of an empty list."""
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: attempt to get more debug output

2014-05-19 Thread pjenvey
Author: Philip Jenvey 
Branch: py3k
Changeset: r71595:8ca6146f84f2
Date: 2014-05-19 17:40 -0700
http://bitbucket.org/pypy/pypy/changeset/8ca6146f84f2/

Log:attempt to get more debug output

diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -116,6 +116,7 @@
 
 except BaseException as e:
 try:
+initstdio()
 stderr = sys.stderr
 print('Error calling sys.excepthook:', file=stderr)
 originalexcepthook(type(e), e, e.__traceback__)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k-memoryview: Fix.

2014-05-19 Thread Manuel Jacob
Author: Manuel Jacob
Branch: py3k-memoryview
Changeset: r71596:7a33e5f4c334
Date: 2014-05-20 02:59 +0200
http://bitbucket.org/pypy/pypy/changeset/7a33e5f4c334/

Log:Fix.

diff --git a/pypy/objspace/std/memoryobject.py 
b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -122,7 +122,7 @@
 
 def descr_len(self, space):
 self._check_released(space)
-return space.wrap(self.buf.getlength())
+return space.wrap(self.getlength())
 
 def w_get_format(self, space):
 self._check_released(space)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k-memoryview: Make lib-python tests work when pypy is translated without cpyext.

2014-05-19 Thread Manuel Jacob
Author: Manuel Jacob
Branch: py3k-memoryview
Changeset: r71597:627832fff626
Date: 2014-05-20 03:29 +0200
http://bitbucket.org/pypy/pypy/changeset/627832fff626/

Log:Make lib-python tests work when pypy is translated without cpyext.

diff --git a/lib-python/3/test/support.py b/lib-python/3/test/support.py
--- a/lib-python/3/test/support.py
+++ b/lib-python/3/test/support.py
@@ -25,7 +25,6 @@
 import logging.handlers
 import struct
 import tempfile
-import _testcapi
 
 try:
 import _thread, threading
@@ -1145,6 +1144,7 @@
 _TPFLAGS_HEAPTYPE = 1<<9
 
 def check_sizeof(test, o, size):
+import _testcapi
 result = sys.getsizeof(o)
 # add GC header size
 if ((type(o) == type) and (o.__flags__ & _TPFLAGS_HEAPTYPE) or\
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Split SomeBuiltinMethod from SomeBuiltin

2014-05-19 Thread rlamy
Author: Ronan Lamy 
Branch: 
Changeset: r71598:d11d5d0dc890
Date: 2014-05-20 02:28 +0100
http://bitbucket.org/pypy/pypy/changeset/d11d5d0dc890/

Log:Split SomeBuiltinMethod from SomeBuiltin

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -9,7 +9,7 @@
 SomeObject, SomeInteger, SomeBool, s_Bool, SomeString, SomeChar, SomeList,
 SomeDict, SomeOrderedDict, SomeUnicodeCodePoint, SomeUnicodeString,
 SomeTuple, SomeImpossibleValue, s_ImpossibleValue, SomeInstance,
-SomeBuiltin, SomeIterator, SomePBC, SomeFloat, s_None, SomeByteArray,
+SomeBuiltinMethod, SomeIterator, SomePBC, SomeFloat, s_None, SomeByteArray,
 SomeWeakRef, SomeSingleFloat,
 SomeLongFloat, SomeType, SomeConstantType, unionof, UnionError,
 read_can_only_throw, add_knowntypedata,
@@ -730,15 +730,14 @@
 return SomeIterator(s_cont, *iter1.variant)
 
 
-class __extend__(pairtype(SomeBuiltin, SomeBuiltin)):
-
+class __extend__(pairtype(SomeBuiltinMethod, SomeBuiltinMethod)):
 def union((bltn1, bltn2)):
 if (bltn1.analyser != bltn2.analyser or
-bltn1.methodname != bltn2.methodname or
-bltn1.s_self is None or bltn2.s_self is None):
+bltn1.methodname != bltn2.methodname):
 raise UnionError(bltn1, bltn2)
 s_self = unionof(bltn1.s_self, bltn2.s_self)
-return SomeBuiltin(bltn1.analyser, s_self, methodname=bltn1.methodname)
+return SomeBuiltinMethod(bltn1.analyser, s_self,
+methodname=bltn1.methodname)
 
 class __extend__(pairtype(SomePBC, SomePBC)):
 
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -533,6 +533,20 @@
 return False
 
 
+class SomeBuiltinMethod(SomeBuiltin):
+""" Stands for a built-in method which has got special meaning
+"""
+def __init__(self, analyser, s_self, methodname):
+if isinstance(analyser, MethodType):
+analyser = descriptor.InstanceMethod(
+analyser.im_func,
+analyser.im_self,
+analyser.im_class)
+self.analyser = analyser
+self.s_self = s_self
+self.methodname = methodname
+
+
 class SomeImpossibleValue(SomeObject):
 """The empty set.  Instances are placeholders for objects that
 will never show up at run-time, e.g. elements of an empty list."""
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -7,8 +7,8 @@
 from rpython.flowspace.operation import op
 from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool,
 SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
-SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeFloat, SomeIterator,
-SomePBC, SomeType, s_ImpossibleValue,
+SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeBuiltinMethod,
+SomeFloat, SomeIterator, SomePBC, SomeType, s_ImpossibleValue,
 s_Bool, s_None, unionof, add_knowntypedata,
 HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray)
 from rpython.annotator.bookkeeper import getbookkeeper, immutablevalue
@@ -108,7 +108,7 @@
 except AttributeError:
 return None
 else:
-return SomeBuiltin(analyser, self, name)
+return SomeBuiltinMethod(analyser, self, name)
 
 def getattr(self, s_attr):
 # get a SomeBuiltin if the SomeObject has
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -11,37 +11,32 @@
 
 class __extend__(annmodel.SomeBuiltin):
 def rtyper_makerepr(self, rtyper):
-if self.s_self is None:
-# built-in function case
-if not self.is_constant():
-raise TyperError("non-constant built-in function!")
-return BuiltinFunctionRepr(self.const)
-else:
-# built-in method case
-assert self.methodname is not None
-result = BuiltinMethodRepr(rtyper, self.s_self, self.methodname)
-return result
+if not self.is_constant():
+raise TyperError("non-constant built-in function!")
+return BuiltinFunctionRepr(self.const)
+
 def rtyper_makekey(self):
-if self.s_self is None:
-# built-in function case
+const = getattr(self, 'const', None)
+if extregistry.is_registered(const):
+const = extregistry.lookup(const)
+return self.__class__, const
 
-const = getattr(self, 'const', None)
+class __extend__(annmodel.SomeBuiltinMethod):
+def rtyper_makerepr(self, rtyper):
+assert self.methodname is not None
+result = BuiltinMethodRepr(rtyper, self.s_self, self.methodname)
+return result