Hi Nobu,

The comment about preventing tail call optimization was copied from another
place where RB_GC_GUARD might have been doing that. In this case the
RB_GC_GUARD is also ensuring that str can never be GC'd before the
rb_reg_new() on the previous line returns.  This RB_GC_GUARD should not be
removed, but the comment on it should be the same as the one on the
RB_GC_GUARD in the NODE_DREGX_ONCE case.

Regarding gcc's setjmp() implementation:
  Yes, gcc tries to save all the registers, and we agree that isn't required
by the 'C' language spec.
  There are also many variables declared volatile that don't need to be,
which slows execution
  unnecessarily (and confuses people like me :-)

MBARI8 is intended to be applied after MBARI7.  You may notice that, often,
the
parameters in the factored eval_node() functions must be declared volatile. 
I missed that requirement in MBARI7. 

(keep in mind that eval_node == eval_body in your patch,
 the original eval_node() was renamed eval_tree()  )

- brent


Nobuyoshi Nakada-2 wrote:
> 
> ...
> 
> Thank you, I consider you're correct, and merged into the 1.8
> head.
> 
>> +       RB_GC_GUARD(str);  /* prevent tail call optimization here */
> 
> But I don't think tail call optimization could be here.
> Possibly, it would be better to backport rb_reg_new_str() from
> the trunk.
> 
>> Second:
> (snip)
>> I'm guessing that we are not seeing failures in the field because the
>> x86-32
>> has very few registers, so, in practice, variables are usually on the
>> stack
>> and thus preserved through longjmps even when they are not explicitly
>> declared volatile.
> 
> I guess you misses a point here, gcc is aware of setjmp() and
> emits code to save and restore registers into the stack before
> and after it.  I suspect it doesn't work enough for some reason.
> Anyway, your way would be correct for other compilers.
> 
> Should I split rb_eval() before your new patch, or do in
> reverse order?
> 
> -- 
> Nobu Nakada
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/MBARI8-patch-fixes-bugs-caused-by-incorrect-volatile-variable-declarations-tp22259357p22265816.html
Sent from the ruby-core mailing list archive at Nabble.com.