Author: mattip <[email protected]>
Branch: win-ordinal
Changeset: r55537:652affed05e0
Date: 2012-06-09 22:37 +0300
http://bitbucket.org/pypy/pypy/changeset/652affed05e0/
Log: merge default into branch
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -96,7 +96,8 @@
requires={
"shadowstack": [("translation.gctransformer",
"framework")],
"asmgcc": [("translation.gctransformer", "framework"),
- ("translation.backend", "c")],
+ ("translation.backend", "c"),
+ ("translation.shared", False)],
}),
# other noticeable options
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -85,13 +85,6 @@
_winreg
- Note that only some of these modules are built-in in a typical
- CPython installation, and the rest is from non built-in extension
- modules. This means that e.g. ``import parser`` will, on CPython,
- find a local file ``parser.py``, while ``import sys`` will not find a
- local file ``sys.py``. In PyPy the difference does not exist: all
- these modules are built-in.
-
* Supported by being rewritten in pure Python (possibly using ``ctypes``):
see the `lib_pypy/`_ directory. Examples of modules that we
support this way: ``ctypes``, ``cPickle``, ``cmath``, ``dbm``,
``datetime``...
diff --git a/pypy/jit/backend/test/runner_test.py
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -1110,6 +1110,79 @@
def test_virtual_ref_finish(self):
pass # VIRTUAL_REF_FINISH must not reach the backend nowadays
+ def test_arguments_to_execute_token(self):
+ # this test checks that execute_token() can be called with any
+ # variant of ints and floats as arguments
+ if self.cpu.supports_floats:
+ numkinds = 2
+ else:
+ numkinds = 1
+ seed = random.randrange(0, 10000)
+ print 'Seed is', seed # or choose it by changing the previous line
+ r = random.Random()
+ r.seed(seed)
+ for nb_args in range(50):
+ print 'Passing %d arguments to execute_token...' % nb_args
+ #
+ inputargs = []
+ values = []
+ for k in range(nb_args):
+ kind = r.randrange(0, numkinds)
+ if kind == 0:
+ inputargs.append(BoxInt())
+ values.append(r.randrange(-100000, 100000))
+ else:
+ inputargs.append(BoxFloat())
+ values.append(longlong.getfloatstorage(r.random()))
+ #
+ looptoken = JitCellToken()
+ faildescr = BasicFailDescr(42)
+ operations = []
+ retboxes = []
+ retvalues = []
+ #
+ ks = range(nb_args)
+ random.shuffle(ks)
+ for k in ks:
+ if isinstance(inputargs[k], BoxInt):
+ newbox = BoxInt()
+ x = r.randrange(-100000, 100000)
+ operations.append(
+ ResOperation(rop.INT_ADD, [inputargs[k],
+ ConstInt(x)], newbox)
+ )
+ y = values[k] + x
+ else:
+ newbox = BoxFloat()
+ x = r.random()
+ operations.append(
+ ResOperation(rop.FLOAT_ADD, [inputargs[k],
+ constfloat(x)], newbox)
+ )
+ y = longlong.getrealfloat(values[k]) + x
+ y = longlong.getfloatstorage(y)
+ kk = r.randrange(0, len(retboxes)+1)
+ retboxes.insert(kk, newbox)
+ retvalues.insert(kk, y)
+ #
+ operations.append(
+ ResOperation(rop.FINISH, retboxes, None, descr=faildescr)
+ )
+ print inputargs
+ for op in operations:
+ print op
+ self.cpu.compile_loop(inputargs, operations, looptoken)
+ #
+ fail = self.cpu.execute_token(looptoken, *values)
+ assert fail.identifier == 42
+ #
+ for k in range(len(retvalues)):
+ if isinstance(retboxes[k], BoxInt):
+ got = self.cpu.get_latest_value_int(k)
+ else:
+ got = self.cpu.get_latest_value_float(k)
+ assert got == retvalues[k]
+
def test_jump(self):
# this test generates small loops where the JUMP passes many
# arguments of various types, shuffling them around.
diff --git a/pypy/jit/backend/x86/tool/viewcode.py
b/pypy/jit/backend/x86/tool/viewcode.py
--- a/pypy/jit/backend/x86/tool/viewcode.py
+++ b/pypy/jit/backend/x86/tool/viewcode.py
@@ -253,7 +253,7 @@
self.logentries[addr] = pieces[3]
elif line.startswith('SYS_EXECUTABLE '):
filename = line[len('SYS_EXECUTABLE '):].strip()
- if filename != self.executable_name:
+ if filename != self.executable_name and filename != '??':
self.symbols.update(load_symbols(filename))
self.executable_name = filename
diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py
--- a/pypy/module/imp/importing.py
+++ b/pypy/module/imp/importing.py
@@ -263,7 +263,7 @@
w_mod = check_sys_modules_w(space, rel_modulename)
if w_mod is not None and space.is_w(w_mod, space.w_None):
# if we already find space.w_None, it means that we
- # already tried and failed and falled back to the
+ # already tried and failed and fell back to the
# end of this function.
w_mod = None
else:
@@ -283,10 +283,16 @@
return w_mod
def absolute_import(space, modulename, baselevel, fromlist_w, tentative):
- # Short path: check in sys.modules
- w_mod = absolute_import_try(space, modulename, baselevel, fromlist_w)
- if w_mod is not None and not space.is_w(w_mod, space.w_None):
- return w_mod
+ # Short path: check in sys.modules, but only if there is no conflict
+ # on the import lock. In the situation of 'import' statements
+ # inside tight loops, this should be true, and absolute_import_try()
+ # should be followed by the JIT and turned into not much code. But
+ # if the import lock is currently held by another thread, then we
+ # have to wait, and so shouldn't use the fast path.
+ if not getimportlock(space).lock_held_by_someone_else():
+ w_mod = absolute_import_try(space, modulename, baselevel, fromlist_w)
+ if w_mod is not None and not space.is_w(w_mod, space.w_None):
+ return w_mod
return absolute_import_with_lock(space, modulename, baselevel,
fromlist_w, tentative)
@@ -741,6 +747,9 @@
self.lockowner = None
self.lockcounter = 0
+ def lock_held_by_someone_else(self):
+ return self.lockowner is not None and not self.lock_held()
+
def lock_held(self):
me = self.space.getexecutioncontext() # used as thread ident
return self.lockowner is me
diff --git a/pypy/module/imp/test/test_import.py
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -1212,3 +1212,45 @@
"objspace.usepycfiles": True,
"objspace.lonepycfiles": True
}
+
+
+class AppTestMultithreadedImp(object):
+ def setup_class(cls):
+ #if not conftest.option.runappdirect:
+ # py.test.skip("meant as an -A test")
+ cls.space = gettestobjspace(usemodules=['thread', 'time'])
+ tmpfile = udir.join('test_multithreaded_imp.py')
+ tmpfile.write('''if 1:
+ x = 666
+ import time
+ for i in range(1000): time.sleep(0.001)
+ x = 42
+ ''')
+ cls.w_tmppath = cls.space.wrap(str(udir))
+
+ def test_multithreaded_import(self):
+ import sys, thread, time
+ oldpath = sys.path[:]
+ try:
+ sys.path.insert(0, self.tmppath)
+ got = []
+
+ def check():
+ import test_multithreaded_imp
+ got.append(getattr(test_multithreaded_imp, 'x', '?'))
+
+ for i in range(5):
+ thread.start_new_thread(check, ())
+
+ for n in range(100):
+ for i in range(105): time.sleep(0.001)
+ if len(got) == 5:
+ break
+ else:
+ raise AssertionError("got %r so far but still waiting" %
+ (got,))
+
+ assert got == [42] * 5, got
+
+ finally:
+ sys.path[:] = oldpath
diff --git a/pypy/translator/c/gcc/trackgcroot.py
b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -483,8 +483,10 @@
'inc', 'dec', 'not', 'neg', 'or', 'and', 'sbb', 'adc',
'shl', 'shr', 'sal', 'sar', 'rol', 'ror', 'mul', 'imul', 'div', 'idiv',
'bswap', 'bt', 'rdtsc',
- 'punpck', 'pshufd', 'pcmp', 'pand', 'psllw', 'pslld', 'psllq',
- 'paddq', 'pinsr', 'pmul', 'psrl',
+ 'pabs', 'pack', 'padd', 'palign', 'pand', 'pavg', 'pcmp', 'pextr',
+ 'phadd', 'phsub', 'pinsr', 'pmadd', 'pmax', 'pmin', 'pmovmsk',
+ 'pmul', 'por', 'psadb', 'pshuf', 'psign', 'psll', 'psra', 'psrl',
+ 'psub', 'punpck', 'pxor',
# all vectors don't produce pointers
'v',
# sign-extending moves should not produce GC pointers
@@ -492,7 +494,7 @@
# zero-extending moves should not produce GC pointers
'movz',
# locked operations should not move GC pointers, at least so far
- 'lock',
+ 'lock', 'pause',
])
# a partial list is hopefully good enough for now; it's all to support
diff --git a/pypy/translator/goal/app_main.py b/pypy/translator/goal/app_main.py
--- a/pypy/translator/goal/app_main.py
+++ b/pypy/translator/goal/app_main.py
@@ -457,13 +457,13 @@
if PYTHON26 and not options["ignore_environment"]:
if os.getenv('PYTHONNOUSERSITE'):
- options["no_user_site"] = True
+ options["no_user_site"] = 1
if os.getenv('PYTHONDONTWRITEBYTECODE'):
- options["dont_write_bytecode"] = True
+ options["dont_write_bytecode"] = 1
if (options["interactive"] or
(not options["ignore_environment"] and os.getenv('PYTHONINSPECT'))):
- options["inspect"] = True
+ options["inspect"] = 1
if PYTHON26 and we_are_translated():
flags = [options[flag] for flag in sys_flags]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit