[pypy-svn] r76867 - in pypy/trunk/pypy: annotation rpython

arigo at codespeak.net arigo at codespeak.net
Sat Sep 4 13:50:54 CEST 2010


Author: arigo
Date: Sat Sep  4 13:50:52 2010
New Revision: 76867

Modified:
   pypy/trunk/pypy/annotation/binaryop.py
   pypy/trunk/pypy/annotation/bookkeeper.py
   pypy/trunk/pypy/annotation/builtin.py
   pypy/trunk/pypy/annotation/model.py
   pypy/trunk/pypy/rpython/rbuiltin.py
Log:
It's wrong to check during the annotation of raw_memclear() that we are
not given the constant NULL; it introduces an order dependency (maybe we
are given the constant NULL so far, but that's because we did not yet
analyze the rest of the code that can pass a non-NULL value).


Modified: pypy/trunk/pypy/annotation/binaryop.py
==============================================================================
--- pypy/trunk/pypy/annotation/binaryop.py	(original)
+++ pypy/trunk/pypy/annotation/binaryop.py	Sat Sep  4 13:50:52 2010
@@ -924,10 +924,10 @@
 
 class __extend__(pairtype(SomeAddress, SomeAddress)):
     def union((s_addr1, s_addr2)):
-        return SomeAddress(is_null=s_addr1.is_null and s_addr2.is_null)
+        return SomeAddress()
 
     def sub((s_addr1, s_addr2)):
-        if s_addr1.is_null and s_addr2.is_null:
+        if s_addr1.is_null_address() and s_addr2.is_null_address():
             return getbookkeeper().immutablevalue(0)
         return SomeInteger()
 
@@ -953,10 +953,10 @@
 
 class __extend__(pairtype(SomeAddress, SomeInteger)):
     def add((s_addr, s_int)):
-        return SomeAddress(is_null=False)
+        return SomeAddress()
 
     def sub((s_addr, s_int)):
-        return SomeAddress(is_null=False)
+        return SomeAddress()
 
 class __extend__(pairtype(SomeAddress, SomeImpossibleValue)):
     # need to override this specifically to hide the 'raise UnionError'

Modified: pypy/trunk/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/trunk/pypy/annotation/bookkeeper.py	(original)
+++ pypy/trunk/pypy/annotation/bookkeeper.py	Sat Sep  4 13:50:52 2010
@@ -431,7 +431,7 @@
         elif isinstance(x, lltype._ptr):
             result = SomePtr(lltype.typeOf(x))
         elif isinstance(x, llmemory.fakeaddress):
-            result = SomeAddress(is_null=not x)
+            result = SomeAddress()
         elif isinstance(x, ootype._static_meth):
             result = SomeOOStaticMeth(ootype.typeOf(x))
         elif isinstance(x, ootype._class):

Modified: pypy/trunk/pypy/annotation/builtin.py
==============================================================================
--- pypy/trunk/pypy/annotation/builtin.py	(original)
+++ pypy/trunk/pypy/annotation/builtin.py	Sat Sep  4 13:50:52 2010
@@ -694,18 +694,14 @@
 
 def raw_free(s_addr):
     assert isinstance(s_addr, SomeAddress)
-    assert not s_addr.is_null
 
 def raw_memclear(s_addr, s_int):
     assert isinstance(s_addr, SomeAddress)
-    assert not s_addr.is_null
     assert isinstance(s_int, SomeInteger)
 
 def raw_memcopy(s_addr1, s_addr2, s_int):
     assert isinstance(s_addr1, SomeAddress)
-    assert not s_addr1.is_null
     assert isinstance(s_addr2, SomeAddress)
-    assert not s_addr2.is_null
     assert isinstance(s_int, SomeInteger) #XXX add noneg...?
 
 BUILTIN_ANALYZERS[llmemory.raw_malloc] = raw_malloc

Modified: pypy/trunk/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/pypy/annotation/model.py	(original)
+++ pypy/trunk/pypy/annotation/model.py	Sat Sep  4 13:50:52 2010
@@ -500,12 +500,13 @@
 
 class SomeAddress(SomeObject):
     immutable = True
-    def __init__(self, is_null=False):
-        self.is_null = is_null
 
     def can_be_none(self):
         return False
 
+    def is_null_address(self):
+        return self.is_immutable_constant() and not self.const
+
 # The following class is used to annotate the intermediate value that
 # appears in expressions of the form:
 # addr.signed[offset] and addr.signed[offset] = value

Modified: pypy/trunk/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/trunk/pypy/rpython/rbuiltin.py	(original)
+++ pypy/trunk/pypy/rpython/rbuiltin.py	Sat Sep  4 13:50:52 2010
@@ -542,16 +542,25 @@
     return hop.genop('raw_malloc_usage', [v_size], resulttype=lltype.Signed)
 
 def rtype_raw_free(hop):
+    s_addr = hop.args_s[0]
+    if s_addr.is_null_address():
+        raise TyperError("raw_free(x) where x is the constant NULL")
     v_addr, = hop.inputargs(llmemory.Address)
     hop.exception_cannot_occur()
     return hop.genop('raw_free', [v_addr])
 
 def rtype_raw_memcopy(hop):
+    for s_addr in hop.args_s[:2]:
+        if s_addr.is_null_address():
+            raise TyperError("raw_memcopy() with a constant NULL")
     v_list = hop.inputargs(llmemory.Address, llmemory.Address, lltype.Signed)
     hop.exception_cannot_occur()
     return hop.genop('raw_memcopy', v_list)
 
 def rtype_raw_memclear(hop):
+    s_addr = hop.args_s[0]
+    if s_addr.is_null_address():
+        raise TyperError("raw_memclear(x, n) where x is the constant NULL")
     v_list = hop.inputargs(llmemory.Address, lltype.Signed)
     return hop.genop('raw_memclear', v_list)
 



More information about the Pypy-commit mailing list