Author: Remi Meier <meier...@student.ethz.ch>
Branch: stmgc-c4
Changeset: r65190:b3adf69b07ae
Date: 2013-07-05 10:46 +0200
http://bitbucket.org/pypy/pypy/changeset/b3adf69b07ae/

Log:    fix some tests

diff --git a/pypy/module/thread/stm.py b/pypy/module/thread/stm.py
--- a/pypy/module/thread/stm.py
+++ b/pypy/module/thread/stm.py
@@ -5,7 +5,7 @@
 from pypy.module.thread.threadlocals import BaseThreadLocals
 from pypy.module.thread.error import wrap_thread_error
 from pypy.interpreter.executioncontext import ExecutionContext
-from pypy.interpreter.gateway import Wrappable, W_Root, interp2app
+from pypy.interpreter.gateway import W_Root, interp2app
 from pypy.interpreter.typedef import TypeDef, GetSetProperty, descr_get_dict
 from rpython.rlib import rthread
 from rpython.rlib import rstm
@@ -122,7 +122,7 @@
 # ____________________________________________________________
 
 
-class STMLocal(Wrappable):
+class STMLocal(W_Root):
     """Thread-local data"""
 
     @jit.dont_look_inside
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -28,13 +28,13 @@
 
 def abort_info_pop(count):
     if we_are_translated():
-        stmgcintf.StmOperations.abort_info_pop(count)
+        pass #stmgcintf.StmOperations.abort_info_pop(count)
 
 def charp_inspect_abort_info():
-    return stmgcintf.StmOperations.inspect_abort_info()
+    pass # return stmgcintf.StmOperations.inspect_abort_info()
 
 def abort_and_retry():
-    stmgcintf.StmOperations.abort_and_retry()
+    pass # stmgcintf.StmOperations.abort_and_retry()
 
 def before_external_call():
     llop.stm_commit_transaction(lltype.Void)
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -584,28 +584,30 @@
             from rpython.translator.stm.funcgen import op_stm
             self.__class__.op_stm = op_stm
         return self.op_stm(op)
-    OP_STM_INITIALIZE = _OP_STM
-    OP_STM_FINALIZE = _OP_STM
-    OP_STM_BECOME_INEVITABLE = _OP_STM
-    OP_STM_BARRIER = _OP_STM
-    OP_STM_PTR_EQ = _OP_STM
-    OP_STM_PUSH_ROOT = _OP_STM
-    OP_STM_POP_ROOT_INTO = _OP_STM
-    OP_STM_ALLOCATE = _OP_STM
-    OP_STM_GET_TID = _OP_STM
-    OP_STM_HASH = _OP_STM
-    OP_STM_ID = _OP_STM
-    OP_STM_COMMIT_TRANSACTION = _OP_STM
+    OP_STM_INITIALIZE                   = _OP_STM
+    OP_STM_FINALIZE                     = _OP_STM
+    OP_STM_BECOME_INEVITABLE            = _OP_STM
+    OP_STM_BARRIER                      = _OP_STM
+    OP_STM_PTR_EQ                       = _OP_STM
+    OP_STM_PUSH_ROOT                    = _OP_STM
+    OP_STM_POP_ROOT_INTO                = _OP_STM
+    OP_STM_ALLOCATE                     = _OP_STM
+    OP_STM_GET_TID                      = _OP_STM
+    OP_STM_HASH                         = _OP_STM
+    OP_STM_ID                           = _OP_STM
+    OP_STM_COMMIT_TRANSACTION           = _OP_STM
     OP_STM_BEGIN_INEVITABLE_TRANSACTION = _OP_STM
-    OP_STM_SHOULD_BREAK_TRANSACTION = _OP_STM
-    OP_STM_SET_TRANSACTION_LENGTH = _OP_STM
-    OP_STM_CHANGE_ATOMIC = _OP_STM
-    OP_STM_GET_ATOMIC = _OP_STM
-    OP_STM_THREADLOCAL_GET = _OP_STM
-    OP_STM_THREADLOCAL_SET = _OP_STM
-    OP_STM_PERFORM_TRANSACTION = _OP_STM
-    OP_STM_ENTER_CALLBACK_CALL = _OP_STM
-    OP_STM_LEAVE_CALLBACK_CALL = _OP_STM
+    OP_STM_SHOULD_BREAK_TRANSACTION     = _OP_STM
+    OP_STM_SET_TRANSACTION_LENGTH       = _OP_STM
+    OP_STM_CHANGE_ATOMIC                = _OP_STM
+    OP_STM_GET_ATOMIC                   = _OP_STM
+    OP_STM_THREADLOCAL_GET              = _OP_STM
+    OP_STM_THREADLOCAL_SET              = _OP_STM
+    OP_STM_PERFORM_TRANSACTION          = _OP_STM
+    OP_STM_ENTER_CALLBACK_CALL          = _OP_STM
+    OP_STM_LEAVE_CALLBACK_CALL          = _OP_STM
+    OP_STM_MAJOR_COLLECT                = _OP_STM
+    OP_STM_MINOR_COLLECT                = _OP_STM
 
 
     def OP_PTR_NONZERO(self, op):
diff --git a/rpython/translator/stm/funcgen.py 
b/rpython/translator/stm/funcgen.py
--- a/rpython/translator/stm/funcgen.py
+++ b/rpython/translator/stm/funcgen.py
@@ -159,6 +159,13 @@
     arg0 = funcgen.expr(op.args[0])
     return 'stm_leave_callback_call(%s);' % (arg0,)
 
+def stm_minor_collect(funcgen, op):
+    return 'stmgc_minor_collect();'
+
+def stm_major_collect(funcgen, op):
+    return 'stmgcpage_possibly_major_collect(1);}' # forced
+
+    
 
 def op_stm(funcgen, op):
     func = globals()[op.opname]
diff --git a/rpython/translator/stm/src_stm/gcpage.c 
b/rpython/translator/stm/src_stm/gcpage.c
--- a/rpython/translator/stm/src_stm/gcpage.c
+++ b/rpython/translator/stm/src_stm/gcpage.c
@@ -226,7 +226,8 @@
             id_copy->h_tid |= GCFLAG_VISITED;
 
             /* XXX: may not always need tracing? */
-            gcptrlist_insert(&objects_to_trace, id_copy);
+            if (!(id_copy->h_tid & GCFLAG_STUB))
+                gcptrlist_insert(&objects_to_trace, id_copy);
         } 
         else {
             /* prebuilt originals won't get collected anyway
diff --git a/rpython/translator/stm/src_stm/revision 
b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-38fcfb8212e2
+7a86a8b3cbb1+
diff --git a/rpython/translator/stm/test/test_ztranslated.py 
b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -120,18 +120,21 @@
 
     def test_bug1(self):
         #
-        class Foobar:
-            pass
         def check(foobar, retry_counter):
             rgc.collect(0)
             return 0
         #
+        from rpython.rtyper.lltypesystem.rclass import OBJECTPTR
+        S = lltype.GcStruct('S', ('got_exception', OBJECTPTR))
+        PS = lltype.Ptr(S)
+        perform_transaction = rstm.make_perform_transaction(check, PS)
         class X:
             def __init__(self, count):
                 self.count = count
         def g():
             x = X(1000)
-            rstm.perform_transaction(check, Foobar, Foobar())
+            perform_transaction(lltype.malloc(S))
+            #rstm.perform_transaction(check, Foobar, Foobar())
             return x
         def entry_point(argv):
             x = X(len(argv))
@@ -145,8 +148,6 @@
 
     def test_bug2(self):
         #
-        class Foobar:
-            pass
         def check(foobar, retry_counter):
             return 0    # do nothing
         #
@@ -154,11 +155,16 @@
             pass
         prebuilt2 = [X2(), X2()]
         #
+        from rpython.rtyper.lltypesystem.rclass import OBJECTPTR
+        S = lltype.GcStruct('S', ('got_exception', OBJECTPTR))
+        PS = lltype.Ptr(S)
+        perform_transaction = rstm.make_perform_transaction(check, PS)
         def bug2(count):
             x = prebuilt2[count]
             x.foobar = 2                    # 'x' becomes a local
             #
-            rstm.perform_transaction(check, Foobar, Foobar())
+            #rstm.perform_transaction(check, Foobar, Foobar())
+            perform_transaction(lltype.malloc(S))
                                             # 'x' becomes the global again
             #
             y = prebuilt2[count]            # same prebuilt obj
@@ -175,10 +181,14 @@
         assert '12\n12\n' in data, "got: %r" % (data,)
 
     def test_prebuilt_nongc(self):
-        class Foobar:
-            pass
         def check(foobar, retry_counter):
             return 0    # do nothing
+        from rpython.rtyper.lltypesystem.rclass import OBJECTPTR
+        from rpython.rtyper.lltypesystem import lltype
+        S = lltype.GcStruct('S', ('got_exception', OBJECTPTR))
+        PS = lltype.Ptr(S)
+        perform_transaction = rstm.make_perform_transaction(check, PS)
+        
         from rpython.rtyper.lltypesystem import lltype
         R = lltype.GcStruct('R', ('x', lltype.Signed))
         S1 = lltype.Struct('S1', ('r', lltype.Ptr(R)))
@@ -187,7 +197,8 @@
         #                   hints={'stm_thread_local': True})
         #s2 = lltype.malloc(S2, immortal=True, flavor='raw')
         def do_stuff():
-            rstm.perform_transaction(check, Foobar, Foobar())
+            perform_transaction(lltype.malloc(S))
+            #rstm.perform_transaction(check, Foobar, Foobar())
             print s1.r.x
             #print s2.r.x
         do_stuff._dont_inline_ = True
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to