Commits

Armin Rigo committed fc5f096

stm_set_transaction_length()

Comments (0)

Files changed (4)

rpython/rtyper/lltypesystem/lloperation.py

     'stm_enter_callback_call':LLOp(canmallocgc=True),
     'stm_leave_callback_call':LLOp(),
     'stm_should_break_transaction': LLOp(sideeffects=False),
+    'stm_set_transaction_length': LLOp(),
 
 ##    'stm_allocate_nonmovable_int_adr': LLOp(sideeffects=False, canmallocgc=True),
 ##    'stm_become_inevitable':  LLOp(canmallocgc=True),
 ##    'stm_major_collect':      LLOp(canmallocgc=True),
 ##    'stm_get_tid':            LLOp(canfold=True),
 ##    'stm_ptr_eq':             LLOp(canfold=True),
-##    'stm_should_break_transaction': LLOp(sideeffects=False),
-##    'stm_set_transaction_length': LLOp(canmallocgc=True),
 ##    'stm_change_atomic':      LLOp(),
 ##    'stm_get_atomic':         LLOp(sideeffects=False),
 ##    'stm_perform_transaction':LLOp(canmallocgc=True),

rpython/translator/stm/funcgen.py

     result = funcgen.expr(op.result)
     return '%s = pypy_stm_should_break_transaction();' % (result,)
 
+def stm_set_transaction_length(funcgen, op):
+    arg0 = funcgen.expr(op.args[0])
+    return 'pypy_stm_set_transaction_length(%s);' % (arg0,)
+
 
 ##def stm_initialize(funcgen, op):
 ##    return '''stm_initialize();
 ##    result = funcgen.expr(op.result)
 ##    return '%s = stm_id((gcptr)%s);' % (result, arg0)
 
-##def stm_set_transaction_length(funcgen, op):
-##    arg0 = funcgen.expr(op.args[0])
-##    return 'stm_set_transaction_length(%s);' % (arg0,)
-
 ##def stm_change_atomic(funcgen, op):
 ##    arg0 = funcgen.expr(op.args[0])
 ##    return 'stm_atomic(%s);' % (arg0,)

rpython/translator/stm/src_stm/stmgcintf.c

 stm_char *pypy_stm_nursery_low_fill_mark;
 
 
+void pypy_stm_set_transaction_length(long percentage)
+{
+    /* the value '100' means 'use the default'.  Other values are
+       interpreted proportionally, up to some maximum. */
+    long low_fill_mark = LOW_FILL_MARK * percentage / 100;
+    if (low_fill_mark > NURSERY_SIZE / 2)
+        low_fill_mark = NURSERY_SIZE / 2;
+    pypy_stm_nursery_low_fill_mark = ((stm_char *)_stm_nursery_start) +
+                                     low_fill_mark;
+}
+
 void pypy_stm_setup(void)
 {
     stm_setup();
     stm_register_thread_local(&stm_thread_local);
-
-    size_t low_fill_mark = LOW_FILL_MARK;
-    if (low_fill_mark > NURSERY_SIZE / 2)
-        low_fill_mark = NURSERY_SIZE / 2;
-    pypy_stm_nursery_low_fill_mark = ((stm_char *)_stm_nursery_start) +
-                                     low_fill_mark;
-
+    pypy_stm_set_transaction_length(100);
     stm_start_inevitable_transaction(&stm_thread_local);
 }
 

rpython/translator/stm/src_stm/stmgcintf.h

 void pypy_stm_setup_prebuilt(void);   /* generated into stm_prebuilt.c */
 long pypy_stm_enter_callback_call(void);
 void pypy_stm_leave_callback_call(long);
+void pypy_stm_set_transaction_length(long);
 
 static inline int pypy_stm_should_break_transaction(void)
 {