Author: Carl Friedrich Bolz <[email protected]>
Branch: value-profiling
Changeset: r81902:c1866643eecd
Date: 2016-01-22 09:13 +0100
http://bitbucket.org/pypy/pypy/changeset/c1866643eecd/

Log:    test and fix for write_necessary logic when mixing ints and objects

diff --git a/rpython/rlib/heapprof.py b/rpython/rlib/heapprof.py
--- a/rpython/rlib/heapprof.py
+++ b/rpython/rlib/heapprof.py
@@ -108,8 +108,9 @@
         # call write_necessary if there is already a value there
         assert not status == SEEN_NOTHING
         if status == SEEN_CONSTANT_INT:
-            return (self.is_int(w_value) and
-                self.read_constant_int() != self.get_int_val(w_value))
+            if not self.is_int(w_value):
+                return True
+            return self.read_constant_int() != self.get_int_val(w_value)
         elif status == SEEN_CONSTANT_OBJ:
             prev_obj = self.try_read_constant_obj()
             return prev_obj is not w_value
diff --git a/rpython/rlib/test/test_heapprof.py 
b/rpython/rlib/test/test_heapprof.py
--- a/rpython/rlib/test/test_heapprof.py
+++ b/rpython/rlib/test/test_heapprof.py
@@ -143,6 +143,13 @@
     res = v.write_necessary(ValueInt(1))
     assert res
 
+    v = HeapProf()
+    assert v._hprof_status == SEEN_NOTHING
+    v.see_write(ValueInt(1))
+    res = v.write_necessary(Value())
+    assert res
+
+
 def test_write_not_necessary_obj():
     v = HeapProf()
     assert v._hprof_status == SEEN_NOTHING
@@ -159,3 +166,4 @@
     v.see_write(Value())
     res = v.write_necessary(Value())
     assert res
+
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to