From 28180292407810e1a7c97278b9b326246856f91b Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Thu, 10 Jan 2008 01:41:07 +0100 Subject: [PATCH] * src/vm/jit/python.c: (python_global_lock) added, (pythonpass_init) creating python lock, (pythonpass_run) locking python lock. * src/vm/jit/jit.c [ENABLE_PYTHON]: Changed name of hardcoded function. --- src/vm/jit/jit.c | 2 +- src/vm/jit/python.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c index ae68ce20b..0c0c17246 100644 --- a/src/vm/jit/jit.c +++ b/src/vm/jit/jit.c @@ -1464,7 +1464,7 @@ static u1 *jit_compile_intern(jitdata *jd) #endif #if defined(ENABLE_PYTHON) - if (!pythonpass_run(jd, "langauer_tarjan", "langauer_tarjan")) { + if (!pythonpass_run(jd, "langauer_tarjan", "main")) { /*return NULL;*/ } #endif diff --git a/src/vm/jit/python.c b/src/vm/jit/python.c index c9bd45279..918beca08 100644 --- a/src/vm/jit/python.c +++ b/src/vm/jit/python.c @@ -61,8 +61,16 @@ #include +#include "vm/global.h" #include "vm/jit/python.h" #include "vm/jit/show.h" +#if defined(ENABLE_THREADS) +# include "threads/lock-common.h" +#endif + +#if defined(ENABLE_THREADS) +static java_object_t *python_global_lock; +#endif /* * Defs @@ -175,6 +183,8 @@ enum field { F_OPCODE, F_OPCODE_EX, F_PARAM_TYPES, + F_PEI, + F_PEI_EX, F_PREDECESSORS, F_REACHED, F_RETURN_TYPE, @@ -214,6 +224,8 @@ struct field_map_entry field_map[] = { { "opcode", F_OPCODE }, { "opcode_ex", F_OPCODE_EX }, { "param_types", F_PARAM_TYPES }, + { "pei", F_PEI }, + { "pei_ex", F_PEI_EX }, { "predecessors", F_PREDECESSORS }, { "reached", F_REACHED }, { "return_type", F_RETURN_TYPE }, @@ -729,6 +741,14 @@ CLASS_FUNC(instruction_func) { return get_int(arg->get.result, iptr->line); case F_SHOW: return get_obj(arg->get.result, instruction_show_func, state->jd, iptr); + case F_PEI: + return get_bool(arg->get.result, icmd_table[iptr->opc].flags & ICMDTABLE_PEI); + case F_PEI_EX: + if (iptr->opc == ICMD_BUILTIN) { + return get_bool(arg->get.result, icmd_table[iptr->sx.s23.s3.bte->opcode].flags & ICMDTABLE_PEI); + } else { + return get_bool(arg->get.result, icmd_table[iptr->opc].flags & ICMDTABLE_PEI); + } } } @@ -1063,6 +1083,11 @@ void pythonpass_init() { constants(m); } +#if defined(ENABLE_THREADS) + python_global_lock = NEW(java_object_t); + LOCK_INIT_OBJECT_LOCK(python_global_lock); +#endif + } void pythonpass_cleanup() { @@ -1079,6 +1104,8 @@ int pythonpass_run(jitdata *jd, const char *module, const char *function) { PyObject *pyarg = NULL; int success = 0; + LOCK_MONITOR_ENTER(python_global_lock); + pymodname = PyString_FromString(module); pymod = PyImport_Import(pymodname); @@ -1114,6 +1141,8 @@ int pythonpass_run(jitdata *jd, const char *module, const char *function) { Py_XDECREF(pyargs); Py_XDECREF(pyret); + LOCK_MONITOR_EXIT(python_global_lock); + return (success == 1 ? 1 : 0); } -- 2.25.1