Commits

Armin Rigo  committed 4077da1

Test and fix

  • Participants
  • Parent commits b08c139

Comments (0)

Files changed (4)

File listobject.c

 void list_print(DuListObject *ob)
 {
     int i;
+    Du_AME_INEVITABLE(ob);
     if (ob->ob_count == 0) {
         printf("[]");
     }
     return localobj;
 }
 
+DuObject *_Du_AME_getlocal(DuObject *glob)
+{
+    struct tx_descriptor *d = thread_descriptor;
+    DuObject *localobj;
+    wlog_t* found;
+    REDOLOG_FIND(d->redolog, glob, found, return glob);
+    localobj = found->val;
+    assert(!Du_AME_GLOBAL(localobj));
+    return localobj;
+}
+
 void _Du_AME_InitThreadDescriptor(void)
 {
     assert(thread_descriptor == NULL);
 DuObject *_Du_AME_read_from_global(DuObject *glob, owner_version_t *vers_out);
 void _Du_AME_oreclist_insert(DuObject *glob);
 DuObject *_Du_AME_writebarrier(DuObject *glob);
+DuObject *_Du_AME_getlocal(DuObject *glob);
 
 void _Du_AME_InitThreadDescriptor(void);
 void _Du_AME_FiniThreadDescriptor(void);
     } while (0)
 
 
+#define Du_AME_INEVITABLE(ob)                                           \
+    do {                                                                \
+        Du_AME_TryInevitable();                                         \
+        if (Du_AME_GLOBAL(ob))                                          \
+            (ob) = (typeof(ob))_Du_AME_getlocal((DuObject *)(ob));      \
+    } while (0)
+
+
 #endif  /* _DUHTON_AME_H_ */

File test/test_transaction.py

             (transaction f)
             """)
         assert res == "'done'\n'done'\n"
+
+def test_list_print():
+    res = run("""
+        (setq lst (list 20))
+        (defun f ()
+            (append lst 30)
+            (print lst))
+        (transaction f)
+        """)
+    assert res == "[ 20 30 ]\n"