[macruby-changes] [1641] MacRuby/branches/experimental/compiler.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Fri May 29 18:06:36 PDT 2009
Revision: 1641
http://trac.macosforge.org/projects/ruby/changeset/1641
Author: lsansonetti at apple.com
Date: 2009-05-29 18:06:35 -0700 (Fri, 29 May 2009)
Log Message:
-----------
disable the recursive dispatch optimization in case there is an arity mismatch (optional arguments)
Modified Paths:
--------------
MacRuby/branches/experimental/compiler.cpp
Modified: MacRuby/branches/experimental/compiler.cpp
===================================================================
--- MacRuby/branches/experimental/compiler.cpp 2009-05-30 00:44:41 UTC (rev 1640)
+++ MacRuby/branches/experimental/compiler.cpp 2009-05-30 01:06:35 UTC (rev 1641)
@@ -3021,25 +3021,27 @@
if (!block_given && !super_call && !splat_args
&& positive_arity && mid == current_mid && recv == NULL) {
- // TODO check if both functions have the same arity
- // (paranoid?)
-
Function *f = bb->getParent();
- std::vector<Value *> params;
+ const unsigned long argc =
+ args == NULL ? 0 : args->nd_alen;
- Function::arg_iterator arg = f->arg_begin();
+ if (f->arg_size() - 2 == argc) {
+ std::vector<Value *> params;
- params.push_back(arg++); // self
- params.push_back(arg++); // sel
+ Function::arg_iterator arg = f->arg_begin();
- for (NODE *n = args; n != NULL; n = n->nd_next) {
- params.push_back(compile_node(n->nd_head));
+ params.push_back(arg++); // self
+ params.push_back(arg++); // sel
+
+ for (NODE *n = args; n != NULL; n = n->nd_next) {
+ params.push_back(compile_node(n->nd_head));
+ }
+
+ CallInst *inst = CallInst::Create(f, params.begin(),
+ params.end(), "", bb);
+ inst->setTailCall(true);
+ return cast<Value>(inst);
}
-
- CallInst *inst = CallInst::Create(f, params.begin(),
- params.end(), "", bb);
- inst->setTailCall(true);
- return cast<Value>(inst);
}
// Let's set the block state as NULL temporarily, when we
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090529/1d882ad8/attachment.html>
More information about the macruby-changes
mailing list