develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34670 - in trunk: compilers/imcc src

From:
chromatic
Date:
December 30, 2008 13:04
Subject:
[svn:parrot] r34670 - in trunk: compilers/imcc src
Message ID:
20081230210445.A4980CB9FA@x12.develooper.com
Author: chromatic
Date: Tue Dec 30 13:04:44 2008
New Revision: 34670

Modified:
   trunk/compilers/imcc/pbc.c
   trunk/src/multidispatch.c

Log:
[MMD] [IMCC] Optimized MMD signature generation where dispatch types are known
at compile time.

Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c	(original)
+++ trunk/compilers/imcc/pbc.c	Tue Dec 30 13:04:44 2008
@@ -979,12 +979,11 @@
 static PMC*
 mk_multi_sig(PARROT_INTERP, ARGIN(const SymReg *r))
 {
-    PMC              *multi_sig;
-    pcc_sub_t * const pcc_sub = r->pcc_sub;
-    const INTVAL      n       = pcc_sub->nmulti;
-    INTVAL            i;
-
     PackFile_ConstTable *ct;
+    PMC                 *multi_sig;
+    pcc_sub_t * const    pcc_sub = r->pcc_sub;
+    const INTVAL         n       = pcc_sub->nmulti;
+    INTVAL               i;
 
     /* a :multi sub with no arguments */
     if (!pcc_sub->multi[0])
@@ -1001,9 +1000,17 @@
         r = pcc_sub->multi[i];
 
         if (r->set == 'S') {
-            sig_pmc = pmc_new(interp, enum_class_String);
-            VTABLE_set_string_native(interp, sig_pmc,
-                    ct->constants[r->color]->u.string);
+            STRING *type_name = ct->constants[r->color]->u.string;
+            INTVAL  type_num  = pmc_type(interp, type_name);
+
+            if (type_num == enum_type_undef) {
+                sig_pmc = pmc_new(interp, enum_class_String);
+                VTABLE_set_string_native(interp, sig_pmc, type_name);
+            }
+            else {
+                sig_pmc = pmc_new(interp, enum_class_Integer);
+                VTABLE_set_integer_native(interp, sig_pmc, type_num);
+            }
         }
         else {
             PARROT_ASSERT(r->set == 'K');

Modified: trunk/src/multidispatch.c
==============================================================================
--- trunk/src/multidispatch.c	(original)
+++ trunk/src/multidispatch.c	Tue Dec 30 13:04:44 2008
@@ -981,6 +981,9 @@
             if (type == enum_type_undef)
                 return PMCNULL;
         }
+        else if (sig_elem->vtable->base_type == enum_class_Integer) {
+            type = VTABLE_get_integer(interp, sig_elem);
+        }
         else
             type = pmc_type_p(interp, sig_elem);
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About