[macruby-changes] [1368] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Sat Apr 4 22:22:03 PDT 2009


Revision: 1368
          http://trac.macosforge.org/projects/ruby/changeset/1368
Author:   lsansonetti at apple.com
Date:     2009-04-04 22:22:02 -0700 (Sat, 04 Apr 2009)
Log Message:
-----------
ported to rb_objc_block_call() + misc cleanup

Modified Paths:
--------------
    MacRuby/branches/experimental/TODO
    MacRuby/branches/experimental/array.c
    MacRuby/branches/experimental/enum.c
    MacRuby/branches/experimental/enumerator.c
    MacRuby/branches/experimental/id.c
    MacRuby/branches/experimental/id.h
    MacRuby/branches/experimental/lib/irb/init.rb
    MacRuby/branches/experimental/process.c
    MacRuby/branches/experimental/range.c
    MacRuby/branches/experimental/roxor.cpp
    MacRuby/branches/experimental/set.c

Modified: MacRuby/branches/experimental/TODO
===================================================================
--- MacRuby/branches/experimental/TODO	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/TODO	2009-04-05 05:22:02 UTC (rev 1368)
@@ -52,7 +52,7 @@
       rb_objc_define_method(*(VALUE *)klass, "alloc", ..., 0)
 
 [/] port all rb_funcall() calls to rb_vm_call()
-[ ] port all rb_block_call() calls to rb_objc_block_call()
+[X] port all rb_block_call() calls to rb_objc_block_call()
 [X] remove the YARV code from the project
 [ ] refactor the VM sources
 [ ] clean objc.m

Modified: MacRuby/branches/experimental/array.c
===================================================================
--- MacRuby/branches/experimental/array.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/array.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -1989,11 +1989,10 @@
     VALUE args[2];
 
     args[0] = result; args[1] = (VALUE)n;
-    rb_block_call(obj, rb_intern("each"), 0, 0, take_i, (VALUE)args);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, take_i, (VALUE)args);
     return result;
 }
 
-
 /*
  *  call-seq:
  *     array.zip(arg, ...)                   -> an_array

Modified: MacRuby/branches/experimental/enum.c
===================================================================
--- MacRuby/branches/experimental/enum.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/enum.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -13,6 +13,7 @@
 #include "ruby/node.h"
 #include "ruby/util.h"
 #include "roxor.h"
+#include "id.h"
 
 VALUE rb_mEnumerable;
 static ID id_each, id_eqq, id_cmp, id_next, id_size;
@@ -80,7 +81,7 @@
     arg[0] = pat;
     arg[1] = ary;
 
-    rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? grep_iter_i : grep_i, (VALUE)arg);
 
     return ary;
 }
@@ -163,7 +164,7 @@
     }
 
     memo[0] = 0;
-    rb_block_call(obj, id_each, 0, 0, func, (VALUE)&memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, func, (VALUE)&memo);
     return INT2NUM(memo[0]);
 }
 
@@ -202,7 +203,7 @@
 
     rb_scan_args(argc, argv, "01", &if_none);
     RETURN_ENUMERATOR(obj, argc, argv);
-    rb_block_call(obj, id_each, 0, 0, find_i, (VALUE)&memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, find_i, (VALUE)&memo);
     if (memo != Qundef) {
 	return memo;
     }
@@ -276,7 +277,7 @@
 
     memo[0] = Qnil;
     memo[1] = 0;
-    rb_block_call(obj, id_each, 0, 0, func, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, func, (VALUE)memo);
     return memo[0];
 }
 
@@ -312,7 +313,7 @@
     RETURN_ENUMERATOR(obj, 0, 0);
 
     ary = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, find_all_i, ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, find_all_i, ary);
 
     return ary;
 }
@@ -347,7 +348,7 @@
     RETURN_ENUMERATOR(obj, 0, 0);
 
     ary = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, reject_i, ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, reject_i, ary);
 
     return ary;
 }
@@ -389,7 +390,7 @@
     RETURN_ENUMERATOR(obj, 0, 0);
 
     ary = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, collect_i, ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, collect_i, ary);
 
     return ary;
 }
@@ -409,7 +410,7 @@
 {
     VALUE ary = rb_ary_new();
 
-    rb_block_call(obj, id_each, argc, argv, collect_all, ary);
+    rb_objc_block_call(obj, selEach, cacheEach, argc, argv, collect_all, ary);
 
     return ary;
 }
@@ -517,7 +518,7 @@
 	iter = inject_op_i;
 	break;
     }
-    rb_block_call(obj, id_each, 0, 0, iter, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, iter, (VALUE)memo);
     if (memo[0] == Qundef) {
 	return Qnil;
     }
@@ -559,7 +560,7 @@
 
     ary[0] = rb_ary_new();
     ary[1] = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, partition_i, (VALUE)ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, partition_i, (VALUE)ary);
 
     return rb_assoc_new(ary[0], ary[1]);
 }
@@ -604,7 +605,7 @@
     RETURN_ENUMERATOR(obj, 0, 0);
 
     hash = rb_hash_new();
-    rb_block_call(obj, id_each, 0, 0, group_by_i, hash);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, group_by_i, hash);
 
     return hash;
 }
@@ -655,7 +656,7 @@
 	ary[0] = n;
 	ary[1] = rb_ary_new2(NUM2LONG(n));
     }
-    rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, first_i, (VALUE)ary);
 
     return ary[1];
 }
@@ -801,7 +802,7 @@
     else {
 	ary = rb_ary_new();
     }
-    rb_block_call(obj, id_each, 0, 0, sort_by_i, ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, sort_by_i, ary);
     if (RARRAY_LEN(ary) > 1) {
 	CFArraySortValues((CFMutableArrayRef)ary, 
 	    CFRangeMake(0, RARRAY_LEN(ary)),
@@ -860,7 +861,7 @@
 {
     VALUE result = Qtrue;
 
-    rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result);
     return result;
 }
 
@@ -899,7 +900,7 @@
 {
     VALUE result = Qfalse;
 
-    rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result);
     return result;
 }
 
@@ -943,7 +944,7 @@
 {
     VALUE result = Qundef;
 
-    rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result);
     if (result == Qundef) return Qfalse;
     return result;
 }
@@ -980,7 +981,7 @@
 {
     VALUE result = Qtrue;
 
-    rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result);
     return result;
 }
 
@@ -1048,10 +1049,10 @@
     result[0] = Qundef;
     if (rb_block_given_p()) {
 	result[1] = rb_ary_new3(2, Qnil, Qnil);
-	rb_block_call(obj, id_each, 0, 0, min_ii, (VALUE)result);
+	rb_objc_block_call(obj, selEach, cacheEach, 0, 0, min_ii, (VALUE)result);
     }
     else {
-	rb_block_call(obj, id_each, 0, 0, min_i, (VALUE)result);
+	rb_objc_block_call(obj, selEach, cacheEach, 0, 0, min_i, (VALUE)result);
     }
     if (result[0] == Qundef) return Qnil;
     return result[0];
@@ -1120,10 +1121,10 @@
     result[0] = Qundef;
     if (rb_block_given_p()) {
 	result[1] = rb_ary_new3(2, Qnil, Qnil);
-	rb_block_call(obj, id_each, 0, 0, max_ii, (VALUE)result);
+	rb_objc_block_call(obj, selEach, cacheEach, 0, 0, max_ii, (VALUE)result);
     }
     else {
-	rb_block_call(obj, id_each, 0, 0, max_i, (VALUE)result);
+	rb_objc_block_call(obj, selEach, cacheEach, 0, 0, max_i, (VALUE)result);
     }
     if (result[0] == Qundef) return Qnil;
     return result[0];
@@ -1207,10 +1208,10 @@
     result[0] = Qundef;
     if (rb_block_given_p()) {
 	result[2] = ary;
-	rb_block_call(obj, id_each, 0, 0, minmax_ii, (VALUE)result);
+	rb_objc_block_call(obj, selEach, cacheEach, 0, 0, minmax_ii, (VALUE)result);
     }
     else {
-	rb_block_call(obj, id_each, 0, 0, minmax_i, (VALUE)result);
+	rb_objc_block_call(obj, selEach, cacheEach, 0, 0, minmax_i, (VALUE)result);
     }
     if (result[0] != Qundef) {
 	rb_ary_store(ary, 0, result[0]);
@@ -1258,7 +1259,7 @@
 
     memo[0] = Qundef;
     memo[1] = Qnil;
-    rb_block_call(obj, id_each, 0, 0, min_by_i, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, min_by_i, (VALUE)memo);
     return memo[1];
 }
 
@@ -1301,7 +1302,7 @@
 
     memo[0] = Qundef;
     memo[1] = Qnil;
-    rb_block_call(obj, id_each, 0, 0, max_by_i, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, max_by_i, (VALUE)memo);
     return memo[1];
 }
 
@@ -1355,7 +1356,7 @@
     memo[1] = Qundef;
     memo[2] = Qnil;
     memo[3] = Qnil;
-    rb_block_call(obj, id_each, 0, 0, minmax_by_i, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, minmax_by_i, (VALUE)memo);
     return rb_assoc_new(memo[2], memo[3]);
 }
 
@@ -1389,7 +1390,7 @@
 
     memo[0] = val;
     memo[1] = Qfalse;
-    rb_block_call(obj, id_each, 0, 0, member_i, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, member_i, (VALUE)memo);
     return memo[1];
 }
 
@@ -1425,7 +1426,7 @@
     RETURN_ENUMERATOR(obj, argc, argv);
 
     memo = 0;
-    rb_block_call(obj, id_each, argc, argv, each_with_index_i, (VALUE)&memo);
+    rb_objc_block_call(obj, selEach, cacheEach, argc, argv, each_with_index_i, (VALUE)&memo);
     return obj;
 }
 
@@ -1581,7 +1582,7 @@
 	result = rb_ary_new();
     }
     memo = rb_node_newnode(NODE_MEMO, result, rb_ary_new4(argc, argv), 0);
-    rb_block_call(obj, id_each, 0, 0, allary ? zip_ary : zip_i, (VALUE)memo);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, allary ? zip_ary : zip_i, (VALUE)memo);
 
     return result;
 }
@@ -1617,7 +1618,7 @@
 
     args[1] = len;
     args[0] = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)args);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, take_i, (VALUE)args);
     return args[0];
 }
 
@@ -1649,7 +1650,7 @@
 
     RETURN_ENUMERATOR(obj, 0, 0);
     ary = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, take_while_i, (VALUE)&ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, take_while_i, (VALUE)&ary);
     return ary;
 }
 
@@ -1689,7 +1690,7 @@
 
     args[1] = len;
     args[0] = rb_ary_new();
-    rb_block_call(obj, id_each, 0, 0, drop_i, (VALUE)args);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, drop_i, (VALUE)args);
     return args[0];
 }
 
@@ -1729,7 +1730,7 @@
     RETURN_ENUMERATOR(obj, 0, 0);
     args[0] = rb_ary_new();
     args[1] = Qfalse;
-    rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)args);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, drop_while_i, (VALUE)args);
     return args[0];
 }
 
@@ -1783,7 +1784,7 @@
 #if !WITH_OBJC
     RBASIC(ary)->klass = 0;
 #endif
-    rb_block_call(obj, id_each, 0, 0, cycle_i, ary);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, cycle_i, ary);
     len = RARRAY_LEN(ary);
     if (len == 0) return Qnil;
     while (n < 0 || 0 < --n) {

Modified: MacRuby/branches/experimental/enumerator.c
===================================================================
--- MacRuby/branches/experimental/enumerator.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/enumerator.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -13,6 +13,7 @@
 ************************************************/
 
 #include "ruby/ruby.h"
+#include "id.h"
 
 /*
  * Document-class: Enumerable::Enumerator
@@ -130,7 +131,7 @@
     args[0] = rb_ary_new2(size);
     args[1] = (VALUE)size;
 
-    rb_block_call(obj, SYM2ID(sym_each), 0, 0, each_slice_i, (VALUE)args);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, each_slice_i, (VALUE)args);
 
     ary = args[0];
     if (RARRAY_LEN(ary) > 0) rb_yield(ary);
@@ -187,7 +188,7 @@
     args[0] = rb_ary_new2(size);
     args[1] = (VALUE)size;
 
-    rb_block_call(obj, SYM2ID(sym_each), 0, 0, each_cons_i, (VALUE)args);
+    rb_objc_block_call(obj, selEach, cacheEach, 0, 0, each_cons_i, (VALUE)args);
 
     return Qnil;
 }

Modified: MacRuby/branches/experimental/id.c
===================================================================
--- MacRuby/branches/experimental/id.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/id.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -10,6 +10,8 @@
 **********************************************************************/
 
 #include "ruby/ruby.h"
+#include "ruby/node.h"
+#include "roxor.h"
 
 #define extern
 #include "id.h"
@@ -84,6 +86,8 @@
     selBackquote = sel_registerName("`:");
     selMethodAdded = sel_registerName("method_added:");
     selSingletonMethodAdded = sel_registerName("singleton_method_added:");
+
+    cacheEach = rb_vm_get_call_cache(selEach);
 #endif
 
     idAREF = rb_intern("[]");

Modified: MacRuby/branches/experimental/id.h
===================================================================
--- MacRuby/branches/experimental/id.h	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/id.h	2009-04-05 05:22:02 UTC (rev 1368)
@@ -98,5 +98,6 @@
 extern ID idIncludedModules;
 extern ID idIncludedInClasses;
 extern ID idAncestors;
+extern void *cacheEach;
 #endif
 #endif /* RUBY_ID_H */

Modified: MacRuby/branches/experimental/lib/irb/init.rb
===================================================================
--- MacRuby/branches/experimental/lib/irb/init.rb	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/lib/irb/init.rb	2009-04-05 05:22:02 UTC (rev 1368)
@@ -240,7 +240,8 @@
     yield proc{|rc| home+"/irb#{rc.sub(/\A_?/, '.')}"}
     yield proc{|rc| home+"/_irb#{rc}"}
     yield proc{|rc| home+"/$irb#{rc}"}
-    yield proc{|rc| "/etc/irb#{rc}"}
+    # MR-hack: let's ignore /etc/irbrc because it brings up RubyGems
+    #yield proc{|rc| "/etc/irb#{rc}"}
   end
 
   # loading modules

Modified: MacRuby/branches/experimental/process.c
===================================================================
--- MacRuby/branches/experimental/process.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/process.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -15,6 +15,7 @@
 #include "ruby/signal.h"
 #include "ruby/io.h"
 #include "ruby/util.h"
+#include "id.h"
 
 #include <stdio.h>
 #include <errno.h>
@@ -1818,7 +1819,7 @@
         VALUE env = rb_const_get(rb_cObject, rb_intern("ENV"));
         if (RTEST(env)) {
             VALUE ary = hide_obj(rb_ary_new());
-            rb_block_call(env, rb_intern("each"), 0, 0, save_env_i,
+            rb_objc_block_call(env, selEach, cacheEach, 0, 0, save_env_i,
                           (VALUE)ary);
             rb_ary_store(save, EXEC_OPTION_ENV, ary);
         }

Modified: MacRuby/branches/experimental/range.c
===================================================================
--- MacRuby/branches/experimental/range.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/range.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -13,9 +13,12 @@
 #include "ruby/encoding.h"
 #include "ruby/node.h"
 #include "roxor.h"
+#include "id.h"
 
 VALUE rb_cRange;
 static ID id_cmp, id_succ, id_beg, id_end, id_excl;
+static SEL selUpto = 0;
+static void *cacheUpto = NULL;
 
 #define RANGE_BEG(r) (RSTRUCT(r)->as.ary[0])
 #define RANGE_END(r) (RSTRUCT(r)->as.ary[1])
@@ -356,7 +359,7 @@
 	    args[1] = EXCL(range) ? Qtrue : Qfalse;
 	    iter[0] = INT2FIX(1);
 	    iter[1] = step;
-	    rb_block_call(b, rb_intern("upto"), 2, args, step_i, (VALUE)iter);
+	    rb_objc_block_call(b, selUpto, cacheUpto, 2, args, step_i, (VALUE)iter);
 	}
 	else {
 	    VALUE args[2];
@@ -428,7 +431,7 @@
 
 	args[0] = end;
 	args[1] = EXCL(range) ? Qtrue : Qfalse;
-	rb_block_call(beg, rb_intern("upto"), 2, args, rb_yield, 0);
+	rb_objc_block_call(beg, selUpto, cacheUpto, 2, args, rb_yield, 0);
     }
     else {
 	range_each_func(range, each_i, NULL);
@@ -500,7 +503,7 @@
     rb_scan_args(argc, argv, "1", &n);
     ary[0] = n;
     ary[1] = rb_ary_new2(NUM2LONG(n));
-    rb_block_call(range, rb_intern("each"), 0, 0, first_i, (VALUE)ary);
+    rb_objc_block_call(range, selEach, cacheEach, 0, 0, first_i, (VALUE)ary);
 
     return ary[1];
 }
@@ -948,4 +951,7 @@
     rb_objc_define_method(rb_cRange, "member?", range_include, 1);
     rb_objc_define_method(rb_cRange, "include?", range_include, 1);
     rb_objc_define_method(rb_cRange, "cover?", range_cover, 1);
+
+    selUpto = sel_registerName("upto:");
+    cacheUpto = rb_vm_get_call_cache(selUpto);
 }

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/roxor.cpp	2009-04-05 05:22:02 UTC (rev 1368)
@@ -15,6 +15,9 @@
 #include <llvm/Target/TargetData.h>
 #include <llvm/ExecutionEngine/JIT.h>
 #include <llvm/ExecutionEngine/JITMemoryManager.h>
+#include <llvm/Target/TargetData.h>
+#include <llvm/Target/TargetMachine.h>
+#include <llvm/Target/TargetOptions.h>
 #include <llvm/Transforms/Scalar.h>
 #include <llvm/Support/raw_ostream.h>
 #include <llvm/Support/IRBuilder.h>
@@ -422,12 +425,7 @@
 
 	ExecutionEngine *execution_engine(void) { return ee; }
 
-	IMP compile(Function *func, bool optimize=true) {
-	    if (optimize) {
-		fpm->run(*func);
-	    }
-	    return (IMP)ee->getPointerToFunction(func);
-	}
+	IMP compile(Function *func);
 
 	bool symbolize_call_address(void *addr, void **startp, unsigned long *ln,
 				    char *name, size_t name_len) {
@@ -2212,6 +2210,41 @@
     fpm->add(createCFGSimplificationPass());
 }
 
+IMP
+RoxorVM::compile(Function *func)
+{
+#if ROXOR_COMPILER_DEBUG
+    if (verifyModule(*RoxorCompiler::module)) {
+	printf("Error during module verification\n");
+	exit(1);
+    }
+
+    uint64_t start = mach_absolute_time();
+#endif
+
+    // Optimize.
+    fpm->run(*func);
+
+    // Compile.
+    IMP imp = (IMP)ee->getPointerToFunction(func);
+
+#if ROXOR_COMPILER_DEBUG
+    uint64_t elapsed = mach_absolute_time() - start;
+
+    static mach_timebase_info_data_t sTimebaseInfo;
+
+    if (sTimebaseInfo.denom == 0) {
+	(void) mach_timebase_info(&sTimebaseInfo);
+    }
+
+    uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom;
+
+    printf("compilation done, took %lld ns\n",  elapsedNano);
+#endif
+
+    return imp;
+}
+
 struct ccache *
 RoxorVM::constant_cache_get(ID path)
 {
@@ -2248,7 +2281,8 @@
 NODE *
 RoxorVM::method_node_get(IMP imp)
 {
-    std::map<IMP, struct RoxorFunctionIMP *>::iterator iter = ruby_imps.find(imp);
+    std::map<IMP, struct RoxorFunctionIMP *>::iterator iter =
+	ruby_imps.find(imp);
     if (iter == ruby_imps.end()) {
 	return NULL;
     }
@@ -2258,7 +2292,8 @@
 inline GlobalVariable *
 RoxorVM::redefined_op_gvar(SEL sel, bool create)
 {
-    std::map <SEL, GlobalVariable *>::iterator iter = redefined_ops_gvars.find(sel);
+    std::map <SEL, GlobalVariable *>::iterator iter =
+	redefined_ops_gvars.find(sel);
     GlobalVariable *gvar = NULL;
     if (iter == redefined_ops_gvars.end()) {
 	if (create) {
@@ -2290,7 +2325,8 @@
     }
 
     if (sel == selLTLT || sel == selAREF || sel == selASET) {
-	return klass == (Class)rb_cNSArray || klass == (Class)rb_cNSMutableArray;
+	return klass == (Class)rb_cNSArray
+	    || klass == (Class)rb_cNSMutableArray;
     }
 
     if (sel == selSend || sel == sel__send__ || sel == selEval) {
@@ -2303,7 +2339,8 @@
 }
 
 void
-RoxorVM::add_method(Class klass, SEL sel, IMP imp, NODE *node, const char *types)
+RoxorVM::add_method(Class klass, SEL sel, IMP imp, NODE *node,
+		    const char *types)
 {
 #if ROXOR_VM_DEBUG
     printf("defining %c[%s %s] with imp %p node %p types %s\n",
@@ -5650,13 +5687,15 @@
 rb_vm_fast_eqq(struct mcache *cache, VALUE self, VALUE comparedTo)
 {
     // This function does not check if === has been or not redefined
-    // so it should only been called by code generated by compile_optimized_dispatch_call.
-    // Fixnums are already tested in compile_optimized_dispatch_call
+    // so it should only been called by code generated by
+    // compile_optimized_dispatch_call().
+    // Fixnums are already handled in compile_optimized_dispatch_call
     switch (TYPE(self)) {
 	// TODO: Range
 	case T_STRING:
-	    if (self == comparedTo)
+	    if (self == comparedTo) {
 		return Qtrue;
+	    }
 	    return rb_str_equal(self, comparedTo);
 
 	case T_REGEXP:
@@ -5693,7 +5732,8 @@
 
 extern "C"
 VALUE
-rb_vm_fast_shift(VALUE obj, VALUE other, struct mcache *cache, unsigned char overriden)
+rb_vm_fast_shift(VALUE obj, VALUE other, struct mcache *cache,
+		 unsigned char overriden)
 {
     if (overriden == 0 && TYPE(obj) == T_ARRAY) {
 	rb_ary_push(obj, other);
@@ -5704,7 +5744,8 @@
 
 extern "C"
 VALUE
-rb_vm_fast_aref(VALUE obj, VALUE other, struct mcache *cache, unsigned char overriden)
+rb_vm_fast_aref(VALUE obj, VALUE other, struct mcache *cache,
+		unsigned char overriden)
 {
     // TODO what about T_HASH?
     if (overriden == 0 && TYPE(obj) == T_ARRAY) {
@@ -5719,7 +5760,8 @@
 
 extern "C"
 VALUE
-rb_vm_fast_aset(VALUE obj, VALUE other1, VALUE other2, struct mcache *cache, unsigned char overriden)
+rb_vm_fast_aset(VALUE obj, VALUE other1, VALUE other2, struct mcache *cache,
+		unsigned char overriden)
 {
     // TODO what about T_HASH?
     if (overriden == 0 && TYPE(obj) == T_ARRAY) {
@@ -6043,7 +6085,8 @@
 
     if (argc < arity.min || argc > arity.max) {
 	VALUE *new_argv;
-	if (argc == 1 && TYPE(argv[0]) == T_ARRAY && (arity.min > 1 || (arity.min == 1 && arity.min != arity.max))) {
+	if (argc == 1 && TYPE(argv[0]) == T_ARRAY
+	    && (arity.min > 1 || (arity.min == 1 && arity.min != arity.max))) {
 	    // Expand the array
 	    long ary_len = RARRAY_LEN(argv[0]);
 	    new_argv = (VALUE *)alloca(sizeof(VALUE) * ary_len);
@@ -6089,7 +6132,8 @@
 	old_dvars[i] = b->dvars[i];
     }
 
-    VALUE v = __rb_vm_bcall(b->self, (VALUE)b->dvars, b->imp, b->arity, argc, argv);
+    VALUE v = __rb_vm_bcall(b->self, (VALUE)b->dvars, b->imp, b->arity, argc,
+			    argv);
 
     for (int i = 0; i < b->dvars_size; i++) {
 	b->dvars[i] = old_dvars[i];
@@ -6174,7 +6218,8 @@
 {
     VALUE klass = CLASS_OF(obj);
 
-    IMP respond_to_imp = class_getMethodImplementation((Class)klass, selRespondTo);
+    IMP respond_to_imp = class_getMethodImplementation((Class)klass,
+	    selRespondTo);
 
     if (respond_to_imp == basic_respond_to_imp) {
 	IMP obj_imp = class_getMethodImplementation((Class)klass, sel);
@@ -6308,7 +6353,8 @@
 	char name[100];
 	unsigned long ln = 0;
 
-	if (GET_VM()->symbolize_call_address(callstack[i], NULL, &ln, name, sizeof name)) {
+	if (GET_VM()->symbolize_call_address(callstack[i], NULL, &ln, name,
+					     sizeof name)) {
 	    char entry[100];
 	    snprintf(entry, sizeof entry, "%ld:in `%s'", ln, name);
 	    rb_ary_push(ary, rb_str_new2(entry));
@@ -6418,10 +6464,6 @@
 
 // END OF VM primitives
 
-#include <llvm/Target/TargetData.h>
-#include <llvm/Target/TargetMachine.h>
-#include <llvm/Target/TargetOptions.h>
-
 extern "C"
 bool
 rb_vm_parse_in_eval(void)
@@ -6468,34 +6510,9 @@
 
     Function *function = compiler->compile_main_function(node);
 
-#if ROXOR_COMPILER_DEBUG
-    if (verifyModule(*RoxorCompiler::module)) {
-	printf("Error during module verification\n");
-	exit(1);
-    }
-
-    uint64_t start = mach_absolute_time();
-#endif
-
-    IMP imp = GET_VM()->compile(function);
-
-#if ROXOR_COMPILER_DEBUG
-    uint64_t elapsed = mach_absolute_time() - start;
-
-    static mach_timebase_info_data_t sTimebaseInfo;
-
-    if (sTimebaseInfo.denom == 0) {
-	(void) mach_timebase_info(&sTimebaseInfo);
-    }
-
-    uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom;
-
-    printf("compilation/optimization done, took %lld ns\n",  elapsedNano);
-#endif
-
     delete compiler;
 
-    return imp;
+    return GET_VM()->compile(function);
 }
 
 extern "C"

Modified: MacRuby/branches/experimental/set.c
===================================================================
--- MacRuby/branches/experimental/set.c	2009-04-05 01:47:49 UTC (rev 1367)
+++ MacRuby/branches/experimental/set.c	2009-04-05 05:22:02 UTC (rev 1368)
@@ -314,7 +314,7 @@
 
     rb_scan_args(argc, argv, "01", &val);
     if (!NIL_P(val)) {
-	rb_block_call(val, rb_intern("each"), 0, 0, initialize_i, (VALUE)set);
+	rb_objc_block_call(val, selEach, cacheEach, 0, 0, initialize_i, (VALUE)set);
     } 
     else if (rb_block_given_p()) {
 	rb_warning("given block not used");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090404/9da14afb/attachment-0001.html>


More information about the macruby-changes mailing list