[pypy-commit] pypy virtual-arguments: make the JIT explode if we try to push negative for alloc_and_set
fijal
noreply at buildbot.pypy.org
Wed Jul 18 13:58:04 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: virtual-arguments
Changeset: r56127:1196e6e8fd85
Date: 2012-07-18 13:57 +0200
http://bitbucket.org/pypy/pypy/changeset/1196e6e8fd85/
Log: make the JIT explode if we try to push negative for alloc_and_set
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -272,7 +272,6 @@
for i in range(take):
scope_w[i + input_argcount] = args_w[i]
input_argcount += take
- input_argcount = max(input_argcount, 0)
# collect extra positional arguments into the *vararg
if signature.has_vararg():
@@ -302,7 +301,10 @@
if num_kwds:
# kwds_mapping maps target indexes in the scope (minus input_argcount)
# to positions in the keywords_w list
- kwds_mapping = [0] * (co_argcount - input_argcount)
+ cnt = (co_argcount - input_argcount)
+ if cnt < 0:
+ cnt = 0
+ kwds_mapping = [0] * cnt
# initialize manually, for the JIT :-(
for i in range(len(kwds_mapping)):
kwds_mapping[i] = -1
diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -1430,6 +1430,8 @@
def do_fixed_newlist(self, op, args, arraydescr):
v_length = self._get_initial_newlist_length(op, args)
+ if v_length.concretetype == lltype.Signed:
+ raise Exception("[item] * lgt must have lgt to be proven non-negative for the JIT")
return SpaceOperation('new_array', [arraydescr, v_length], op.result)
def do_fixed_list_len(self, op, args, arraydescr):
diff --git a/pypy/jit/codewriter/test/test_codewriter.py b/pypy/jit/codewriter/test/test_codewriter.py
--- a/pypy/jit/codewriter/test/test_codewriter.py
+++ b/pypy/jit/codewriter/test/test_codewriter.py
@@ -221,3 +221,14 @@
assert 'setarrayitem_raw_i' in s
assert 'getarrayitem_raw_i' in s
assert 'residual_call_ir_v $<* fn _ll_1_raw_free__arrayPtr>' in s
+
+def test_newlist_negativ():
+ def f(n):
+ l = [0] * n
+ return len(l)
+
+ rtyper = support.annotate(f, [-1])
+ jitdriver_sd = FakeJitDriverSD(rtyper.annotator.translator.graphs[0])
+ cw = CodeWriter(FakeCPU(rtyper), [jitdriver_sd])
+ cw.find_all_graphs(FakePolicy())
+ py.test.raises(Exception, "cw.make_jitcodes(verbose=True)")
More information about the pypy-commit
mailing list