diff options
author | Pekka Enberg <penberg@kernel.org> | 2011-09-19 17:10:08 +0300 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2011-09-19 17:10:08 +0300 |
commit | 65d441d7c2b8c2dcd43da0f398ca11e0f4b4de43 (patch) | |
tree | c75ee94b835762e5fc4765960d45ca5028147362 /include | |
parent | 4700c1d3c058a8fe6e363029ca38817e9a15f3e8 (diff) | |
download | jato-65d441d7c2b8c2dcd43da0f398ca11e0f4b4de43.tar.gz |
jit: Kill compile lock from 'struct compilation_unit'
This patch re-implements the 'struct compilation_unit' parts of commit 4c197c5
("jit: Kill "compile lock" locking primitive") without breaking lusearch.
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/jit/compilation-unit.h | 26 | ||||
-rw-r--r-- | include/vm/method.h | 5 |
2 files changed, 26 insertions, 5 deletions
diff --git a/include/jit/compilation-unit.h b/include/jit/compilation-unit.h index 42c4eb02..c5a6c5fa 100644 --- a/include/jit/compilation-unit.h +++ b/include/jit/compilation-unit.h @@ -10,7 +10,6 @@ #include "lib/list.h" #include "lib/radix-tree.h" #include "lib/stack.h" -#include "lib/compile-lock.h" #include "vm/static.h" #include "vm/types.h" @@ -25,6 +24,13 @@ struct vm_method; struct insn; enum machine_reg; +enum compilation_state { + COMPILATION_STATE_INITIAL, + COMPILATION_STATE_COMPILING, + COMPILATION_STATE_COMPILED, + COMPILATION_STATE_ERROR, +}; + struct compilation_unit { struct vm_method *method; unsigned long nr_bb; @@ -43,7 +49,11 @@ struct compilation_unit { /* Contains the number of uses of any bytecode within the method */ uint16_t bytecode_stats[NR_OPCS]; - struct compile_lock compile_lock; + /* Mutex that protects ->state */ + pthread_mutex_t compile_mutex; + + /* See enum compilation_state for values */ + unsigned long state; pthread_mutex_t mutex; @@ -170,6 +180,18 @@ static inline void *cu_ic_entry_point(struct compilation_unit *cu) return cu->ic_entry_point; } +unsigned long compilation_unit_get_state(struct compilation_unit *cu); + +static inline bool compilation_unit_is_compiled(struct compilation_unit *cu) +{ + /* Optimistic unlocked check */ + if (cu->state == COMPILATION_STATE_COMPILED) + return true; + + /* Slowpath */ + return compilation_unit_get_state(cu) == COMPILATION_STATE_COMPILED; +} + struct compilation_unit *compilation_unit_alloc(struct vm_method *); int init_stack_slots(struct compilation_unit *cu); void free_compilation_unit(struct compilation_unit *); diff --git a/include/vm/method.h b/include/vm/method.h index 8431b452..d938701a 100644 --- a/include/vm/method.h +++ b/include/vm/method.h @@ -156,8 +156,7 @@ static inline bool vm_method_is_special(struct vm_method *vmm) static inline bool vm_method_is_compiled(struct vm_method *vmm) { - return compile_lock_get_status(&vmm->compilation_unit->compile_lock) - == STATUS_COMPILED_OK; + return compilation_unit_is_compiled(vmm->compilation_unit); } static inline enum vm_type method_return_type(struct vm_method *method) @@ -186,7 +185,7 @@ static inline void *vm_method_call_ptr(struct vm_method *vmm) { void *result; - if (compile_lock_get_status(&vmm->compilation_unit->compile_lock) == STATUS_COMPILED_OK) + if (vm_method_is_compiled(vmm)) result = vm_method_entry_point(vmm); else result = vm_method_trampoline_ptr(vmm); |