[pypy-commit] stmgc c7: remove some read barriers from duhton in case the field that is read is actually immutable (hopefully)

Remi Meier noreply at buildbot.pypy.org
Mon Jan 27 14:37:43 CET 2014


Author: Remi Meier
Branch: c7
Changeset: r678:7743314d82eb
Date: 2014-01-27 14:37 +0100
http://bitbucket.org/pypy/stmgc/changeset/7743314d82eb/

Log:	remove some read barriers from duhton in case the field that is read
	is actually immutable (hopefully)

diff --git a/c7/largemalloc.c b/c7/largemalloc.c
--- a/c7/largemalloc.c
+++ b/c7/largemalloc.c
@@ -99,8 +99,10 @@
        spans over. the CHUNK_HEADER is not included in the calculations */
     mchunk_t *chunk = data2chunk((char*)data);
     *start = (((char*)data) - get_thread_base(0)) / 4096UL;
+    assert(*start < NB_PAGES);
     size_t offset_into_page = ((uintptr_t)data) & 4095UL; // % 4096
     *num = ((chunk->size & ~FLAG_SORTED) + offset_into_page + 4095) / 4096UL;
+    assert(*num < NB_PAGES);
 }
 
 size_t _stm_data_size(struct object_s *data)
diff --git a/duhton/consobject.c b/duhton/consobject.c
--- a/duhton/consobject.c
+++ b/duhton/consobject.c
@@ -12,7 +12,7 @@
     DuObject *p;
     printf("( ");
     while (1) {
-        _du_read1(ob);
+        /* _du_read1(ob); IMMUTABLE */
         _du_save1(ob);
         Du_Print(ob->car, 0);
         _du_restore1(ob);
@@ -33,7 +33,7 @@
 
 DuObject *cons_eval(DuConsObject *ob, DuObject *locals)
 {
-    _du_read1(ob);
+    /* _du_read1(ob); IMMUTABLE */
     return _DuFrame_EvalCall(locals, ob->car, ob->cdr, 1);
 }
 
@@ -59,14 +59,14 @@
 DuObject *DuCons_Car(DuObject *cons)
 {
     DuCons_Ensure("DuCons_Car", cons);
-    _du_read1(cons);
+    /* _du_read1(cons); IMMUTABLE */
     return ((DuConsObject *)cons)->car;
 }
 
 DuObject *DuCons_Cdr(DuObject *cons)
 {
     DuCons_Ensure("DuCons_Cdr", cons);
-    _du_read1(cons);
+    /* _du_read1(cons); IMMUTABLE */
     return ((DuConsObject *)cons)->cdr;
 }
 
diff --git a/duhton/demo/container_transaction.duh b/duhton/demo/container_transaction.duh
--- a/duhton/demo/container_transaction.duh
+++ b/duhton/demo/container_transaction.duh
@@ -3,11 +3,11 @@
 
 (defun g (thread n)
     (set c (+ (get c) 1))
-    (if (> (get c) 20000)
+    (if (> (get c) 200000)
         (print (quote overflow) (get c))
-      (if (< n 10000)
+      (if (< n 100000)
           (transaction f thread (+ n 1))
-        (if (< (get c) 20000)
+        (if (< (get c) 200000)
             (print (quote not-enough))
           (print (quote ok))))))
 
diff --git a/duhton/intobject.c b/duhton/intobject.c
--- a/duhton/intobject.c
+++ b/duhton/intobject.c
@@ -7,13 +7,13 @@
 
 void int_print(DuIntObject *ob)
 {
-    _du_read1(ob);
+    /* _du_read1(ob); IMMUTABLE */
     printf("%d", ob->ob_intval);
 }
 
 int int_is_true(DuIntObject *ob)
 {
-    _du_read1(ob);
+    /* _du_read1(ob); IMMUTABLE */
     return ob->ob_intval;
 }
 
@@ -38,7 +38,7 @@
 int DuInt_AsInt(DuObject *ob)
 {
     DuInt_Ensure("DuInt_AsInt", ob);
-    _du_read1(ob);
+    /* _du_read1(ob); IMMUTABLE */
     return ((DuIntObject *)ob)->ob_intval;
 }
 
diff --git a/duhton/symbol.c b/duhton/symbol.c
--- a/duhton/symbol.c
+++ b/duhton/symbol.c
@@ -21,7 +21,7 @@
 
 void symbol_print(DuSymbolObject *ob)
 {
-    _du_read1(ob);
+    /* _du_read1(ob); IMMUTABLE name */
     printf("'%s'", ob->name);
 }
 
@@ -66,6 +66,7 @@
 DuObject *DuSymbol_FromString(const char *name)
 {
     DuSymbolObject *p, *head = _Du_AllSymbols;
+    _du_read1(head);
     for (p=head; p != NULL; p=p->next) {
         _du_read1(p);
         if (strcmp(name, p->name) == 0) {
@@ -86,7 +87,7 @@
 char *DuSymbol_AsString(DuObject *ob)
 {
     DuSymbol_Ensure("DuSymbol_AsString", ob);
-    _du_read1(ob);
+    /* _du_read1(ob); IMMUTABLE name */
     return ((DuSymbolObject *)ob)->name;
 }
 


More information about the pypy-commit mailing list