[pypy-commit] pypy optresult: merge default
fijal
noreply at buildbot.pypy.org
Fri Feb 27 15:40:46 CET 2015
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: optresult
Changeset: r76161:49b01bee468c
Date: 2015-02-27 14:15 +0200
http://bitbucket.org/pypy/pypy/changeset/49b01bee468c/
Log: merge default
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -36,7 +36,7 @@
def pytest_addoption(parser):
from rpython.conftest import pytest_addoption
pytest_addoption(parser)
-
+
group = parser.getgroup("pypy options")
group.addoption('-A', '--runappdirect', action="store_true",
default=False, dest="runappdirect",
@@ -44,6 +44,9 @@
group.addoption('--direct', action="store_true",
default=False, dest="rundirect",
help="run pexpect tests directly")
+ group.addoption('--raise-operr', action="store_true",
+ default=False, dest="raise_operr",
+ help="Show the interp-level OperationError in app-level tests")
def pytest_funcarg__space(request):
from pypy.tool.pytest.objspace import gettestobjspace
diff --git a/pypy/doc/embedding.rst b/pypy/doc/embedding.rst
--- a/pypy/doc/embedding.rst
+++ b/pypy/doc/embedding.rst
@@ -36,7 +36,8 @@
"PyPy home directory". The arguments are:
* ``home``: NULL terminated path to an executable inside the pypy directory
- (can be a .so name, can be made up)
+ (can be a .so name, can be made up). Used to look up the standard
+ library, and is also set as ``sys.executable``.
* ``verbose``: if non-zero, it will print error messages to stderr
diff --git a/pypy/doc/jit-hooks.rst b/pypy/doc/jit-hooks.rst
--- a/pypy/doc/jit-hooks.rst
+++ b/pypy/doc/jit-hooks.rst
@@ -39,3 +39,30 @@
Reason is a string, the meaning of other arguments is the same
as attributes on JitLoopInfo object
+.. function:: enable_debug()
+
+ Start recording debugging counters for ``get_stats_snapshot``
+
+.. function:: disable_debug()
+
+ Stop recording debugging counters for ``get_stats_snapshot``
+
+.. function:: get_stats_snapshot()
+
+ Get the jit status in the specific moment in time. Note that this
+ is eager - the attribute access is not lazy, if you need new stats
+ you need to call this function again. You might want to call
+ ``enable_debug`` to get more information. It returns an instance
+ of ``JitInfoSnapshot``
+
+.. class:: JitInfoSnapshot
+
+ A class describing current snapshot. Usable attributes:
+
+ * ``counters`` - internal JIT integer counters
+
+ * ``counter_times`` - internal JIT float counters, notably time spent
+ TRACING and in the JIT BACKEND
+
+ * ``loop_run_times`` - counters for number of times loops are run, only
+ works when ``enable_debug`` is called.
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -106,6 +106,9 @@
space.call_function(w_pathsetter, w_path)
# import site
try:
+ space.setattr(space.getbuiltinmodule('sys'),
+ space.wrap('executable'),
+ space.wrap(home))
import_ = space.getattr(space.getbuiltinmodule('__builtin__'),
space.wrap('__import__'))
space.call_function(import_, space.wrap('site'))
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
@@ -1,5 +1,5 @@
#! /usr/bin/env python
-# App-level version of py.py.
+# This is pure Python code that handles the main entry point into "pypy".
# See test/test_app_main.
# Missing vs CPython: -d, -t, -v, -x, -3
@@ -157,10 +157,13 @@
current = group
raise SystemExit
+def get_sys_executable():
+ return getattr(sys, 'executable', 'pypy')
+
def print_help(*args):
import os
print 'usage: %s [option] ... [-c cmd | -m mod | file | -] [arg] ...' % (
- sys.executable,)
+ get_sys_executable(),)
print USAGE1,
if 'pypyjit' in sys.builtin_module_names:
print "--jit options: advanced JIT options: try 'off' or 'help'"
@@ -171,7 +174,7 @@
try:
import pypyjit
except ImportError:
- print >> sys.stderr, "No jit support in %s" % (sys.executable,)
+ print >> sys.stderr, "No jit support in %s" % (get_sys_executable(),)
return
items = sorted(pypyjit.defaults.items())
print 'Advanced JIT options: a comma-separated list of OPTION=VALUE:'
@@ -209,7 +212,7 @@
raise SystemExit
if 'pypyjit' not in sys.builtin_module_names:
print >> sys.stderr, ("Warning: No jit support in %s" %
- (sys.executable,))
+ (get_sys_executable(),))
else:
import pypyjit
pypyjit.set_param(jitparam)
@@ -219,8 +222,8 @@
def print_error(msg):
print >> sys.stderr, msg
- print >> sys.stderr, 'usage: %s [options]' % (sys.executable,)
- print >> sys.stderr, 'Try `%s -h` for more information.' % (sys.executable,)
+ print >> sys.stderr, 'usage: %s [options]' % (get_sys_executable(),)
+ print >> sys.stderr, 'Try `%s -h` for more information.' % (get_sys_executable(),)
def fdopen(fd, mode, bufsize=-1):
try:
@@ -514,6 +517,10 @@
elif not sys.stdout.isatty():
set_fully_buffered_io()
+ if we_are_translated():
+ import __pypy__
+ __pypy__.save_module_content_for_future_reload(sys)
+
mainmodule = type(sys)('__main__')
sys.modules['__main__'] = mainmodule
diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py
--- a/pypy/interpreter/mixedmodule.py
+++ b/pypy/interpreter/mixedmodule.py
@@ -55,7 +55,10 @@
if self.w_initialdict is None:
Module.init(self, space)
if not self.lazy and self.w_initialdict is None:
- self.w_initialdict = space.call_method(self.w_dict, 'items')
+ self.save_module_content_for_future_reload()
+
+ def save_module_content_for_future_reload(self):
+ self.w_initialdict = self.space.call_method(self.w_dict, 'items')
def get_applevel_name(cls):
@@ -119,7 +122,7 @@
w_value = self.get(name)
space.setitem(self.w_dict, space.new_interned_str(name), w_value)
self.lazy = False
- self.w_initialdict = space.call_method(self.w_dict, 'items')
+ self.save_module_content_for_future_reload()
return self.w_dict
def _cleanup_(self):
diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py
--- a/pypy/interpreter/test/test_objspace.py
+++ b/pypy/interpreter/test/test_objspace.py
@@ -373,7 +373,7 @@
config = make_config(None)
space = make_objspace(config)
w_executable = space.wrap('executable')
- assert space.str_w(space.getattr(space.sys, w_executable)) == 'py.py'
+ assert space.findattr(space.sys, w_executable) is None
space.setattr(space.sys, w_executable, space.wrap('foobar'))
assert space.str_w(space.getattr(space.sys, w_executable)) == 'foobar'
space.startup()
diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py
--- a/pypy/interpreter/test/test_targetpypy.py
+++ b/pypy/interpreter/test/test_targetpypy.py
@@ -8,7 +8,7 @@
entry_point = get_entry_point(config)[0]
entry_point(['pypy-c' , '-S', '-c', 'print 3'])
-def test_exeucte_source(space):
+def test_execute_source(space):
_, d = create_entry_point(space, None)
execute_source = d['pypy_execute_source']
lls = rffi.str2charp("import sys; sys.modules['xyz'] = 3")
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -82,6 +82,8 @@
'strategy' : 'interp_magic.strategy', # dict,set,list
'set_debug' : 'interp_magic.set_debug',
'locals_to_fast' : 'interp_magic.locals_to_fast',
+ 'save_module_content_for_future_reload':
+ 'interp_magic.save_module_content_for_future_reload',
}
if sys.platform == 'win32':
interpleveldefs['get_console_cp'] = 'interp_magic.get_console_cp'
diff --git a/pypy/module/__pypy__/interp_magic.py b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -1,6 +1,7 @@
from pypy.interpreter.error import OperationError, wrap_oserror
from pypy.interpreter.gateway import unwrap_spec
from pypy.interpreter.pyframe import PyFrame
+from pypy.interpreter.mixedmodule import MixedModule
from rpython.rlib.objectmodel import we_are_translated
from pypy.objspace.std.dictmultiobject import W_DictMultiObject
from pypy.objspace.std.listobject import W_ListObject
@@ -130,3 +131,7 @@
def locals_to_fast(space, w_frame):
assert isinstance(w_frame, PyFrame)
w_frame.locals2fast()
+
+ at unwrap_spec(w_module=MixedModule)
+def save_module_content_for_future_reload(space, w_module):
+ w_module.save_module_content_for_future_reload()
diff --git a/pypy/module/__pypy__/test/test_magic.py b/pypy/module/__pypy__/test/test_magic.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/__pypy__/test/test_magic.py
@@ -0,0 +1,15 @@
+
+class AppTestMagic:
+ spaceconfig = dict(usemodules=['__pypy__'])
+
+ def test_save_module_content_for_future_reload(self):
+ import sys, __pypy__
+ d = sys.dont_write_bytecode
+ sys.dont_write_bytecode = "hello world"
+ __pypy__.save_module_content_for_future_reload(sys)
+ sys.dont_write_bytecode = d
+ reload(sys)
+ assert sys.dont_write_bytecode == "hello world"
+ #
+ sys.dont_write_bytecode = d
+ __pypy__.save_module_content_for_future_reload(sys)
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -1,4 +1,4 @@
-from rpython.rlib import jit
+from rpython.rlib import jit, rgc
from rpython.rlib.buffer import Buffer
from rpython.rlib.objectmodel import keepalive_until_here
from rpython.rlib.rarithmetic import ovfcheck, widen
@@ -698,11 +698,9 @@
self.space.wrap(msg))
return result
+ @rgc.must_be_light_finalizer
def __del__(self):
- # note that we don't call clear_all_weakrefs here because
- # an array with freed buffer is ok to see - it's just empty with 0
- # length
- self.setlen(0)
+ lltype.free(self.buffer, flavor='raw')
def setlen(self, size, zero=False, overallocate=True):
if size > 0:
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -64,7 +64,6 @@
'call_tracing' : 'vm.call_tracing',
'getsizeof' : 'vm.getsizeof',
- 'executable' : 'space.wrap("py.py")',
'api_version' : 'version.get_api_version(space)',
'version_info' : 'version.get_version_info(space)',
'version' : 'version.get_version(space)',
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -500,7 +500,7 @@
assert isinstance(sys.builtin_module_names, tuple)
assert isinstance(sys.copyright, basestring)
#assert isinstance(sys.exec_prefix, basestring) -- not present!
- assert isinstance(sys.executable, basestring)
+ #assert isinstance(sys.executable, basestring) -- not present!
assert isinstance(sys.hexversion, int)
assert isinstance(sys.maxint, int)
assert isinstance(sys.maxsize, int)
@@ -519,6 +519,12 @@
assert vi[3] in ("alpha", "beta", "candidate", "final")
assert isinstance(vi[4], int)
+ def test_reload_doesnt_override_sys_executable(self):
+ import sys
+ sys.executable = 'from_test_sysmodule'
+ reload(sys)
+ assert sys.executable == 'from_test_sysmodule'
+
def test_settrace(self):
import sys
counts = []
diff --git a/pypy/tool/pytest/apptest.py b/pypy/tool/pytest/apptest.py
--- a/pypy/tool/pytest/apptest.py
+++ b/pypy/tool/pytest/apptest.py
@@ -35,7 +35,7 @@
try:
target(*args)
except OperationError, e:
- if self.config.option.verbose:
+ if self.config.option.raise_operr:
raise
tb = sys.exc_info()[2]
if e.match(space, space.w_KeyboardInterrupt):
diff --git a/rpython/doc/index.rst b/rpython/doc/index.rst
--- a/rpython/doc/index.rst
+++ b/rpython/doc/index.rst
@@ -36,6 +36,7 @@
:maxdepth: 1
arm
+ logging
Writing your own interpreter in RPython
diff --git a/rpython/doc/logging.rst b/rpython/doc/logging.rst
new file mode 100644
--- /dev/null
+++ b/rpython/doc/logging.rst
@@ -0,0 +1,55 @@
+Logging environment variables
+=============================
+
+PyPy, and all other RPython programs, support some special environment
+variables used to tweak various advanced parameters.
+
+
+Garbage collector
+-----------------
+
+Right now the default GC is (an incremental version of) MiniMark__.
+It has :ref:`a number of environment variables
+<minimark-environment-variables>` that can be tweaked. Their default
+value should be ok for most usages.
+
+.. __: garbage_collection.html#minimark-gc
+
+
+PYPYLOG
+-------
+
+The ``PYPYLOG`` environment variable enables debugging output. For
+example::
+
+ PYPYLOG=jit:log
+
+means enabling all debugging output from the JIT, and writing to a
+file called ``log``. More precisely, the condition ``jit`` means
+enabling output of all sections whose name start with ``jit``; other
+interesting names to use here are ``gc`` to get output from the GC, or
+``jit-backend`` to get only output from the JIT's machine code
+backend. It is possible to use several prefixes, like in the
+following example::
+
+ PYPYLOG=jit-log-opt,jit-backend:log
+
+which outputs sections containing to the optimized loops plus anything
+produced from the JIT backend. The above example is what you need for
+jitviewer_.
+
+.. _jitviewer: https://bitbucket.org/pypy/jitviewer
+
+The filename can be given as ``-`` to dump the log to stderr.
+
+As a special case, the value ``PYPYLOG=+filename`` means that only
+the section markers are written (for any section). This is mostly
+only useful for ``rpython/tool/logparser.py``.
+
+
+PYPYSTM
+-------
+
+Only available in ``pypy-stm``. Names a log file into which the
+PyPy-STM will output contention information. Can be read with
+``pypy/stm/print_stm_log.py``.
diff --git a/rpython/jit/backend/llsupport/test/test_asmmemmgr.py b/rpython/jit/backend/llsupport/test/test_asmmemmgr.py
--- a/rpython/jit/backend/llsupport/test/test_asmmemmgr.py
+++ b/rpython/jit/backend/llsupport/test/test_asmmemmgr.py
@@ -178,7 +178,11 @@
assert p[3] == 'y'
assert p[4] == 'Z'
assert p[5] == 'z'
- assert allblocks == [(rawstart, rawstart + 6)]
+ # 'allblocks' should be one block of length 6 + 15
+ # (15 = alignment - 1) containing the range(rawstart, rawstart + 6)
+ [(blockstart, blockend)] = allblocks
+ assert blockend == blockstart + 6 + (mc.ALIGN_MATERIALIZE - 1)
+ assert blockstart <= rawstart < rawstart + 6 <= blockend
assert puts == [(rawstart + 2, ['a', 'b', 'c', 'd']),
(rawstart + 4, ['e', 'f', 'g'])]
diff --git a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
--- a/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
+++ b/rpython/jit/backend/x86/test/test_rx86_32_auto_encoding.py
@@ -317,7 +317,9 @@
# CALL_j is actually relative, so tricky to test
(instrname == 'CALL' and argmodes == 'j') or
# SET_ir must be tested manually
- (instrname == 'SET' and argmodes == 'ir')
+ (instrname == 'SET' and argmodes == 'ir') or
+ # MULTIBYTE_NOPs can't easily be tested the same way
+ (instrname == 'MULTIBYTE')
)
diff --git a/rpython/jit/metainterp/compile.py b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -696,6 +696,9 @@
class ResumeGuardNotInvalidated(ResumeGuardDescr):
guard_opnum = rop.GUARD_NOT_INVALIDATED
+ def must_compile(self, deadframe, metainterp_sd, jitdriver_sd):
+ return False
+
class ResumeAtPositionDescr(ResumeGuardDescr):
guard_opnum = rop.GUARD_FUTURE_CONDITION
diff --git a/rpython/rlib/listsort.py b/rpython/rlib/listsort.py
--- a/rpython/rlib/listsort.py
+++ b/rpython/rlib/listsort.py
@@ -496,6 +496,12 @@
# 1. len[-3] > len[-2] + len[-1]
# 2. len[-2] > len[-1]
#
+ # Note these invariants will not hold for the entire pending array even
+ # after this function completes. [1] This does not affect the
+ # correctness of the overall algorithm.
+ #
+ # [1] http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/
+ #
# See listsort.txt for more info.
def merge_collapse(self):
diff --git a/rpython/translator/goal/order.py b/rpython/translator/goal/order.py
deleted file mode 100644
--- a/rpython/translator/goal/order.py
+++ /dev/null
@@ -1,56 +0,0 @@
-import sys
-import os
-
-RTYPERORDER = os.getenv('RTYPERORDER').split(',')
-if len(RTYPERORDER) == 2:
- module_list = RTYPERORDER[1]
-else:
- module_list = 'module-list'
-
-lst = open(module_list, 'r')
-try:
- print "reading module-list: %s" % module_list
- prefixes = lst.readlines()
-finally:
- lst.close()
-
-prefixes = [line.strip() for line in prefixes]
-prefixes = [line for line in prefixes if line and not line.startswith('#')]
-
-NOMATCH = sys.maxint
-
-def order(annotator, pending):
- cache = {}
- annotated = annotator.annotated
- def indx(block):
- func = annotated[block]
- module = func.__module__
- if module is None:
- module = 'None'
- tag = "%s:%s" % (module, func.__name__)
- try:
- return cache[tag]
- except KeyError:
- match = NOMATCH
- i = 0
- for pfx in prefixes:
- if tag.startswith(pfx):
- if match == NOMATCH:
- match = i
- else:
- if len(pfx) > len(prefixes[match]):
- match = i
- i += 1
- cache[tag] = match, module
- return match
-
- pending.sort(lambda blk1, blk2: cmp(indx(blk1), indx(blk2)))
-
- cur_module = ['$']
-
- def track(block):
- module = annotated[block].__module__
- if module != cur_module[0]:
- print "--- Specializing blocks in module: %s" % module
- cur_module[0] = module
- return track
More information about the pypy-commit
mailing list