Author: Armin Rigo <ar...@tunes.org> Branch: reverse-debugger Changeset: r85444:172c97e74bff Date: 2016-06-29 11:50 +0200 http://bitbucket.org/pypy/pypy/changeset/172c97e74bff/
Log: Prebuilt weakrefs diff --git a/rpython/translator/revdb/src-revdb/revdb.c b/rpython/translator/revdb/src-revdb/revdb.c --- a/rpython/translator/revdb/src-revdb/revdb.c +++ b/rpython/translator/revdb/src-revdb/revdb.c @@ -389,6 +389,8 @@ it with WEAKREF_AFTERWARDS_ALIVE. */ if (!RPY_RDB_REPLAY) r->re_off_prev = recording_offset(); + else + r->re_off_prev = 1; /* any number > 0 */ RPY_REVDB_EMIT(alive = WEAKREF_AFTERWARDS_DEAD;, char _e, alive); @@ -420,29 +422,34 @@ struct WEAKLINK *r = (struct WEAKLINK *)weakref; void *result = r->re_addr; if (result && flag_io_disabled == FID_REGULAR_MODE) { - char alive; - if (!RPY_RDB_REPLAY) { - if (r->re_off_prev <= 0) { - fprintf(stderr, "bug in weakrefs: bad previous offset %lld\n", - (long long)r->re_off_prev); - exit(1); + if (r->re_off_prev < 0) { + fprintf(stderr, "bug in weakrefs: bad previous offset %lld\n", + (long long)r->re_off_prev); + exit(1); + } + if (r->re_off_prev == 0) { + /* A prebuilt weakref. Don't record anything */ + } + else { + char alive; + if (!RPY_RDB_REPLAY) { + patch_prev_offset(r->re_off_prev, WEAKREF_AFTERWARDS_DEAD, + WEAKREF_AFTERWARDS_ALIVE); + r->re_off_prev = recording_offset(); } - patch_prev_offset(r->re_off_prev, WEAKREF_AFTERWARDS_DEAD, - WEAKREF_AFTERWARDS_ALIVE); - r->re_off_prev = recording_offset(); - } - RPY_REVDB_EMIT(alive = WEAKREF_AFTERWARDS_DEAD;, char _e, alive); + RPY_REVDB_EMIT(alive = WEAKREF_AFTERWARDS_DEAD;, char _e, alive); - if (RPY_RDB_REPLAY) { - switch (alive) { - case WEAKREF_AFTERWARDS_DEAD: - r->re_addr = NULL; - break; - case WEAKREF_AFTERWARDS_ALIVE: - break; - default: - fprintf(stderr, "bad weakref_deref byte in log\n"); - exit(1); + if (RPY_RDB_REPLAY) { + switch (alive) { + case WEAKREF_AFTERWARDS_DEAD: + r->re_addr = NULL; + break; + case WEAKREF_AFTERWARDS_ALIVE: + break; + default: + fprintf(stderr, "bad weakref_deref byte in log\n"); + exit(1); + } } } } diff --git a/rpython/translator/revdb/test/test_weak.py b/rpython/translator/revdb/test/test_weak.py --- a/rpython/translator/revdb/test/test_weak.py +++ b/rpython/translator/revdb/test/test_weak.py @@ -151,6 +151,22 @@ x = rdb.next('q'); assert x == 0 # number of stop points assert rdb.done() + def test_prebuilt_weakref(self): + class X: + pass + x1 = X() + x1.foobar = 9 + wr = weakref.ref(x1) + def main(argv): + X().foobar = 43 + return wr().foobar + self.compile(main, backendopt=False) + out = self.run('Xx') + rdb = self.fetch_rdb([self.exename, 'Xx']) + # the weakref is prebuilt, so doesn't generate any WEAKREF_xxx + x = rdb.next('q'); assert x == 0 # number of stop points + assert rdb.done() + def test_finalizer_light_ignored(self): py.test.skip("lightweight finalizers could be skipped, but that " "requires also skipping (instead of recording) any " _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit