[macruby-changes] [3866] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 25 20:49:54 PDT 2010


Revision: 3866
          http://trac.macosforge.org/projects/ruby/changeset/3866
Author:   lsansonetti at apple.com
Date:     2010-03-25 20:49:52 -0700 (Thu, 25 Mar 2010)
Log Message:
-----------
get rid of placeholder code, it's not necessary and too fragile

Modified Paths:
--------------
    MacRuby/trunk/gc.c
    MacRuby/trunk/objc.h
    MacRuby/trunk/objc.m
    MacRuby/trunk/object.c

Modified: MacRuby/trunk/gc.c
===================================================================
--- MacRuby/trunk/gc.c	2010-03-25 23:40:59 UTC (rev 3865)
+++ MacRuby/trunk/gc.c	2010-03-26 03:49:52 UTC (rev 3866)
@@ -646,11 +646,6 @@
 	    case T_MODULE:
 		rb_bug("object %p of type %d should not be recorded", 
 		       (void *)r->address, TYPE(r->address));
-
-	    case T_NATIVE:
-		if (rb_objc_is_placeholder((void *)r->address)) {
-		    continue;
-		}
 	}
 	rb_yield((VALUE)r->address);
 	ctx->break_value = rb_vm_pop_broken_value();
@@ -862,7 +857,6 @@
 	auto_memory_type_t type = 
 	    auto_zone_get_layout_type(__auto_zone, p0);
 	if ((type == AUTO_OBJECT_SCANNED || type == AUTO_OBJECT_UNSCANNED)
-	    && !rb_objc_is_placeholder(p0)
 	    && (NATIVE((VALUE)p0)
 		|| (BUILTIN_TYPE(p0) < T_FIXNUM && BUILTIN_TYPE(p0) != T_ICLASS)))
 	    return (VALUE)p0;

Modified: MacRuby/trunk/objc.h
===================================================================
--- MacRuby/trunk/objc.h	2010-03-25 23:40:59 UTC (rev 3865)
+++ MacRuby/trunk/objc.h	2010-03-26 03:49:52 UTC (rev 3866)
@@ -50,18 +50,6 @@
     return false;
 }
 
-extern void *placeholder_String;
-extern void *placeholder_Dictionary;
-extern void *placeholder_Array;
-
-static inline bool
-rb_objc_is_placeholder(id obj)
-{
-    void *klass = *(void **)obj;
-    return klass == placeholder_String || klass == placeholder_Dictionary
-	|| klass == placeholder_Array;
-}
-
 bool rb_objc_symbolize_address(void *addr, void **start, char *name,
 	size_t name_len);
 

Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m	2010-03-25 23:40:59 UTC (rev 3865)
+++ MacRuby/trunk/objc.m	2010-03-26 03:49:52 UTC (rev 3866)
@@ -631,10 +631,6 @@
     return 0; // never reached
 }
 
-void *placeholder_String = NULL;
-void *placeholder_Dictionary = NULL;
-void *placeholder_Array = NULL;
-
 void
 Init_ObjC(void)
 {
@@ -646,10 +642,6 @@
     old_imp_isaForAutonotifying = method_getImplementation(m);
     method_setImplementation(m, (IMP)rb_obj_imp_isaForAutonotifying);
 
-    placeholder_String = objc_getClass("NSPlaceholderMutableString");
-    placeholder_Dictionary = objc_getClass("__NSPlaceholderDictionary");
-    placeholder_Array = objc_getClass("__NSPlaceholderArray");
-
     reload_class_constants();
 }
 

Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c	2010-03-25 23:40:59 UTC (rev 3865)
+++ MacRuby/trunk/object.c	2010-03-26 03:49:52 UTC (rev 3866)
@@ -1917,27 +1917,15 @@
 static inline VALUE
 rb_obj_alloc0(VALUE klass)
 {
-#if 0
-    if (RCLASS_SUPER(klass) == 0 && klass != rb_cBasicObject && klass != rb_cObject) {
-	rb_raise(rb_eTypeError, "can't instantiate uninitialized class");
-    }
-#endif
     if (RCLASS_SINGLETON(klass)) {
 	rb_raise(rb_eTypeError, "can't create instance of singleton class");
     }
 
     if ((RCLASS_VERSION(*(void **)klass) & RCLASS_HAS_ROBJECT_ALLOC) == RCLASS_HAS_ROBJECT_ALLOC) {
+	// Fast path!
 	return rb_robject_allocate_instance(klass);
     }
-    else {
-	//obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0);
-	VALUE obj = rb_vm_call_with_cache(allocCache, klass, selAlloc, 0, NULL);
-
-	if (rb_objc_is_placeholder((id)obj)) {
-	    return (VALUE)objc_msgSend((void *)obj, selInit);
-	}
-	return obj;
-    }
+    return rb_vm_call_with_cache(allocCache, klass, selAlloc, 0, NULL);
 }
 
 VALUE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100325/17c94b60/attachment-0001.html>


More information about the macruby-changes mailing list