From: Aleksey Demakov Date: Fri, 12 Oct 2012 17:34:26 +0000 (+0400) Subject: Make _jit_cache_create() figure cache parameters from context metadata itself. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=3cd1f1124b6a693b23fe0d0a12d7680ff6d3e991;p=francis%2Flibjit.git Make _jit_cache_create() figure cache parameters from context metadata itself. --- diff --git a/jit/jit-cache.c b/jit/jit-cache.c index 088b71e..c4b3951 100644 --- a/jit/jit-cache.c +++ b/jit/jit-cache.c @@ -359,11 +359,20 @@ AddToLookupTree(jit_cache_t cache, jit_cache_method_t method) } jit_cache_t -_jit_cache_create(long limit, long cache_page_size, int max_page_factor) +_jit_cache_create(jit_context_t context) { jit_cache_t cache; + long limit, cache_page_size; + int max_page_factor; unsigned long exec_page_size; + limit = (long) + jit_context_get_meta_numeric(context, JIT_OPTION_CACHE_LIMIT); + cache_page_size = (long) + jit_context_get_meta_numeric(context, JIT_OPTION_CACHE_PAGE_SIZE); + max_page_factor = (int) + jit_context_get_meta_numeric(context, JIT_OPTION_CACHE_MAX_PAGE_FACTOR); + /* Allocate space for the cache control structure */ if((cache = (jit_cache_t )jit_malloc(sizeof(struct jit_cache))) == 0) { diff --git a/jit/jit-cache.h b/jit/jit-cache.h index 88889ef..5f23d02 100644 --- a/jit/jit-cache.h +++ b/jit/jit-cache.h @@ -44,9 +44,7 @@ extern "C" { * indicates the maximum cache page size as multiple of * "max_page_factor" and "cache_page_size". */ -jit_cache_t _jit_cache_create(long limit, - long cache_page_size, - int max_page_factor); +jit_cache_t _jit_cache_create(jit_context_t context); /* * Destroy a code cache. diff --git a/jit/jit-context.c b/jit/jit-context.c index c1ab3bf..db66fc4 100644 --- a/jit/jit-context.c +++ b/jit/jit-context.c @@ -312,17 +312,12 @@ void jit_context_free_meta(jit_context_t context, int type) jit_meta_free(&(context->meta), type); } -struct jit_cache *_jit_context_get_cache(jit_context_t context) +struct jit_cache * +_jit_context_get_cache(jit_context_t context) { - if(!(context->cache)) + if(!context->cache) { - context->cache = _jit_cache_create - ((long)jit_context_get_meta_numeric - (context, JIT_OPTION_CACHE_LIMIT), - (long)jit_context_get_meta_numeric - (context, JIT_OPTION_CACHE_PAGE_SIZE), - (int)jit_context_get_meta_numeric - (context, JIT_OPTION_CACHE_MAX_PAGE_FACTOR)); + context->cache = _jit_cache_create(context); } return context->cache; }