Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 70ea0b5aed43f8f4206a71f5c8e0cf64c678a6ae 1 parent 11c0b48
Laurent Sansonetti authored
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
2  MacRuby.m
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, ...
2  NSDictionary.m
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;
}
6 NSString.m
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;
}
10 array.c
View
@@ -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;
}
6 bridgesupport.cpp
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;
4 bridgesupport.h
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; }
12 class.c
View
@@ -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);
}
4 class.h
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
40 compar.c
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);
}
131 compiler.cpp
View
@@ -306,7 +306,6 @@ RoxorCompiler::compile_single_when_argument(NODE *arg, Value *comparedToVal,
Value *condVal;
if (comparedToVal != NULL) {
std::vector<Value *> params;
- params.push_back(compile_mcache(selEqq, false));
params.push_back(current_self);
params.push_back(subnodeVal);
params.push_back(compile_sel(selEqq));
@@ -463,12 +462,11 @@ RoxorCompiler::compile_when_splat(Value *comparedToVal, Value *splatVal)
{
GlobalVariable *is_redefined = GET_CORE()->redefined_op_gvar(selEqq, true);
Value *args[] = {
- compile_mcache(selEqq, false),
new LoadInst(is_redefined, "", bb),
comparedToVal,
splatVal
};
- return compile_protected_call(whenSplatFunc, args, args + 4);
+ return compile_protected_call(whenSplatFunc, args, args + 3);
}
GlobalVariable *
@@ -538,55 +536,6 @@ RoxorCompiler::compile_const_global_string(const char *str,
}
Value *
-RoxorCompiler::compile_get_mcache(Value *sel, bool super)
-{
- if (getCacheFunc == NULL) {
- // void *rb_vm_get_call_cache2(SEL sel, unsigned char super);
- getCacheFunc =
- cast<Function>(module->getOrInsertFunction(
- "rb_vm_get_call_cache2", PtrTy, PtrTy, Int8Ty,
- NULL));
- }
-
- Value *args[] = {
- sel,
- ConstantInt::get(Int8Ty, super ? 1 : 0)
- };
- return CallInst::Create(getCacheFunc, args, args + 2, "", bb);
-}
-
-Value *
-RoxorCompiler::compile_mcache(SEL sel, bool super)
-{
- struct mcache *cache = GET_CORE()->method_cache_get(sel, super);
- return compile_const_pointer(cache);
-}
-
-Value *
-RoxorAOTCompiler::compile_mcache(SEL sel, bool super)
-{
- if (super) {
- char buf[100];
- snprintf(buf, sizeof buf, "__super__:%s", sel_getName(sel));
- sel = sel_registerName(buf);
- }
-
- GlobalVariable *gvar;
- std::map<SEL, GlobalVariable *>::iterator iter = mcaches.find(sel);
- if (iter == mcaches.end()) {
- gvar = new GlobalVariable(*RoxorCompiler::module, PtrTy, false,
- GlobalValue::InternalLinkage, Constant::getNullValue(PtrTy),
- "");
- assert(gvar != NULL);
- mcaches[sel] = gvar;
- }
- else {
- gvar = iter->second;
- }
- return new LoadInst(gvar, "", bb);
-}
-
-Value *
RoxorCompiler::compile_ccache(ID name)
{
struct ccache *cache = GET_CORE()->constant_cache_get(name);
@@ -716,10 +665,9 @@ Value *
RoxorCompiler::compile_dispatch_call(std::vector<Value *> &params)
{
if (dispatcherFunc == NULL) {
- // VALUE rb_vm_dispatch(struct mcache *cache, VALUE top, VALUE self,
- // SEL sel, void *block, unsigned char opt, int argc, ...);
+ // VALUE rb_vm_dispatch(VALUE top, VALUE self, SEL sel, void *block,
+ // unsigned char opt, int argc, ...);
std::vector<const Type *> types;
- types.push_back(PtrTy);
types.push_back(RubyObjTy);
types.push_back(RubyObjTy);
types.push_back(PtrTy);
@@ -764,7 +712,6 @@ RoxorCompiler::compile_attribute_assign(NODE *node, Value *extra_val)
std::vector<Value *> params;
const SEL sel = mid_to_sel(mid, argc);
- params.push_back(compile_mcache(sel, false));
params.push_back(current_self);
params.push_back(recv);
params.push_back(compile_sel(sel));
@@ -1891,7 +1838,7 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
return NULL;
}
- Value *val = params[2]; // self
+ Value *val = params[1]; // self
Function *f = bb->getParent();
@@ -1922,7 +1869,7 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
return NULL;
}
- Value *leftVal = params[2]; // self
+ Value *leftVal = params[1]; // self
Value *rightVal = params.back();
Function *func = NULL;
@@ -1964,12 +1911,11 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
GlobalVariable *is_redefined = GET_CORE()->redefined_op_gvar(sel, true);
Value *args[] = {
- compile_mcache(sel, false),
leftVal,
rightVal,
new LoadInst(is_redefined, "", bb)
};
- return compile_protected_call(func, args, args + 4);
+ return compile_protected_call(func, args, args + 3);
}
// Other operators (#<< or #[] or #[]=)
else if (sel == selLTLT || sel == selAREF || sel == selASET) {
@@ -1979,7 +1925,7 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
return NULL;
}
- if (params.size() - argc > 7) {
+ if (params.size() - argc > 6) {
// Looks like there is a splat argument there, we can't handle this
// in the primitives.
return NULL;
@@ -1998,14 +1944,13 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
assert(func != NULL);
std::vector<Value *> new_params;
- new_params.push_back(params[2]); // self
+ new_params.push_back(params[1]); // self
if (argc == 1) {
new_params.push_back(params.back()); // other
}
else {
new_params.insert(new_params.end(), params.end() - 2, params.end());
}
- new_params.push_back(params[0]); // cache
GlobalVariable *is_redefined = GET_CORE()->redefined_op_gvar(sel, true);
new_params.push_back(new LoadInst(is_redefined, "", bb));
@@ -2044,16 +1989,15 @@ RoxorCompiler::compile_optimized_dispatch_call(SEL sel, int argc,
bb = thenBB;
std::vector<Value *> new_params;
- new_params.push_back(compile_mcache(new_sel, false));
// Compile a null top reference, to ignore protected visibility.
new_params.push_back(ConstantInt::get(RubyObjTy, 0));
- new_params.push_back(params[2]);
+ new_params.push_back(params[1]);
new_params.push_back(compile_sel(new_sel));
- new_params.push_back(params[4]);
+ new_params.push_back(params[3]);
new_params.push_back(ConstantInt::get(Int8Ty, DISPATCH_FCALL));
new_params.push_back(ConstantInt::get(Int32Ty, argc - 1));
for (int i = 0; i < argc - 1; i++) {
- new_params.push_back(params[8 + i]);
+ new_params.push_back(params[7 + i]);
}
Value *thenVal = compile_dispatch_call(new_params);
thenBB = bb;
@@ -2899,7 +2843,6 @@ RoxorCompiler::compile_node(NODE *node)
assert(node->nd_next->nd_vid > 0);
sel = mid_to_sel(node->nd_next->nd_vid, 0);
}
- params.push_back(compile_mcache(sel, false));
params.push_back(current_self);
params.push_back(recv);
params.push_back(compile_sel(sel));
@@ -2959,7 +2902,6 @@ RoxorCompiler::compile_node(NODE *node)
? node->nd_mid : node->nd_next->nd_mid;
sel = mid_to_sel(mid, 1);
params.clear();
- params.push_back(compile_mcache(sel, false));
params.push_back(current_self);
params.push_back(tmp);
params.push_back(compile_sel(sel));
@@ -2984,7 +2926,6 @@ RoxorCompiler::compile_node(NODE *node)
sel = mid_to_sel(node->nd_next->nd_aid, 1);
}
params.clear();
- params.push_back(compile_mcache(sel, false));
params.push_back(current_self);
params.push_back(recv);
params.push_back(compile_sel(sel));
@@ -3036,7 +2977,6 @@ RoxorCompiler::compile_node(NODE *node)
}
std::vector<Value *> params;
- params.push_back(compile_mcache(selBackquote, false));
params.push_back(current_self);
params.push_back(current_self);
params.push_back(compile_sel(selBackquote));
@@ -3477,7 +3417,7 @@ RoxorCompiler::compile_node(NODE *node)
// Prepare the dispatcher parameters.
std::vector<Value *> params;
- // Method cache (and prepare the selector).
+ // Prepare the selector.
Value *sel_val;
SEL sel;
if (mid != 0) {
@@ -3503,10 +3443,6 @@ RoxorCompiler::compile_node(NODE *node)
dyn_sel, compile_const_pointer(NULL));
sel_val = SelectInst::Create(is_null, sel_val, dyn_sel,
"", bb);
- params.push_back(compile_get_mcache(sel_val, true));
- }
- else {
- params.push_back(compile_mcache(sel, super_call));
}
}
else {
@@ -3514,7 +3450,6 @@ RoxorCompiler::compile_node(NODE *node)
// A super call outside a method definition. Compile a
// null selector, the runtime will raise an exception.
sel = 0;
- params.push_back(compile_const_pointer(NULL));
sel_val = compile_const_pointer(NULL);
}
@@ -3626,7 +3561,7 @@ RoxorCompiler::compile_node(NODE *node)
blockVal = compile_const_pointer(NULL);
}
}
- params[4] = blockVal;
+ params[3] = blockVal;
// If we are calling a method that needs a top-level binding
// object, let's create it.
@@ -3845,7 +3780,6 @@ RoxorCompiler::compile_node(NODE *node)
}
std::vector<Value *> params;
- params.push_back(compile_mcache(selEqTilde, false));
params.push_back(current_self);
params.push_back(reTarget);
params.push_back(compile_sel(selEqTilde));
@@ -4424,7 +4358,6 @@ RoxorCompiler::compile_node(NODE *node)
// dispatch #each on the receiver
std::vector<Value *> params;
- params.push_back(compile_mcache((is_lambda ? selLambda : selEach), false));
params.push_back(current_self);
if (!is_lambda) {
@@ -4641,7 +4574,6 @@ RoxorCompiler::compile_node(NODE *node)
std::vector<Value *> params;
SEL sel = sel_registerName("at_exit");
- params.push_back(compile_mcache(sel, false));
params.push_back(current_self);
params.push_back(compile_nsobject());
params.push_back(compile_sel(sel));
@@ -4723,33 +4655,6 @@ RoxorAOTCompiler::compile_main_function(NODE *node)
function->getEntryBlock().getInstList();
bb = &function->getEntryBlock();
- // Compile method caches.
-
- Function *getMethodCacheFunc = cast<Function>(module->getOrInsertFunction(
- "rb_vm_get_method_cache",
- PtrTy, PtrTy, NULL));
-
- for (std::map<SEL, GlobalVariable *>::iterator i = mcaches.begin();
- i != mcaches.end();
- ++i) {
-
- SEL sel = i->first;
- GlobalVariable *gvar = i->second;
-
- Value *load = compile_sel(sel, false);
-
- Instruction *call = CallInst::Create(getMethodCacheFunc, load, "");
-
- Instruction *assign = new StoreInst(call, gvar, "");
-
- list.insert(list.begin(), assign);
- list.insert(list.begin(), call);
- Instruction *load_insn = dyn_cast<Instruction>(load);
- if (load_insn != NULL) {
- list.insert(list.begin(), load_insn);
- }
- }
-
// Compile constant caches.
Function *getConstCacheFunc = cast<Function>(module->getOrInsertFunction(
@@ -6359,10 +6264,12 @@ RoxorCompiler::compile_objc_stub(Function *ruby_func, IMP ruby_imp,
rescue_invoke_bb = old_rescue_invoke_bb;
#endif
- // Now that the function is finished, we can inline the Ruby method.
- if (CallInst::classof(ruby_call_insn)) {
- CallInst *insn = cast<CallInst>(ruby_call_insn);
- InlineFunction(insn);
+ if (ruby_func != NULL) {
+ // Now that the function is finished, we can inline the Ruby method.
+ if (CallInst::classof(ruby_call_insn)) {
+ CallInst *insn = cast<CallInst>(ruby_call_insn);
+ InlineFunction(insn);
+ }
}
return f;
4 compiler.h
View
@@ -357,8 +357,6 @@ class RoxorCompiler {
void compile_return_from_block(Value *val, int id);
void compile_return_from_block_handler(int id);
Value *compile_jump(NODE *node);
- virtual Value *compile_mcache(SEL sel, bool super);
- Value *compile_get_mcache(Value *sel, bool super);
virtual Value *compile_ccache(ID id);
virtual Value *compile_sel(SEL sel, bool add_to_bb=true) {
return compile_const_pointer(sel, PtrTy);
@@ -431,7 +429,6 @@ class RoxorAOTCompiler : public RoxorCompiler {
Function *compile_main_function(NODE *node);
private:
- std::map<SEL, GlobalVariable *> mcaches;
std::map<ID, GlobalVariable *> ccaches;
std::map<SEL, GlobalVariable *> sels;
std::map<ID, GlobalVariable *> ids;
@@ -443,7 +440,6 @@ class RoxorAOTCompiler : public RoxorCompiler {
GlobalVariable *cStandardError_gvar;
std::vector<GlobalVariable *> class_gvars;
- Value *compile_mcache(SEL sel, bool super);
Value *compile_ccache(ID id);
Value *compile_sel(SEL sel, bool add_to_bb=true);
void compile_prepare_method(Value *classVal, Value *sel,
43 complex.c
View
@@ -31,28 +31,28 @@ static SEL sel_abs, sel_abs2, sel_arg, sel_cmp, sel_conj, sel_convert,
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
- return rb_vm_call(x, op, 1, &y, false);\
+ return rb_vm_call(x, op, 1, &y);\
}
#define fun1(n) \
inline static VALUE \
f_##n(VALUE x)\
{\
- return rb_vm_call(x, sel_##n, 0, NULL, false);\
+ return rb_vm_call(x, sel_##n, 0, NULL);\
}
#define fun2(n) \
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
- return rb_vm_call(x, sel_##n, 1, &y, false);\
+ return rb_vm_call(x, sel_##n, 1, &y);\
}
#define math1(n) \
inline static VALUE \
m_##n(VALUE x)\
{\
- return rb_vm_call(rb_mMath, sel_##n, 1, &x, false);\
+ return rb_vm_call(rb_mMath, sel_##n, 1, &x);\
}
#define math2(n) \
@@ -60,7 +60,7 @@ inline static VALUE \
m_##n(VALUE x, VALUE y)\
{\
VALUE args[2]; args[0] = x; args[1] = y;\
- return rb_vm_call(rb_mMath, sel_##n, 2, args, false);\
+ return rb_vm_call(rb_mMath, sel_##n, 2, args);\
}
#define PRESERVE_SIGNEDZERO
@@ -74,7 +74,7 @@ f_add(VALUE x, VALUE y)
else if (FIXNUM_P(x) && FIX2LONG(x) == 0)
return y;
#endif
- return rb_vm_call(x, selPLUS, 1, &y, false);
+ return rb_vm_call(x, selPLUS, 1, &y);
}
inline static VALUE
@@ -90,31 +90,34 @@ f_cmp(VALUE x, VALUE y)
}
return INT2FIX(c);
}
- return rb_vm_call(x, selCmp, 1, &y, false);
+ return rb_vm_call(x, selCmp, 1, &y);
}
inline static VALUE
f_div(VALUE x, VALUE y)
{
- if (FIXNUM_P(y) && FIX2LONG(y) == 1)
+ if (FIXNUM_P(y) && FIX2LONG(y) == 1) {
return x;
- return rb_vm_call(x, selDIV, 1, &y, false);
+ }
+ return rb_vm_call(x, selDIV, 1, &y);
}
inline static VALUE
f_gt_p(VALUE x, VALUE y)
{
- if (FIXNUM_P(x) && FIXNUM_P(y))
+ if (FIXNUM_P(x) && FIXNUM_P(y)) {
return f_boolcast(FIX2LONG(x) > FIX2LONG(y));
- return rb_vm_call(x, selGT, 1, &y, false);
+ }
+ return rb_vm_call(x, selGT, 1, &y);
}
inline static VALUE
f_lt_p(VALUE x, VALUE y)
{
- if (FIXNUM_P(x) && FIXNUM_P(y))
+ if (FIXNUM_P(x) && FIXNUM_P(y)) {
return f_boolcast(FIX2LONG(x) < FIX2LONG(y));
- return rb_vm_call(x, selLT, 1, &y, false);
+ }
+ return rb_vm_call(x, selLT, 1, &y);
}
binop(mod, selMOD)
@@ -142,7 +145,7 @@ f_mul(VALUE x, VALUE y)
return y;
}
#endif
- return rb_vm_call(x, selMULT, 1, &y, false);
+ return rb_vm_call(x, selMULT, 1, &y);
}
inline static VALUE
@@ -152,7 +155,7 @@ f_sub(VALUE x, VALUE y)
if (FIXNUM_P(y) && FIX2LONG(y) == 0)
return x;
#endif
- return rb_vm_call(x, selMINUS, 1, &y, false);
+ return rb_vm_call(x, selMINUS, 1, &y);
}
fun1(abs)
@@ -181,7 +184,7 @@ f_eqeq_p(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) {
return f_boolcast(FIX2LONG(x) == FIX2LONG(y));
}
- return rb_vm_call(x, selEq, 1, &y, false);
+ return rb_vm_call(x, selEq, 1, &y);
}
fun2(expt)
@@ -196,7 +199,7 @@ f_negative_p(VALUE x)
return f_boolcast(FIX2LONG(x) < 0);
}
VALUE v = ZERO;
- return rb_vm_call(x, selLT, 1, &v, false);
+ return rb_vm_call(x, selLT, 1, &v);
}
#define f_positive_p(x) (!f_negative_p(x))
@@ -217,7 +220,7 @@ f_zero_p(VALUE x)
}
}
VALUE v = ZERO;
- return rb_vm_call(x, selEq, 1, &v, false);
+ return rb_vm_call(x, selEq, 1, &v);
}
#define f_nonzero_p(x) (!f_zero_p(x))
@@ -240,7 +243,7 @@ f_one_p(VALUE x)
}
}
VALUE v = ONE;
- return rb_vm_call(x, selEq, 1, &v, false);
+ return rb_vm_call(x, selEq, 1, &v);
}
inline static VALUE
@@ -479,7 +482,7 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y)
static VALUE
nucomp_f_complex(VALUE klass, SEL sel, int argc, VALUE *argv)
{
- return rb_vm_call(rb_cComplex, sel_convert, argc, argv, false);
+ return rb_vm_call(rb_cComplex, sel_convert, argc, argv);
}
#define imp1(n) \
200 dispatcher.cpp
View
@@ -347,10 +347,8 @@ method_missing(VALUE obj, SEL sel, rb_vm_block_t *block, int argc,
return Qnil; // never reached
}
else {
- struct mcache *cache = GET_CORE()->method_cache_get(selMethodMissing,
- false);
- return rb_vm_call_with_cache2(cache, block, obj, NULL, selMethodMissing,
- argc + 1, new_argv);
+ return rb_vm_call2(block, obj, (VALUE)k, selMethodMissing, argc + 1,
+ new_argv);
}
}
@@ -464,8 +462,9 @@ fill_rcache(struct mcache *cache, Class klass, SEL sel,
rb_vm_method_node_t *node)
{
cache->flag = MCACHE_RCALL;
- rcache.klass = klass;
- rcache.node = node;
+ cache->sel = sel;
+ cache->klass = klass;
+ cache->as.rcall.node = node;
}
static void
@@ -473,12 +472,13 @@ fill_ocache(struct mcache *cache, VALUE self, Class klass, IMP imp, SEL sel,
Method method, int argc)
{
cache->flag = MCACHE_OCALL;
- ocache.klass = klass;
- ocache.imp = imp;
- ocache.bs_method = GET_CORE()->find_bs_method(klass, sel);
+ cache->sel = sel;
+ cache->klass = klass;
+ cache->as.ocall.imp = imp;
+ cache->as.ocall.bs_method = GET_CORE()->find_bs_method(klass, sel);
char types[200];
- if (!rb_objc_get_types(self, klass, sel, method, ocache.bs_method,
+ if (!rb_objc_get_types(self, klass, sel, method, cache->as.ocall.bs_method,
types, sizeof types)) {
printf("cannot get encoding types for %c[%s %s]\n",
class_isMetaClass(klass) ? '+' : '-',
@@ -487,8 +487,8 @@ fill_ocache(struct mcache *cache, VALUE self, Class klass, IMP imp, SEL sel,
abort();
}
bool variadic = false;
- if (ocache.bs_method != NULL && ocache.bs_method->variadic
- && method != NULL) {
+ if (cache->as.ocall.bs_method != NULL
+ && cache->as.ocall.bs_method->variadic && method != NULL) {
// TODO honor printf_format
const int real_argc = method_getNumberOfArguments(method) - 2;
if (real_argc < argc) {
@@ -501,8 +501,8 @@ fill_ocache(struct mcache *cache, VALUE self, Class klass, IMP imp, SEL sel,
}
variadic = true;
}
- ocache.stub = (rb_vm_objc_stub_t *)GET_CORE()->gen_stub(types, variadic,
- argc, true);
+ cache->as.ocall.stub = (rb_vm_objc_stub_t *)GET_CORE()->gen_stub(types,
+ variadic, argc, true);
}
static bool
@@ -520,7 +520,6 @@ reinstall_method_maybe(Class klass, SEL sel, const char *types)
}
GET_CORE()->retype_method(klass, node, method_getTypeEncoding(m), types);
-
return true;
}
@@ -536,22 +535,34 @@ sel_equal(Class klass, SEL x, SEL y)
return x_imp == y_imp;
}
-static force_inline VALUE
-__rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
- Class klass, SEL sel, rb_vm_block_t *block, unsigned char opt,
- int argc, const VALUE *argv)
+static int
+mcache_hash(Class klass, SEL sel)
{
- if (cache == NULL) {
- if (sel == 0 && opt == DISPATCH_SUPER) {
- rb_raise(rb_eNoMethodError, "super called outside of method");
- }
- abort();
- }
+ return (((unsigned long)klass >> 3) ^ (unsigned long)sel)
+ & (VM_MCACHE_SIZE - 1);
+}
- if (klass == NULL) {
- klass = (Class)CLASS_OF(self);
+static struct mcache *
+mcache_get(RoxorVM *vm, Class klass, SEL sel, bool super)
+{
+ struct mcache *cache;
+ if (super) {
+ const int hash = mcache_hash(klass, sel) + 1;
+ cache = &vm->get_mcache()[hash];
+ cache->flag = 0; // TODO
}
+ else {
+ const int hash = mcache_hash(klass, sel);
+ cache = &vm->get_mcache()[hash];
+ }
+ return cache;
+}
+static force_inline VALUE
+vm_call_with_cache(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
+ Class klass, SEL sel, rb_vm_block_t *block, unsigned char opt,
+ int argc, const VALUE *argv)
+{
#if ROXOR_VM_DEBUG
bool cached = true;
#endif
@@ -560,14 +571,7 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
Class current_super_class = vm->get_current_super_class();
SEL current_super_sel = vm->get_current_super_sel();
- // XXX: super method cache is disabled because it causes random runtime
- // bugs in rails. Instead of fixing the problem, we wait for the new
- // method cache implementation which should be different (and thread-safe).
- if (opt == DISPATCH_SUPER) {
- cache->flag = 0;
- }
-
- if (cache->flag == 0) {
+ if (cache->sel != sel || cache->klass != klass || cache->flag == 0) {
recache:
#if ROXOR_VM_DEBUG
cached = false;
@@ -606,6 +610,10 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
// objc call
fill_ocache(cache, self, klass, imp, sel, method, argc);
}
+
+ if (opt == DISPATCH_SUPER) {
+ cache->flag |= MCACHE_SUPER;
+ }
}
else {
// Method is not found...
@@ -705,11 +713,13 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
vm_gen_bs_func_types(argc, argv, bs_func, types);
cache->flag = MCACHE_FCALL;
- fcache.bs_function = bs_func;
- fcache.imp = (IMP)dlsym(RTLD_DEFAULT, bs_func->name);
- assert(fcache.imp != NULL);
- fcache.stub = (rb_vm_c_stub_t *)GET_CORE()->gen_stub(types,
- bs_func->variadic, bs_func->args_count, false);
+ cache->sel = sel;
+ cache->klass = klass;
+ cache->as.fcall.bs_function = bs_func;
+ cache->as.fcall.imp = (IMP)dlsym(RTLD_DEFAULT, bs_func->name);
+ assert(cache->as.fcall.imp != NULL);
+ cache->as.fcall.stub = (rb_vm_c_stub_t *)GET_CORE()->gen_stub(
+ types, bs_func->variadic, bs_func->args_count, false);
}
else {
// Still nothing, then let's call #method_missing.
@@ -719,10 +729,7 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
}
dispatch:
- if (cache->flag == MCACHE_RCALL) {
- if (rcache.klass != klass) {
- goto recache;
- }
+ if (cache->flag & MCACHE_RCALL) {
if (!cache_method) {
cache->flag = 0;
}
@@ -733,7 +740,7 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
class_getName(klass),
(void *)self,
sel_getName(sel),
- rcache.node->ruby_imp,
+ cache->as.rcall.node->ruby_imp,
block,
argc,
opt,
@@ -791,8 +798,8 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
MACRUBY_METHOD_ENTRY(class_name, method_name, file, line);
}
- VALUE v = __rb_vm_ruby_dispatch(top, self, sel, rcache.node, opt,
- argc, argv);
+ VALUE v = __rb_vm_ruby_dispatch(top, self, sel, cache->as.rcall.node,
+ opt, argc, argv);
// DTrace probe: method__return
if (MACRUBY_METHOD_RETURN_ENABLED()) {
@@ -807,10 +814,7 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
return v;
}
- else if (cache->flag == MCACHE_OCALL) {
- if (ocache.klass != klass) {
- goto recache;
- }
+ else if (cache->flag & MCACHE_OCALL) {
if (!cache_method) {
cache->flag = 0;
}
@@ -843,21 +847,24 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
}
#if ROXOR_VM_DEBUG
- printf("objc dispatch %c[<%s %p> %s] imp=%p argc=%d (cached=%s)\n",
+ printf("objc dispatch %c[<%s %p> %s] imp=%p cache=%p argc=%d (cached=%s)\n",
class_isMetaClass(klass) ? '+' : '-',
class_getName(klass),
(void *)self,
sel_getName(sel),
- ocache.imp,
+ cache->as.ocall.imp,
+ cache,
argc,
cached ? "true" : "false");
#endif
id ocrcv = RB2OC(self);
- if (ocache.bs_method != NULL) {
- for (int i = 0; i < (int)ocache.bs_method->args_count; i++) {
- bs_element_arg_t *arg = &ocache.bs_method->args[i];
+ if (cache->as.ocall.bs_method != NULL) {
+ Class ocklass = object_getClass(ocrcv);
+ for (int i = 0; i < (int)cache->as.ocall.bs_method->args_count;
+ i++) {
+ bs_element_arg_t *arg = &cache->as.ocall.bs_method->args[i];
if (arg->sel_of_type != NULL) {
// BridgeSupport tells us that this argument contains a
// selector of the given type, but we don't have any
@@ -870,12 +877,12 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
// that either the receiver or one of the arguments of this
// call is the future target.
const int arg_i = arg->index;
- assert(arg_i >= 0);
+ assert(arg_i >= 0 && arg_i < argc);
if (argv[arg_i] != Qnil) {
ID arg_selid = rb_to_id(argv[arg_i]);
SEL arg_sel = sel_registerName(rb_id2name(arg_selid));
- if (reinstall_method_maybe(*(Class *)ocrcv, arg_sel,
+ if (reinstall_method_maybe(ocklass, arg_sel,
arg->sel_of_type)) {
goto sel_target_found;
}
@@ -896,18 +903,18 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
}
}
- return __rb_vm_objc_dispatch(ocache.stub, ocache.imp, ocrcv, sel,
- argc, argv);
+ return __rb_vm_objc_dispatch(cache->as.ocall.stub, cache->as.ocall.imp,
+ ocrcv, sel, argc, argv);
}
- else if (cache->flag == MCACHE_FCALL) {
+ else if (cache->flag & MCACHE_FCALL) {
#if ROXOR_VM_DEBUG
printf("C dispatch %s() imp=%p argc=%d (cached=%s)\n",
- fcache.bs_function->name,
- fcache.imp,
+ cache->as.fcall.bs_function->name,
+ cache->as.fcall.imp,
argc,
cached ? "true" : "false");
#endif
- return (*fcache.stub)(fcache.imp, argc, argv);
+ return (*cache->as.fcall.stub)(cache->as.fcall.imp, argc, argv);
}
printf("method dispatch is b0rked\n");
@@ -964,6 +971,15 @@ __rb_vm_dispatch(RoxorVM *vm, struct mcache *cache, VALUE top, VALUE self,
return method_missing((VALUE)self, sel, block, argc, argv, status);
}
+static force_inline VALUE
+vm_call(RoxorVM *vm, VALUE top, VALUE self, Class klass, SEL sel,
+ rb_vm_block_t *block, unsigned char opt, int argc, const VALUE *argv)
+{
+ struct mcache *cache = mcache_get(vm, klass, sel, opt == DISPATCH_SUPER);
+ return vm_call_with_cache(vm, cache, top, self, klass, sel, block, opt,
+ argc, argv);
+}
+
static force_inline void
__rb_vm_resolve_args(VALUE **pargv, size_t argv_size, int *pargc, va_list ar)
{
@@ -1022,9 +1038,16 @@ __rb_vm_resolve_args(VALUE **pargv, size_t argv_size, int *pargc, va_list ar)
extern "C"
VALUE
-rb_vm_dispatch(struct mcache *cache, VALUE top, VALUE self, SEL sel,
- rb_vm_block_t *block, unsigned char opt, int argc, ...)
+rb_vm_dispatch(VALUE top, VALUE self, SEL sel, rb_vm_block_t *block,
+ unsigned char opt, int argc, ...)
{
+ if (sel == 0) {
+ if (opt == DISPATCH_SUPER) {
+ rb_raise(rb_eNoMethodError, "super called outside of method");
+ }
+ abort();
+ }
+
VALUE base_argv[MAX_DISPATCH_ARGS];
VALUE *argv = base_argv;
if (argc > 0) {
@@ -1056,47 +1079,36 @@ rb_vm_dispatch(struct mcache *cache, VALUE top, VALUE self, SEL sel,
~Finally() { vm->pop_current_binding(); }
} finalizer(vm);
- VALUE retval = __rb_vm_dispatch(vm, cache, top, self, NULL, sel, block,
+ return vm_call(vm, top, self, (Class)CLASS_OF(self), sel, block,
opt, argc, argv);
-
- return retval;
}
extern "C"
VALUE
-rb_vm_call(VALUE self, SEL sel, int argc, const VALUE *argv, bool super)
+rb_vm_call(VALUE self, SEL sel, int argc, const VALUE *argv)
{
- struct mcache *cache;
- unsigned char opt = DISPATCH_FCALL;
- if (super) {
- cache = (struct mcache *)alloca(sizeof(struct mcache));
- cache->flag = 0;
- opt = DISPATCH_SUPER;
- }
- else {
- cache = GET_CORE()->method_cache_get(sel, false);
- }
-
- return __rb_vm_dispatch(GET_VM(), cache, 0, self, NULL, sel, NULL, opt,
- argc, argv);
+ return vm_call(GET_VM(), 0, self, (Class)CLASS_OF(self), sel, NULL,
+ DISPATCH_FCALL, argc, argv);
}
extern "C"
VALUE
-rb_vm_call_with_cache(void *cache, VALUE self, SEL sel, int argc,
- const VALUE *argv)
+rb_vm_call_super(VALUE self, SEL sel, int argc, const VALUE *argv)
{
- return __rb_vm_dispatch(GET_VM(), (struct mcache *)cache, 0, self, NULL,
- sel, NULL, DISPATCH_FCALL, argc, argv);
+ return vm_call(GET_VM(), 0, self, (Class)CLASS_OF(self), sel, NULL,
+ DISPATCH_SUPER, argc, argv);
}
extern "C"
VALUE
-rb_vm_call_with_cache2(void *cache, rb_vm_block_t *block, VALUE self,
- VALUE klass, SEL sel, int argc, const VALUE *argv)
+rb_vm_call2(rb_vm_block_t *block, VALUE self, VALUE klass, SEL sel, int argc,
+ const VALUE *argv)
{
- return __rb_vm_dispatch(GET_VM(), (struct mcache *)cache, 0, self,
- (Class)klass, sel, block, DISPATCH_FCALL, argc, argv);
+ if (klass == 0) {
+ klass = CLASS_OF(self);
+ }
+ return vm_call(GET_VM(), 0, self, (Class)klass, sel, block,
+ DISPATCH_FCALL, argc, argv);
}
static rb_vm_block_t *
@@ -1264,8 +1276,8 @@ rb_vm_block_eval0(rb_vm_block_t *b, SEL sel, VALUE self, int argc,
if (b->flags & VM_BLOCK_METHOD) {
rb_vm_method_t *m = (rb_vm_method_t *)b->imp;
- return rb_vm_call_with_cache2(m->cache, NULL, m->recv, m->oclass,
- m->sel, argc, argv);
+ return vm_call_with_cache(vm, (struct mcache *)m->cache, 0, m->recv,
+ (Class)m->oclass, m->sel, NULL, DISPATCH_FCALL, argc, argv);
}
return __rb_vm_bcall(self, sel, (VALUE)b->dvars, b, b->imp, b->arity,
argc, argv);
@@ -1655,7 +1667,7 @@ RoxorCore::respond_to(VALUE obj, VALUE klass, SEL sel, bool priv,
args[n++] = Qtrue;
}
}
- return rb_vm_call(obj, selRespondTo, n, args, false) == Qtrue;
+ return rb_vm_call(obj, selRespondTo, n, args) == Qtrue;
}
}
79 enum.c
View
@@ -82,7 +82,7 @@ enum_grep(VALUE obj, SEL sel, VALUE pat)
arg[0] = pat;
arg[1] = ary;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
+ rb_objc_block_call(obj, selEach, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
return ary;
}
@@ -165,7 +165,7 @@ enum_count(VALUE obj, SEL sel, int argc, VALUE *argv)
}
memo[0] = 0;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, func, (VALUE)&memo);
+ rb_objc_block_call(obj, selEach, 0, 0, func, (VALUE)&memo);
return INT2NUM(memo[0]);
}
@@ -204,7 +204,7 @@ enum_find(VALUE obj, SEL sel, int argc, VALUE *argv)
rb_scan_args(argc, argv, "01", &if_none);
RETURN_ENUMERATOR(obj, argc, argv);
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, find_i, (VALUE)&memo);
+ rb_objc_block_call(obj, selEach, 0, 0, find_i, (VALUE)&memo);
if (memo != Qundef) {
return memo;
}
@@ -278,7 +278,7 @@ enum_find_index(VALUE obj, SEL sel, int argc, VALUE *argv)
memo[0] = Qnil;
memo[1] = 0;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, func, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, func, (VALUE)memo);
return memo[0];
}
@@ -314,7 +314,7 @@ enum_find_all(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
ary = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, find_all_i, ary);
+ rb_objc_block_call(obj, selEach, 0, 0, find_all_i, ary);
return ary;
}
@@ -349,7 +349,7 @@ enum_reject(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
ary = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, reject_i, ary);
+ rb_objc_block_call(obj, selEach, 0, 0, reject_i, ary);
return ary;
}
@@ -391,7 +391,7 @@ enum_collect(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
ary = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, collect_i, ary);
+ rb_objc_block_call(obj, selEach, 0, 0, collect_i, ary);
return ary;
}
@@ -433,7 +433,7 @@ enum_flat_map(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
ary = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, flat_map_i, ary);
+ rb_objc_block_call(obj, selEach, 0, 0, flat_map_i, ary);
return ary;
}
@@ -453,7 +453,7 @@ enum_to_a(VALUE obj, SEL sel, int argc, VALUE *argv)
{
VALUE ary = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, argc, argv, collect_all, ary);
+ rb_objc_block_call(obj, selEach, argc, argv, collect_all, ary);
return ary;
}
@@ -561,7 +561,7 @@ enum_inject(VALUE obj, SEL sel, int argc, VALUE *argv)
iter = inject_op_i;
break;
}
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, iter, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, iter, (VALUE)memo);
if (memo[0] == Qundef) {
return Qnil;
}
@@ -603,7 +603,7 @@ enum_partition(VALUE obj, SEL sel)
ary[0] = rb_ary_new();
ary[1] = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, partition_i, (VALUE)ary);
+ rb_objc_block_call(obj, selEach, 0, 0, partition_i, (VALUE)ary);
return rb_assoc_new(ary[0], ary[1]);
}
@@ -648,7 +648,7 @@ enum_group_by(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
hash = rb_hash_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, group_by_i, hash);
+ rb_objc_block_call(obj, selEach, 0, 0, group_by_i, hash);
return hash;
}
@@ -701,7 +701,7 @@ enum_first(VALUE obj, SEL sel, int argc, VALUE *argv)
ary[0] = n;
ary[1] = rb_ary_new2(NUM2LONG(n));
}
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, first_i, (VALUE)ary);
+ rb_objc_block_call(obj, selEach, 0, 0, first_i, (VALUE)ary);
return ary[1];
}
@@ -835,7 +835,7 @@ enum_sort_by(VALUE obj, SEL sel)
else {
ary = rb_ary_new();
}
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, sort_by_i, ary);
+ rb_objc_block_call(obj, selEach, 0, 0, sort_by_i, ary);
if (RARRAY_LEN(ary) > 1) {
qsort_r((VALUE *)RARRAY_PTR(ary), RARRAY_LEN(ary), sizeof(VALUE), NULL,
sort_by_cmp);
@@ -893,7 +893,7 @@ enum_all(VALUE obj, SEL sel)
{
VALUE result = Qtrue;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result);
+ rb_objc_block_call(obj, selEach, 0, 0, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result);
return result;
}
@@ -932,7 +932,7 @@ enum_any(VALUE obj, SEL sel)
{
VALUE result = Qfalse;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result);
+ rb_objc_block_call(obj, selEach, 0, 0, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result);
return result;
}
@@ -976,7 +976,7 @@ enum_one(VALUE obj, SEL sel)
{
VALUE result = Qundef;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result);
+ rb_objc_block_call(obj, selEach, 0, 0, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result);
if (result == Qundef) return Qfalse;
return result;
}
@@ -1013,7 +1013,7 @@ enum_none(VALUE obj, SEL sel)
{
VALUE result = Qtrue;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result);
+ rb_objc_block_call(obj, selEach, 0, 0, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result);
return result;
}
@@ -1081,10 +1081,10 @@ enum_min(VALUE obj, SEL sel)
result[0] = Qundef;
if (rb_block_given_p()) {
result[1] = rb_ary_new3(2, Qnil, Qnil);
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, min_ii, (VALUE)result);
+ rb_objc_block_call(obj, selEach, 0, 0, min_ii, (VALUE)result);
}
else {
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, min_i, (VALUE)result);
+ rb_objc_block_call(obj, selEach, 0, 0, min_i, (VALUE)result);
}
if (result[0] == Qundef) return Qnil;
return result[0];
@@ -1153,10 +1153,10 @@ enum_max(VALUE obj, SEL sel)
result[0] = Qundef;
if (rb_block_given_p()) {
result[1] = rb_ary_new3(2, Qnil, Qnil);
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, max_ii, (VALUE)result);
+ rb_objc_block_call(obj, selEach, 0, 0, max_ii, (VALUE)result);
}
else {
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, max_i, (VALUE)result);
+ rb_objc_block_call(obj, selEach, 0, 0, max_i, (VALUE)result);
}
if (result[0] == Qundef) return Qnil;
return result[0];
@@ -1240,10 +1240,10 @@ enum_minmax(VALUE obj, SEL sel)
result[0] = Qundef;
if (rb_block_given_p()) {
result[2] = ary;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, minmax_ii, (VALUE)result);
+ rb_objc_block_call(obj, selEach, 0, 0, minmax_ii, (VALUE)result);
}
else {
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, minmax_i, (VALUE)result);
+ rb_objc_block_call(obj, selEach, 0, 0, minmax_i, (VALUE)result);
}
if (result[0] != Qundef) {
rb_ary_store(ary, 0, result[0]);
@@ -1291,7 +1291,7 @@ enum_min_by(VALUE obj, SEL sel)
memo[0] = Qundef;
memo[1] = Qnil;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, min_by_i, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, min_by_i, (VALUE)memo);
return memo[1];
}
@@ -1334,7 +1334,7 @@ enum_max_by(VALUE obj, SEL sel)
memo[0] = Qundef;
memo[1] = Qnil;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, max_by_i, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, max_by_i, (VALUE)memo);
return memo[1];
}
@@ -1388,7 +1388,7 @@ enum_minmax_by(VALUE obj, SEL sel)
memo[1] = Qundef;
memo[2] = Qnil;
memo[3] = Qnil;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, minmax_by_i, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, minmax_by_i, (VALUE)memo);
return rb_assoc_new(memo[2], memo[3]);
}
@@ -1422,7 +1422,7 @@ enum_member(VALUE obj, SEL sel, VALUE val)
memo[0] = val;
memo[1] = Qfalse;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, member_i, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, member_i, (VALUE)memo);
return memo[1];
}
@@ -1458,7 +1458,7 @@ enum_each_with_index(VALUE obj, SEL sel, int argc, VALUE *argv)
RETURN_ENUMERATOR(obj, argc, argv);
memo = 0;
- rb_objc_block_call(obj, selEach, cacheEach, argc, argv, each_with_index_i, (VALUE)&memo);
+ rb_objc_block_call(obj, selEach, argc, argv, each_with_index_i, (VALUE)&memo);
return obj;
}
@@ -1522,7 +1522,7 @@ static VALUE
enum_each_entry(VALUE obj, SEL sel, int argc, VALUE *argv)
{
RETURN_ENUMERATOR(obj, argc, argv);
- rb_objc_block_call(obj, selEach, cacheEach, argc, argv, each_val_i, 0);
+ rb_objc_block_call(obj, selEach, argc, argv, each_val_i, 0);
return obj;
}
@@ -1574,7 +1574,7 @@ enum_each_slice(VALUE obj, SEL sel, VALUE n)
args[0] = rb_ary_new2(size);
args[1] = (VALUE)size;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, each_slice_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, each_slice_i, (VALUE)args);
ary = args[0];
if (RARRAY_LEN(ary) > 0) {
@@ -1636,7 +1636,7 @@ enum_each_cons(VALUE obj, SEL sel, VALUE n)
args[0] = rb_ary_new2(size);
args[1] = (VALUE)size;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, each_cons_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, each_cons_i, (VALUE)args);
return Qnil;
}
@@ -1668,8 +1668,7 @@ enum_each_with_object(VALUE obj, SEL sel, VALUE memo)
{
RETURN_ENUMERATOR(obj, 1, &memo);
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0,
- each_with_object_i, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, each_with_object_i, (VALUE)memo);
return memo;
}
@@ -1803,7 +1802,7 @@ enum_zip(VALUE obj, SEL sel, int argc, VALUE *argv)
result = rb_ary_new();
}
memo = rb_node_newnode(NODE_MEMO, result, args, 0);
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, allary ? zip_ary : zip_i, (VALUE)memo);
+ rb_objc_block_call(obj, selEach, 0, 0, allary ? zip_ary : zip_i, (VALUE)memo);
return result;
}
@@ -1844,7 +1843,7 @@ enum_take(VALUE obj, SEL sel, VALUE n)
}
args[0] = rb_ary_new();
args[1] = len;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, take_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, take_i, (VALUE)args);
return args[0];
}
@@ -1878,7 +1877,7 @@ enum_take_while(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
ary = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, take_while_i, (VALUE)&ary);
+ rb_objc_block_call(obj, selEach, 0, 0, take_while_i, (VALUE)&ary);
return ary;
}
@@ -1918,7 +1917,7 @@ enum_drop(VALUE obj, SEL sel, VALUE n)
args[1] = len;
args[0] = rb_ary_new();
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, drop_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, drop_i, (VALUE)args);
return args[0];
}
@@ -1958,7 +1957,7 @@ enum_drop_while(VALUE obj, SEL sel)
RETURN_ENUMERATOR(obj, 0, 0);
args[0] = rb_ary_new();
args[1] = Qfalse;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, drop_while_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, drop_while_i, (VALUE)args);
return args[0];
}
@@ -2012,7 +2011,7 @@ enum_cycle(VALUE obj, SEL sel, int argc, VALUE *argv)
#if !WITH_OBJC
RBASIC(ary)->klass = 0;
#endif
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, cycle_i, ary);
+ rb_objc_block_call(obj, selEach, 0, 0, cycle_i, ary);
len = RARRAY_LEN(ary);
if (len == 0) return Qnil;
while (n < 0 || 0 < --n) {
6 enumerator.c
View
@@ -141,7 +141,7 @@ enum_each_slice(VALUE obj, SEL sel, VALUE n)
args[0] = rb_ary_new2(size);
args[1] = (VALUE)size;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, each_slice_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, each_slice_i, (VALUE)args);
ary = args[0];
if (RARRAY_LEN(ary) > 0) rb_yield(ary);
@@ -198,7 +198,7 @@ enum_each_cons(VALUE obj, SEL sel, VALUE n)
args[0] = rb_ary_new2(size);
args[1] = (VALUE)size;
- rb_objc_block_call(obj, selEach, cacheEach, 0, 0, each_cons_i, (VALUE)args);
+ rb_objc_block_call(obj, selEach, 0, 0, each_cons_i, (VALUE)args);
return Qnil;
}
@@ -312,7 +312,7 @@ enumerator_block_call(VALUE obj, VALUE (*func)(ANYARGS), VALUE arg)
argc = RARRAY_LEN(e->args);
argv = RARRAY_PTR(e->args);
}
- return rb_objc_block_call(e->obj, e->sel, NULL, argc, (VALUE *)argv,
+ return rb_objc_block_call(e->obj, e->sel, argc, (VALUE *)argv,
func, arg);
}
29 error.c
View
@@ -595,8 +595,7 @@ exc_equal(VALUE exc, SEL sel, VALUE obj)
* Create a new +SystemExit+ exception with the given status.
*/
-/* XXX not a static/local symbol because of the super call that calls dladdr */
-VALUE
+static VALUE
exit_initialize(VALUE exc, SEL sel, int argc, VALUE *argv)
{
VALUE status = INT2FIX(EXIT_SUCCESS);
@@ -604,11 +603,10 @@ exit_initialize(VALUE exc, SEL sel, int argc, VALUE *argv)
status = *argv++;
--argc;
}
- //rb_call_super(argc, argv);
if (sel == 0) {
sel = argc == 0 ? selInitialize : selInitialize2;
}
- rb_vm_call(exc, sel, argc, argv, true);
+ rb_vm_call_super(exc, sel, argc, argv);
rb_iv_set(exc, "status", status);
return exc;
}
@@ -670,18 +668,16 @@ rb_name_error(ID id, const char *fmt, ...)
* method.
*/
-/* XXX not a static/local symbol because of the super call that calls dladdr */
-VALUE
+static VALUE
name_err_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
{
VALUE name;
name = (argc > 1) ? argv[--argc] : Qnil;
- //rb_call_super(argc, argv);
if (sel == 0) {
sel = argc == 0 ? selInitialize : selInitialize2;
}
- rb_vm_call(self, sel, argc, argv, true);
+ rb_vm_call_super(self, sel, argc, argv);
rb_iv_set(self, "name", name);
return self;
}
@@ -733,8 +729,7 @@ name_err_to_s(VALUE exc, SEL sel)
* arguments using the <code>#args</code> method.
*/
-/* XXX not a static/local symbol because of the super call that calls dladdr */
-VALUE
+static VALUE
nometh_err_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
{
VALUE args = (argc > 2) ? argv[--argc] : Qnil;
@@ -742,7 +737,7 @@ nometh_err_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
if (sel == 0) {
sel = argc == 0 ? selInitialize : selInitialize2;
}
- rb_vm_call(self, sel, argc, argv, true);
+ rb_vm_call_super(self, sel, argc, argv);
rb_iv_set(self, "args", args);
return self;
}
@@ -933,8 +928,7 @@ get_syserr(int n)
* method.
*/
-/* XXX not a static/local symbol because of the super call that calls dladdr */
-VALUE
+static VALUE
syserr_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
{
#if !defined(_WIN32) && !defined(__VMS)
@@ -973,8 +967,7 @@ syserr_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
else {
mesg = rb_str_new2(err);
}
- //rb_call_super(1, &mesg);
- rb_vm_call(self, selInitialize2, 1, &mesg, true);
+ rb_vm_call_super(self, selInitialize2, 1, &mesg);
rb_iv_set(self, "errno", error);
return self;
}
@@ -1224,10 +1217,8 @@ rb_check_frozen(VALUE obj)
VALUE
rb_format_exception_message(VALUE exc)
{
- VALUE message = rb_vm_call(exc, sel_registerName("message"), 0, NULL,
- false);
- VALUE bt = rb_vm_call(exc, sel_registerName("backtrace"), 0, NULL,
- false);
+ VALUE message = rb_vm_call(exc, sel_registerName("message"), 0, NULL);
+ VALUE bt = rb_vm_call(exc, sel_registerName("backtrace"), 0, NULL);
CFMutableStringRef result = CFStringCreateMutable(NULL, 0);
2  exported_symbols_list
View
@@ -8,7 +8,7 @@ _st_*
# used by the kernel:
_rary_reserve
-_rhash_call_default
+_rhash_aref
_rhash_aset
_rstr_concat
_selPLUS
20 ext/libyaml/rubyext.c
View
@@ -63,10 +63,6 @@ static SEL sel_yaml_new;
static VALUE rb_oDefaultResolver;
-static struct mcache *to_yaml_cache = NULL;
-static struct mcache *call_cache = NULL;
-static struct mcache *yaml_new_cache = NULL;
-
static const int DEFAULT_STACK_SIZE = 8;
static VALUE
@@ -278,12 +274,10 @@ interpret_value(rb_yaml_parser_t *parser, VALUE result, VALUE handler)
return result;
}
if (rb_vm_respond_to(handler, sel_call, 0)) {
- return rb_vm_call_with_cache(call_cache, handler, sel_call, 1,
- &result);
+ return rb_vm_call(handler, sel_call, 1, &result);
}
else if (rb_vm_respond_to(handler, sel_yaml_new, 0)) {
- return rb_vm_call_with_cache(yaml_new_cache, handler, sel_yaml_new,
- 1, &result);
+ return rb_vm_call(handler, sel_yaml_new, 1, &result);
}
return result;
}
@@ -957,9 +951,9 @@ rb_yaml_emitter_add(VALUE self, SEL sel, int argc, VALUE *argv)
{
VALUE first = Qnil, second = Qnil;
rb_scan_args(argc, argv, "11", &first, &second);
- rb_vm_call_with_cache(to_yaml_cache, first, sel_to_yaml, 1, &self);
+ rb_vm_call(first, sel_to_yaml, 1, &self);
if (argc == 2) {
- rb_vm_call_with_cache(to_yaml_cache, second, sel_to_yaml, 1, &self);
+ rb_vm_call(second, sel_to_yaml, 1, &self);
}
return self;
}
@@ -1019,10 +1013,6 @@ Init_libyaml()
sel_call = sel_registerName("call:");
sel_yaml_new = sel_registerName("yaml_new:");
- to_yaml_cache = rb_vm_get_call_cache(sel_to_yaml);
- call_cache = rb_vm_get_call_cache(sel_call);
- yaml_new_cache = rb_vm_get_call_cache(sel_yaml_new);
-
rb_mYAML = rb_define_module("YAML");
rb_mLibYAML = rb_define_module_under(rb_mYAML, "LibYAML");
@@ -1057,7 +1047,7 @@ Init_libyaml()
//rb_objc_define_method(rb_cResolver, "add_ruby_type", rb_yaml_resolver_add_ruby_type, 1);
//rb_objc_define_method(rb_cResolver, "add_builtin_type", rb_yaml_resolver_add_builtin_type, 1);
//rb_objc_define_method(rb_cResolver, "add_private_type", rb_yaml_resolver_add_private_type, 1);
- rb_oDefaultResolver = rb_vm_call(rb_cResolver, sel_registerName("new"), 0, NULL, false);
+ rb_oDefaultResolver = rb_vm_call(rb_cResolver, sel_registerName("new"), 0, NULL);
rb_define_const(rb_mLibYAML, "DEFAULT_RESOLVER", rb_oDefaultResolver);
rb_cEmitter = rb_define_class_under(rb_mLibYAML, "Emitter", rb_cObject);
3  ext/openssl/ossl_ssl.c
View
@@ -964,8 +964,7 @@ ossl_ssl_initialize(VALUE self, SEL sel, int argc, VALUE *argv)
ossl_ssl_set_sync_close(self, Qfalse);
ossl_sslctx_setup(ctx);
- //rb_call_super(0, 0);
- rb_vm_call(self, sel, 0, NULL, true);
+ rb_vm_call_super(self, sel, 0, NULL);
return self;
}
2  file.c
View
@@ -106,7 +106,7 @@ rb_get_path_check(VALUE obj, int check)
}
if (rb_vm_respond_to(obj, selToPath, true)) {
- tmp = rb_vm_call(obj, selToPath, 0, NULL, false);
+ tmp = rb_vm_call(obj, selToPath, 0, NULL);
}
else {
tmp = rb_check_string_type(obj);
12 hash.c
View
@@ -32,8 +32,6 @@ VALUE rb_cRubyHash;
static ID id_yield;
-static void *defaultCache = NULL;
-static void *hashCache = NULL;
static SEL selFlattenBang = 0;
static SEL selDefault = 0;
static SEL selHash = 0;
@@ -41,7 +39,7 @@ static SEL selHash = 0;
VALUE
rb_hash(VALUE obj)
{
- VALUE v = rb_vm_call_with_cache(hashCache, obj, selHash, 0, NULL);
+ VALUE v = rb_vm_call(obj, selHash, 0, NULL);
retry:
switch (TYPE(v)) {
case T_FIXNUM:
@@ -428,10 +426,10 @@ rhash_rehash(VALUE hash, SEL sel)
*
*/
-VALUE
+static inline VALUE
rhash_call_default(VALUE hash, VALUE key)
{
- return rb_vm_call_with_cache(defaultCache, hash, selDefault, 1, &key);
+ return rb_vm_call(hash, selDefault, 1, &key);
}
VALUE
@@ -1617,7 +1615,7 @@ rhash_flatten(VALUE hash, SEL sel, int argc, VALUE *argv)
tmp = INT2FIX(1);
argv = &tmp;
}
- rb_vm_call(ary, selFlattenBang, argc, argv, false);
+ rb_vm_call(ary, selFlattenBang, argc, argv);
return ary;
}
@@ -1773,8 +1771,6 @@ Init_Hash(void)
selFlattenBang = sel_registerName("flatten!:");
selDefault = sel_registerName("default:");
selHash = sel_registerName("hash");
- defaultCache = rb_vm_get_call_cache(selDefault);
- hashCache = rb_vm_get_call_cache(selHash);
id_yield = rb_intern("yield");
1  hash.h
View
@@ -101,7 +101,6 @@ VALUE rhash_aref(VALUE hash, SEL sel, VALUE key);
VALUE rhash_aset(VALUE hash, SEL sel, VALUE key, VALUE val);
VALUE rhash_keys(VALUE hash, SEL sel);
VALUE rhash_has_key(VALUE hash, SEL sel, VALUE key);
-VALUE rhash_call_default(VALUE hash, VALUE key);
VALUE rhash_set_default(VALUE hash, SEL sel, VALUE ifnone);
#if defined(__cplusplus)
2  id.c
View
@@ -106,8 +106,6 @@ Init_id(void)
selLambda = sel_registerName("lambda");
selObjectForKey = sel_registerName("objectForKey:");
selSetObjectForKey = sel_registerName("setObject:forKey:");
-
- cacheEach = rb_vm_get_call_cache(selEach);
#endif
idAREF = rb_intern("[]");
1  id.h
View
@@ -119,6 +119,5 @@ extern SEL selSetObjectForKey;
extern ID idIncludedModules;
extern ID idIncludedInClasses;
extern ID idAncestors;
-extern void *cacheEach;
#endif
#endif /* RUBY_ID_H */
6 include/ruby/ruby.h
View
@@ -802,8 +802,8 @@ VALUE rb_funcall(VALUE, ID, int, ...);
VALUE rb_funcall2(VALUE, ID, int, const VALUE*);
VALUE rb_funcall3(VALUE, ID, int, const VALUE*);
int rb_scan_args(int, const VALUE*, const char*, ...);
-VALUE rb_call_super(int, const VALUE*);
-VALUE rb_vm_call(VALUE self, SEL sel, int argc, const VALUE *args, bool super);
+VALUE rb_vm_call(VALUE self, SEL sel, int argc, const VALUE *args);
+VALUE rb_vm_call_super(VALUE self, SEL sel, int argc, const VALUE *args);
VALUE rb_gv_set(const char*, VALUE);
VALUE rb_gv_get(const char*);
@@ -868,7 +868,7 @@ int rb_block_given_p(void);
void rb_need_block(void);
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE);
VALUE rb_block_call(VALUE,ID,int,VALUE*,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_objc_block_call(VALUE obj, SEL sel, void *cache, int argc,
+VALUE rb_objc_block_call(VALUE obj, SEL sel, int argc,
VALUE *argv, VALUE (*bl_proc) (ANYARGS), VALUE data2);
VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...);
2  io.c
View
@@ -415,7 +415,7 @@ io_write(VALUE io, SEL sel, VALUE data)
VALUE tmp = rb_io_check_io(io);
if (NIL_P(tmp)) {
// receiver is not IO, dispatch the write method on it
- return rb_vm_call(io, selWrite, 1, &data, false);
+ return rb_vm_call(io, selWrite, 1, &data);
}
io = tmp;
75 kernel.c
View
@@ -166,8 +166,8 @@ vm_set_const(VALUE outer, ID id, VALUE obj, unsigned char dynamic_class)
rb_const_set(outer, id, obj);
}
-VALUE rb_vm_dispatch(void *cache, VALUE top, VALUE self, void *sel,
- void *block, unsigned char opt, int argc, ...);
+VALUE rb_vm_dispatch(VALUE top, VALUE self, void *sel, void *block,
+ unsigned char opt, int argc, ...);
// Only numeric immediates have their lsb at 1.
#define NUMERIC_IMM_P(x) ((x & 0x1) == 0x1)
@@ -175,7 +175,7 @@ VALUE rb_vm_dispatch(void *cache, VALUE top, VALUE self, void *sel,
#define IMM2DBL(x) (FIXFLOAT_P(x) ? FIXFLOAT2DBL(x) : FIX2LONG(x))
inline VALUE
-vm_fast_plus(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_plus(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -189,11 +189,11 @@ vm_fast_plus(void *cache, VALUE left, VALUE right, unsigned char overriden)
return DBL2FIXFLOAT(res);
}
}
- return rb_vm_dispatch(cache, 0, left, selPLUS, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selPLUS, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_minus(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_minus(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -207,11 +207,11 @@ vm_fast_minus(void *cache, VALUE left, VALUE right, unsigned char overriden)
return DBL2FIXFLOAT(res);
}
}
- return rb_vm_dispatch(cache, 0, left, selMINUS, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selMINUS, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_mult(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_mult(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -225,11 +225,11 @@ vm_fast_mult(void *cache, VALUE left, VALUE right, unsigned char overriden)
return DBL2FIXFLOAT(res);
}
}
- return rb_vm_dispatch(cache, 0, left, selMULT, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selMULT, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_div(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_div(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -251,11 +251,11 @@ vm_fast_div(void *cache, VALUE left, VALUE right, unsigned char overriden)
return DBL2FIXFLOAT(res);
}
}
- return rb_vm_dispatch(cache, 0, left, selDIV, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selDIV, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_lt(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_lt(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -265,11 +265,11 @@ vm_fast_lt(void *cache, VALUE left, VALUE right, unsigned char overriden)
return IMM2DBL(left) < IMM2DBL(right) ? Qtrue : Qfalse;
}
}
- return rb_vm_dispatch(cache, 0, left, selLT, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selLT, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_le(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_le(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -279,11 +279,11 @@ vm_fast_le(void *cache, VALUE left, VALUE right, unsigned char overriden)
return IMM2DBL(left) <= IMM2DBL(right) ? Qtrue : Qfalse;
}
}
- return rb_vm_dispatch(cache, 0, left, selLE, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selLE, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_gt(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_gt(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -293,11 +293,11 @@ vm_fast_gt(void *cache, VALUE left, VALUE right, unsigned char overriden)
return IMM2DBL(left) > IMM2DBL(right) ? Qtrue : Qfalse;
}
}
- return rb_vm_dispatch(cache, 0, left, selGT, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selGT, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_ge(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_ge(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
if (FIXNUM_P(left) && FIXNUM_P(right)) {
@@ -307,11 +307,11 @@ vm_fast_ge(void *cache, VALUE left, VALUE right, unsigned char overriden)
return IMM2DBL(left) >= IMM2DBL(right) ? Qtrue : Qfalse;
}
}
- return rb_vm_dispatch(cache, 0, left, selGE, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selGE, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_eq(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_eq(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0) {
if (NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
@@ -327,11 +327,11 @@ vm_fast_eq(void *cache, VALUE left, VALUE right, unsigned char overriden)
}
// TODO: opt for non-immediate types
}
- return rb_vm_dispatch(cache, 0, left, selEq, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selEq, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_eqq(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_eqq(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0) {
if (NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
@@ -347,11 +347,11 @@ vm_fast_eqq(void *cache, VALUE left, VALUE right, unsigned char overriden)
}
// TODO: opt for non-immediate types
}
- return rb_vm_dispatch(cache, 0, left, selEqq, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selEqq, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_neq(void *cache, VALUE left, VALUE right, unsigned char overriden)
+vm_fast_neq(VALUE left, VALUE right, unsigned char overriden)
{
if (overriden == 0) {
if (NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
@@ -367,11 +367,11 @@ vm_fast_neq(void *cache, VALUE left, VALUE right, unsigned char overriden)
}
// TODO: opt for non-immediate types
}
- return rb_vm_dispatch(cache, 0, left, selNeq, NULL, 0, 1, right);
+ return rb_vm_dispatch(0, left, selNeq, NULL, 0, 1, right);
}
inline VALUE
-vm_fast_aref(VALUE obj, VALUE other, void *cache, unsigned char overriden)
+vm_fast_aref(VALUE obj, VALUE other, unsigned char overriden)
{
if (overriden == 0 && !SPECIAL_CONST_P(obj)) {
VALUE klass = *(VALUE *)obj;
@@ -381,22 +381,14 @@ vm_fast_aref(VALUE obj, VALUE other, void *cache, unsigned char overriden)
}
}
else if (klass == rb_cRubyHash) {
- VALUE val = rhash_lookup(obj, other);
- if (val == Qundef) {
- if (RHASH(obj)->ifnone == Qnil) {
- return Qnil;
- }
- return rhash_call_default(obj, other);
- }
- return val;
+ return rhash_aref(obj, 0, other);
}
}
- return rb_vm_dispatch(cache, 0, obj, selAREF, NULL, 0, 1, other);
+ return rb_vm_dispatch(0, obj, selAREF, NULL, 0, 1, other);
}
inline VALUE
-vm_fast_aset(VALUE obj, VALUE other1, VALUE other2, void *cache,
- unsigned char overriden)
+vm_fast_aset(VALUE obj, VALUE other1, VALUE other2, unsigned char overriden)
{
if (overriden == 0 && !SPECIAL_CONST_P(obj)) {
VALUE klass = *(VALUE *)obj;
@@ -410,11 +402,11 @@ vm_fast_aset(VALUE obj, VALUE other1, VALUE other2, void *cache,
return rhash_aset(obj, 0, other1, other2);
}
}
- return rb_vm_dispatch(cache, 0, obj, selASET, NULL, 0, 2, other1, other2);
+ return rb_vm_dispatch(0, obj, selASET, NULL, 0, 2, other1, other2);
}
inline VALUE
-vm_fast_shift(VALUE obj, VALUE other, void *cache, unsigned char overriden)
+vm_fast_shift(VALUE obj, VALUE other, unsigned char overriden)
{
if (overriden == 0 && !SPECIAL_CONST_P(obj)) {
VALUE klass = *(VALUE *)obj;
@@ -427,12 +419,11 @@ vm_fast_shift(VALUE obj, VALUE other, void *cache, unsigned char overriden)
return rstr_concat(obj, 0, other);
}
}
- return rb_vm_dispatch(cache, 0, obj, selLTLT, NULL, 0, 1, other);
+ return rb_vm_dispatch(0, obj, selLTLT, NULL, 0, 1, other);
}
inline VALUE
-vm_when_splat(void *cache, unsigned char overriden,
- VALUE comparedTo, VALUE splat)