[ruby-core:60682] volatile usages

From: Eric Wong <normalperson@...>
Date: 2014-02-13 10:04:36 UTC
List: ruby-core #60682
Hi all, I went ahead and removed some use of volatile which were once
needed, but no longer.  (r44929. r44930)

I'm not sure about the reason for the volatile VALUE v in re.c:
rb_reg_s_union, so I'm leaving it alone.


Also, in string.c, I'm not sure if the volatile declaration is enough,
using RB_GC_GUARD below seems more correct (and generates smaller code
on x86-32, at least):

--- a/string.c
+++ b/string.c
@@ -1401,10 +1401,12 @@ rb_str_times(VALUE str, VALUE times)
 static VALUE
 rb_str_format_m(VALUE str, VALUE arg)
 {
-    volatile VALUE tmp = rb_check_array_type(arg);
+    VALUE tmp = rb_check_array_type(arg);
 
     if (!NIL_P(tmp)) {
-	return rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
+	VALUE rv = rb_str_format(RARRAY_LENINT(tmp), RARRAY_CONST_PTR(tmp), str);
+	RB_GC_GUARD(tmp);
+	return rv;
     }
     return rb_str_format(1, &arg, str);
 }

In This Thread

Prev Next