Commit 6d3cc33e authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

comments, freeing routine

[r3197]
parent cc1eb794
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "dbginfo_t.h" #include "dbginfo_t.h"
#include "irdump.h"
/* Eindeutige Adresse zur Markierung von besuchten Knoten und zur /* Eindeutige Adresse zur Markierung von besuchten Knoten und zur
* Darstellung der unbekannten Methode. */ * Darstellung der unbekannten Methode. */
static void * MARK = &MARK; static void * MARK = &MARK;
...@@ -460,7 +462,10 @@ static void callee_ana_node(ir_node * node, eset * methods) { ...@@ -460,7 +462,10 @@ static void callee_ana_node(ir_node * node, eset * methods) {
entity * ent = tarval_to_entity(get_Const_tarval(node)); entity * ent = tarval_to_entity(get_Const_tarval(node));
assert(ent && is_method_type(get_entity_type(ent))); assert(ent && is_method_type(get_entity_type(ent)));
if (get_entity_visibility(ent) != visibility_external_allocated) { if (get_entity_visibility(ent) != visibility_external_allocated) {
assert(get_entity_irg(ent)); if (!get_entity_irg(ent)) {
dump_entity(ent);
assert(get_entity_irg(ent));
}
eset_insert(methods, ent); eset_insert(methods, ent);
} else { } else {
eset_insert(methods, MARK); /* free method -> unknown */ eset_insert(methods, MARK); /* free method -> unknown */
...@@ -763,13 +768,34 @@ void cgana(int *length, entity ***free_methods) { ...@@ -763,13 +768,34 @@ void cgana(int *length, entity ***free_methods) {
DEL_ARR_F(free_meths); DEL_ARR_F(free_meths);
} }
static void destruct_walker(ir_node * node, void * env) {
if (get_irn_op(node) == op_Call) {
remove_Call_callee_arr(node);
}
}
void free_callee_info(ir_graph *irg) {
irg_walk_graph(irg, destruct_walker, NULL, NULL);
set_irg_callee_info_state(irg, irg_callee_info_none);
}
/* Optimize the address expressions passed to call nodes. /* Optimize the address expressions passed to call nodes.
* Alle SymConst-Operationen, die auf interne Methoden verweisen, *
* werden durch Const-Operationen ersetzt. * This optimization performs the following transformations for
* Sel Knoten deren entitaeten nicht ueberschrieben werden, werden * all ir graphs:
* durch Const ersetzt. * - All SymConst operations that refer to intern methods are replaced
* Sel Knoten, fuer die keine Implementierung existiert, werden * by Const operations refering to the corresponding entity.
* durch Bad ersetzt. */ * - Sel nodes, that select entities that are not overwritten are
* replaced by Const nodes refering to the selected entity.
* - Sel nodes, for witch no method exists at all are replaced by Bad
* nodes.
* - Sel nodes with a pointer input that is an Alloc node are replaced
* by Const nodes refering to the entity that implements the method in
* the type given by the Alloc node.
*/
void opt_call_addrs(void) { void opt_call_addrs(void) {
sel_methods_init(); sel_methods_init();
sel_methods_dispose(); sel_methods_dispose();
......
...@@ -38,11 +38,17 @@ ...@@ -38,11 +38,17 @@
/** Analyses a rough estimation of the possible call graph. /** Analyses a rough estimation of the possible call graph.
* *
* Bestimmt fuer jede Call-Operation die Menge der aufrufbaren Methode * Determines for each Call node the set of possibly called methods.
* und speichert das Ergebnis in der Call-Operation. (siehe * Stores the result in the field 'callees' of the Call node. If the
* "set_Call_callee"). Die Methode gibt die Menge der * address can not be analysed, e.g. because it is loaded from a
* "freien" Methoden zurueck, die vom Aufrufer wieder freigegeben * variable, the array contains NULL. @@@ the array should contain a
* werden muss (free). * special entity 'unknown'. (See "set_Call_callee"). cgana returns
* the set of 'free' methods, i.e., the methods that can be called
* from external or via function pointers. This datastructure must
* be freed with 'free()' by the caller of cgana.
*
* cgana sets the callee_info_state of each graph to consistent.
*
* The algorithm implements roughly Static Class Hierarchy Analysis * The algorithm implements roughly Static Class Hierarchy Analysis
* as described in "Optimization of Object-Oriented Programs Using * as described in "Optimization of Object-Oriented Programs Using
* Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove * Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
...@@ -56,6 +62,12 @@ ...@@ -56,6 +62,12 @@
/* @@@ I assume this can not be called via JNI :-( -- how to obtain the array pointer? */ /* @@@ I assume this can not be called via JNI :-( -- how to obtain the array pointer? */
void cgana(int *len, entity ***free_methods); void cgana(int *len, entity ***free_methods);
/** Free callee information.
*
* Sets callee_info_state of the graph passed to none.
*/
void free_callee_info(ir_graph *irg);
/* Optimize the address expressions passed to call nodes. /* Optimize the address expressions passed to call nodes.
* Performs only the optimizations done by cgana. */ * Performs only the optimizations done by cgana. */
/* @@@ move to irgopt ?! */ /* @@@ move to irgopt ?! */
......
Markdown is supported
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