aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2012-04-27 19:20:33 +0000
committerPekka Enberg <penberg@kernel.org>2012-04-27 19:26:00 +0000
commit2a109fb51efbc8d32313c412f717bee4df32e4f2 (patch)
tree9e3477079027b52ba150ffe18fa855aa3306e9c9
parent5e166fa537797513ffcdd75a90c97f2ea033b5c8 (diff)
downloadjato-2a109fb51efbc8d32313c412f717bee4df32e4f2.tar.gz
x86: Simplify IC code wrt. return address and call-site
This patch simplifies the inline caching code by separating 'return addresses' from 'call-sites'. Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--arch/x86/inline-cache.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/x86/inline-cache.c b/arch/x86/inline-cache.c
index e8693de5..632b7dff 100644
--- a/arch/x86/inline-cache.c
+++ b/arch/x86/inline-cache.c
@@ -32,14 +32,14 @@ static pthread_mutex_t ic_patch_lock = PTHREAD_MUTEX_INITIALIZER;
static void ic_from_callsite(struct x86_ic *ic, unsigned long callsite)
{
- ic->fn = callsite - X86_CALL_INSN_SIZE + X86_CALL_DISP_OFFSET;
+ ic->fn = callsite + X86_CALL_DISP_OFFSET;
- ic->imm = callsite - X86_CALL_INSN_SIZE - X86_MOV_IMM_REG_INSN_SIZE + X86_MOV_IMM_REG_IMM_OFFSET;
+ ic->imm = callsite - X86_MOV_IMM_REG_INSN_SIZE + X86_MOV_IMM_REG_IMM_OFFSET;
}
static inline unsigned long x86_call_disp(void *callsite, void *target)
{
- return (unsigned long) target - (unsigned long) callsite;
+ return (unsigned long) target - (unsigned long) callsite - X86_CALL_INSN_SIZE;
}
static inline bool is_valid_ic(struct x86_ic *ic)
@@ -134,8 +134,9 @@ static void ic_set_to_megamorphic(struct vm_method *vmm, void *callsite)
die("Failed to unlock ic_patch_lock\n");
}
-void *do_ic_setup(struct vm_class *vmc, struct vm_method *i_vmm, void *callsite)
+void *do_ic_setup(struct vm_class *vmc, struct vm_method *i_vmm, void *return_addr)
{
+ void *callsite = return_addr - X86_CALL_INSN_SIZE;
struct compilation_unit *cu;
struct vm_method *c_vmm;
void *entry_point;
@@ -225,8 +226,11 @@ int convert_ic_calls(struct compilation_unit *cu)
return 0;
}
-void *resolve_ic_miss(struct vm_class *vmc, struct vm_method *vmm, void *callsite)
+void *resolve_ic_miss(struct vm_class *vmc, struct vm_method *vmm, void *return_addr)
{
+ void *callsite = return_addr - X86_CALL_INSN_SIZE;
+
ic_set_to_megamorphic(vmm, callsite);
+
return ic_lookup_vtable(vmc, vmm);
}