[macruby-changes] [413] MacRuby/branches/lrz_unstable

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 7 18:48:14 PDT 2008


Revision: 413
          http://trac.macosforge.org/projects/ruby/changeset/413
Author:   lsansonetti at apple.com
Date:     2008-08-07 18:48:13 -0700 (Thu, 07 Aug 2008)
Log Message:
-----------
wip

Modified Paths:
--------------
    MacRuby/branches/lrz_unstable/Rakefile
    MacRuby/branches/lrz_unstable/class.c
    MacRuby/branches/lrz_unstable/compile.c
    MacRuby/branches/lrz_unstable/debug.h
    MacRuby/branches/lrz_unstable/eval.c
    MacRuby/branches/lrz_unstable/id.c
    MacRuby/branches/lrz_unstable/id.h
    MacRuby/branches/lrz_unstable/include/ruby/ruby.h
    MacRuby/branches/lrz_unstable/insns.def
    MacRuby/branches/lrz_unstable/objc.m
    MacRuby/branches/lrz_unstable/parse.y
    MacRuby/branches/lrz_unstable/variable.c
    MacRuby/branches/lrz_unstable/vm_insnhelper.c

Modified: MacRuby/branches/lrz_unstable/Rakefile
===================================================================
--- MacRuby/branches/lrz_unstable/Rakefile	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/Rakefile	2008-08-08 01:48:13 UTC (rev 413)
@@ -21,7 +21,7 @@
 NO_WARN_BUILD = !do_option('allow_build_warnings', false)
 BUILD_AS_EMBEDDABLE = do_option('build_as_embeddable', false)
 ENABLE_STATIC_LIBRARY = do_option('enable_static_library', 'no') { 'yes' }
-ENABLE_DEBUG_LOGGING = do_option('enable_debug_logging', false)
+ENABLE_DEBUG_LOGGING = do_option('enable_debug_logging', true)
 
 # TODO: we should find a way to document these options in rake's --help
 

Modified: MacRuby/branches/lrz_unstable/class.c
===================================================================
--- MacRuby/branches/lrz_unstable/class.c	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/class.c	2008-08-08 01:48:13 UTC (rev 413)
@@ -882,7 +882,7 @@
 	    method = methods[i];
 
 	    sel = method_getName(method);
-	    if (rb_ignored_selector(sel)) 
+	    if (sel == sel_ignored)
 		continue; 
 
 	    sel_name = (char *)sel_getName(sel);

Modified: MacRuby/branches/lrz_unstable/compile.c
===================================================================
--- MacRuby/branches/lrz_unstable/compile.c	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/compile.c	2008-08-08 01:48:13 UTC (rev 413)
@@ -692,20 +692,18 @@
     operands[1] = argc;
     operands[2] = block;
     operands[3] = flag;
-    operands[4] = 0;
     if (FIX2INT(argc) > 0) {
         char buf[512];
 
         strlcpy(buf, rb_sym2name(id), sizeof buf);
 	if (buf[strlen(buf) - 1] != ':')
 	    strlcat(buf, ":", sizeof buf);
-	operands[5] = (VALUE)sel_registerName(buf);
+	operands[4] = (VALUE)sel_registerName(buf);
     }
     else {
-	operands[5] = (VALUE)sel_registerName(rb_sym2name(id));
+	operands[4] = (VALUE)sel_registerName(rb_sym2name(id));
     }
-    operands[6] = 0;
-    iobj = new_insn_core(iseq, line_no, BIN(send), 6, operands);
+    iobj = new_insn_core(iseq, line_no, BIN(send), 5, operands);
     return iobj;
 }
 

Modified: MacRuby/branches/lrz_unstable/debug.h
===================================================================
--- MacRuby/branches/lrz_unstable/debug.h	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/debug.h	2008-08-08 01:48:13 UTC (rev 413)
@@ -30,23 +30,14 @@
 void  ruby_debug_gc_check_func(void);
 
 #if ENABLE_DEBUG_LOGGING 
-static inline bool dlog_enabled(void) {
-    static int flag = -1;
-    if (flag == -1) {
-	char *s = getenv("MACRUBY_DEBUG");
-	flag = !(s == NULL || *s == '0');
+# include "vm_core.h"
+extern bool ruby_dlog_enabled;
+# define DLOG(mod, fmt, args...)         \
+    if (UNLIKELY(ruby_dlog_enabled)) {   \
+	printf("%10s   ", mod);          \
+	printf(fmt, ##args);             \
+	printf("\n");                    \
     }
-    return (bool)flag;
-}
-# define DLOG(mod, fmt, args...)        \
-  do {                                  \
-    if (dlog_enabled()) {               \
-        printf("%10s   ", mod);         \
-        printf(fmt, ##args);            \
-        printf("\n");                   \
-    }                                   \
-  }                                     \
-  while (0)
 #else
 # define DLOG(mod, fmt, args...)
 #endif

Modified: MacRuby/branches/lrz_unstable/eval.c
===================================================================
--- MacRuby/branches/lrz_unstable/eval.c	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/eval.c	2008-08-08 01:48:13 UTC (rev 413)
@@ -54,6 +54,10 @@
 void Init_PreGC(void);
 void Init_BareVM(void);
 
+#if WITH_OBJC
+bool ruby_dlog_enabled = false;
+#endif
+
 void
 ruby_init(void)
 {
@@ -70,6 +74,11 @@
     rb_origenviron = environ;
 #endif
 
+#if WITH_OBJC
+    char *s = getenv("MACRUBY_DEBUG");
+    ruby_dlog_enabled = !(s == NULL || *s == '0');
+#endif
+
     Init_stack((void *)&state);
     Init_PreGC();
     Init_BareVM();

Modified: MacRuby/branches/lrz_unstable/id.c
===================================================================
--- MacRuby/branches/lrz_unstable/id.c	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/id.c	2008-08-08 01:48:13 UTC (rev 413)
@@ -60,6 +60,8 @@
     selNot = sel_registerName("!");
     selInit = sel_registerName("init");
     selCopy = sel_registerName("copy");
+    sel_ignored = sel_registerName("retain");
+    assert(sel_ignored == sel_registerName("release"));
 #endif
 
     idAREF = rb_intern("[]");

Modified: MacRuby/branches/lrz_unstable/id.h
===================================================================
--- MacRuby/branches/lrz_unstable/id.h	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/id.h	2008-08-08 01:48:13 UTC (rev 413)
@@ -72,6 +72,7 @@
 extern SEL selNot;
 extern SEL selInit;
 extern SEL selCopy;
+extern SEL sel_ignored;
 extern ID idIncludedModules;
 extern ID idIncludedInClasses;
 #endif

Modified: MacRuby/branches/lrz_unstable/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/lrz_unstable/include/ruby/ruby.h	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/include/ruby/ruby.h	2008-08-08 01:48:13 UTC (rev 413)
@@ -1138,18 +1138,6 @@
 #define RB2OC(obj) (rb_rval_to_ocid((VALUE)obj))
 #define OC2RB(obj) (rb_ocid_to_rval((id)obj))
 
-static inline bool
-rb_ignored_selector(SEL sel)
-{
-#if defined(__ppc__)
-    return sel == (SEL)0xfffef000;
-#elif defined(__i386__)
-    return sel == (SEL)0xfffeb010;
-#else
-# error Unsupported arch
-#endif
-}
-
 static inline VALUE
 rb_ary_elt_fast(CFArrayRef ary, long i)
 {

Modified: MacRuby/branches/lrz_unstable/insns.def
===================================================================
--- MacRuby/branches/lrz_unstable/insns.def	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/insns.def	2008-08-08 01:48:13 UTC (rev 413)
@@ -1035,7 +1035,7 @@
  */
 DEFINE_INSN
 send
-(ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, IC ic, VALUE sel)
+(ID op_id, rb_num_t op_argc, ISEQ blockiseq, rb_num_t op_flag, VALUE sel)
 (...)
 (VALUE val) // inc += - (op_argc + ((op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? 1 : 0));
 {
@@ -1051,7 +1051,6 @@
     recv = (flag & VM_CALL_FCALL_BIT) ? GET_SELF() : TOPN(num);
     klass = CLASS_OF(recv);
 #if WITH_OBJC
-    ic = 0;
     mn = NULL;
 #else
     mn = vm_method_search(id, klass, ic);

Modified: MacRuby/branches/lrz_unstable/objc.m
===================================================================
--- MacRuby/branches/lrz_unstable/objc.m	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/objc.m	2008-08-08 01:48:13 UTC (rev 413)
@@ -1460,10 +1460,10 @@
 	sel = sel_registerName(mid_str);
     }
 
-    if (rb_ignored_selector(sel)) {
-	rb_warn("cannot register %c[%s %s] because it is an ignored selector",
-		class_isMetaClass((Class)mod) ? '+' : '-', class_getName((Class)mod), mid_str);
-	return;
+    if (sel == sel_ignored) {
+	char buf[100];
+	snprintf(buf, sizeof buf, "__rb_%s__", mid_str);
+	sel = sel_registerName(buf);
     }
 
     direct_override = false;

Modified: MacRuby/branches/lrz_unstable/parse.y
===================================================================
--- MacRuby/branches/lrz_unstable/parse.y	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/parse.y	2008-08-08 01:48:13 UTC (rev 413)
@@ -9380,6 +9380,17 @@
 	e = m + len;
     }
     SEL name_hash = sel_registerName(name);
+    if (name_hash == sel_ignored) {
+	if (strcmp(name, "retain") == 0) {
+	    name_hash = (SEL)0x1000;
+	}
+	else if (strcmp(name, "release") == 0) {
+	    name_hash = (SEL)0x2000;
+	}
+	else {
+	    assert(1==0);
+	}
+    }
     id = (ID)CFDictionaryGetValue((CFDictionaryRef)global_symbols.sym_id, 
 	(const void *)name_hash);
     if (id != 0)

Modified: MacRuby/branches/lrz_unstable/variable.c
===================================================================
--- MacRuby/branches/lrz_unstable/variable.c	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/variable.c	2008-08-08 01:48:13 UTC (rev 413)
@@ -405,10 +405,13 @@
     struct trace_var *trace;
 };
 
+#if !WITH_OBJC
+/* defined in vm_core.h, imported by debug.h */
 struct global_entry {
     struct global_variable *var;
     ID id;
 };
+#endif
 
 static VALUE undef_getter(ID id);
 static void  undef_setter(VALUE val, ID id, void *data, struct global_variable *var);
@@ -482,7 +485,7 @@
 static void
 val_setter(VALUE val, ID id, void *data, struct global_variable *var)
 {
-    var->data = (void*)val;
+    GC_WB(&var->data, (void*)val);
 }
 
 static void

Modified: MacRuby/branches/lrz_unstable/vm_insnhelper.c
===================================================================
--- MacRuby/branches/lrz_unstable/vm_insnhelper.c	2008-08-06 09:29:17 UTC (rev 412)
+++ MacRuby/branches/lrz_unstable/vm_insnhelper.c	2008-08-08 01:48:13 UTC (rev 413)
@@ -516,8 +516,14 @@
 #if WITH_OBJC
     IMP imp;
 
-#define STUPID_CACHE 1
+#define STUPID_CACHE 0
 
+    if (sel == sel_ignored) {
+	char buf[100];
+	snprintf(buf, sizeof buf, "__rb_%s__", rb_id2name(id));
+	sel = sel_registerName(buf);
+    }
+
 #if STUPID_CACHE
 static VALUE c_klass = 0;
 static SEL c_sel = 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080807/77d9510b/attachment-0001.html 


More information about the macruby-changes mailing list