[pypy-svn] r18223 - in pypy/dist/pypy/rpython: . memory

arigo at codespeak.net arigo at codespeak.net
Thu Oct 6 21:09:47 CEST 2005


Author: arigo
Date: Thu Oct  6 21:09:46 2005
New Revision: 18223

Modified:
   pypy/dist/pypy/rpython/llinterp.py
   pypy/dist/pypy/rpython/memory/gc.py
Log:
* SemiSpaceGC: raise MemoryError instead of going into an infinite recursion
  when the free space is exhausted

* Defaulting space size to 1024 words instead of 4096 bytes, to pass the
  tests on 64-bit machines as well

* A more useful __str__ for LLExceptions in llinterp



Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Thu Oct  6 21:09:46 2005
@@ -13,7 +13,9 @@
 log = py.log.Producer('llinterp')
 
 class LLException(Exception):
-    pass
+    def __str__(self):
+        etype, evalue = self.args
+        return '<LLException %r>' % (''.join(etype.name).rstrip('\x00'),)
 
 class LLInterpreter(object):
     """ low level interpreter working with concrete values. """
@@ -40,8 +42,7 @@
         try:
             return llframe.eval()
         except LLException, e:
-            etype, evalue = e.args
-            print "LLEXCEPTION:", etype.name
+            print "LLEXCEPTION:", e
             self.print_traceback()
             raise
         except Exception, e:

Modified: pypy/dist/pypy/rpython/memory/gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc.py	(original)
+++ pypy/dist/pypy/rpython/memory/gc.py	Thu Oct  6 21:09:46 2005
@@ -178,7 +178,7 @@
 class SemiSpaceGC(GCBase):
     _alloc_flavor_ = "raw"
 
-    def __init__(self, space_size=4096, get_roots=None):
+    def __init__(self, space_size=1024*int_size, get_roots=None):
         self.bytes_malloced = 0
         self.space_size = space_size
         self.tospace = raw_malloc(space_size)
@@ -204,7 +204,8 @@
             self.collect()
             #XXX need to increase the space size if the object is too big
             #for bonus points do big objects differently
-            return self.malloc(typeid, length)
+            if self.free + totalsize > self.top_of_space:
+                raise MemoryError
         result = self.free
         self.init_gc_object(result, typeid)
 ##         print "mallocing %s, size %s at %s" % (typeid, size, result)



More information about the Pypy-commit mailing list