Author: Armin Rigo <[email protected]>
Branch:
Changeset: r75587:e207c2d0f728
Date: 2015-01-30 18:07 +0100
http://bitbucket.org/pypy/pypy/changeset/e207c2d0f728/
Log: (based on a suggestion by mjacob)
If an RPython class says "foo = None" at class-level, and "foo" is
typed as something that turns into a GC Ptr, then don't put the
"x.foo = NULL" after the malloc. Whatever the GC we use, the malloc
must initialize such fields to NULL already.
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -711,8 +711,15 @@
continue
value = self.classdef.classdesc.read_attribute(fldname, None)
if value is not None:
- cvalue = inputconst(r.lowleveltype,
- r.convert_desc_or_const(value))
+ ll_value = r.convert_desc_or_const(value)
+ # don't write NULL GC pointers: we know that the malloc
+ # done above initialized at least the GC Ptr fields to
+ # NULL already, and that's true for all our GCs
+ if (isinstance(r.lowleveltype, Ptr) and
+ r.lowleveltype.TO._gckind == 'gc' and
+ not ll_value):
+ continue
+ cvalue = inputconst(r.lowleveltype, ll_value)
self.setfield(vptr, fldname, cvalue, llops,
flags={'access_directly': True})
return vptr
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit