[pypy-commit] lang-smalltalk default: fixed the error causing test-sequence impact

lwassermann noreply at buildbot.pypy.org
Thu Feb 28 21:20:46 CET 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r109:05d2c1f89455
Date: 2013-02-28 21:18 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/05d2c1f89455/

Log:	fixed the error causing test-sequence impact test_bootstrappedimage
	now takes twice as long :)

diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -460,11 +460,11 @@
                 match_w.append(w_obj)
             pending.extend(rgc.get_rpy_referents(gcref))
 
-    while pending:
-        gcref = pending.pop()
+    while roots:
+        gcref = roots.pop()
         if rgc.get_gcflag_extra(gcref):
             rgc.toggle_gcflag_extra(gcref)
-            pending.extend(rgc.get_rpy_referents(gcref))
+            roots.extend(rgc.get_rpy_referents(gcref))
 
     s_frame.store_instances_array(match_w)
     try:
@@ -472,14 +472,22 @@
     except IndexError:
         raise PrimitiveFailedError()
 
+def next_instance(space, list_of_objects, w_obj):
+    try:
+        retval = list_of_objects.pop()
+        # just in case, that one of the objects in the list changes its class
+        if retval.getclass(space).is_same_object(w_obj.getclass(space)):
+            return retval
+        else:
+            return next_instance(space, list_of_objects, w_obj)
+    except IndexError:
+        raise PrimitiveFailedError()
+
 @expose_primitive(NEXT_INSTANCE, unwrap_spec=[object])
 def func(interp, s_frame, w_obj):
     # This primitive is used to iterate through all instances of a class:
     # it returns the "next" instance after w_obj.
-    try:
-        return s_frame.instances_array().pop()
-    except IndexError:
-        raise PrimitiveFailedError()
+    return next_instance(interp.space, s_frame.instances_array(), w_obj)
 
 @expose_primitive(NEW_METHOD, unwrap_spec=[object, int, int])
 def func(interp, s_frame, w_class, bytecount, header):
diff --git a/spyvm/test/test_bootstrappedimage.py b/spyvm/test/test_bootstrappedimage.py
--- a/spyvm/test/test_bootstrappedimage.py
+++ b/spyvm/test/test_bootstrappedimage.py
@@ -24,6 +24,11 @@
     w_result = perform(tools.image.w_asSymbol, "asSymbol")
     assert w_result is tools.image.w_asSymbol
 
+def test_create_new_symbol():
+    w_result = perform(w("someString"), "asSymbol")
+    assert w_result is not None
+    assert w_result.as_string() == "someString"
+
 def test_retrieve_symbol():
     """asSymbol
     "This is the only place that new Symbols are created. A Symbol is created 
@@ -37,11 +42,6 @@
     w_anotherSymbol = perform(w("someString"), "asSymbol")
     assert w_result is w_anotherSymbol
 
-def test_create_new_symbol():
-    w_result = perform(w("someString"), "asSymbol")
-    assert w_result is not None
-    assert w_result.as_string() == "someString"
-
 def test_all_pointers_are_valid():
     tools.test_all_pointers_are_valid()
     tools.test_lookup_abs_in_integer()


More information about the pypy-commit mailing list