#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;
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]);
}
}
int *node_map;
int *inv_node_map;
- java_coal_t *coal;
+ be_java_coal_t *coal;
ir_node *n, *m;
int max_idx = 0;
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) {
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);
}
}
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);
}
}
}
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);
}
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;
}
{ 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);
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;
}
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);
(*jni)->ExceptionDescribe(jni);
(*jni)->ExceptionClear(jni);
stop_vm(env);
- exit(1);
+ abort();
}
}
{ "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(); */
};
"createExtern", "(Ljava/lang/String;III)Lcoalescing/Extern;"
};
-struct _java_coal_t {
+struct _be_java_coal_t {
jni_env_t *env;
jclass cls;
jobject obj;
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];
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];
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;
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];
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;
#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
/**
* 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 */
* @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.
* @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.
* @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.
* @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