]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Make _jit_cache_create() figure cache parameters from context metadata itself.
authorAleksey Demakov <ademakov@gmail.com>
Fri, 12 Oct 2012 17:34:26 +0000 (21:34 +0400)
committerAleksey Demakov <ademakov@gmail.com>
Fri, 12 Oct 2012 17:34:26 +0000 (21:34 +0400)
jit/jit-cache.c
jit/jit-cache.h
jit/jit-context.c

index 088b71ed1aa00fbeb2029085e895068586fc8a52..c4b39511d1e36d12fa71c5f7bd9e87c9351eddbe 100644 (file)
@@ -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)
        {
index 88889ef0abc44cbedd8e66a3bf37cdfd9ac578b7..5f23d0266a7e6ea72f932c63f1bed6141b3de773 100644 (file)
@@ -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.
index c1ab3bf0a54d11bb24f55262da8f2df09cc90442..db66fc4d803f5fb77ce5892fad30ee68bcec549e 100644 (file)
@@ -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;
 }