-2006-08-22 Klaus treichel <ktreichel@web.de>
-
- * jit/jit-alloc.c: Use mmap and munmap to allocate executable memory
- where available because memory allocated with malloc is not executable
- on some archs/distros.
-
2006-08-23 Aleksey Demakov <ademakov@gmail.com>
+ * jit/jit-internal.h (struct _jit_function): change the type of
+ redirector and indirector fields from char array to pointer.
+ * jit/jit-function.c (jit_function_create): allocate the redirector
+ and indirector buffers in the code cache. Call jit_flush_exec on
+ these buffers.
+ * jit/jit-rules-x86.c (_jit_gen_redirector): ifdef out as this
+ function is not used with the x86 backend.
+
* jit/jit-reg-alloc.c: improve handling of three-address op codes.
Now the dest register may re-use one of the input registers while
previously it was always assigned to a separate register. Also
ops for x86 as three-address. Adjust IREM ops so that they work
correctly together with the latest allocator changes.
+2006-08-22 Klaus Treichel <ktreichel@web.de>
+
+ * jit/jit-alloc.c: Use mmap and munmap to allocate executable memory
+ where available because memory allocated with malloc is not executable
+ on some archs/distros.
+
2006-08-21 Thomas Cort <linuxgeek@gmail.com>
* jit/jit-rules-alpha.c jit/jit-gen-alpha.h: Add macros for
int to fp and fp to int conversions. Use _jit_pad_bufer.
jit_function_t jit_function_create(jit_context_t context, jit_type_t signature)
{
jit_function_t func;
+#if defined(jit_redirector_size) || defined(jit_indirector_size)
+ jit_cache_t cache;
+#endif
/* Allocate memory for the function and clear it */
func = jit_cnew(struct _jit_function);
return 0;
}
+#if defined(jit_redirector_size) || defined(jit_indirector_size)
+ /* TODO: if the function is destroyed the redirector and indirector memory
+ is leaked */
+
+ /* We need the cache lock while we are allocating redirector and indirector */
+ jit_mutex_lock(&(context->cache_lock));
+
+ /* Get the method cache */
+ cache = _jit_context_get_cache(context);
+ if(!cache)
+ {
+ jit_mutex_unlock(&(context->cache_lock));
+ jit_free(func);
+ return 0;
+ }
+
+# if defined(jit_redirector_size)
+ /* Allocate redirector buffer */
+ func->redirector = _jit_cache_alloc_no_method(cache, jit_redirector_size, 1);
+ if(!func->redirector)
+ {
+ jit_mutex_unlock(&(context->cache_lock));
+ jit_free(func);
+ return 0;
+ }
+# endif
+# if defined(jit_indirector_size)
+ /* Allocate indirector buffer */
+ func->indirector = _jit_cache_alloc_no_method(cache, jit_indirector_size, 1);
+ if(!func->indirector)
+ {
+ jit_mutex_unlock(&(context->cache_lock));
+ jit_free(func);
+ return 0;
+ }
+# endif
+
+ jit_mutex_unlock(&(context->cache_lock));
+#endif
+
/* Initialize the function block */
func->context = context;
func->signature = jit_type_copy(signature);
func->entry_point = _jit_create_redirector
(func->redirector, (void *)_jit_function_compile_on_demand,
func, jit_type_get_abi(signature));
+ jit_flush_exec(func->redirector, jit_redirector_size);
# if defined(jit_indirector_size)
func->closure_entry = _jit_create_indirector
(func->indirector, (void**) &(func->entry_point));
+ jit_flush_exec(func->indirector, jit_indirector_size);
# else
func->closure_entry = func->entry_point;
# endif
#ifdef jit_redirector_size
/* Buffer that contains the redirector for this function.
Redirectors are used to support on-demand compilation */
- unsigned char redirector[jit_redirector_size];
+ unsigned char *redirector;
#endif
#ifdef jit_indirector_size
/* Buffer that contains the indirector for this function.
The indirector is used to jump either to the function
redirector or the compiled function itself. */
- unsigned char indirector[jit_indirector_size];
+ unsigned char *indirector;
#endif
};
gen->posn.ptr = inst;
}
+#if 0
+/*
+ * The x86 backend does not need this function because it uses
+ * _jit_create_indirector() instead.
+ */
void *_jit_gen_redirector(jit_gencode_t gen, jit_function_t func)
{
void *ptr, *entry;
x86_jump_mem(gen->posn.ptr, ptr);
return entry;
}
+#endif
/*
* Setup or teardown the x86 code output process.