Author: allison
Date: Tue May  8 13:20:35 2007
New Revision: 18470

Modified:
   trunk/include/parrot/pobj.h
   trunk/src/gc/dod.c
   trunk/src/gc/res_lea.c

Log:
Propagating a few earlier refactors to infrequently used code paths, as
partial solution for RT#42774.

* PObj_bufstart_external_FLAG is no longer defined (as of r10582),
  remove accessors PObj_bufstart_external_TEST and
  PObj_bufstart_external_SET.
* Remove check that calls PObj_bufstart_external_TEST, following r10582.
* STRING_ALIGNMENT is replaced by BUFFER_ALIGNMENT, following r10591.
* Make the declarations of Parrot_reallocate, Parrot_allocate, and
  Parrot_reallocate_string match their prototypes, following r10587.
* Remove Parrot_allocate_zeroed, following r10587.


Modified: trunk/include/parrot/pobj.h
==============================================================================
--- trunk/include/parrot/pobj.h (original)
+++ trunk/include/parrot/pobj.h Tue May  8 13:20:35 2007
@@ -286,9 +286,6 @@
 #define PObj_external_SET(o) PObj_flag_SET(external, o)
 #define PObj_external_CLEAR(o) PObj_flag_CLEAR(external, o)
 
-#define PObj_bufstart_external_TEST(o) PObj_flag_TEST(bufstart_external, o)
-#define PObj_bufstart_external_SET(o) PObj_flag_SET(bufstart_external, o)
-
 #define PObj_report_TEST(o) PObj_flag_TEST(report, o)
 #define PObj_report_SET(o) PObj_flag_SET(report, o)
 #define PObj_report_CLEAR(o) PObj_flag_CLEAR(report, o)

Modified: trunk/src/gc/dod.c
==============================================================================
--- trunk/src/gc/dod.c  (original)
+++ trunk/src/gc/dod.c  Tue May  8 13:20:35 2007
@@ -458,10 +458,6 @@
                     /* clear COWed external FLAG */
                     PObj_external_CLEAR(b);
 
-                    /* the real external flag */
-                    if (PObj_bufstart_external_TEST(b))
-                        PObj_external_SET(b);
-
                     /* if cleanup (Parrot_destroy) constants are dead too */
                     PObj_constant_CLEAR(b);
                     PObj_live_CLEAR(b);

Modified: trunk/src/gc/res_lea.c
==============================================================================
--- trunk/src/gc/res_lea.c      (original)
+++ trunk/src/gc/res_lea.c      Tue May  8 13:20:35 2007
@@ -112,8 +112,8 @@
 
 /*
 
-=item C<void *
-Parrot_reallocate(Interp *interp, void *from, size_t size)>
+=item C<void
+Parrot_reallocate(Interp *interp, Buffer *from, size_t tosize)>
 
 COWable objects (strings or Buffers) use an INTVAL at C<bufstart> for
 refcounting in DOD. C<bufstart> is incremented by that C<INTVAL>.
@@ -122,34 +122,33 @@
 
 */
 
-void *
-Parrot_reallocate(Interp *interp, void *from, size_t size)
+void
+Parrot_reallocate(Interp *interp, Buffer *from, size_t tosize)
 {
     Buffer * const buffer = from;
     const size_t oldlen = PObj_buflen(buffer);
     void *p;
 
     if (!PObj_bufstart(buffer)) {
-        p = 1 + (INTVAL *)xcalloc(1, sizeof (INTVAL) + size);
+        p = 1 + (INTVAL *)xcalloc(1, sizeof (INTVAL) + tosize);
     }
     else {
-        if (!size) {    /* realloc(3) does free, if size == 0 here */
-            return PObj_bufstart(buffer);    /* do nothing */
+        if (!tosize) {    /* realloc(3) does free, if tosize == 0 here */
+            return;    /* do nothing */
         }
         p = 1 + (INTVAL *)xrealloc((INTVAL *)PObj_bufstart(buffer) - 1,
-                                   sizeof (INTVAL) + size);
-        if (size > oldlen)
-            memset(p + oldlen, 0, size - oldlen);
+                                   sizeof (INTVAL) + tosize);
+        if (tosize > oldlen)
+            memset(p + oldlen, 0, tosize - oldlen);
     }
     PObj_bufstart(buffer) = p;
-    PObj_buflen(buffer) = size;
-    return PObj_bufstart(buffer);
+    PObj_buflen(buffer) = tosize;
 }
 
 /*
 
-=item C<void *
-Parrot_allocate(Interp *interp, void *buffer, size_t size)>
+=item C<void
+Parrot_allocate(Interp *interp, Buffer *buffer, size_t size)>
 
 Allocates and returns the required memory. C<size> is the number of
 bytes of memory required.
@@ -158,8 +157,8 @@
 
 */
 
-void *
-Parrot_allocate(Interp *interp, void *buffer, size_t size)
+void
+Parrot_allocate(Interp *interp, Buffer *buffer, size_t size)
 {
     Buffer * const b = buffer;
     void * const p = xmalloc(sizeof (INTVAL) + size);
@@ -167,63 +166,39 @@
     *(INTVAL *)p = 0;
     PObj_bufstart(b) = 1 + (INTVAL *)p;
     PObj_buflen(b) = size;
-    return b;
-}
-
-/*
-
-=item C<void *
-Parrot_allocate_zeroed(Interp *interp, void *buffer, size_t size)>
-
-Allocates, zeros and returns the required memory. C<size> is the number
-in bytes of memory required.
-
-=cut
-
-*/
-
-void *
-Parrot_allocate_zeroed(Interp *interp, void *buffer, size_t size)
-{
-    Buffer * const b = buffer;
-
-    PObj_bufstart(b) = 1 + (INTVAL *)xcalloc(1, sizeof (INTVAL) + size);
-    PObj_buflen(b) = size;
-    return b;
 }
 
 /*
 
-=item C<void *
-Parrot_reallocate_string(Interp *interp, STRING *str, size_t size)>
+=item C<void
+Parrot_reallocate_string(Interp *interp, STRING *str, size_t tosize)>
 
-Reallocates the string buffer in C<*str> and returns it. C<size> is the
+Reallocates the string buffer in C<*str> and returns it. C<tosize> is the
 number of bytes memory required.
 
 =cut
 
 */
 
-void *
-Parrot_reallocate_string(Interp *interp, STRING *str, size_t size)
+void
+Parrot_reallocate_string(Interp *interp, STRING *str, size_t tosize)
 {
     if (!PObj_bufstart(str))
-        Parrot_allocate_string(interp, str, size);
-    else if (size) {
-        const size_t pad = STRING_ALIGNMENT - 1;
+        Parrot_allocate_string(interp, str, tosize);
+    else if (tosize) {
+        const size_t pad = BUFFER_ALIGNMENT - 1;
         void *p;
-        size = ((size + pad + sizeof (INTVAL)) & ~pad);
-        p = xrealloc((char *)((INTVAL*)PObj_bufstart(str) - 1), size);
+        tosize = ((tosize + pad + sizeof (INTVAL)) & ~pad);
+        p = xrealloc((char *)((INTVAL*)PObj_bufstart(str) - 1), tosize);
         PObj_bufstart(str) = str->strstart = (char *)p + sizeof (INTVAL);
         /* usable size at bufstart */
-        PObj_buflen(str) = size - sizeof (INTVAL);
+        PObj_buflen(str) = tosize - sizeof (INTVAL);
     }
-    return str->strstart;
 }
 
 /*
 
-=item C<void *
+=item C<void
 Parrot_allocate_string(Interp *interp, STRING *str, size_t size)>
 
 Allocates the string buffer in C<*str> and returns it. C<size> is the
@@ -233,18 +208,17 @@
 
 */
 
-void *
+void
 Parrot_allocate_string(Interp *interp, STRING *str, size_t size)
 {
     void *p;
-    const size_t pad = STRING_ALIGNMENT - 1;
+    const size_t pad = BUFFER_ALIGNMENT - 1;
 
     size = ((size + pad + sizeof (INTVAL)) & ~pad);
     p = xcalloc(1, size);
     *(INTVAL*)p = 0;
     PObj_bufstart(str) = str->strstart = (char *)p + sizeof (INTVAL);
     PObj_buflen(str) = size - sizeof (INTVAL);
-    return str;
 }
 
 /*

Reply via email to