Skip to content

Commit

Permalink
Merge branch 'mmd-cache-pmc'
Browse files Browse the repository at this point in the history
  • Loading branch information
cotto committed Mar 3, 2011
2 parents db77547 + 259ae36 commit ecc49a6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 42 deletions.
12 changes: 2 additions & 10 deletions include/parrot/multidispatch.h
Expand Up @@ -16,6 +16,7 @@
#include "parrot/parrot.h"

#define PARROT_MMD_MAX_CLASS_DEPTH 1000
#define Parrot_mmd_cache_destroy(x, y)

/* function typedefs */
typedef PMC* (*mmd_f_p_ppp)(PARROT_INTERP, PMC *, PMC *, PMC *);
Expand Down Expand Up @@ -53,7 +54,7 @@ typedef struct _multi_func_list {
funcptr_t func_ptr;
} multi_func_list;

#define MMD_Cache Hash
#define MMD_Cache PMC

/* HEADERIZER BEGIN: src/multidispatch.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
Expand Down Expand Up @@ -100,12 +101,6 @@ PARROT_CANNOT_RETURN_NULL
MMD_Cache * Parrot_mmd_cache_create(PARROT_INTERP)
__attribute__nonnull__(1);

PARROT_EXPORT
void Parrot_mmd_cache_destroy(PARROT_INTERP, ARGMOD(MMD_Cache *cache))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
FUNC_MODIFIES(*cache);

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CAN_RETURN_NULL
Expand Down Expand Up @@ -227,9 +222,6 @@ PMC * Parrot_mmd_sort_manhattan_by_sig_pmc(PARROT_INTERP,
, PARROT_ASSERT_ARG(sig_obj))
#define ASSERT_ARGS_Parrot_mmd_cache_create __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_mmd_cache_destroy __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(cache))
#define ASSERT_ARGS_Parrot_mmd_cache_lookup_by_types \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
Expand Down
4 changes: 4 additions & 0 deletions src/call/context.c
Expand Up @@ -74,6 +74,8 @@ static void allocate_registers(PARROT_INTERP,
__attribute__nonnull__(2)
__attribute__nonnull__(3);

PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
static size_t calculate_registers_size(SHIM_INTERP,
ARGIN(const UINTVAL *number_regs_used))
__attribute__nonnull__(2);
Expand All @@ -87,6 +89,8 @@ static void init_context(ARGMOD(PMC *pmcctx), ARGIN_NULLOK(PMC *pmcold))
__attribute__nonnull__(1)
FUNC_MODIFIES(*pmcctx);

PARROT_WARN_UNUSED_RESULT
PARROT_PURE_FUNCTION
static size_t Parrot_pcc_calculate_registers_size(PARROT_INTERP,
ARGIN(const UINTVAL *number_regs_used))
__attribute__nonnull__(1)
Expand Down
12 changes: 5 additions & 7 deletions src/interp/inter_create.c
Expand Up @@ -210,9 +210,6 @@ initialize_interpreter(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
*/
Parrot_str_init(interp);

/* Set up MMD; MMD cache for builtins. */
interp->op_mmd_cache = Parrot_mmd_cache_create(interp);

/* create caches structure */
init_object_cache(interp);

Expand All @@ -222,7 +219,11 @@ initialize_interpreter(PARROT_INTERP, ARGIN(Parrot_GC_Init_Args *args))
Parrot_vtbl_initialize_core_vtables(interp);

/* create the root set registry */
interp->gc_registry = Parrot_pmc_new(interp, enum_class_AddrRegistry);
interp->gc_registry = Parrot_pmc_new(interp, enum_class_AddrRegistry);

/* Set up MMD; MMD cache for builtins. */
interp->op_mmd_cache = Parrot_mmd_cache_create(interp);
Parrot_pmc_gc_register(interp, interp->op_mmd_cache);

Parrot_gbl_init_world_once(interp);

Expand Down Expand Up @@ -432,9 +433,6 @@ Parrot_really_destroy(PARROT_INTERP, SHIM(int exit_code), SHIM(void *arg))

Parrot_gc_mark_and_sweep(interp, GC_finish_FLAG);

/* MMD cache */
Parrot_mmd_cache_destroy(interp, interp->op_mmd_cache);

/* copies of constant tables */
Parrot_destroy_constants(interp);

Expand Down
31 changes: 6 additions & 25 deletions src/multidispatch.c
Expand Up @@ -1109,7 +1109,7 @@ Parrot_mmd_cache_create(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_mmd_cache_create)
/* String hash. */
Hash *cache = Parrot_hash_new(interp);
PMC *cache = Parrot_pmc_new(interp, enum_class_Hash);
return cache;
}

Expand Down Expand Up @@ -1184,7 +1184,7 @@ Parrot_mmd_cache_lookup_by_values(PARROT_INTERP, ARGMOD(MMD_Cache *cache),
STRING * const key = mmd_cache_key_from_values(interp, name, values);

if (key)
return (PMC *)Parrot_hash_get(interp, cache, key);
return VTABLE_get_pmc_keyed_str(interp, cache, key);

return PMCNULL;
}
Expand All @@ -1211,7 +1211,7 @@ Parrot_mmd_cache_store_by_values(PARROT_INTERP, ARGMOD(MMD_Cache *cache),
STRING * const key = mmd_cache_key_from_values(interp, name, values);

if (key)
Parrot_hash_put(interp, cache, key, chosen);
VTABLE_set_pmc_keyed_str(interp, cache, key, chosen);
}


Expand Down Expand Up @@ -1287,7 +1287,7 @@ Parrot_mmd_cache_lookup_by_types(PARROT_INTERP, ARGMOD(MMD_Cache *cache),
const STRING * const key = mmd_cache_key_from_types(interp, name, types);

if (key)
return (PMC *)Parrot_hash_get(interp, cache, key);
return VTABLE_get_pmc_keyed_str(interp, cache, key);

return PMCNULL;
}
Expand Down Expand Up @@ -1315,7 +1315,7 @@ Parrot_mmd_cache_store_by_types(PARROT_INTERP, ARGMOD(MMD_Cache *cache),
STRING * const key = mmd_cache_key_from_types(interp, name, types);

if (key)
Parrot_hash_put(interp, cache, key, chosen);
VTABLE_set_pmc_keyed_str(interp, cache, key, chosen);
}


Expand All @@ -1337,26 +1337,7 @@ Parrot_mmd_cache_mark(PARROT_INTERP, ARGMOD(MMD_Cache *cache))
/* As a small future optimization, note that we only *really* need to mark
* keys - the candidates will be referenced outside the cache, provided it's
* invalidated properly. */
Parrot_hash_mark(interp, cache);
}


/*
=item C<void Parrot_mmd_cache_destroy(PARROT_INTERP, MMD_Cache *cache)>
Destroys an MMD cache.
=cut
*/

PARROT_EXPORT
void
Parrot_mmd_cache_destroy(PARROT_INTERP, ARGMOD(MMD_Cache *cache))
{
ASSERT_ARGS(Parrot_mmd_cache_destroy)
Parrot_hash_destroy(interp, cache);
Parrot_gc_mark_PMC_alive(interp, cache);
}


Expand Down

0 comments on commit ecc49a6

Please sign in to comment.