[pypy-commit] pypy default: Add HF_KNOWN_NULLITY in two more cases: in new() and in
arigo
pypy.commits at gmail.com
Sun Dec 18 07:35:57 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r89137:33a1651e9061
Date: 2016-12-18 13:33 +0100
http://bitbucket.org/pypy/pypy/changeset/33a1651e9061/
Log: Add HF_KNOWN_NULLITY in two more cases: in new() and in
class_now_known(). I think it's a safe way to avoid a couple of
extra GUARD_NONNULLs.
diff --git a/rpython/jit/metainterp/heapcache.py b/rpython/jit/metainterp/heapcache.py
--- a/rpython/jit/metainterp/heapcache.py
+++ b/rpython/jit/metainterp/heapcache.py
@@ -373,7 +373,7 @@
def class_now_known(self, box):
if isinstance(box, Const):
return
- self._set_flag(box, HF_KNOWN_CLASS)
+ self._set_flag(box, HF_KNOWN_CLASS | HF_KNOWN_NULLITY)
def is_nullity_known(self, box):
if isinstance(box, Const):
@@ -403,7 +403,8 @@
def new(self, box):
assert isinstance(box, RefFrontendOp)
self.update_version(box)
- add_flags(box, HF_LIKELY_VIRTUAL | HF_SEEN_ALLOCATION | HF_IS_UNESCAPED)
+ add_flags(box, HF_LIKELY_VIRTUAL | HF_SEEN_ALLOCATION | HF_IS_UNESCAPED
+ | HF_KNOWN_NULLITY)
def new_array(self, box, lengthbox):
self.new(box)
diff --git a/rpython/jit/metainterp/test/test_heapcache.py b/rpython/jit/metainterp/test/test_heapcache.py
--- a/rpython/jit/metainterp/test/test_heapcache.py
+++ b/rpython/jit/metainterp/test/test_heapcache.py
@@ -83,6 +83,19 @@
assert not h.is_nullity_known(box1)
assert not h.is_nullity_known(box2)
+ def test_known_nullity_more_cases(self):
+ h = HeapCache()
+ box1 = RefFrontendOp(1)
+ box2 = RefFrontendOp(2)
+ h.class_now_known(box1)
+ assert h.is_nullity_known(box1)
+
+ h.new(box2)
+ assert h.is_nullity_known(box2)
+
+ h.reset()
+ assert not h.is_nullity_known(box1)
+ assert not h.is_nullity_known(box2)
def test_nonstandard_virtualizable(self):
h = HeapCache()
More information about the pypy-commit
mailing list