Hi Tomek,
On Sun, 2009-05-03 at 21:14 +0200, Tomek Grabiec wrote:
> Motivation: Exception manager will need to translate native
> instruction pointers to bytecode offsets to select appropriate
> exception handler from exception_table.
>
> This solution uses a per-thread variable to store the current bytecode
> offset, which is set before converting a bytecode and before selecting
> instructions for a tree node. HIR (struct expression, struct statement)
> and LIR (struct insn) entities upon allocation assign that variable's
> value to 'bytecode_offset' field.
>
> Signed-off-by: Tomek Grabiec <[email protected]>
> diff --git a/jit/bc-offset-mapping.c b/jit/bc-offset-mapping.c
> new file mode 100644
> index 0000000..e6a9906
> --- /dev/null
> +++ b/jit/bc-offset-mapping.c
> @@ -0,0 +1,115 @@
> +#include <pthread.h>
> +#include <malloc.h>
> +
> +static pthread_key_t bytecode_offset_key;
> +
> +static void key_descructor(void *value)
> +{
> + free(value);
> + pthread_setspecific(bytecode_offset_key, NULL);
> +}
> +
> +void init_bytecode_offset_mapping(void)
> +{
> + pthread_key_create(&bytecode_offset_key, key_descructor);
> +}
[snip]
I don't like this hidden state trick at all which is why I merged commit
acdd32a ("jit: introduce convert_statement() and convert_expression()")
to master. I think you can just use the two new hooks to do the
->bytecode_offset there? There's few cases where a converting a
statement also allocates an expression but those can be handled
separately.
Pekka
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel