Permalink
Browse files

per-vm method cache + misc fixes/improvements

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4181 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 11c0b48 commit 70ea0b5aed43f8f4206a71f5c8e0cf64c678a6ae @lrz lrz committed Jun 1, 2010
Showing with 452 additions and 632 deletions.
  1. +1 −1 MacRuby.m
  2. +1 −1 NSDictionary.m
  3. +2 −4 NSString.m
  4. +4 −6 array.c
  5. +4 −2 bridgesupport.cpp
  6. +2 −2 bridgesupport.h
  7. +6 −6 class.c
  8. +2 −2 class.h
  9. +18 −22 compar.c
  10. +19 −112 compiler.cpp
  11. +0 −4 compiler.h
  12. +23 −20 complex.c
  13. +106 −94 dispatcher.cpp
  14. +39 −40 enum.c
  15. +3 −3 enumerator.c
  16. +10 −19 error.c
  17. +1 −1 exported_symbols_list
  18. +5 −15 ext/libyaml/rubyext.c
  19. +1 −2 ext/openssl/ossl_ssl.c
  20. +1 −1 file.c
  21. +4 −8 hash.c
  22. +0 −1 hash.h
  23. +0 −2 id.c
  24. +0 −1 id.h
  25. +3 −3 include/ruby/ruby.h
  26. +1 −1 io.c
  27. +33 −42 kernel.c
  28. +41 −41 numeric.c
  29. +10 −26 object.c
  30. +1 −2 proc.c
  31. +1 −2 process.c
  32. +2 −2 random.c
  33. +24 −30 range.c
  34. +6 −6 rational.c
  35. +2 −3 signal.c
  36. +8 −0 spec/macruby/core/constant_spec.rb
  37. +6 −6 string.c
  38. +0 −5 variable.c
  39. +26 −54 vm.cpp
  40. +29 −28 vm.h
  41. +6 −11 vm_eval.c
  42. +1 −1 vm_method.c
View
@@ -87,7 +87,7 @@ - (id)performRubySelector:(SEL)sel withArguments:(id *)argv count:(int)argc
}
}
- return RB2OC(rb_vm_call(OC2RB(self), sel, argc, rargv, false));
+ return RB2OC(rb_vm_call(OC2RB(self), sel, argc, rargv));
}
- (id)performRubySelector:(SEL)sel withArguments:firstArg, ...
View
@@ -432,7 +432,7 @@
tmp = INT2FIX(1);
argv = &tmp;
}
- rb_vm_call((VALUE)ary, sel_registerName("flatten!:"), argc, argv, false);
+ rb_vm_call((VALUE)ary, sel_registerName("flatten!:"), argc, argv);
return ary;
}
View
@@ -206,8 +206,7 @@
static VALUE
nsstr_forward_m1(id rcv, SEL sel, int argc, VALUE *argv)
{
- return rb_vm_call_with_cache2(rb_vm_get_call_cache(sel),
- rb_vm_current_block(), nsstr_to_rstr(rcv), 0, sel, argc, argv);
+ return rb_vm_call2(rb_vm_current_block(), nsstr_to_rstr(rcv), 0, sel, argc, argv);
}
static VALUE
@@ -241,8 +240,7 @@
{
CHECK_MUTABLE(rcv);
VALUE rcv_rstr = nsstr_to_rstr(rcv);
- VALUE ret = rb_vm_call_with_cache2(rb_vm_get_call_cache(sel),
- rb_vm_current_block(), rcv_rstr, 0, sel, argc, argv);
+ VALUE ret = rb_vm_call2(rb_vm_current_block(), rcv_rstr, 0, sel, argc, argv);
TRY_MOP([rcv setString:(id)rcv_rstr]);
return ret;
}
View
10 array.c
@@ -1565,12 +1565,10 @@ sort_by_i(VALUE i)
static VALUE
rary_sort_by_bang(VALUE ary, SEL sel)
{
- VALUE sorted;
-
RETURN_ENUMERATOR(ary, 0, 0);
rb_ary_modify(ary);
- sorted = rb_objc_block_call(ary, sel_registerName("sort_by"), NULL, 0, 0,
- sort_by_i, 0);
+ VALUE sorted = rb_objc_block_call(ary, sel_registerName("sort_by"), 0, 0,
+ sort_by_i, 0);
rb_ary_replace(ary, sorted);
return ary;
}
@@ -2058,8 +2056,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;
}
View
@@ -405,7 +405,7 @@ rb_vm_struct_aset(VALUE rcv, SEL sel, VALUE index, VALUE val)
char buf[100];
snprintf(buf, sizeof buf, "%s=:", bs_boxed->as.s->fields[idx].name);
- return rb_vm_call(rcv, sel_registerName(buf), 1, &val, false);
+ return rb_vm_call(rcv, sel_registerName(buf), 1, &val);
}
static VALUE
@@ -1313,7 +1313,8 @@ RoxorCore::load_bridge_support(const char *path, const char *framework_path,
if (!ok) {
rb_raise(rb_eRuntimeError, "%s", error);
}
-#if defined(__LP64__)
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+# if defined(__LP64__)
static bool R6399046_fixed = false;
// XXX work around for
// <rdar://problem/6399046> NSNotFound 64-bit value is incorrect
@@ -1327,6 +1328,7 @@ RoxorCore::load_bridge_support(const char *path, const char *framework_path,
R6399046_fixed = true;
}
}
+# endif
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
static bool R6401816_fixed = false;
View
@@ -13,6 +13,8 @@
extern "C" {
#endif
+#include "bs.h"
+
void *rb_pointer_get_data(VALUE rcv, const char *type);
VALUE rb_pointer_new(const char *type_str, void *val, size_t len);
VALUE rb_pointer_new2(const char *type_str, VALUE val);
@@ -21,8 +23,6 @@ bool rb_boxed_is_type(VALUE klass, const char *type);
#if defined(__cplusplus)
} // extern "C"
-#include "bs.h"
-
typedef struct rb_vm_bs_boxed {
bs_element_type_t bs_type;
bool is_struct(void) { return bs_type == BS_ELEMENT_STRUCT; }
View
12 class.c
@@ -61,20 +61,20 @@ rb_obj_imp_isEqual(void *rcv, SEL sel, void *obj)
return false;
}
VALUE arg = OC2RB(obj);
- return rb_vm_call((VALUE)rcv, selEq, 1, &arg, false) == Qtrue;
+ return rb_vm_call((VALUE)rcv, selEq, 1, &arg) == Qtrue;
}
static void *
rb_obj_imp_init(void *rcv, SEL sel)
{
- rb_vm_call((VALUE)rcv, selInitialize, 0, NULL, false);
+ rb_vm_call((VALUE)rcv, selInitialize, 0, NULL);
return rcv;
}
static void *
rb_obj_imp_description(void *rcv, SEL sel)
{
- return (void *)rb_vm_call(OC2RB(rcv), selToS, 0, NULL, false);
+ return (void *)rb_vm_call(OC2RB(rcv), selToS, 0, NULL);
}
static VALUE
@@ -415,7 +415,7 @@ rb_class_inherited(VALUE super, VALUE klass)
if (super == 0) {
super = rb_cObject;
}
- return rb_vm_call(super, selInherited, 1, &klass, false);
+ return rb_vm_call(super, selInherited, 1, &klass);
}
return Qnil;
}
@@ -1258,8 +1258,8 @@ rb_class_flags_cache_t *rb_class_flags;
void
Init_PreClass(void)
{
- rb_class_flags = (rb_class_flags_cache_t *)calloc(CACHE_SIZE,
- sizeof(rb_class_flags_cache_t));
+ rb_class_flags = (rb_class_flags_cache_t *)calloc(
+ CLASS_FLAGS_CACHE_SIZE, sizeof(rb_class_flags_cache_t));
assert(rb_class_flags != NULL);
}
View
@@ -30,14 +30,14 @@ typedef struct rb_class_flags_cache {
struct rb_class_flags_cache *next;
} rb_class_flags_cache_t;
-#define CACHE_SIZE 0x1000
+#define CLASS_FLAGS_CACHE_SIZE 0x1000
extern rb_class_flags_cache_t *rb_class_flags;
static unsigned int
rb_class_flags_hash(Class k)
{
- return ((unsigned long)k >> 2) & (CACHE_SIZE - 1);
+ return ((unsigned long)k >> 2) & (CLASS_FLAGS_CACHE_SIZE - 1);
}
static inline unsigned long
View
@@ -16,7 +16,6 @@
VALUE rb_mComparable;
static SEL cmp = 0;
-static struct mcache *cmp_cache = NULL;
void
rb_cmperr(VALUE x, VALUE y)
@@ -37,15 +36,13 @@ 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);
}
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]);
if (NIL_P(c)) {
return Qfalse;
}
@@ -92,10 +89,10 @@ cmp_equal(VALUE x, SEL sel, VALUE y)
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);
-
- if (rb_cmpint(c, x, y) > 0) return Qtrue;
+ VALUE c = rb_vm_call(x, cmp, 1, &y);
+ if (rb_cmpint(c, x, y) > 0) {
+ return Qtrue;
+ }
return Qfalse;
}
@@ -110,10 +107,10 @@ cmp_gt(VALUE x, SEL sel, VALUE y)
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);
-
- if (rb_cmpint(c, x, y) >= 0) return Qtrue;
+ VALUE c = rb_vm_call(x, cmp, 1, &y);
+ if (rb_cmpint(c, x, y) >= 0) {
+ return Qtrue;
+ }
return Qfalse;
}
@@ -128,10 +125,10 @@ cmp_ge(VALUE x, SEL sel, VALUE y)
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);
-
- if (rb_cmpint(c, x, y) < 0) return Qtrue;
+ VALUE c = rb_vm_call(x, cmp, 1, &y);
+ if (rb_cmpint(c, x, y) < 0) {
+ return Qtrue;
+ }
return Qfalse;
}
@@ -146,10 +143,10 @@ cmp_lt(VALUE x, SEL sel, VALUE y)
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);
-
- if (rb_cmpint(c, x, y) <= 0) return Qtrue;
+ VALUE c = rb_vm_call(x, cmp, 1, &y);
+ if (rb_cmpint(c, x, y) <= 0) {
+ return Qtrue;
+ }
return Qfalse;
}
@@ -225,5 +222,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);
}
Oops, something went wrong.

0 comments on commit 70ea0b5

Please sign in to comment.