[macruby-changes] [2635] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 25 03:03:40 PDT 2009
Revision: 2635
http://trac.macosforge.org/projects/ruby/changeset/2635
Author: vincent.isambart at gmail.com
Date: 2009-09-25 03:03:37 -0700 (Fri, 25 Sep 2009)
Log Message:
-----------
a few GC-related fixes (mostly done by Laurent)
Modified Paths:
--------------
MacRuby/trunk/gc.c
MacRuby/trunk/parse.y
Modified: MacRuby/trunk/gc.c
===================================================================
--- MacRuby/trunk/gc.c 2009-09-25 08:18:02 UTC (rev 2634)
+++ MacRuby/trunk/gc.c 2009-09-25 10:03:37 UTC (rev 2635)
@@ -156,11 +156,26 @@
size = 1;
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ {
+ size_t old_size = malloc_size(ptr);
+ if (old_size >= size) {
+ return ptr;
+ }
+ mem = ruby_xmalloc(size);
+ if (mem == NULL) {
+ rb_memerror();
+ }
+ auto_zone_write_barrier_memmove(__auto_zone, mem, ptr, old_size);
+ xfree(ptr);
+ }
+#else
mem = malloc_zone_realloc(__auto_zone, ptr, size);
if (mem == NULL) {
rb_memerror();
}
+#endif
return mem;
}
Modified: MacRuby/trunk/parse.y
===================================================================
--- MacRuby/trunk/parse.y 2009-09-25 08:18:02 UTC (rev 2634)
+++ MacRuby/trunk/parse.y 2009-09-25 10:03:37 UTC (rev 2635)
@@ -10115,12 +10115,19 @@
}
#ifdef YYMALLOC
-// FIXME the following functions are definitely missing write barriers
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
#define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
-#define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
- (n)->u3.cnt = (c), (p))
+static inline void *
+__add2heap(struct parser_params *parser, NODE *n, size_t c, void *p)
+{
+ GC_WB(&parser->heap, n);
+ GC_WB(&n->u1.node, p);
+ n->u3.cnt = c;
+ return p;
+}
+#define ADD2HEAP(n, c, p) (__add2heap(parser, (NODE *)n, (size_t)c, (void *)p))
+
void *
rb_parser_malloc(struct parser_params *parser, size_t size)
{
@@ -10150,7 +10157,8 @@
if (ptr && (n = parser->heap) != NULL) {
do {
if (n->u1.node == ptr) {
- n->u1.node = ptr = xrealloc(ptr, size);
+ ptr = xrealloc(ptr, size);
+ GC_WB(&n->u1.node, ptr);
if (n->u3.cnt) n->u3.cnt = cnt;
return ptr;
}
@@ -10168,7 +10176,7 @@
while ((n = *prev) != NULL) {
if (n->u1.node == ptr) {
- *prev = n->u2.node;
+ GC_WB(prev, n->u2.node);
rb_gc_force_recycle((VALUE)n);
break;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090925/9ee0d8e5/attachment.html>
More information about the macruby-changes
mailing list