[pypy-commit] stmgc c7: fix possible bug in duhton

Remi Meier noreply at buildbot.pypy.org
Tue Jan 28 15:05:47 CET 2014


Author: Remi Meier
Branch: c7
Changeset: r683:3bb2c6fb41f2
Date: 2014-01-28 13:39 +0100
http://bitbucket.org/pypy/stmgc/changeset/3bb2c6fb41f2/

Log:	fix possible bug in duhton

diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -113,14 +113,15 @@
         _stm_chunk_pages((struct object_s*)REAL_ADDRESS(get_thread_base(0), obj),
                          &pagenum2, &pages);
         assert(pagenum == pagenum2);
-        assert(pages == (stmcb_size(real_address(obj)) +4095) / 4096);
+        assert(pages == (stmcb_size(real_address(obj)) + 4095) / 4096);
     }
     
     for (pagenum2 += pages - 1; pagenum2 >= pagenum; pagenum2--)
         stm_pages_privatize(pagenum2);
 
     
-    /* claim the write-lock for this object */
+    /* claim the write-lock for this object (XXX: maybe a fastpath
+       for prev_owner == lock_num?) */
     uintptr_t lock_idx = (((uintptr_t)obj) >> 4) - READMARKER_START;
     uint8_t lock_num = _STM_TL->thread_num + 1;
     uint8_t prev_owner;
diff --git a/duhton/duhton.h b/duhton/duhton.h
--- a/duhton/duhton.h
+++ b/duhton/duhton.h
@@ -155,6 +155,11 @@
 #define _du_save3(p1,p2,p3)     (_push_root((DuObject *)(p1)),  \
                                  _push_root((DuObject *)(p2)),  \
                                  _push_root((DuObject *)(p3)))
+#define _du_save4(p1,p2,p3,p4)  (_push_root((DuObject *)(p1)), \
+                                 _push_root((DuObject *)(p2)),          \
+                                 _push_root((DuObject *)(p3)),          \
+                                 _push_root((DuObject *)(p4)))
+
 
 #define _du_restore1(p1)        (p1 = (typeof(p1))_pop_root())
 #define _du_restore2(p1,p2)     (p2 = (typeof(p2))_pop_root(),  \
@@ -162,6 +167,11 @@
 #define _du_restore3(p1,p2,p3)  (p3 = (typeof(p3))_pop_root(),  \
                                  p2 = (typeof(p2))_pop_root(),  \
                                  p1 = (typeof(p1))_pop_root())
+#define _du_restore4(p1,p2,p3,p4)(p4 = (typeof(p4))_pop_root(), \
+                                  p3 = (typeof(p3))_pop_root(),         \
+                                  p2 = (typeof(p2))_pop_root(),         \
+                                  p1 = (typeof(p1))_pop_root())
+
 
 #define _du_read1(p1)           stm_read((object_t *)(p1))
 #define _du_write1(p1)          stm_write((object_t *)(p1))
diff --git a/duhton/frame.c b/duhton/frame.c
--- a/duhton/frame.c
+++ b/duhton/frame.c
@@ -118,6 +118,7 @@
 static dictentry_t *
 find_entry(DuFrameObject *frame, DuObject *symbol, int write_mode)
 {
+    /* only allocates if write_mode = 1 */
     _du_read1(frame);
     DuFrameNodeObject *ob = frame->ob_nodes;
 
@@ -259,13 +260,14 @@
     }
     if (e->func_progn) {
         DuObject *func = e->func_progn;
+        DuObject *func_arglist = e->func_arglist;
         _du_save1(func);
-        _du_save3(frame, symbol, rest);
+        _du_save4(frame, symbol, rest, func_arglist);
         DuObject *callee_frame = DuFrame_New();
-        _du_restore3(frame, symbol, rest);
+        _du_restore4(frame, symbol, rest, func_arglist);
 
         _du_save1(callee_frame);
-        _parse_arguments(symbol, rest, e->func_arglist, frame, callee_frame);
+        _parse_arguments(symbol, rest, func_arglist, frame, callee_frame);
         _du_restore1(callee_frame);
         _du_restore1(func);
 


More information about the pypy-commit mailing list