From 7c3cd3d7c2481a52fe62b5b77ee08bd0be152cd0 Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Tue, 28 Nov 2006 16:10:07 +0000 Subject: [PATCH] applied patch #5503 with some modifications --- ChangeLog | 12 ++++++++++++ jit/jit-rules-x86.c | 18 ++++++++++++++---- jit/jit-rules-x86.ins | 30 ++++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33c63f0..2007c81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-11-27 Kirill Kononenko + + * jit/jit-rules-x86.c (throw_builtin): + * jit/jit-rules-x86.ins (JIT_OP_THROW, JIT_OP_LOAD_PC): directly use + the inst variable to get current PC value for the position-dependent + code case (patch #5503). + 2006-11-27 Aleksey Demakov * include/jit/jit-context.h: add JIT_OPTION_POSITION_INDEPENDENT @@ -7,6 +14,11 @@ * jit/jit-function.c (_jit_function_ensure_builder): initialize position_independent field. + * jit/jit-rules-x86.c (throw_builtin): + * jit/jit-rules-x86.ins (JIT_OP_ADDRESS_OF_LABEL, JIT_OP_JUMP_TABLE) + (JIT_OP_THROW, JIT_OP_LOAD_PC): add position_independent check and + stub missing cases. + 2006-11-26 Kirill Kononenko * jit/jit-rules-x86.ins: if JIT_USE_SIGNALS is defined do not emit diff --git a/jit/jit-rules-x86.c b/jit/jit-rules-x86.c index 11107b8..39b669d 100644 --- a/jit/jit-rules-x86.c +++ b/jit/jit-rules-x86.c @@ -1296,10 +1296,20 @@ static unsigned char *throw_builtin if(func->builder->setjmp_value != 0) { _jit_gen_fix_value(func->builder->setjmp_value); - x86_call_imm(inst, 0); - x86_pop_membase(inst, X86_EBP, - func->builder->setjmp_value->frame_offset + - jit_jmp_catch_pc_offset); + if(func->builder->position_independent) + { + x86_call_imm(inst, 0); + x86_pop_membase(inst, X86_EBP, + func->builder->setjmp_value->frame_offset + + jit_jmp_catch_pc_offset); + } + else + { + int pc = (int) inst; + x86_mov_membase_imm(inst, X86_EBP, + func->builder->setjmp_value->frame_offset + + jit_jmp_catch_pc_offset, pc, 4); + } } /* Push the exception type onto the stack */ diff --git a/jit/jit-rules-x86.ins b/jit/jit-rules-x86.ins index 54257be..e584da7 100644 --- a/jit/jit-rules-x86.ins +++ b/jit/jit-rules-x86.ins @@ -1623,10 +1623,20 @@ JIT_OP_THROW: unary_branch /* We have a "setjmp" block in the current function, so we must record the location of the throw first */ _jit_gen_fix_value(func->builder->setjmp_value); - x86_call_imm(inst, 0); - x86_pop_membase(inst, X86_EBP, - func->builder->setjmp_value->frame_offset + - jit_jmp_catch_pc_offset); + if(func->builder->position_independent) + { + x86_call_imm(inst, 0); + x86_pop_membase(inst, X86_EBP, + func->builder->setjmp_value->frame_offset + + jit_jmp_catch_pc_offset); + } + else + { + int pc = (int) inst; + x86_mov_membase_imm(inst, X86_EBP, + func->builder->setjmp_value->frame_offset + + jit_jmp_catch_pc_offset, pc, 4); + } } x86_call_code(inst, (void *)jit_exception_throw); } @@ -1636,8 +1646,16 @@ JIT_OP_RETHROW: manual JIT_OP_LOAD_PC: [=reg] -> { - x86_call_imm(inst, 0); - x86_pop_reg(inst, $1); + if(func->builder->position_independent) + { + x86_call_imm(inst, 0); + x86_pop_reg(inst, $1); + } + else + { + int pc = (int) inst; + x86_mov_reg_imm(inst, $1, pc); + } } JIT_OP_LOAD_EXCEPTION_PC: manual -- 2.47.3