[svn:parrot] r38779 - in trunk/src: . pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Thu May 14 21:45:03 UTC 2009
Author: chromatic
Date: Thu May 14 21:45:02 2009
New Revision: 38779
URL: https://trac.parrot.org/parrot/changeset/38779
Log:
[MMD] Changed MULTI initialization to delay generating type typles of candidate
NCIs until the point of a multi call for which they are valid variants.
(There's probably another optimization here.) This avoids a lot of temporary
STRING creation and manipulation for MULTIs which may never get called and
improves Parrot's startup time by 14.81%.
Modified:
trunk/src/multidispatch.c
trunk/src/pmc/nci.pmc
Modified: trunk/src/multidispatch.c
==============================================================================
--- trunk/src/multidispatch.c Thu May 14 21:33:50 2009 (r38778)
+++ trunk/src/multidispatch.c Thu May 14 21:45:02 2009 (r38779)
@@ -798,8 +798,8 @@
*sub_pmc)>
Get the cached multisig of the given sub, if one exists. The cached signature
-might be in different formats, so put it into a type tuple like is expected
-by the rest of the MMD system.
+might be in different formats, so put it into a type tuple like the rest of the
+MMD system expects.
=cut
@@ -857,6 +857,13 @@
/* has to be a builtin multi method */
if (pmc->vtable->base_type == enum_class_NCI) {
GETATTR_NCI_multi_sig(interp, pmc, multi_sig);
+ if (PMC_IS_NULL(multi_sig)) {
+ STRING *long_sig;
+
+ GETATTR_NCI_long_signature(interp, pmc, long_sig);
+ multi_sig = mmd_build_type_tuple_from_long_sig(interp, long_sig);
+ SETATTR_NCI_multi_sig(interp, pmc, multi_sig);
+ }
}
else {
/* not a multi; no distance */
@@ -1346,10 +1353,8 @@
STRING *short_sig = mmd_info[i].short_sig;
STRING *ns_name = mmd_info[i].ns_name;
- /* Create an NCI sub for the C function */
+ /* Create an NCI sub for the C function */
PMC *sub_obj = constant_pmc_new(interp, enum_class_NCI);
- PMC *multi_sig = mmd_build_type_tuple_from_long_sig(interp,
- long_sig);
#ifdef PARROT_HAS_ALIGNED_FUNCPTR
PARROT_ASSERT((PTR2UINTVAL(func_ptr) & 3) == 0);
@@ -1359,7 +1364,7 @@
F2DPTR(func_ptr));
/* Attach a type tuple array to the NCI sub for multi dispatch */
- SETATTR_NCI_multi_sig(interp, sub_obj, multi_sig);
+ SETATTR_NCI_long_signature(interp, sub_obj, long_sig);
mmd_add_multi_to_namespace(interp, ns_name, sub_name, sub_obj);
mmd_add_multi_global(interp, sub_name, sub_obj);
Modified: trunk/src/pmc/nci.pmc
==============================================================================
--- trunk/src/pmc/nci.pmc Thu May 14 21:33:50 2009 (r38778)
+++ trunk/src/pmc/nci.pmc Thu May 14 21:45:02 2009 (r38779)
@@ -98,12 +98,14 @@
pmclass NCI need_ext {
ATTR STRING *signature; /* The signature. */
- ATTR void *func; /* Function pointer to what we'll call. */
- ATTR void *orig_func; /* Function pointer used to create func*/
+ ATTR void *func; /* Function pointer to call. */
+ ATTR void *orig_func; /* Function pointer
+ * used to create func */
ATTR STRING *pcc_params_signature; /* The signature. */
+ ATTR STRING *long_signature; /* The full signature. */
+ ATTR PMC *multi_sig; /* type tuple array (?) */
ATTR INTVAL arity; /* Cached arity of the NCI. */
ATTR INTVAL jitted; /* Is this a jitted NCI stub. */
- ATTR PMC *multi_sig; /* type tuple array (?) */
/*
More information about the parrot-commits
mailing list