[phc-internals] [phc commit] r2673 - convert_context_names now works. Once again, it is much simpler with the new design.

codesite-noreply at google.com codesite-noreply at google.com
Mon May 25 18:48:48 IST 2009


Author: paul.biggar
Date: Mon May 25 10:48:10 2009
New Revision: 2673

Modified:
    branches/dataflow/src/optimize/wpa/Points_to.cpp
    branches/dataflow/src/optimize/wpa/Points_to.h

Log:
convert_context_names now works. Once again, it is much simpler with the  
new design.


Modified: branches/dataflow/src/optimize/wpa/Points_to.cpp
==============================================================================
--- branches/dataflow/src/optimize/wpa/Points_to.cpp	(original)
+++ branches/dataflow/src/optimize/wpa/Points_to.cpp	Mon May 25 10:48:10  
2009
@@ -614,51 +614,44 @@
  void
  Points_to::convert_context_names ()
  {
-	// TODO: check that this creates new Index_nodes, as the pointers are  
shared
-	// between differene Pair_maps.
-
-	phc_TODO ();
  	// Each alias_name can be converted in either the prefix or the suffix.
  	// By_source and by_target need to be updated.

-	// Symtables definitely need to be merged. Other storage nodes, I'm not
-	// sure. So we'll merge them all.
-	/*
+	// Merging storage nodes:
+	//		Symtables definitely need to be merged.
+	//		There are pros and cons to merging Objects and arrays:
+	//			- We might like to distinguish between them
+	//			- We might like to have a single node representing an allocation
+	//			- If we dont merge them, we're still merging the LHS of the
+	//			  allocation, so $x = new X will have $x pointing to multiple X
+	//			  nodes.
+	//
+	//	So just merge them all, until there is a good reason not to.

  	// Save the old alias pairs
-	Map<Alias_name, int> old_abstract_counts = this->abstract_counts;
-	Set<Alias_name> old_symtables = this->symtables;
-	Set<Alias_pair*> old_all_pairs = this->all_pairs;
-
-	// Clear the current set
-	this->abstract_counts.clear ();
-	this->symtables.clear ();
-	this->all_pairs.clear ();
-	this->by_source.clear ();
-	this->by_target.clear ();
-
+	fields.convert_context_names ();
+	references.convert_context_names ();
+	points_to.convert_context_names ();

-	foreach (Alias_pair* pair, old_all_pairs)
-	{
-		PT_node* source = pair->source->convert_context_name ();
-		PT_node* target = pair->target->convert_context_name ();
-
-		add_edge (source, target, pair->cert);
-	}

+	// Convert symtable names
+	Set<Alias_name> old_symtables = this->symtables;
+	this->symtables.clear ();
  	foreach (Alias_name name, old_symtables)
  	{
  		this->symtables.insert (name.convert_context_name ());
  	}

+	// Convert abstract counts
  	// I'm not really sure what to do here.
  	Alias_name name;
  	int count;
+	Map<Alias_name, int> old_abstract_counts = this->abstract_counts;
+	this->abstract_counts.clear ();
  	foreach (tie (name, count), old_abstract_counts)
  	{
  		abstract_counts[name.convert_context_name ()] += count;
  	}
-	*/
  }



Modified: branches/dataflow/src/optimize/wpa/Points_to.h
==============================================================================
--- branches/dataflow/src/optimize/wpa/Points_to.h	(original)
+++ branches/dataflow/src/optimize/wpa/Points_to.h	Mon May 25 10:48:10 2009
@@ -349,7 +349,7 @@

  		foreach (Edge_type* e, *other->get_edges ())
  		{
-			if (result->has_edge (e) and boost::is_same <Edge_type, Empty> ())
+			if (result->has_edge (e) and not boost::is_same <Value_type, Empty> ())
  				phc_TODO (); // combine values

  			result->add_edge (e);
@@ -358,6 +358,25 @@
  		return result;
  	}

+	// Returns a clone in which all the names are converted to context names.
+	this_type* convert_context_names ()
+	{
+		this_type* result = new this_type;
+
+		foreach (Edge_type* e, *this->get_edges ())
+		{
+			Edge_type* new_edge = new Edge_type (
+				e->source->convert_context_name (),
+				e->target->convert_context_name ());
+
+			if (result->has_edge (new_edge) and not boost::is_same <Value_type,  
Empty> ())
+				phc_TODO (); // combine values
+
+			result->add_edge (new_edge);
+		}
+		return result;
+	}
+


  private:
@@ -388,7 +407,10 @@
  	// implicitly by the number of points-to edges from SOURCE.
  	Pair_map<Index_node, Storage_node, Points_to_edge> points_to;

-	// TARGETs are indices of SOURCE. A certainty doesn't make sense.
+	// TARGETs are indices of SOURCE. A certainty would indicate whether it is
+	// initialized, but is probably a bit hard to do (and not worth it  
compared
+	// to an 'is_initialized' analysis.
+	// TODO: might be much easier with the new design.
  	// (Storage_node, Index_node) set.
  	Pair_map<Storage_node, Index_node, Field_edge> fields;



More information about the phc-internals mailing list