Permalink
Browse files

rb_yield is now inlined + improved GC_WB to not emit a write barrier …

…if the slot already has the value

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@2955 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 203b879 commit dabee30646079778e601fe6b2704e36a7be22397 @lrz lrz committed Nov 4, 2009
Showing with 31 additions and 33 deletions.
  1. +28 −5 include/ruby/ruby.h
  2. +3 −28 vm_eval.c
View
@@ -1023,10 +1023,30 @@ PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);
VALUE rb_each(VALUE);
-VALUE rb_yield(VALUE);
+
+VALUE rb_vm_yield(int argc, const VALUE *argv);
+
+static inline VALUE
+rb_yield(VALUE val)
+{
+ if (val == Qundef) {
+ return rb_vm_yield(0, 0);
+ }
+ else {
+ return rb_vm_yield(1, &val);
+ }
+}
+
+static inline VALUE
+rb_yield_values2(int argc, const VALUE *argv)
+{
+ return rb_vm_yield(argc, argv);
+}
+
VALUE rb_yield_values(int n, ...);
VALUE rb_yield_values2(int n, const VALUE *argv);
VALUE rb_yield_splat(VALUE);
+
int rb_block_given_p(void);
void rb_need_block(void);
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE);
@@ -1399,12 +1419,15 @@ extern auto_zone_t *__auto_zone;
#define GC_WB(dst, newval) \
do { \
void *nv = (void *)newval; \
- if (!SPECIAL_CONST_P(nv)) { \
- if (!auto_zone_set_write_barrier(__auto_zone, (const void *)dst, (const void *)nv)) { \
- rb_bug("destination %p isn't in the auto zone", dst); \
+ if (*(void **)dst != nv) { \
+ if (!SPECIAL_CONST_P(nv)) { \
+ if (!auto_zone_set_write_barrier(__auto_zone, \
+ (const void *)dst, (const void *)nv)) { \
+ rb_bug("destination %p isn't in the auto zone", dst); \
+ } \
} \
+ *(void **)dst = nv; \
} \
- *(void **)dst = nv; \
} \
while (0)
View
@@ -188,28 +188,11 @@ rb_f_public_send(VALUE recv, SEL sel, int argc, VALUE *argv)
/* yield */
-static inline VALUE
-rb_yield_0(int argc, const VALUE * argv)
-{
- return rb_vm_yield(argc, argv);
-}
-
-VALUE
-rb_yield(VALUE val)
-{
- if (val == Qundef) {
- return rb_yield_0(0, 0);
- }
- else {
- return rb_yield_0(1, &val);
- }
-}
-
VALUE
rb_yield_values(int n, ...)
{
if (n == 0) {
- return rb_yield_0(0, 0);
+ return rb_vm_yield(0, 0);
}
else {
int i;
@@ -223,26 +206,18 @@ rb_yield_values(int n, ...)
}
va_end(args);
- return rb_yield_0(n, argv);
+ return rb_vm_yield(n, argv);
}
}
VALUE
-rb_yield_values2(int argc, const VALUE *argv)
-{
- return rb_yield_0(argc, argv);
-}
-
-VALUE
rb_yield_splat(VALUE values)
{
VALUE tmp = rb_check_array_type(values);
- volatile VALUE v;
if (NIL_P(tmp)) {
rb_raise(rb_eArgError, "not an array");
}
- v = rb_yield_0(RARRAY_LEN(tmp), RARRAY_PTR(tmp));
- return v;
+ return rb_vm_yield(RARRAY_LEN(tmp), RARRAY_PTR(tmp));
}
static VALUE

0 comments on commit dabee30

Please sign in to comment.