Skip to content

Commit

Permalink
experimental per-VM method cache
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/vm-mcache@3927 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed Apr 14, 2010
1 parent 286b7b9 commit 57119dd
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 486 deletions.
4 changes: 2 additions & 2 deletions array.c
Expand Up @@ -1889,8 +1889,8 @@ take_items(VALUE obj, long n)
args[0] = result;
args[1] = (VALUE)n;

rb_objc_block_call(obj, selEach, cacheEach, 0, 0,
(VALUE(*)(ANYARGS))take_i, (VALUE)args);
rb_objc_block_call(obj, selEach, 0, 0, (VALUE(*)(ANYARGS))take_i,
(VALUE)args);

return result;
}
Expand Down
14 changes: 6 additions & 8 deletions compar.c
Expand Up @@ -16,7 +16,6 @@
VALUE rb_mComparable;

static SEL cmp = 0;
static struct mcache *cmp_cache = NULL;

void
rb_cmperr(VALUE x, VALUE y)
Expand All @@ -37,14 +36,14 @@ rb_cmperr(VALUE x, VALUE y)
VALUE
rb_objs_cmp(VALUE x, VALUE y)
{
return rb_vm_call_with_cache(cmp_cache, x, cmp, 1, &y);
return rb_vm_call(x, cmp, 1, &y, false);
}

static VALUE
cmp_eq(VALUE *a)
{
//VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
VALUE c = rb_vm_call_with_cache(cmp_cache, a[0], cmp, 1, &a[1]);
VALUE c = rb_vm_call(a[0], cmp, 1, &a[1], false);

if (NIL_P(c)) {
return Qfalse;
Expand Down Expand Up @@ -93,7 +92,7 @@ static VALUE
cmp_gt(VALUE x, SEL sel, VALUE y)
{
//VALUE c = rb_funcall(x, cmp, 1, y);
VALUE c = rb_vm_call_with_cache(cmp_cache, x, cmp, 1, &y);
VALUE c = rb_vm_call(x, cmp, 1, &y, false);

if (rb_cmpint(c, x, y) > 0) return Qtrue;
return Qfalse;
Expand All @@ -111,7 +110,7 @@ static VALUE
cmp_ge(VALUE x, SEL sel, VALUE y)
{
//VALUE c = rb_funcall(x, cmp, 1, y);
VALUE c = rb_vm_call_with_cache(cmp_cache, x, cmp, 1, &y);
VALUE c = rb_vm_call(x, cmp, 1, &y, false);

if (rb_cmpint(c, x, y) >= 0) return Qtrue;
return Qfalse;
Expand All @@ -129,7 +128,7 @@ static VALUE
cmp_lt(VALUE x, SEL sel, VALUE y)
{
//VALUE c = rb_funcall(x, cmp, 1, y);
VALUE c = rb_vm_call_with_cache(cmp_cache, x, cmp, 1, &y);
VALUE c = rb_vm_call(x, cmp, 1, &y, false);

if (rb_cmpint(c, x, y) < 0) return Qtrue;
return Qfalse;
Expand All @@ -147,7 +146,7 @@ static VALUE
cmp_le(VALUE x, SEL sel, VALUE y)
{
//VALUE c = rb_funcall(x, cmp, 1, y);
VALUE c = rb_vm_call_with_cache(cmp_cache, x, cmp, 1, &y);
VALUE c = rb_vm_call(x, cmp, 1, &y, false);

if (rb_cmpint(c, x, y) <= 0) return Qtrue;
return Qfalse;
Expand Down Expand Up @@ -225,5 +224,4 @@ Init_Comparable(void)
rb_objc_define_method(rb_mComparable, "between?", cmp_between, 2);

cmp = sel_registerName("<=>:");
cmp_cache = rb_vm_get_call_cache(cmp);
}

0 comments on commit 57119dd

Please sign in to comment.