Author: fijal
Branch: memory-accounting
Changeset: r92510:4420cc75f88e
Date: 2017-09-29 19:37 +0200
http://bitbucket.org/pypy/pypy/changeset/4420cc75f88e/

Log:    whack for a bit until we a) initialize to 0 and b) have it not on
        W_Root

diff --git a/pypy/module/__pypy__/interp_magic.py 
b/pypy/module/__pypy__/interp_magic.py
--- a/pypy/module/__pypy__/interp_magic.py
+++ b/pypy/module/__pypy__/interp_magic.py
@@ -146,10 +146,10 @@
     """ Add memory pressure of estimate bytes. Useful when calling a C function
     that internally allocates a big chunk of memory. This instructs the GC to
     garbage collect sooner than it would otherwise."""
-    if space.is_none(w_obj):
-        rgc.add_memory_pressure(estimate)
-    else:
-        rgc.add_memory_pressure(estimate, w_obj)
+    #if space.is_none(w_obj):
+    rgc.add_memory_pressure(estimate)
+    #else:
+    #    rgc.add_memory_pressure(estimate, w_obj)
 
 @unwrap_spec(w_frame=PyFrame)
 def locals_to_fast(space, w_frame):
diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -447,7 +447,10 @@
             with self as ptr:
                 w_res = W_CDataGCP(space, ptr, self.ctype, self, w_destructor)
         if size != 0:
-            rgc.add_memory_pressure(size, w_res)
+            if isinstance(w_res, W_CDataGCP):
+                rgc.add_memory_pressure(size, w_res)
+            else:
+                rgc.add_memory_pressure(size, self)
         return w_res
 
     def unpack(self, length):
diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -1316,6 +1316,7 @@
             raise ssl_error(space, "failed to allocate SSL context")
 
         self = space.allocate_instance(_SSLContext, w_subtype)
+        assert isinstance(self, _SSLContext)
         rgc.add_memory_pressure(10 * 1024, self)
         self.ctx = ctx
         self.check_hostname = False
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -15,6 +15,7 @@
     RuntimeTypeInfo, getRuntimeTypeInfo, typeOf, Void, FuncType, Bool, Signed,
     functionptr, attachRuntimeTypeInfo)
 from rpython.rtyper.lltypesystem.lloperation import llop
+from rpython.rtyper.llannotation import lltype_to_annotation
 from rpython.rtyper.llannotation import SomePtr
 from rpython.rtyper.lltypesystem import rstr
 from rpython.rtyper.rmodel import (
@@ -536,6 +537,9 @@
                 # the parent type
                 if not 
self.has_special_memory_pressure(self.rbase.object_type):
                     llfields.append(('special_memory_pressure', lltype.Signed))
+                    fields['special_memory_pressure'] = (
+                        'special_memory_pressure',
+                        
self.rtyper.getrepr(lltype_to_annotation(lltype.Signed)))
 
             object_type = MkStruct(self.classdef.name,
                                    ('super', self.rbase.object_type),
@@ -677,6 +681,8 @@
         while base.classdef is not None:
             base = base.rbase
             for fieldname in base.fields:
+                if fieldname == 'special_memory_pressure':
+                    continue
                 try:
                     mangled, r = base._get_field(fieldname)
                 except KeyError:
@@ -731,6 +737,9 @@
                            resulttype=Ptr(self.object_type))
         ctypeptr = inputconst(CLASSTYPE, self.rclass.getvtable())
         self.setfield(vptr, '__class__', ctypeptr, llops)
+        if self.has_special_memory_pressure(self.object_type):
+            self.setfield(vptr, 'special_memory_pressure',
+                inputconst(lltype.Signed, 0), llops)
         # initialize instance attributes from their defaults from the class
         if self.classdef is not None:
             flds = self.allinstancefields.keys()
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to