Author: Carl Friedrich Bolz <[email protected]>
Branch: guard-compatible
Changeset: r85356:3c07b3cda170
Date: 2016-06-22 15:41 +0200
http://bitbucket.org/pypy/pypy/changeset/3c07b3cda170/
Log: produce guards for QuasiimmutGetfieldAndPureCallCondition
(more mess)
diff --git a/rpython/jit/metainterp/compatible.py
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -270,6 +270,8 @@
def __init__(self, op, qmutdescr, optimizer):
PureCallCondition.__init__(self, op, optimizer)
self.args[2] = None
+ # XXX not 100% sure whether it's save to store the whole descr
+ self.qmutdescr = qmutdescr
self.qmut = qmutdescr.qmut
self.mutatefielddescr = qmutdescr.mutatefielddescr
self.fielddescr = qmutdescr.fielddescr
@@ -330,6 +332,33 @@
return False
return True
+ def emit_condition(self, op, short, optimizer):
+ from rpython.jit.metainterp.resoperation import rop, ResOperation
+ # more mess
+ fielddescr = self.fielddescr
+ if fielddescr.is_pointer_field():
+ getfield_op = ResOperation(
+ rop.GETFIELD_GC_R, [op], fielddescr)
+ elif fielddescr.is_float_field():
+ getfield_op = ResOperation(
+ rop.GETFIELD_GC_F, [op], fielddescr)
+ else:
+ getfield_op = ResOperation(
+ rop.GETFIELD_GC_I, [op], fielddescr)
+ short.extend([
+ ResOperation(
+ rop.QUASIIMMUT_FIELD, [op], self.qmutdescr),
+ ResOperation(
+ rop.GUARD_NOT_INVALIDATED, []),
+ getfield_op])
+ index = len(short)
+ PureCallCondition.emit_condition(self, op, short, optimizer)
+ call_op = short[index]
+ assert call_op.opnum in (
+ rop.CALL_PURE_I, rop.CALL_PURE_R,
+ rop.CALL_PURE_F, rop.CALL_PURE_N)
+ call_op.setarg(2, getfield_op)
+
def repr(self, argrepr="?"):
addr = self.args[0].getaddr()
funcname = self.metainterp_sd.get_name_from_address(addr)
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_virtualstate.py
@@ -28,6 +28,7 @@
self.optearlyforce = None
self.metainterp_sd = None
self._last_debug_merge_point = None
+ self.quasi_immutable_deps = None
class BaseTestGenerateGuards(BaseTest):
def setup_class(self):
@@ -488,21 +489,43 @@
value1 = info.PtrInfo()
ptr = "fakeptr"
ccond = value1._compatibility_conditions = CompatibilityCondition(
- ConstPtr(self.myptr))
+ ConstPtr(self.quasiptr))
+
+ # regular call
op = ResOperation(
- rop.CALL_PURE_I, [ConstInt(123), ConstPtr(self.myptr)],
+ rop.CALL_PURE_I, [ConstInt(123), ConstPtr(self.quasiptr)],
descr=self.plaincalldescr)
copied_op, cond = ccond.prepare_const_arg_call(
op, optimizer)
ccond.record_condition(cond, ConstInt(5), optimizer)
+
+ # call with quasi-immut
+ box = InputArgRef()
+ ccond.register_quasi_immut_field(
+ ResOperation(rop.QUASIIMMUT_FIELD, [box], self.quasiimmutdescr))
+ getfield_op = ResOperation(
+ rop.GETFIELD_GC_I, [box], self.quasifielddescr)
+ op = ResOperation(
+ rop.CALL_PURE_I,
+ [ConstInt(123), ConstPtr(self.quasiptr), getfield_op],
+ descr=self.nonwritedescr)
+ copied_op, cond = ccond.prepare_const_arg_call(
+ op, optimizer)
+ ccond.record_condition(cond, ConstInt(5), optimizer)
+
box = InputArgRef()
guards = []
value1.make_guards(box, guards, FakeOptimizer(self.cpu))
expected = """
[p0]
- guard_compatible(p0, ConstPtr(myptr)) []
+ guard_compatible(p0, ConstPtr(quasiptr)) []
i1 = call_pure_i(123, p0, descr=plaincalldescr)
guard_value(i1, 5) []
+ quasiimmut_field(p0, descr=quasiimmutdescr)
+ guard_not_invalidated() []
+ i0 = getfield_gc_i(p0, descr=quasifielddescr)
+ i2 = call_pure_i(123, p0, i0, descr=nonwritedescr)
+ guard_value(i2, 5) []
"""
self.compare(guards, expected, [box])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit