Permalink
Browse files

[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%.

git-svn-id: https://svn.parrot.org/parrot/trunk@38779 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
chromatic committed May 14, 2009
1 parent c4cd281 commit 9ed2bdcff4f9f32f71ffef5fc005fc07b496b96e
Showing with 16 additions and 9 deletions.
  1. +11 −6 src/multidispatch.c
  2. +5 −3 src/pmc/nci.pmc
View
@@ -798,8 +798,8 @@ mmd_cvt_to_types(PARROT_INTERP, ARGIN(PMC *multi_sig))
*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 @@ mmd_distance(PARROT_INTERP, ARGIN(PMC *pmc), ARGIN(PMC *arg_tuple))
/* 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 @@ Parrot_mmd_add_multi_list_from_c_args(PARROT_INTERP,
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 @@ Parrot_mmd_add_multi_list_from_c_args(PARROT_INTERP,
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);
View
@@ -98,12 +98,14 @@ void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_in
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 (?) */
/*

0 comments on commit 9ed2bdc

Please sign in to comment.