[pypy-commit] pypy default: merge heads
arigo
noreply at buildbot.pypy.org
Mon Jun 13 20:31:54 CEST 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r44912:b76d054cf69d
Date: 2011-06-13 20:35 +0200
http://bitbucket.org/pypy/pypy/changeset/b76d054cf69d/
Log: merge heads
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -84,6 +84,7 @@
"_rawffi": [("objspace.usemodules.struct", True)],
"cpyext": [("translation.secondaryentrypoints", "cpyext"),
("translation.shared", sys.platform == "win32")],
+ "_ffi": [("translation.jit_ffi", True)],
}
module_import_dependencies = {
diff --git a/pypy/config/test/test_pypyoption.py b/pypy/config/test/test_pypyoption.py
--- a/pypy/config/test/test_pypyoption.py
+++ b/pypy/config/test/test_pypyoption.py
@@ -73,3 +73,7 @@
fn = prefix + "." + path + ".txt"
yield check_file_exists, fn
+def test__ffi_opt():
+ config = get_pypy_config(translating=True)
+ config.objspace.usemodules._ffi = True
+ assert config.translation.jit_ffi
diff --git a/pypy/config/translationoption.py b/pypy/config/translationoption.py
--- a/pypy/config/translationoption.py
+++ b/pypy/config/translationoption.py
@@ -117,6 +117,8 @@
ChoiceOption("jit_profiler", "integrate profiler support into the JIT",
["off", "oprofile"],
default="off"),
+ # jit_ffi is automatically turned on by withmod-_ffi (which is enabled by default)
+ BoolOption("jit_ffi", "optimize libffi calls", default=False, cmdline=None),
# misc
BoolOption("verbose", "Print extra information", default=False),
diff --git a/pypy/jit/metainterp/optimizeopt/__init__.py b/pypy/jit/metainterp/optimizeopt/__init__.py
--- a/pypy/jit/metainterp/optimizeopt/__init__.py
+++ b/pypy/jit/metainterp/optimizeopt/__init__.py
@@ -15,7 +15,7 @@
('virtualize', OptVirtualize),
('string', OptString),
('heap', OptHeap),
- ('ffi', OptFfiCall),
+ ('ffi', None),
('unroll', None)]
# no direct instantiation of unroll
unroll_all_opts = unrolling_iterable(ALL_OPTS)
@@ -25,10 +25,9 @@
ALL_OPTS_NAMES = ':'.join([name for name, _ in ALL_OPTS])
PARAMETERS['enable_opts'] = ALL_OPTS_NAMES
-def optimize_loop_1(metainterp_sd, loop, enable_opts,
+def build_opt_chain(metainterp_sd, enable_opts,
inline_short_preamble=True, retraced=False):
- """Optimize loop.operations to remove internal overheadish operations.
- """
+ config = metainterp_sd.config
optimizations = []
unroll = 'unroll' in enable_opts
for name, opt in unroll_all_opts:
@@ -40,6 +39,11 @@
# FIXME: Workaround to disable string optimisation
# during preamble but to keep it during the loop
optimizations.append(o)
+ elif name == 'ffi' and config.translation.jit_ffi:
+ # we cannot put the class directly in the unrolling_iterable,
+ # because we do not want it to be seen at all (to avoid to
+ # introduce a dependency on libffi in case we do not need it)
+ optimizations.append(OptFfiCall())
if ('rewrite' not in enable_opts or 'virtualize' not in enable_opts
or 'heap' not in enable_opts):
@@ -48,6 +52,17 @@
if inline_short_preamble:
optimizations = [OptInlineShortPreamble(retraced)] + optimizations
+ return optimizations, unroll
+
+
+def optimize_loop_1(metainterp_sd, loop, enable_opts,
+ inline_short_preamble=True, retraced=False):
+ """Optimize loop.operations to remove internal overheadish operations.
+ """
+
+ optimizations, unroll = build_opt_chain(metainterp_sd, enable_opts,
+ inline_short_preamble, retraced)
+
if unroll:
optimize_unroll(metainterp_sd, loop, optimizations)
else:
diff --git a/pypy/jit/metainterp/pyjitpl.py b/pypy/jit/metainterp/pyjitpl.py
--- a/pypy/jit/metainterp/pyjitpl.py
+++ b/pypy/jit/metainterp/pyjitpl.py
@@ -1262,8 +1262,7 @@
logger_ops = None
def __init__(self, cpu, options,
- ProfilerClass=EmptyProfiler, warmrunnerdesc=None,
- jit_ffi=True):
+ ProfilerClass=EmptyProfiler, warmrunnerdesc=None):
self.cpu = cpu
self.stats = self.cpu.stats
self.options = options
@@ -1273,7 +1272,11 @@
self.profiler = ProfilerClass()
self.profiler.cpu = cpu
self.warmrunnerdesc = warmrunnerdesc
- self.jit_ffi = jit_ffi
+ if warmrunnerdesc:
+ self.config = warmrunnerdesc.translator.config
+ else:
+ from pypy.config.pypyoption import get_pypy_config
+ self.config = get_pypy_config(translating=True)
backendmodule = self.cpu.__module__
backendmodule = backendmodule.split('.')[-2]
diff --git a/pypy/jit/metainterp/test/test_compile.py b/pypy/jit/metainterp/test/test_compile.py
--- a/pypy/jit/metainterp/test/test_compile.py
+++ b/pypy/jit/metainterp/test/test_compile.py
@@ -61,7 +61,6 @@
stats = Stats()
profiler = jitprof.EmptyProfiler()
warmrunnerdesc = None
- jit_ffi = False
def log(self, msg, event_kind=None):
pass
diff --git a/pypy/jit/metainterp/test/test_optimizefficall.py b/pypy/jit/metainterp/test/test_optimizefficall.py
--- a/pypy/jit/metainterp/test/test_optimizefficall.py
+++ b/pypy/jit/metainterp/test/test_optimizefficall.py
@@ -32,7 +32,6 @@
class TestFfiCall(BaseTestBasic, LLtypeMixin):
- jit_ffi = True
class namespace:
cpu = LLtypeMixin.cpu
diff --git a/pypy/jit/metainterp/test/test_optimizeopt.py b/pypy/jit/metainterp/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/test/test_optimizeopt.py
@@ -5,7 +5,7 @@
BaseTest)
import pypy.jit.metainterp.optimizeopt.optimizer as optimizeopt
import pypy.jit.metainterp.optimizeopt.virtualize as virtualize
-from pypy.jit.metainterp.optimizeopt import optimize_loop_1, ALL_OPTS_DICT
+from pypy.jit.metainterp.optimizeopt import optimize_loop_1, ALL_OPTS_DICT, build_opt_chain
from pypy.jit.metainterp.optimizeutil import InvalidLoop
from pypy.jit.metainterp.history import AbstractDescr, ConstInt, BoxInt
from pypy.jit.metainterp.history import TreeLoop, LoopToken
@@ -15,6 +15,7 @@
from pypy.jit.tool.oparser import pure_parse
from pypy.jit.metainterp.test.test_optimizebasic import equaloplists
from pypy.jit.metainterp.optimizeutil import args_dict
+from pypy.config.pypyoption import get_pypy_config
class Fake(object):
failargs_limit = 1000
@@ -22,12 +23,48 @@
class FakeMetaInterpStaticData(object):
- def __init__(self, cpu, jit_ffi=False):
+ def __init__(self, cpu):
self.cpu = cpu
self.profiler = EmptyProfiler()
self.options = Fake()
self.globaldata = Fake()
- self.jit_ffi = jit_ffi
+ self.config = get_pypy_config(translating=True)
+ self.config.translation.jit_ffi = True
+
+
+def test_build_opt_chain():
+ def check(chain, expected_names):
+ names = [opt.__class__.__name__ for opt in chain]
+ assert names == expected_names
+ #
+ metainterp_sd = FakeMetaInterpStaticData(None)
+ chain, _ = build_opt_chain(metainterp_sd, "", inline_short_preamble=False)
+ check(chain, ["OptSimplify"])
+ #
+ chain, _ = build_opt_chain(metainterp_sd, "")
+ check(chain, ["OptInlineShortPreamble", "OptSimplify"])
+ #
+ chain, _ = build_opt_chain(metainterp_sd, "")
+ check(chain, ["OptInlineShortPreamble", "OptSimplify"])
+ #
+ chain, _ = build_opt_chain(metainterp_sd, "heap:intbounds")
+ check(chain, ["OptInlineShortPreamble", "OptIntBounds", "OptHeap", "OptSimplify"])
+ #
+ chain, unroll = build_opt_chain(metainterp_sd, "unroll")
+ check(chain, ["OptInlineShortPreamble", "OptSimplify"])
+ assert unroll
+ #
+ chain, _ = build_opt_chain(metainterp_sd, "aaa:bbb", inline_short_preamble=False)
+ check(chain, ["OptSimplify"])
+ #
+ chain, _ = build_opt_chain(metainterp_sd, "ffi", inline_short_preamble=False)
+ check(chain, ["OptFfiCall", "OptSimplify"])
+ #
+ metainterp_sd.config = get_pypy_config(translating=True)
+ assert not metainterp_sd.config.translation.jit_ffi
+ chain, _ = build_opt_chain(metainterp_sd, "ffi", inline_short_preamble=False)
+ check(chain, ["OptSimplify"])
+
def test_store_final_boxes_in_guard():
from pypy.jit.metainterp.compile import ResumeGuardDescr
@@ -143,7 +180,6 @@
return sorted(boxes, key=lambda box: _kind2count[box.type])
class BaseTestOptimizeOpt(BaseTest):
- jit_ffi = False
def invent_fail_descr(self, model, fail_args):
if fail_args is None:
@@ -180,7 +216,7 @@
loop.preamble = TreeLoop('preamble')
loop.preamble.inputargs = loop.inputargs
loop.preamble.token = LoopToken()
- metainterp_sd = FakeMetaInterpStaticData(self.cpu, self.jit_ffi)
+ metainterp_sd = FakeMetaInterpStaticData(self.cpu)
if hasattr(self, 'vrefinfo'):
metainterp_sd.virtualref_info = self.vrefinfo
if hasattr(self, 'callinfocollection'):
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -84,7 +84,7 @@
return self.get_concrete().descr_len(space)
def descr_getitem(self, space, w_idx):
- # TODO: indexation by tuples
+ # TODO: indexing by tuples
start, stop, step, slice_length = space.decode_index4(w_idx, self.find_size())
if step == 0:
# Single index
@@ -93,7 +93,6 @@
# Slice
res = SingleDimSlice(start, stop, step, slice_length, self, self.signature.transition(SingleDimSlice.static_signature))
return space.wrap(res)
-
@unwrap_spec(item=int, value=float)
def descr_setitem(self, space, item, value):
@@ -233,7 +232,7 @@
def descr_len(self, space):
return space.wrap(self.find_size())
-
+
def calc_index(self, item):
raise NotImplementedError
diff --git a/pypy/module/micronumpy/test/test_base.py b/pypy/module/micronumpy/test/test_base.py
--- a/pypy/module/micronumpy/test/test_base.py
+++ b/pypy/module/micronumpy/test/test_base.py
@@ -17,3 +17,13 @@
assert v2.signature is v3.signature
v4 = ar.descr_add(space, ar)
assert v1.signature is v4.signature
+
+ def test_slice_signature(self, space):
+ ar = SingleDimArray(10)
+ v1 = ar.descr_getitem(space, space.wrap(slice(1, 5, 1)))
+ v2 = ar.descr_getitem(space, space.wrap(slice(4, 6, 1)))
+ assert v1.signature is v2.signature
+
+ v3 = ar.descr_add(space, v1)
+ v4 = ar.descr_add(space, v2)
+ assert v3.signature is v4.signature
\ No newline at end of file
More information about the pypy-commit
mailing list