[PATCH 17/22] x86-64: set state->reg1 in EXPR_ARG(reg) rule

2009-07-25 Thread Eduard - Gabriel Munteanu
This fixes an issue where state->reg1 wasn't properly set on x86-64. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg index b32fedf..5ef161

[PATCH 22/22] x86-64: pass arguments correctly to fixup_vtable()

2009-07-25 Thread Eduard - Gabriel Munteanu
This fixes the improper passing of arguments to fixup_vtable() from within trampolines. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index 5b3ab70..f

[PATCH 21/22] x86-64: refactor register parameter support

2009-07-25 Thread Eduard - Gabriel Munteanu
This refactoring introduces a general mechanism usable by other arches to provide argument passing in registers. Developers of other arches where this applies need only write a parser that allocates registers for arguments. The additional code and data structure support is controlled by CONFIG_ARGS

[PATCH 13/22] x86-64: fix EXPR_NEW

2009-07-25 Thread Eduard - Gabriel Munteanu
This fixes the handling of EXPR_NEW, to make it suitable on x86-64. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg | 23 ++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg inde

[PATCH 20/22] x86-64: use GPR_VM_TYPE in select_exception_test()

2009-07-25 Thread Eduard - Gabriel Munteanu
We use GPR_VM_TYPE instead of J_INT, because the former expands to J_LONG on x86-64. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg index bf8

[PATCH 18/22] x86-64: implement INSN_CALL_REG

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements the emitter for INSN_CALL_REG. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index a1f0f3c..47bd429 100644 --- a/arch/x86/emit-code.

[PATCH 19/22] x86-64: don't use imm_membase_insn() to set fields

2009-07-25 Thread Eduard - Gabriel Munteanu
There's no 64-bit operand size imm->membase move instruction on x86-64. Therefore, we first do an imm->reg move, then a reg->membase move. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c|8 +++ arch/x86/include/arch/instruction.h |1 + arch/x86/insn-sele

[PATCH 15/22] x86-64: make vm_native_call() a stub

2009-07-25 Thread Eduard - Gabriel Munteanu
This makes vm_native_call() a stub which will be properly implemented later. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/include/arch/call.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/arch/call.h b/arch/x86/include/arch/call.h index abba90

[PATCH 16/22] x86-64: implement other INSN_*_THREAD_LOCAL_*

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements the rest of the emitters for INSN_*_THREAD_LOCAL_*, where this is useful on x86-64. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 40 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-cod

[PATCH 14/22] x86-64: don't alter the tree in the insn selector

2009-07-25 Thread Eduard - Gabriel Munteanu
We shouldn't alter the tree from the instruction selector. Instead, we should implement copy propagation later. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg | 11 +++ 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/x86/insn-selector.brg b/

[PATCH 08/22] x86-64: implement INSN_CMP_*

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements emitters for INSN_CMP_* instructions. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 38 ++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index 46c586a..c54f42

[PATCH 12/22] x86-64: fix newarray instruction selection

2009-07-25 Thread Eduard - Gabriel Munteanu
This fixes the implementation of newarray selectors on x86-64. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg | 43 ++- 1 files changed, 42 insertions(+), 1 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-se

[PATCH 09/22] x86-64: implement INSN_MOV_THREAD_LOCAL_MEMDISP_REG

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements the emitter for INSN_MOV_THREAD_LOCAL_MEMDISP_REG. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index c54f428..c9bdae4 100644 --- a

[PATCH 07/22] x86-64: implement INSN_MOV_REG_MEMDISP

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements emitters for INSN_MOV_REG_MEMDISP. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index 5a5d006..46c586a 100644 --- a/arch/x8

[PATCH 06/22] x86-64: fix JNI argument passing

2009-07-25 Thread Eduard - Gabriel Munteanu
This fixes problems encountered with passing arguments in case of JNI. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/args.c | 14 ++ 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/args.c b/arch/x86/args.c index c52f3cd..5b5a740 100644 --- a/arch/x8

[PATCH 04/22] x86-64: fix J_LONG handling in binary ops

2009-07-25 Thread Eduard - Gabriel Munteanu
On x86-64 we can use 64-bit operands directly, unlike on x86-32. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg | 201 ++-- 1 files changed, 64 insertions(+), 137 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/in

[PATCH 11/22] x86-64: use vm parser functions to handle arguments

2009-07-25 Thread Eduard - Gabriel Munteanu
We reuse the existing code for parsing the vm_method->type string. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/args.c| 22 +++--- include/vm/types.h |1 + vm/types.c |2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/x86/ar

[PATCH 05/22] x86-64: fix STMT_RETURN

2009-07-25 Thread Eduard - Gabriel Munteanu
J_LONG values should be returned in a 64-bit register on x86-64. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/insn-selector.brg | 18 ++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg index 184874

[PATCH 03/22] x86-64: implement INSN_MOV_REG_MEMLOCAL

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements the emitter for INSN_MOV_REG_MEMLOCAL. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 40 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index 2f1a810..5a5

[PATCH 10/22] x86-64: implement INSN_MOV_MEMDISP_REG

2009-07-25 Thread Eduard - Gabriel Munteanu
This implements the emitter for INSN_MOV_MEMDISP_REG. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/emit-code.c | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c index c9bdae4..239d91a 100644 --- a/arch/x86/emit

[PATCH 02/22] x86-64: prevent disabling of frame pointer

2009-07-25 Thread Eduard - Gabriel Munteanu
On x86-64, GCC disables frame pointers at optimization levels beyond -O0. This works correctly for debuggers such as GDB because they use debugging information available by default on x86-64. But stack traversal code within Jato no longer works, so we prevent disabling frame pointers at any optimiz

[PATCH 01/22] x86-64: make native_call() a stub

2009-07-25 Thread Eduard - Gabriel Munteanu
This makes the function a stub which will be actually implemented later. Signed-off-by: Eduard - Gabriel Munteanu --- arch/x86/include/arch/call.h |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/arch/x86/include/arch/call.h b/arch/x86/include/arch/call.h index bc9e9ec.

[PATCH 18/22] vm: pass correct call site address to vm_enter_jni()

2009-07-25 Thread Tomek Grabiec
This is needed for native stack trace printing Signed-off-by: Tomek Grabiec --- vm/call.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/vm/call.c b/vm/call.c index 6041494..11c9dca 100644 --- a/vm/call.c +++ b/vm/call.c @@ -64,9 +64,10 @@ vm_call_method_a(struct vm

[PATCH 14/22] vm: make frame pointed by bottom_stack_frame be included in stack trace

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- vm/stack-trace.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vm/stack-trace.c b/vm/stack-trace.c index 30c0595..4e9638b 100644 --- a/vm/stack-trace.c +++ b/vm/stack-trace.c @@ -162,6 +162,9 @@ static int get_caller_stack_trace_el

[PATCH 15/22] vm: let bottom_stack_frame be NULL outside main() java method.

2009-07-25 Thread Tomek Grabiec
If bottom_stack_frame is not NULL and stack walker is called from outside main() function then it could loop forever. Stack walker can be called in the future outside main() to print the stack trace. Signed-off-by: Tomek Grabiec --- vm/jato.c |2 ++ 1 files changed, 2 insertions(+), 0 deleti

[PATCH 07/22] jit: rename throw_exception_from() to throw_from_jit()

2009-07-25 Thread Tomek Grabiec
also rename throw_exception_from_trampoline() to throw_from_trampoline() and throw_exception_from_signal() to throw_from_signal(). Signed-off-by: Tomek Grabiec --- arch/x86/exception.c|8 arch/x86/unwind_32.S|2 +- arch/x86/unwind_64.S|2 +- include/jit/exception

[PATCH 16/22] vm: cleanups in vm/stack-trace.c

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- include/vm/stack-trace.h | 20 + vm/jato.c|4 ++- vm/stack-trace.c | 69 ++--- 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/include/vm/stack-trace.h b/include/

[PATCH 08/22] vm: save and clear exception before printing.

2009-07-25 Thread Tomek Grabiec
When vm_print_exception() is called from JNI then exception that is printed is signalled. Therefore we have to clear exceptions before printing to be able to detect when exception is thrown from printing code. Signed-off-by: Tomek Grabiec --- vm/stack-trace.c |7 +++ 1 files changed, 7 i

[PATCH 11/22] x86: advance JNI and VM native call stack offsets before setting entry values.

2009-07-25 Thread Tomek Grabiec
It is more natural behavior to reserve the space before writing to it. Signed-off-by: Tomek Grabiec --- arch/x86/insn-selector.brg | 36 1 files changed, 20 insertions(+), 16 deletions(-) diff --git a/arch/x86/insn-selector.brg b/arch/x86/insn-selector.brg

[PATCH 01/22] vm: define vm_call_method_*() functions for various return types.

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- include/vm/call.h | 31 ++- vm/call.c | 12 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/include/vm/call.h b/include/vm/call.h index c1ed6bd..557fb86 100644 --- a/include/vm/call.h +++ b/inc

[PATCH 17/22] vm: set ->addr field of stack_trace_elem for JNI methods

2009-07-25 Thread Tomek Grabiec
The ->addr can be set from the return address of ->vm_frame. This makes ->addr field set for all types of stack trace elements. Signed-off-by: Tomek Grabiec --- vm/stack-trace.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/vm/stack-trace.c b/vm/stack-trace.c index

[PATCH 19/22] jit: add compilation unit mapping for trampoline code

2009-07-25 Thread Tomek Grabiec
This is needed to print trampoline's method signature in stack trace. Signed-off-by: Tomek Grabiec --- jit/trampoline.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jit/trampoline.c b/jit/trampoline.c index ba1a495..880a899 100644 --- a/jit/trampoline.c +++ b/j

[PATCH 13/22] vm: make throw_from_signal_bh() a macro

2009-07-25 Thread Tomek Grabiec
Making it a macro rules out the risk of using __builtin_frame_address(). When __builtin_frame_address() is used in a function it is possible that a call to it will be optimized so that new frame is not created. Signed-off-by: Tomek Grabiec --- include/vm/signal.h | 16 test/

[PATCH 20/22] vm: zero line_number_table_attribute for native methods

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- vm/method.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/vm/method.c b/vm/method.c index eb618f2..37bd54d 100644 --- a/vm/method.c +++ b/vm/method.c @@ -95,6 +95,9 @@ int vm_method_init(struct vm_method *vmm, /* Hm, w

[RFC][PATCH 22/22] x86: print mixed native and java backtrace.

2009-07-25 Thread Tomek Grabiec
Backtrace is now printed using the VM stack walker. One advantage of this is that it can recognize JIT, trampoline, VM native and JNI frames. JIT frames have different format than native frames - return address is misplaced so the stamdard backtrace() doesn't work with jit frames involved. Example

[PATCH 21/22] vm: stack_trace_elem_get_cu() should return NULL for non-java elements.

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- vm/stack-trace.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/vm/stack-trace.c b/vm/stack-trace.c index 3d8b723..81ca7aa 100644 --- a/vm/stack-trace.c +++ b/vm/stack-trace.c @@ -306,6 +306,9 @@ void init_stack_trace_elem_current(stru

[PATCH 05/22] vm: remove unnecessary clear_exception() before exception printing

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- vm/jato.c |7 +-- 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/vm/jato.c b/vm/jato.c index 636f6a9..6aa3854 100644 --- a/vm/jato.c +++ b/vm/jato.c @@ -736,12 +736,7 @@ main(int argc, char *argv[]) out_check_exception: if (exce

[PATCH 04/22] vm: remove redundant clear_exception()

2009-07-25 Thread Tomek Grabiec
It is unnecessary to clear exception prior to signaling since signaling overrides any pending exception. Signed-off-by: Tomek Grabiec --- vm/class.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/vm/class.c b/vm/class.c index 915e5e0..a96f1b6 100644 --- a/vm/class.c +++

[PATCH 10/22] jit: remove throw_from_signal()

2009-07-25 Thread Tomek Grabiec
This function can be replaced by signal bottom half with throw_from_signal_bh() call. Less code increases maintainability. Signed-off-by: Tomek Grabiec --- arch/x86/exception.c| 21 - include/jit/exception.h |1 - vm/signal.c |7 ++- 3 files chan

[PATCH 12/22] x86: fix bug in show_exe_function()

2009-07-25 Thread Tomek Grabiec
function_name might be NULL even if bfd_find_nearest_line() returned value != 0. Signed-off-by: Tomek Grabiec --- arch/x86/backtrace.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/x86/backtrace.c b/arch/x86/backtrace.c index 6b2dde4..9fd28b4 100644 --- a/arch/x

[PATCH 09/22] jit: remove unused declaration

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- include/jit/emit-code.h |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/include/jit/emit-code.h b/include/jit/emit-code.h index c9cf8ee..f08bee6 100644 --- a/include/jit/emit-code.h +++ b/include/jit/emit-code.h @@ -40,7 +40,5 @@ extern

[PATCH 02/22] vm: call java methods from VM with vm_call_method()

2009-07-25 Thread Tomek Grabiec
In general we should use vm_call_method() to call methods from VM. Calling methods from VM is not only about calling native function, but we also have to save any pending exceptions before that. Besides that, using vm_call_method() increases maintainability. Calling methods by getting trampoline a

[PATCH 06/22] vm: fix comment in vm_call_method_a()

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- vm/call.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/call.c b/vm/call.c index 718917e..6041494 100644 --- a/vm/call.c +++ b/vm/call.c @@ -48,9 +48,9 @@ vm_call_method_a(struct vm_method *method, unsigned long *args)

[PATCH 03/22] vm: remove junk declaration

2009-07-25 Thread Tomek Grabiec
Signed-off-by: Tomek Grabiec --- vm/jni-interface.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/vm/jni-interface.c b/vm/jni-interface.c index 6a5488c..07cfaa4 100644 --- a/vm/jni-interface.c +++ b/vm/jni-interface.c @@ -262,8 +262,6 @@ vm_jni_call_static_void_method