[pypy-svn] r71355 - in pypy/branch/debug-vref2/pypy/jit: backend backend/llgraph backend/x86 metainterp
arigo at codespeak.net
arigo at codespeak.net
Sat Feb 20 10:07:16 CET 2010
Author: arigo
Date: Sat Feb 20 10:07:14 2010
New Revision: 71355
Modified:
pypy/branch/debug-vref2/pypy/jit/backend/llgraph/llimpl.py
pypy/branch/debug-vref2/pypy/jit/backend/model.py
pypy/branch/debug-vref2/pypy/jit/backend/x86/assembler.py
pypy/branch/debug-vref2/pypy/jit/backend/x86/regalloc.py
pypy/branch/debug-vref2/pypy/jit/metainterp/optimizeopt.py
pypy/branch/debug-vref2/pypy/jit/metainterp/resoperation.py
pypy/branch/debug-vref2/pypy/jit/metainterp/virtualref.py
Log:
Merge r71260 from debug-vref. Also found out a possible reason
for which debug-vref no longer shows the bug at all:
optimize_VIRTUAL_REF_FINISH was always forcing the complete
structure, just by passing it to ASSERT.
Modified: pypy/branch/debug-vref2/pypy/jit/backend/llgraph/llimpl.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/backend/llgraph/llimpl.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/backend/llgraph/llimpl.py Sat Feb 20 10:07:14 2010
@@ -156,6 +156,7 @@
'guard_not_forced': ((), None),
'virtual_ref' : (('ref', 'int'), 'ref'),
'virtual_ref_finish': (('ref', 'ref'), None),
+ 'assert' : (('int',), None),
#'getitem' : (('void', 'ref', 'int'), 'int'),
#'setitem' : (('void', 'ref', 'int', 'int'), None),
#'newlist' : (('void', 'varargs'), 'ref'),
@@ -1337,6 +1338,9 @@
uni = lltype.cast_opaque_ptr(lltype.Ptr(rstr.UNICODE), string)
uni.chars[index] = unichr(newvalue)
+def do_assert(_, condition):
+ assert condition
+
# ---------- call ----------
_call_args = []
Modified: pypy/branch/debug-vref2/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/backend/model.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/backend/model.py Sat Feb 20 10:07:14 2010
@@ -237,6 +237,9 @@
def do_call_may_force(self, args, calldescr):
return self.do_call(args, calldescr)
+ def do_assert(self, xbox):
+ assert xbox.nonnull()
+
def force(self, force_token):
raise NotImplementedError
Modified: pypy/branch/debug-vref2/pypy/jit/backend/x86/assembler.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/backend/x86/assembler.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/backend/x86/assembler.py Sat Feb 20 10:07:14 2010
@@ -714,6 +714,18 @@
genop_cast_ptr_to_int = genop_same_as
genop_virtual_ref = genop_same_as
+ def genop_assert(self, op, arglocs, resloc):
+ mc = self._start_block()
+ mc.CMP(arglocs[0], imm8(0))
+ mc.write(constlistofchars('\x75\x00')) # JNE later
+ jne_location = mc.get_relative_pos()
+ mc.UD2()
+ # patch the JNE above
+ offset = mc.get_relative_pos() - jne_location
+ assert 0 < offset <= 127
+ mc.overwrite(jne_location-1, [chr(offset)])
+ self._stop_block()
+
def genop_int_mod(self, op, arglocs, resloc):
self.mc.CDQ()
self.mc.IDIV(ecx)
Modified: pypy/branch/debug-vref2/pypy/jit/backend/x86/regalloc.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/backend/x86/regalloc.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/backend/x86/regalloc.py Sat Feb 20 10:07:14 2010
@@ -880,6 +880,11 @@
else:
self.consider_int_neg(op)
+ def consider_assert(self, op):
+ argloc = self.loc(op.args[0])
+ self.Perform(op, [argloc], None)
+ self.rm.possibly_free_var(op.args[0])
+
def consider_same_as(self, op):
argloc = self.loc(op.args[0])
self.possibly_free_var(op.args[0])
Modified: pypy/branch/debug-vref2/pypy/jit/metainterp/optimizeopt.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/metainterp/optimizeopt.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/metainterp/optimizeopt.py Sat Feb 20 10:07:14 2010
@@ -795,6 +795,10 @@
# forcing it now does not have catastrophic effects.
vrefinfo = self.metainterp_sd.virtualref_info
assert op.args[1].nonnull()
+ # - write code to check that op.args[1] is not null
+ if not self.getvalue(op.args[1]).is_virtual():
+ op1 = ResOperation(rop.ASSERT, [op.args[1]], None)
+ self.emit_operation(op1)
# - set 'forced' to point to the real object
op1 = ResOperation(rop.SETFIELD_GC, op.args, None,
descr = vrefinfo.descr_forced)
@@ -804,6 +808,11 @@
op1 = ResOperation(rop.SETFIELD_GC, args, None,
descr = vrefinfo.descr_virtual_token)
self.optimize_SETFIELD_GC(op1)
+ # - set debug stuff
+ args = [op.args[0], ConstInt(120)]
+ op1 = ResOperation(rop.SETFIELD_GC, args, None,
+ descr = vrefinfo.descr_debug_from)
+ self.optimize_SETFIELD_GC(op1)
# Note that in some cases the virtual in op.args[1] has been forced
# already. This is fine. In that case, and *if* a residual
# CALL_MAY_FORCE suddenly turns out to access it, then it will
Modified: pypy/branch/debug-vref2/pypy/jit/metainterp/resoperation.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/metainterp/resoperation.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/metainterp/resoperation.py Sat Feb 20 10:07:14 2010
@@ -226,6 +226,7 @@
# => result (for mallocs)
'DEBUG_MERGE_POINT/1', # debugging only
'VIRTUAL_REF_FINISH/2',
+ 'ASSERT/1',
'_CANRAISE_FIRST', # ----- start of can_raise operations -----
'CALL',
Modified: pypy/branch/debug-vref2/pypy/jit/metainterp/virtualref.py
==============================================================================
--- pypy/branch/debug-vref2/pypy/jit/metainterp/virtualref.py (original)
+++ pypy/branch/debug-vref2/pypy/jit/metainterp/virtualref.py Sat Feb 20 10:07:14 2010
@@ -13,7 +13,9 @@
('super', rclass.OBJECT),
('virtual_token', lltype.Signed),
('virtualref_index', lltype.Signed),
- ('forced', rclass.OBJECTPTR))
+ ('forced', rclass.OBJECTPTR),
+ ('debug_from', lltype.Signed),
+ ('debug_setforced', rclass.OBJECTPTR))
self.jit_virtual_ref_vtable = lltype.malloc(rclass.OBJECT_VTABLE,
zero=True, flavor='raw')
self.jit_virtual_ref_vtable.name = rclass.alloc_array_name(
@@ -27,6 +29,10 @@
self.descr_virtualref_index = fielddescrof(self.JIT_VIRTUAL_REF,
'virtualref_index')
self.descr_forced = fielddescrof(self.JIT_VIRTUAL_REF, 'forced')
+ self.descr_debug_from = fielddescrof(self.JIT_VIRTUAL_REF,
+ 'debug_from')
+ self.descr_debug_setforced = fielddescrof(self.JIT_VIRTUAL_REF,
+ 'debug_setforced')
def _freeze_(self):
return True
@@ -73,6 +79,7 @@
p.typeptr = self.jit_virtual_ref_vtable
vref.virtual_token = self.TOKEN_NONE
vref.forced = lltype.cast_opaque_ptr(rclass.OBJECTPTR, real_object)
+ vref.debug_from = 100
return lltype.cast_opaque_ptr(llmemory.GCREF, vref)
def is_virtual_ref(self, gcref):
@@ -87,6 +94,7 @@
vref = lltype.cast_opaque_ptr(lltype.Ptr(self.JIT_VIRTUAL_REF), gcref)
assert vref.virtual_token == self.TOKEN_NONE
vref.virtual_token = self.TOKEN_TRACING_RESCALL
+ vref.debug_from = 101
def tracing_after_residual_call(self, gcref):
if not self.is_virtual_ref(gcref):
@@ -98,6 +106,8 @@
# set to TOKEN_TRACING_RESCALL and clear it.
assert vref.virtual_token == self.TOKEN_TRACING_RESCALL
vref.virtual_token = self.TOKEN_NONE
+ vref.debug_from = 102
+ vref.debug_setforced = vref.forced
return False
else:
# marker "modified during residual call" set.
@@ -112,6 +122,8 @@
vref.virtual_token != self.TOKEN_TRACING_RESCALL)
vref.virtual_token = self.TOKEN_NONE
vref.forced = lltype.cast_opaque_ptr(rclass.OBJECTPTR, real_object)
+ vref.debug_from = 103
+ vref.debug_setforced = vref.forced
def continue_tracing(self, gcref, real_object):
if not self.is_virtual_ref(gcref):
@@ -121,6 +133,8 @@
assert vref.virtual_token != self.TOKEN_TRACING_RESCALL
vref.virtual_token = self.TOKEN_NONE
vref.forced = lltype.cast_opaque_ptr(rclass.OBJECTPTR, real_object)
+ vref.debug_from = 104
+ vref.debug_setforced = vref.forced
# ____________________________________________________________
@@ -148,13 +162,17 @@
# "virtual" escapes.
assert vref.forced
vref.virtual_token = self.TOKEN_NONE
+ vref.debug_from = 110
else:
assert not vref.forced
from pypy.jit.metainterp.compile import ResumeGuardForcedDescr
ResumeGuardForcedDescr.force_now(self.cpu, token)
assert vref.virtual_token == self.TOKEN_NONE
assert vref.forced
+ vref.debug_from = 111
else:
assert vref.forced
+ vref.debug_from = 112
+ vref.debug_setforced = vref.forced
return vref.forced
force_virtual._dont_inline_ = True
More information about the Pypy-commit
mailing list