Author: Carl Friedrich Bolz <[email protected]>
Branch: value-profiling
Changeset: r78977:f5eeb7187c3e
Date: 2015-08-13 18:51 +0200
http://bitbucket.org/pypy/pypy/changeset/f5eeb7187c3e/
Log: (cfbolz, arigo): fix a segfault
diff --git a/pypy/interpreter/test/test_valueprof.py
b/pypy/interpreter/test/test_valueprof.py
--- a/pypy/interpreter/test/test_valueprof.py
+++ b/pypy/interpreter/test/test_valueprof.py
@@ -66,7 +66,7 @@
v = ValueProf()
assert v._vprof_status == SEEN_NOTHING
v.see_write(Value())
- v.see_write(Value())
+ v.see_write(OtherValue())
assert v._vprof_status == SEEN_TOO_MUCH
@@ -91,6 +91,8 @@
assert v._vprof_status == SEEN_TOO_MUCH
def test_known_class():
+ import gc
+
v = ValueProf()
value = Value()
assert v._vprof_status == SEEN_NOTHING
@@ -109,3 +111,16 @@
assert v._vprof_status == SEEN_CONSTANT_CLASS
v.see_write(ValueInt(5))
assert v._vprof_status == SEEN_TOO_MUCH
+
+ v = ValueProf()
+ assert v._vprof_status == SEEN_NOTHING
+ v.see_write(Value())
+ assert v._vprof_status == SEEN_CONSTANT_OBJ
+ gc.collect()
+ gc.collect()
+ gc.collect()
+ v.see_write(Value())
+ assert v._vprof_status == SEEN_CONSTANT_CLASS
+ v.see_write(OtherValue())
+ assert v._vprof_status == SEEN_TOO_MUCH
+
diff --git a/pypy/interpreter/valueprof.py b/pypy/interpreter/valueprof.py
--- a/pypy/interpreter/valueprof.py
+++ b/pypy/interpreter/valueprof.py
@@ -44,10 +44,12 @@
else:
try:
self._vprof_value_wref = ref(w_value)
- self._vprof_status = SEEN_CONSTANT_OBJ
except TypeError:
# for tests, which really use unwrapped ints in a few
places
self._vprof_status = SEEN_TOO_MUCH
+ else:
+ self._vprof_const_cls = w_value.__class__
+ self._vprof_status = SEEN_CONSTANT_OBJ
elif status == SEEN_CONSTANT_INT:
if self.is_int(w_value):
if self.read_constant_int() != self.get_int_val(w_value):
@@ -70,7 +72,7 @@
if prev_obj is not w_value:
if self._vprof_counter >= 200:
print "NO LONGER CONSTANT", self._vprof_msg, 'obj', w_value
- prev_cls = prev_obj.__class__
+ prev_cls = self.read_constant_cls()
if prev_cls is w_value.__class__:
self._vprof_const_cls = prev_cls
self._vprof_status = SEEN_CONSTANT_CLASS
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit