[macruby-changes] [1038] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 20 20:09:59 PDT 2009
Revision: 1038
http://trac.macosforge.org/projects/ruby/changeset/1038
Author: lsansonetti at apple.com
Date: 2009-03-20 20:09:59 -0700 (Fri, 20 Mar 2009)
Log Message:
-----------
fixed robject slots regrowth
Modified Paths:
--------------
MacRuby/branches/experimental/include/ruby/ruby.h
MacRuby/branches/experimental/roxor.h
Modified: MacRuby/branches/experimental/include/ruby/ruby.h
===================================================================
--- MacRuby/branches/experimental/include/ruby/ruby.h 2009-03-21 01:51:28 UTC (rev 1037)
+++ MacRuby/branches/experimental/include/ruby/ruby.h 2009-03-21 03:09:59 UTC (rev 1038)
@@ -468,7 +468,7 @@
struct RBasic basic;
CFMutableDictionaryRef tbl; /* dynamic ivars (runtime) */
unsigned int num_slots;
- VALUE slots[1]; /* static ivars (compilation) */
+ VALUE *slots; /* static ivars (compilation) */
};
#if !WITH_OBJC
Modified: MacRuby/branches/experimental/roxor.h
===================================================================
--- MacRuby/branches/experimental/roxor.h 2009-03-21 01:51:28 UTC (rev 1037)
+++ MacRuby/branches/experimental/roxor.h 2009-03-21 03:09:59 UTC (rev 1038)
@@ -32,13 +32,21 @@
int rb_vm_find_class_ivar_slot(VALUE klass, ID name);
static inline void
-rb_vm_regrow_robject_slots(struct RObject *obj, int new_num_slot)
+rb_vm_regrow_robject_slots(struct RObject *obj, unsigned int new_num_slot)
{
+ unsigned int i;
+#if 0
VALUE *new_slots = (VALUE *)xrealloc(obj->slots, sizeof(VALUE) * new_num_slot);
if (obj->slots != new_slots) {
GC_WB(&obj->slots, new_slots);
}
- int i;
+#else
+ VALUE *new_slots = (VALUE *)xmalloc(sizeof(VALUE) * new_num_slot);
+ for (i = 0; i < obj->num_slots; i++) {
+ GC_WB(&new_slots[i], obj->slots[i]);
+ }
+ GC_WB(&obj->slots, new_slots);
+#endif
for (i = obj->num_slots; i < new_num_slot; i++) {
obj->slots[i] = Qundef;
}
@@ -62,7 +70,7 @@
struct RObject *robj = (struct RObject *)obj;
assert(slot >= 0);
if (robj->num_slots < (unsigned int)slot) {
- rb_vm_regrow_robject_slots(robj, slot);
+ rb_vm_regrow_robject_slots(robj, (unsigned int)slot);
}
robj->slots[slot] = val;
}
@@ -121,7 +129,9 @@
struct RObject *obj;
int num_slots = 10;
- obj = (struct RObject *)xmalloc(sizeof(struct RObject) + (num_slots * sizeof(VALUE)));
+ obj = (struct RObject *)xmalloc(sizeof(struct RObject));
+ GC_WB(&obj->slots, xmalloc(num_slots * sizeof(VALUE)));
+
OBJSETUP(obj, klass, T_OBJECT);
ROBJECT(obj)->tbl = NULL;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090320/89abce56/attachment.html>
More information about the macruby-changes
mailing list