[pypy-svn] pypy jit-int: hg merge default
hakanardo
commits-noreply at bitbucket.org
Sat Jan 8 13:13:06 CET 2011
Author: Hakan Ardo <hakan at debian.org>
Branch: jit-int
Changeset: r40490:3b4c00b5fa96
Date: 2011-01-08 11:41 +0100
http://bitbucket.org/pypy/pypy/changeset/3b4c00b5fa96/
Log: hg merge default
diff --git a/pypy/doc/faq.txt b/pypy/doc/faq.txt
--- a/pypy/doc/faq.txt
+++ b/pypy/doc/faq.txt
@@ -62,13 +62,8 @@
extensively). PyPy needs a CPython running on the target platform to
bootstrap, as cross compilation is not really meant to work yet.
At the moment you need CPython 2.4 (with ctypes) or CPython 2.5 or 2.6
-for the translation process.
+for the translation process. PyPy's JIT requires an x86 or x86_64 CPU.
-PyPy also basically works in a 64-bit Linux environment, but
-*it requires a 32-bit Intel CPU* for the JIT right now. (It works
-fine in a 32-bit chroot of an Intel 64.). There is also an ongoing
-summer of code project to provide 64bit support for JIT. It's scheduled
-to be finished by end of summer 2010.
------------------------------------------------
Which Python version (2.x?) does PyPy implement?
diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -1,6 +1,7 @@
-import py, sys, os
+import py, sys, os, textwrap, types
from pypy.interpreter.gateway import app2interp_temp
from pypy.interpreter.error import OperationError
+from pypy.interpreter.function import Method
from pypy.tool.pytest import appsupport
from pypy.tool.option import make_config, make_objspace
from pypy.config.config import ConflictConfigError
@@ -14,8 +15,8 @@
rsyncdirs = ['.', '../lib-python', '../lib_pypy', '../demo']
rsyncignore = ['_cache']
-# PyPy's command line extra options (these are added
-# to py.test's standard options)
+# PyPy's command line extra options (these are added
+# to py.test's standard options)
#
def _set_platform(opt, opt_str, value, parser):
@@ -54,8 +55,8 @@
_SPACECACHE={}
def gettestobjspace(name=None, **kwds):
- """ helper for instantiating and caching space's for testing.
- """
+ """ helper for instantiating and caching space's for testing.
+ """
try:
config = make_config(option, objspace=name, **kwds)
except ConflictConfigError, e:
@@ -195,30 +196,30 @@
except AttributeError:
pass
-#
-# Interfacing/Integrating with py.test's collection process
+#
+# Interfacing/Integrating with py.test's collection process
#
#
def ensure_pytest_builtin_helpers(helpers='skip raises'.split()):
""" hack (py.test.) raises and skip into builtins, needed
- for applevel tests to run directly on cpython but
+ for applevel tests to run directly on cpython but
apparently earlier on "raises" was already added
- to module's globals.
- """
+ to module's globals.
+ """
import __builtin__
- for helper in helpers:
+ for helper in helpers:
if not hasattr(__builtin__, helper):
setattr(__builtin__, helper, getattr(py.test, helper))
def pytest_pycollect_makemodule(path, parent):
return PyPyModule(path, parent)
-class PyPyModule(py.test.collect.Module):
- """ we take care of collecting classes both at app level
- and at interp-level (because we need to stick a space
- at the class) ourselves.
- """
+class PyPyModule(py.test.collect.Module):
+ """ we take care of collecting classes both at app level
+ and at interp-level (because we need to stick a space
+ at the class) ourselves.
+ """
def __init__(self, *args, **kwargs):
if hasattr(sys, 'pypy_objspaceclass'):
option.conf_iocapture = "sys" # pypy cannot do FD-based
@@ -252,16 +253,16 @@
# return True
return False
- def setup(self):
+ def setup(self):
# stick py.test raise in module globals -- carefully
- ensure_pytest_builtin_helpers()
- super(PyPyModule, self).setup()
- # if hasattr(mod, 'objspacename'):
+ ensure_pytest_builtin_helpers()
+ super(PyPyModule, self).setup()
+ # if hasattr(mod, 'objspacename'):
# mod.space = getttestobjspace(mod.objspacename)
- def makeitem(self, name, obj):
- if isclass(obj) and self.classnamefilter(name):
- if name.startswith('AppTest'):
+ def makeitem(self, name, obj):
+ if isclass(obj) and self.classnamefilter(name):
+ if name.startswith('AppTest'):
return AppClassCollector(name, parent=self)
elif name.startswith('ExpectTest'):
if option.rundirect:
@@ -274,18 +275,18 @@
# return AppExpectClassCollector(name, parent=self)
else:
return IntClassCollector(name, parent=self)
-
- elif hasattr(obj, 'func_code') and self.funcnamefilter(name):
- if name.startswith('app_test_'):
+
+ elif hasattr(obj, 'func_code') and self.funcnamefilter(name):
+ if name.startswith('app_test_'):
assert not obj.func_code.co_flags & 32, \
- "generator app level functions? you must be joking"
- return AppTestFunction(name, parent=self)
- elif obj.func_code.co_flags & 32: # generator function
- return self.Generator(name, parent=self)
- else:
- return IntTestFunction(name, parent=self)
+ "generator app level functions? you must be joking"
+ return AppTestFunction(name, parent=self)
+ elif obj.func_code.co_flags & 32: # generator function
+ return self.Generator(name, parent=self)
+ else:
+ return IntTestFunction(name, parent=self)
-def skip_on_missing_buildoption(**ropts):
+def skip_on_missing_buildoption(**ropts):
__tracebackhide__ = True
import sys
options = getattr(sys, 'pypy_translation_info', None)
@@ -293,12 +294,12 @@
py.test.skip("not running on translated pypy "
"(btw, i would need options: %s)" %
(ropts,))
- for opt in ropts:
- if not options.has_key(opt) or options[opt] != ropts[opt]:
+ for opt in ropts:
+ if not options.has_key(opt) or options[opt] != ropts[opt]:
break
else:
return
- py.test.skip("need translated pypy with: %s, got %s"
+ py.test.skip("need translated pypy with: %s, got %s"
%(ropts,options))
def getwithoutbinding(x, name):
@@ -361,8 +362,8 @@
tb = sys.exc_info()[2]
if e.match(space, space.w_KeyboardInterrupt):
raise OpErrKeyboardInterrupt, OpErrKeyboardInterrupt(), tb
- appexcinfo = appsupport.AppExceptionInfo(space, e)
- if appexcinfo.traceback:
+ appexcinfo = appsupport.AppExceptionInfo(space, e)
+ if appexcinfo.traceback:
raise AppError, AppError(appexcinfo), tb
raise
@@ -420,7 +421,7 @@
target = self.obj
if option.runappdirect:
return target()
- space = gettestobjspace()
+ space = gettestobjspace()
filename = self._getdynfilename(target)
func = app2interp_temp(target, filename=filename)
print "executing", func
@@ -430,47 +431,56 @@
code = getattr(func, 'im_func', func).func_code
return "[%s:%s]" % (code.co_filename, code.co_firstlineno)
-class AppTestMethod(AppTestFunction):
-
- def setup(self):
- super(AppTestMethod, self).setup()
- instance = self.parent.obj
- w_instance = self.parent.w_instance
- space = instance.space
- for name in dir(instance):
- if name.startswith('w_'):
+class AppTestMethod(AppTestFunction):
+ def setup(self):
+ super(AppTestMethod, self).setup()
+ instance = self.parent.obj
+ w_instance = self.parent.w_instance
+ space = instance.space
+ for name in dir(instance):
+ if name.startswith('w_'):
if option.runappdirect:
# if the value is a function living on the class,
# don't turn it into a bound method here
obj = getwithoutbinding(instance, name)
setattr(instance, name[2:], obj)
else:
- space.setattr(w_instance, space.wrap(name[2:]),
- getattr(instance, name))
+ obj = getattr(instance, name)
+ if isinstance(obj, types.MethodType):
+ source = py.std.inspect.getsource(obj).lstrip()
+ w_func = space.appexec([], textwrap.dedent("""
+ ():
+ %s
+ return %s
+ """) % (source, name))
+ w_obj = Method(space, w_func, w_instance, space.w_None)
+ else:
+ w_obj = obj
+ space.setattr(w_instance, space.wrap(name[2:]), w_obj)
def runtest_perform(self):
target = self.obj
if option.runappdirect:
return target()
- space = target.im_self.space
+ space = target.im_self.space
filename = self._getdynfilename(target)
- func = app2interp_temp(target.im_func, filename=filename)
- w_instance = self.parent.w_instance
- self.execute_appex(space, func, space, w_instance)
+ func = app2interp_temp(target.im_func, filename=filename)
+ w_instance = self.parent.w_instance
+ self.execute_appex(space, func, space, w_instance)
class PyPyClassCollector(py.test.collect.Class):
def setup(self):
- cls = self.obj
+ cls = self.obj
if not hasattr(cls, 'spaceconfig'):
- cls.space = LazyObjSpaceGetter()
+ cls.space = LazyObjSpaceGetter()
else:
assert hasattr(cls, 'space') # set by pytest_runtest_setup
- super(PyPyClassCollector, self).setup()
+ super(PyPyClassCollector, self).setup()
class IntInstanceCollector(py.test.collect.Instance):
- Function = IntTestFunction
-
-class IntClassCollector(PyPyClassCollector):
+ Function = IntTestFunction
+
+class IntClassCollector(PyPyClassCollector):
Instance = IntInstanceCollector
def _haskeyword(self, keyword):
@@ -480,21 +490,21 @@
def _keywords(self):
return super(IntClassCollector, self)._keywords() + ['interplevel']
-class AppClassInstance(py.test.collect.Instance):
- Function = AppTestMethod
+class AppClassInstance(py.test.collect.Instance):
+ Function = AppTestMethod
- def setup(self):
- super(AppClassInstance, self).setup()
- instance = self.obj
- space = instance.space
- w_class = self.parent.w_class
+ def setup(self):
+ super(AppClassInstance, self).setup()
+ instance = self.obj
+ space = instance.space
+ w_class = self.parent.w_class
if option.runappdirect:
self.w_instance = instance
else:
self.w_instance = space.call_function(w_class)
-class AppClassCollector(PyPyClassCollector):
- Instance = AppClassInstance
+class AppClassCollector(PyPyClassCollector):
+ Instance = AppClassInstance
def _haskeyword(self, keyword):
return keyword == 'applevel' or \
@@ -503,11 +513,11 @@
def _keywords(self):
return super(AppClassCollector, self)._keywords() + ['applevel']
- def setup(self):
- super(AppClassCollector, self).setup()
- cls = self.obj
- space = cls.space
- clsname = cls.__name__
+ def setup(self):
+ super(AppClassCollector, self).setup()
+ cls = self.obj
+ space = cls.space
+ clsname = cls.__name__
if option.runappdirect:
w_class = cls
else:
@@ -515,7 +525,7 @@
space.wrap(clsname),
space.newtuple([]),
space.newdict())
- self.w_class = w_class
+ self.w_class = w_class
class ExpectTestMethod(py.test.collect.Function):
def safe_name(target):
More information about the Pypy-commit
mailing list