Author: Armin Rigo <[email protected]>
Branch: reverse-debugger
Changeset: r85097:59cd9a5ec3f6
Date: 2016-06-11 12:50 +0200
http://bitbucket.org/pypy/pypy/changeset/59cd9a5ec3f6/
Log: Don't record/replay the reads from static, immutable structures (the
RPython classes or the PBCs)
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -172,7 +172,8 @@
('name', Ptr(rstr.STR)),
('hash', Signed),
('instantiate', Ptr(FuncType([], OBJECTPTR))),
- hints={'immutable': True}))
+ hints={'immutable': True,
+ 'static_immutable': True}))
# non-gc case
NONGCOBJECT = Struct('nongcobject', ('typeptr', CLASSTYPE))
NONGCOBJECTPTR = Ptr(NONGCOBJECT)
@@ -273,7 +274,7 @@
#
self.rbase = getclassrepr(self.rtyper, self.classdef.basedef)
self.rbase.setup()
- kwds = {'hints': {'immutable': True}}
+ kwds = {'hints': {'immutable': True, 'static_immutable': True}}
vtable_type = Struct('%s_vtable' % self.classdef.name,
('super', self.rbase.vtable_type),
*llfields, **kwds)
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -243,7 +243,7 @@
fields = []
for row in self.uniquerows:
fields.append((row.attrname, row.fntype))
- kwds = {'hints': {'immutable': True}}
+ kwds = {'hints': {'immutable': True, 'static_immutable': True}}
return Ptr(Struct('specfunc', *fields, **kwds))
def create_specfunc(self):
@@ -658,7 +658,7 @@
"""For a SomePBC of frozen PBCs that have no common access set.
The only possible operation on such a thing is comparison with 'is'."""
lowleveltype = llmemory.Address
- EMPTY = Struct('pbc', hints={'immutable': True})
+ EMPTY = Struct('pbc', hints={'immutable': True, 'static_immutable': True})
def __init__(self, rtyper):
self.rtyper = rtyper
@@ -719,7 +719,7 @@
def _setup_repr(self):
llfields = self._setup_repr_fields()
- kwds = {'hints': {'immutable': True}}
+ kwds = {'hints': {'immutable': True, 'static_immutable': True}}
self.pbc_type.become(Struct('pbc', *llfields, **kwds))
def create_instance(self):
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -438,7 +438,8 @@
result = '/* %s */' % result
if self.db.reverse_debugger:
S = self.lltypemap(op.args[0]).TO
- if S._gckind != 'gc' and not S._hints.get('is_excdata'):
+ if (S._gckind != 'gc' and not S._hints.get('is_excdata')
+ and not S._hints.get('static_immutable')):
from rpython.translator.revdb import revdb_genc
result = revdb_genc.emit(result, self.lltypename(op.result),
newvalue)
diff --git a/rpython/translator/revdb/rdb-src/revdb_include.h
b/rpython/translator/revdb/rdb-src/revdb_include.h
--- a/rpython/translator/revdb/rdb-src/revdb_include.h
+++ b/rpython/translator/revdb/rdb-src/revdb_include.h
@@ -40,7 +40,7 @@
normal_code \
{ \
decl_e = variable; \
- _RPY_REVDB_PRINT((stderr, "%s:%d: write %*llx\n", \
+ _RPY_REVDB_PRINT((stderr, "%s:%d: write %0*llx\n", \
__FILE__, __LINE__, \
2 * sizeof(_e), (unsigned long long)_e)); \
memcpy(rpy_revdb.buf_p, &_e, sizeof(_e)); \
@@ -57,7 +57,7 @@
} \
rpy_revdb.buf_p = _end1; \
memcpy(&_e, _src, sizeof(_e)); \
- _RPY_REVDB_PRINT((stderr, "%s:%d: read %*llx\n", \
+ _RPY_REVDB_PRINT((stderr, "%s:%d: read %0*llx\n", \
__FILE__, __LINE__, \
2 * sizeof(_e), (unsigned long long)_e)); \
variable = _e; \
diff --git a/rpython/translator/revdb/test/test_basic.py
b/rpython/translator/revdb/test/test_basic.py
--- a/rpython/translator/revdb/test/test_basic.py
+++ b/rpython/translator/revdb/test/test_basic.py
@@ -127,6 +127,51 @@
x = rdb.next('q'); assert x == 0 # number of stop points
assert rdb.done()
+ def test_dont_record_vtable_reads(self):
+ class A(object):
+ x = 42
+ class B(A):
+ x = 43
+ lst = [A(), B()]
+ def main(argv):
+ print lst[len(argv) & 1].x
+ return 9
+ self.compile(main, [], backendopt=False)
+ out = self.run('Xx')
+ assert out == '42\n'
+ rdb = self.fetch_rdb()
+ rdb.read_check_argv([self.exename, 'Xx'])
+ # write() call (it used to be the case that vtable reads where
+ # recorded too; the single byte fetched from the vtable from
+ # the '.x' in main() would appear here)
+ x = rdb.next(); assert x == len(out)
+ x = rdb.next('i'); assert x == 0 # errno
+ # done
+ x = rdb.next('q'); assert x == 0 # number of stop points
+ assert rdb.done()
+
+ def test_dont_record_pbc_reads(self):
+ class MyPBC:
+ def _freeze_(self):
+ return True
+ pbc1 = MyPBC(); pbc1.x = 41
+ pbc2 = MyPBC(); pbc2.x = 42
+ lst = [pbc1, pbc2]
+ def main(argv):
+ print lst[len(argv) & 1].x
+ return 9
+ self.compile(main, [], backendopt=False)
+ out = self.run('Xx')
+ assert out == '41\n'
+ rdb = self.fetch_rdb()
+ rdb.read_check_argv([self.exename, 'Xx'])
+ # write() call
+ x = rdb.next(); assert x == len(out)
+ x = rdb.next('i'); assert x == 0 # errno
+ # done
+ x = rdb.next('q'); assert x == 0 # number of stop points
+ assert rdb.done()
+
class InteractiveTests(object):
EOF = pexpect.EOF
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit