]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
2006-12-17 Klaus Treichel <ktreichel@web.de>
authorKlaus Treichel <ktreichel@web.de>
Sun, 17 Dec 2006 21:06:26 +0000 (21:06 +0000)
committerKlaus Treichel <ktreichel@web.de>
Sun, 17 Dec 2006 21:06:26 +0000 (21:06 +0000)
* include/jit/jit-function.h, jit/jit-function.c: Add the function
jit_function_from_vtable_pointer to convert a vtable pointer back to the
jit_function_t.

ChangeLog
include/jit/jit-function.h
jit/jit-function.c

index c6b13351bc25d3f7fb5773f03a13e8d662037e95..f4465345272fb3ae42476d5e35d66c70eadd3ca1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-17  Klaus Treichel  <ktreichel@web.de>
+
+       * include/jit/jit-function.h, jit/jit-function.c: Add the function
+       jit_function_from_vtable_pointer to convert a vtable pointer back to the
+       jit_function_t.
+
 2006-11-29  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-reg-alloc.c (save_value): fix bug freeing stack register
index cd5e5d614378ebd40904dec67b51a698a249a603..7e5e7a999e6726742c415bca4ff149ed89aa57a2 100644 (file)
@@ -59,6 +59,8 @@ jit_function_t jit_function_from_closure
 jit_function_t jit_function_from_pc
        (jit_context_t context, void *pc, void **handler) JIT_NOTHROW;
 void *jit_function_to_vtable_pointer(jit_function_t func) JIT_NOTHROW;
+jit_function_t jit_function_from_vtable_pointer
+       (jit_context_t context, void *vtable_pointer) JIT_NOTHROW;
 void jit_function_set_on_demand_compiler
                (jit_function_t func, jit_on_demand_func on_demand) JIT_NOTHROW;
 int jit_function_apply
index 4f618fd03c93e20dcafe7d4d5c672887e971583c..d92229474f59bf675dac9a01de5fade9d1c99152 100644 (file)
@@ -1138,6 +1138,34 @@ void *jit_function_to_vtable_pointer(jit_function_t func)
 #endif
 }
 
+/*@
+ * @deftypefun jit_function_t jit_function_from_vtable_pointer (jit_context_t context, {void *} vtable_pointer)
+ * Convert a vtable_pointer back into a function.  Returns NULL if the
+ * vtable_pointer does not correspond to a function in the specified context.
+ * @end deftypefun
+@*/
+jit_function_t jit_function_from_vtable_pointer(jit_context_t context, void *vtable_pointer)
+{
+#ifdef JIT_BACKEND_INTERP
+       /* In the interpreted version, the function pointer is used in vtables */
+       jit_function_t func = (jit_function_t)vtable_pinter;
+
+       if(func && func->context == context)
+       {
+               return func;
+       }
+       return 0;
+#else
+       void *cookie;
+       if(!context || !(context->cache))
+       {
+               return 0;
+       }
+       return (jit_function_t)_jit_cache_get_method
+               (context->cache, vtable_pointer, &cookie);
+#endif
+}
+
 /*@
  * @deftypefun void jit_function_set_on_demand_compiler (jit_function_t func, jit_on_demand_func on_demand)
  * Specify the C function to be called when @code{func} needs to be