[svn:parrot] r42073 - trunk/src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Oct 24 09:00:47 UTC 2009


Author: chromatic
Date: Sat Oct 24 09:00:47 2009
New Revision: 42073
URL: https://trac.parrot.org/parrot/changeset/42073

Log:
[PMC] Added allocate_initial_values() static function to CallSignatureReturns
PMC so that set_pointer_keyed_int() and set_integer_native() can inline it.
This gives another 0.729% speed improvement on fib.pir because this is the most
common use of this PMC.

Modified:
   trunk/src/pmc/callsignaturereturns.pmc

Modified: trunk/src/pmc/callsignaturereturns.pmc
==============================================================================
--- trunk/src/pmc/callsignaturereturns.pmc	Sat Oct 24 09:00:37 2009	(r42072)
+++ trunk/src/pmc/callsignaturereturns.pmc	Sat Oct 24 09:00:47 2009	(r42073)
@@ -47,6 +47,16 @@
 
 */
 
+static void **
+allocate_initial_values(PARROT_INTERP, ARGIN(PMC *SELF))
+{
+    void **values = (void **)Parrot_gc_allocate_fixed_size_storage(interp,
+                                 8 * sizeof (void *));
+
+    SETATTR_CallSignatureReturns_resize_threshold(interp, SELF, 8);
+    return values;
+}
+
 
 /* mask off lower two bits (1 + 2 = 3) for pointer tags */
 #define TAG_BITS 3
@@ -103,14 +113,11 @@
         GET_ATTR_values(INTERP, SELF, values);
         GET_ATTR_resize_threshold(INTERP, SELF, resize_threshold);
 
+        /* Empty. Allocate 8 elements (arbitary number) */
         if (!values) {
-            /* Empty. Allocate 8 elements (arbitary number) */
-            values = (void **)Parrot_gc_allocate_fixed_size_storage(INTERP,
-                                 8 * sizeof (void *));
-
+            values = allocate_initial_values(INTERP, SELF);
             SET_ATTR_values(INTERP, SELF, values);
             SET_ATTR_size(INTERP, SELF, size);
-            SET_ATTR_resize_threshold(INTERP, SELF, 8);
         }
         else if (size <= resize_threshold) {
             SET_ATTR_size(INTERP, SELF, size);
@@ -179,11 +186,17 @@
         void   **values;
         INTVAL   size;
 
-        GET_ATTR_size(INTERP, SELF, size);
-        if (key >= size)
+        GET_ATTR_values(INTERP, SELF, values);
+        GET_ATTR_size(INTERP,   SELF, size);
+
+        if (!values && key < 8) {
+            values = allocate_initial_values(INTERP, SELF);
+            SET_ATTR_values(INTERP, SELF, values);
+            SET_ATTR_size(INTERP, SELF, key + 1);
+        }
+        else if (key >= size)
             STATICSELF.set_integer_native(key + 1);
 
-        GET_ATTR_values(INTERP, SELF, values);
         values[key] = value;
     }
 


More information about the parrot-commits mailing list