[pypy-commit] pypy force-virtual-state: Assertion and add a proper test
sbauman
pypy.commits at gmail.com
Wed Aug 31 19:20:45 EDT 2016
Author: Spenser Andrew Bauman <sabauma at gmail.com>
Branch: force-virtual-state
Changeset: r86801:b46132df6a05
Date: 2016-08-31 19:19 -0400
http://bitbucket.org/pypy/pypy/changeset/b46132df6a05/
Log: Assertion and add a proper test
diff --git a/rpython/jit/metainterp/optimizeopt/virtualstate.py b/rpython/jit/metainterp/optimizeopt/virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/virtualstate.py
@@ -552,10 +552,10 @@
"""
Generate the guards and add state information for unifying a virtual
object with a non-virtual. This involves forcing the object in the
- event that unifcation can succeed. Since virtual objects cannot be null,
+ event that unification can succeed. Since virtual objects cannot be null,
this method need only check that the virtual object has the expected type.
"""
- assert isinstance(other, VirtualStateInfo)
+ assert state.force_boxes and isinstance(other, VirtualStateInfo)
if self.level == LEVEL_CONSTANT:
raise VirtualStatesCantMatch(
diff --git a/rpython/jit/metainterp/test/test_ajit.py b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -4508,32 +4508,3 @@
return i
self.meta_interp(f, [])
- def test_loop_unroll_bug(self):
- driver = JitDriver(greens=[], reds=['acc', 'i', 'val'])
- class X(object):
- # _immutable_ = True
- def __init__(self, v):
- self.v = v
-
- class Box(object):
- def __init__(self, v):
- self.unbox = v
-
- const = Box(X(5))
- def f(v):
- val = X(0)
- acc = 0
- i = 0
- const.unbox = X(5)
- while i < 100:
- driver.can_enter_jit(acc=acc, i=i, val=val)
- driver.jit_merge_point(acc=acc, i=i, val=val)
- acc += val.v
- if i & 0b100 == 0:
- val = const.unbox
- else:
- val = X(i)
- i += 1
- return acc
- result = self.meta_interp(f, [10])
- # import pdb; pdb.set_trace()
diff --git a/rpython/jit/metainterp/test/test_virtual.py b/rpython/jit/metainterp/test/test_virtual.py
--- a/rpython/jit/metainterp/test/test_virtual.py
+++ b/rpython/jit/metainterp/test/test_virtual.py
@@ -1,8 +1,8 @@
import py
-from rpython.rlib.jit import JitDriver, promote, dont_look_inside
+from rpython.rlib.jit import JitDriver, promote, dont_look_inside, set_param
from rpython.rlib.objectmodel import compute_unique_id
from rpython.jit.codewriter.policy import StopAtXPolicy
-from rpython.jit.metainterp.test.support import LLJitMixin
+from rpython.jit.metainterp.test.support import LLJitMixin, get_stats
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.rtyper import rclass
from rpython.rtyper.lltypesystem.lloperation import llop
@@ -965,6 +965,47 @@
self.check_aborted_count(0)
self.check_target_token_count(4)
+ def test_avoid_preamble(self):
+ driver = JitDriver(greens=[], reds=['i', 'val'])
+ class X(object):
+ def __init__(self, v):
+ self.v = v
+
+ class Box(object):
+ def __init__(self, v):
+ self.unbox = v
+
+ mask = -2
+ const = Box(X(5))
+ def f():
+ # Prevent all retracing of side exits. Ensures that the unroll
+ # optimizer will attempt to jump to either the preamble or loop.
+ set_param(driver, 'retrace_limit', -1)
+ set_param(driver, 'threshold', 1)
+ val = X(0)
+ i = 0
+ const.unbox = X(5)
+ while i < 17:
+ driver.can_enter_jit(i=i, val=val)
+ driver.jit_merge_point(i=i, val=val)
+ # Logical & rather than comparison to confuse range analysis.
+ # Test only succeeds on the first 2 iterations
+ if i & -2 == 0:
+ val = const.unbox
+ else:
+ val = X(i)
+ i += 1
+ return 0
+
+ self.meta_interp(f, [])
+
+ # With retracing disable, there will be one optimized loop expecting a
+ # non-virtual X object. The side exit creates a virtual object which must
+ # be allocated to jump to the optimized trace.
+ self.check_resops(jump=3, label=2, new_with_vtable=2)
+ self.check_target_token_count(2)
+ self.check_trace_count(3)
+
class VirtualMiscTests:
def test_multiple_equal_virtuals(self):
More information about the pypy-commit
mailing list