[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question on Strins in PointsToSet



The standard libraries contain many string constants, so propagating all
of them slows Spark down significantly, and also increases its memory
requirements. Therefore, when I added the string constant handling, I
limited it to string constants that may be the names of classes loaded
dynamically through reflection, since these are the only string
constants that Spark itself is interested in. All other string constants
are grouped together in a single AllocNode.

But, in talking with other people about the kinds of things that they
want to use Spark for, I've become convinced that Spark should at least
have an option to propagate all string constants, not just those that
are the names of classes. I will implement such an option in the
development version, and it will appear in a future release of Soot.
Until then, it is very easy to modify Spark to propagate all string
constants. In the file src/soot/jimple/spark/builder/StandardParms.java,
in the method caseStringConstant(), there is the following code:

        if( Scene.v().containsClass(sc.value) 
        || ( sc.value.length() > 0 && sc.value.charAt(0) == '[' ) ) {
            stringConstant = pag.makeStringConstantNode( sc.value );
        } else {
            stringConstant = pag.makeAllocNode(
                PointsToAnalysis.STRING_NODE,
                RefType.v( "java.lang.String" ), null );
        }

Simply replace this code with just the line:

        stringConstant = pag.makeStringConstantNode( sc.value );

Ondrej

On Tue, Oct 14, 2003 at 09:40:09AM +0200, CREGUT Pierre FTRD/DTL/LAN wrote:
> Let us consider the analysis of the following program with a modified
> version of soot using a custom transform added to the wjtp phase.
> 
> class B {
> 	String s1 = "aaa";
> 	static String s2 = "bbb";
> 	
> 	void m() {
> 		f(s1);
> 		f(s2);
> 	}
> }
> 
> I am trying to analyze the arguments of f. I use a 'LocalDefs' analysis
> to get the definition of locals in methods and the Spark PointsToAnalysis
> to get the propagation of allocation to variables 
> (option -p cg.spark enabled:true).
> 
> I have seen in the documentation that Strings receive a special treatment 
> and that constant strings are propagated in PointsToSets but I do not manage
> to get it working.
> 
> For f(s2), I only get that the definition is an assignment following a 
> field dereference where the object is r0 (self) but the PointsToSet is empty.
> Here is the code (without any coercion test but this is not the problem).
> stmt is the statement containing the definition of the local used as
> argument of f :
> 
>   Value r = ((JAssignStmt) stmt).getRightOp ();
>   InstanceFieldRef fr = (InstanceFieldRef) r;
>   Local b = (Local) fr.getBase();
>   PointsToSet fdefs = pag.reachingObjects((Local) b,fr.getField());
>   Set result = fdefs.possibleStringConstants();
> 
> and for s1, it contains an AllocNode but not a ConstantStringNode. The
> corresponding code for a static field is :
> 
>   Value r = ((JAssignStmt) stmt).getRightOp ();
>   StaticFieldRef fr = (StaticFieldRef) r;
>   PointsToSet fdefs = pag.reachingObjects(fr.getField());
>   Set result = possibleStringConstants((PointsToSetInternal) fdefs);
> 
> What am I doing wrong ? Is there something to trigger the special treatment
> of strings ? As a new user, am I just expecting too much from the Spark 
> propagation algorithm ?
> Thank you in advance for your help,
> 
> Pierre Cregut
> 
> -- 
> Pierre Cregut - pierre.cregut@rd.francetelecom.com - +33 2 96 05 16 28
> FTR&D - DTL/TAL - 2 avenue Pierre Marzin - 22307 Lannion Cedex - France
>