[macruby-changes] [2955] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 4 11:58:59 PST 2009
Revision: 2955
http://trac.macosforge.org/projects/ruby/changeset/2955
Author: lsansonetti at apple.com
Date: 2009-11-04 11:58:58 -0800 (Wed, 04 Nov 2009)
Log Message:
-----------
rb_yield is now inlined + improved GC_WB to not emit a write barrier if the slot already has the value
Modified Paths:
--------------
MacRuby/trunk/include/ruby/ruby.h
MacRuby/trunk/vm_eval.c
Modified: MacRuby/trunk/include/ruby/ruby.h
===================================================================
--- MacRuby/trunk/include/ruby/ruby.h 2009-11-04 19:57:24 UTC (rev 2954)
+++ MacRuby/trunk/include/ruby/ruby.h 2009-11-04 19:58:58 UTC (rev 2955)
@@ -1023,10 +1023,30 @@
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 @@
#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)
Modified: MacRuby/trunk/vm_eval.c
===================================================================
--- MacRuby/trunk/vm_eval.c 2009-11-04 19:57:24 UTC (rev 2954)
+++ MacRuby/trunk/vm_eval.c 2009-11-04 19:58:58 UTC (rev 2955)
@@ -188,28 +188,11 @@
/* 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 @@
}
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091104/5074b876/attachment-0001.html>
More information about the macruby-changes
mailing list