Commit f7c9890c authored by Matthias Braun's avatar Matthias Braun
Browse files

- rename java_* stuff to be_java_*

parent c0461ca4
......@@ -74,7 +74,7 @@ void be_co3_register_options(lc_opt_entry_t *grp)
#endif
static void set_admissible_regs(java_coal_t *coal, copy_opt_t *co, ir_node *irn, int t_idx, int *col_map)
static void set_admissible_regs(be_java_coal_t *coal, copy_opt_t *co, ir_node *irn, int t_idx, int *col_map)
{
unsigned i;
arch_register_req_t req;
......@@ -87,7 +87,7 @@ static void set_admissible_regs(java_coal_t *coal, copy_opt_t *co, ir_node *irn,
req.limited(req.limited_env, adm);
for(i = 0; i < n_regs; ++i)
if(!bitset_is_set(adm, i) && col_map[i] >= 0)
java_coal_forbid_color(coal, t_idx, col_map[i]);
be_java_coal_forbid_color(coal, t_idx, col_map[i]);
}
}
......@@ -106,7 +106,7 @@ int co_solve_heuristic_java(copy_opt_t *co)
int *node_map;
int *inv_node_map;
java_coal_t *coal;
be_java_coal_t *coal;
ir_node *n, *m;
int max_idx = 0;
......@@ -144,10 +144,10 @@ int co_solve_heuristic_java(copy_opt_t *co)
free(node_map);
free(inv_node_map);
bitset_free(nodes);
return;
return 0;
}
coal = java_coal_init("test", curr_idx, j, dbg_level);
coal = be_java_coal_init("test", curr_idx, j, dbg_level);
/* Check, if all neighbours are indeed connected to the node. */
be_ifg_foreach_node(ifg, nodes_it, n) {
......@@ -157,14 +157,14 @@ int co_solve_heuristic_java(copy_opt_t *co)
if(bitset_is_set(nodes, n_idx)) {
affinity_node_t *an = get_affinity_info(co, n);
java_coal_set_color(coal, t_idx, col_map[arch_get_irn_register(co->aenv, n)->index]);
be_java_coal_set_color(coal, t_idx, col_map[arch_get_irn_register(co->aenv, n)->index]);
set_admissible_regs(coal, co, n, t_idx, col_map);
be_ifg_foreach_neighbour(ifg, neigh_it, n, m) {
int m_idx = get_irn_idx(m);
int s_idx = node_map[m_idx];
if(n_idx < m_idx && bitset_is_set(nodes, m_idx)) {
java_coal_add_int_edge(coal, s_idx, t_idx);
be_java_coal_add_int_edge(coal, s_idx, t_idx);
}
}
......@@ -175,7 +175,7 @@ int co_solve_heuristic_java(copy_opt_t *co)
int s_idx = node_map[m_idx];
if(n_idx < m_idx && bitset_is_set(nodes, m_idx)) {
java_coal_add_aff_edge(coal, s_idx, t_idx, neigh->costs);
be_java_coal_add_aff_edge(coal, s_idx, t_idx, neigh->costs);
}
}
}
......@@ -185,16 +185,16 @@ int co_solve_heuristic_java(copy_opt_t *co)
if(dump_flags & DUMP_BEFORE) {
char fn[512];
ir_snprintf(fn, sizeof(fn), "%F-%s-before.dot", co->cenv->irg, co->cenv->cls->name);
java_coal_dump(coal, fn);
be_java_coal_dump(coal, fn);
}
java_coal_coalesce(coal);
be_java_coal_coalesce(coal);
be_ifg_foreach_node(ifg, nodes_it, n) {
unsigned idx = get_irn_idx(n);
if(bitset_is_set(nodes, idx)) {
unsigned t_idx = node_map[idx];
unsigned col = inv_col_map[java_coal_get_color(coal, t_idx)];
unsigned col = inv_col_map[be_java_coal_get_color(coal, t_idx)];
const arch_register_t *reg = &co->cls->regs[col];
arch_set_irn_register(co->aenv, n, reg);
}
......@@ -203,10 +203,10 @@ int co_solve_heuristic_java(copy_opt_t *co)
if(dump_flags & DUMP_AFTER) {
char fn[512];
ir_snprintf(fn, sizeof(fn), "%F-%s-after.dot", co->cenv->irg, co->cenv->cls->name);
java_coal_dump(coal, fn);
be_java_coal_dump(coal, fn);
}
java_coal_destroy(coal);
be_java_coal_destroy(coal);
bitset_free(nodes);
return 0;
}
......@@ -43,7 +43,7 @@ static const lc_opt_table_entry_t options[] = {
{ NULL }
};
void java_coal_register_options(lc_opt_entry_t *grp)
void be_java_coal_register_options(lc_opt_entry_t *grp)
{
lc_opt_entry_t *jc_grp = lc_opt_get_grp(grp, "jc");
lc_opt_add_table(jc_grp, options);
......@@ -140,8 +140,10 @@ static int start_vm(jni_env_t *env, int argc, char *argv[])
ret = create_func(&env->jvm, (void **) &env->jni, &args);
free(opts);
if(ret == JNI_ERR)
if(ret != JNI_OK) {
fprintf(stderr, "JNI_CreateJavaVM returned errrocode %d\n" , ret);
return 0;
}
return 1;
}
......@@ -195,7 +197,10 @@ static jni_env_t *get_jvm(void)
snprintf(cp_param, sizeof(cp_param), "-Djava.class.path=%s", jar_file);
args[0] = cp_param;
start_vm(&env, sizeof(args) / sizeof(args[0]), args);
if(!start_vm(&env, sizeof(args) / sizeof(args[0], args), args)) {
fprintf(stderr, "Couldn't initialize java VM\n");
abort();
}
jvm_inited = 1;
old_int_handler = signal(SIGINT, sig_jvm_destroy_at_exit);
old_abrt_handler = signal(SIGABRT, sig_jvm_destroy_at_exit);
......@@ -214,7 +219,7 @@ static void check(jni_env_t *env, const char *file, int line)
(*jni)->ExceptionDescribe(jni);
(*jni)->ExceptionClear(jni);
stop_vm(env);
exit(1);
abort();
}
}
......@@ -244,7 +249,7 @@ static const struct _mth_info_t mthis[mth_last] = {
{ "getColor", "(I)I" }, /* public int getColor(int); */
{ "forbidColor", "(II)V" }, /* public void forbidColor(int, int); */
{ "coalesce", "()V" }, /* public void coalesce(); */
{ "dump", "(Ljava/lang/String;)V" } /* public void dump(String); */
{ "dump", "(Ljava/lang/String;)V" }, /* public void dump(String); */
{ "finish", "()V" } /* public void finish(); */
};
......@@ -253,7 +258,7 @@ static const struct _mth_info_t mthi_factory = {
"createExtern", "(Ljava/lang/String;III)Lcoalescing/Extern;"
};
struct _java_coal_t {
struct _be_java_coal_t {
jni_env_t *env;
jclass cls;
jobject obj;
......@@ -261,7 +266,7 @@ struct _java_coal_t {
jmethodID mth_ids[mth_last];
};
static void jc_call_void(java_coal_t *c, int mth_index, ...)
static void jc_call_void(be_java_coal_t *c, int mth_index, ...)
{
JNIEnv *jni = c->env->jni;
jmethodID mid = c->mth_ids[mth_index];
......@@ -274,7 +279,7 @@ static void jc_call_void(java_coal_t *c, int mth_index, ...)
va_end(args);
}
static int jc_call_int(java_coal_t *c, int mth_index, ...)
static int jc_call_int(be_java_coal_t *c, int mth_index, ...)
{
JNIEnv *jni = c->env->jni;
jmethodID mid = c->mth_ids[mth_index];
......@@ -290,9 +295,9 @@ static int jc_call_int(java_coal_t *c, int mth_index, ...)
return res;
}
java_coal_t *java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level)
be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level)
{
java_coal_t *c;
be_java_coal_t *c;
jni_env_t *env = get_jvm();
JNIEnv *jni = env->jni;
jmethodID fact;
......@@ -332,39 +337,39 @@ java_coal_t *java_coal_init(const char *graph_name, int n_nodes, int n_regs, int
return c;
}
void java_coal_destroy(java_coal_t *c) {
void be_java_coal_destroy(be_java_coal_t *c) {
JNIEnv *jni = c->env->jni;
jc_call_void(c, mth_finish);
(*jni)->DeleteGlobalRef(jni, c->obj);
free(c);
}
void java_coal_add_int_edge(java_coal_t *c, int n, int m)
void be_java_coal_add_int_edge(be_java_coal_t *c, int n, int m)
{
jc_call_void(c, mth_add_int_edge, (jint) n, (jint) m);
}
void java_coal_add_aff_edge(java_coal_t *c, int n, int m, int weight)
void be_java_coal_add_aff_edge(be_java_coal_t *c, int n, int m, int weight)
{
jc_call_void(c, mth_add_aff_edge, (jint) n, (jint) m, (jint) weight);
}
void java_coal_set_color(java_coal_t *c, int n, int col)
void be_java_coal_set_color(be_java_coal_t *c, int n, int col)
{
jc_call_void(c, mth_set_color, (jint) n, (jint) col);
}
void java_coal_forbid_color(java_coal_t *c, int n, int col)
void be_java_coal_forbid_color(be_java_coal_t *c, int n, int col)
{
jc_call_void(c, mth_forbid_color, (jint) n, (jint) col);
}
void java_coal_coalesce(java_coal_t *c)
void be_java_coal_coalesce(be_java_coal_t *c)
{
jc_call_void(c, mth_coalesce);
}
void java_coal_dump(java_coal_t *c, const char *fn)
void be_java_coal_dump(be_java_coal_t *c, const char *fn)
{
JNIEnv *jni = c->env->jni;
jmethodID mid = c->mth_ids[mth_dump];
......@@ -376,56 +381,56 @@ void java_coal_dump(java_coal_t *c, const char *fn)
CHECK(c->env);
}
int java_coal_get_color(java_coal_t *c, int n)
int be_java_coal_get_color(be_java_coal_t *c, int n)
{
return jc_call_int(c, mth_get_color, (jint) n);
}
#else
java_coal_t *java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level)
be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level)
{
assert(0 && "use --enable-jvm");
return NULL;
}
void java_coal_destroy(java_coal_t *c)
void be_java_coal_destroy(be_java_coal_t *c)
{
assert(0 && "use --enable-jvm");
}
void java_coal_add_int_edge(java_coal_t *c, int n, int m)
void be_java_coal_add_int_edge(be_java_coal_t *c, int n, int m)
{
assert(0 && "use --enable-jvm");
}
void java_coal_add_aff_edge(java_coal_t *c, int n, int m, int weight)
void be_java_coal_add_aff_edge(be_java_coal_t *c, int n, int m, int weight)
{
assert(0 && "use --enable-jvm");
}
void java_coal_set_color(java_coal_t *c, int n, int col)
void be_java_coal_set_color(be_java_coal_t *c, int n, int col)
{
assert(0 && "use --enable-jvm");
}
void java_coal_forbid_color(java_coal_t *c, int n, int col)
void be_java_coal_forbid_color(be_java_coal_t *c, int n, int col)
{
assert(0 && "use --enable-jvm");
}
void java_coal_coalesce(java_coal_t *c)
void be_java_coal_coalesce(be_java_coal_t *c)
{
assert(0 && "use --enable-jvm");
}
void java_coal_dump(java_coal_t *c, const char *fn)
void be_java_coal_dump(be_java_coal_t *c, const char *fn)
{
assert(0 && "use --enable-jvm");
}
int java_coal_get_color(java_coal_t *c, int n)
int be_java_coal_get_color(be_java_coal_t *c, int n)
{
assert(0 && "use --enable-jvm");
return -1;
......
......@@ -2,8 +2,8 @@
#ifndef _BEJAVACOAL_H
#define _BEJAVACOAL_H
struct _java_coal_t;
typedef struct _java_coal_t java_coal_t;
struct _be_java_coal_t;
typedef struct _be_java_coal_t be_java_coal_t;
#ifdef WITH_LIBCORE
......@@ -15,7 +15,7 @@ typedef struct _java_coal_t java_coal_t;
/**
* Register libcore options.
*/
void java_coal_register_options(lc_opt_entry_t *grp);
void be_java_coal_register_options(lc_opt_entry_t *grp);
#endif /* WITH_LIBCORE */
......@@ -24,7 +24,7 @@ void java_coal_register_options(lc_opt_entry_t *grp);
* @param n first node id.
* @param m second node id.
*/
void java_coal_add_int_edge(java_coal_t *c, int n, int m);
void be_java_coal_add_int_edge(be_java_coal_t *c, int n, int m);
/**
* Add an affinity edge.
......@@ -32,14 +32,14 @@ void java_coal_add_int_edge(java_coal_t *c, int n, int m);
* @param m second node id.
* @param costs Costs for the edge.
*/
void java_coal_add_aff_edge(java_coal_t *c, int n, int m, int costs);
void be_java_coal_add_aff_edge(be_java_coal_t *c, int n, int m, int costs);
/**
* Set the color of a node.
* @param n The node.
* @param col The color.
*/
void java_coal_set_color(java_coal_t *c, int n, int col);
void be_java_coal_set_color(be_java_coal_t *c, int n, int col);
/**
* Forbid a color for a node.
......@@ -47,25 +47,25 @@ void java_coal_set_color(java_coal_t *c, int n, int col);
* @param n The node.
* @param col The color.
*/
void java_coal_forbid_color(java_coal_t *c, int n, int col);
void be_java_coal_forbid_color(be_java_coal_t *c, int n, int col);
/**
* Start the coalescing.
*/
void java_coal_coalesce(java_coal_t *c);
void be_java_coal_coalesce(be_java_coal_t *c);
/**
* Dump the graph into a dot file.
* @param fn Filename to dump to.
*/
void java_coal_dump(java_coal_t *c, const char *fn);
void be_java_coal_dump(be_java_coal_t *c, const char *fn);
/**
* Get the color of a node.
* @param n The node.
* @return The color of the node.
*/
int java_coal_get_color(java_coal_t *c, int n);
int be_java_coal_get_color(be_java_coal_t *c, int n);
/**
* Init the JAVA coalescer.
......@@ -75,12 +75,11 @@ int java_coal_get_color(java_coal_t *c, int n);
* @param dbg_level Te debug level for the coalescer. 0 means quiet. >0 more verbose.
* @return The coalescing object.
*/
java_coal_t *java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level);
be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level);
/**
* Destroy the coalescing object.
*/
void java_coal_destroy(java_coal_t *c);
void be_java_coal_destroy(be_java_coal_t *c);
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment