Phase 2
Install the project
- Copy /projects/proganalysis/SEII-project/phase2/phase2.tar
in directory "project" that was created during phase 1. For example, if in
phase 1 you had "/A/B/C/project/phase1", copy the file in
"/A/B/C/project".
- tar xvf phase2.tar
This should create a new directory
"/A/B/C/project/phase2" with a Perl script "run" and 5 Java classes
(ChaMain.java, ...). Read "project/phase2/run". It is quite similar to the
script from phase 1 — for example, you have to set the root directory again.
Generate JIMPLE
Make the appropriate changes in "run" — uncomment the
call to genJimple and comment out the call to runCHA. Generate the JIMPLE for
the 7 programs. Note than now the JIMPLE files are stored in a subdirectory.
Run CHA
First, compile the implementation: javac *.java. Then,
edit the script and run CHA on each of the 7 programs. The implementation reads
the JIMPLE files, creates in-memory representation for them, executes CHA on
this representation, and writes the results to several text files. Note that it
takes a while to process a program. This is because Soot loads the JIMPLE for
many Java library classes, and it takes a while to process all of them. The
actual CHA only takes a few seconds.
Examine the output
After running CHA, examine the following output
files:
- hier: This file contains the list of all non-library classes in the
program. Next to each class/interface X, there is an integer representing the
number of non-abstract classes that are reachable from X in the class
hierarchy (going downwards). In other words, it represents the number of
non-abstract classes for which X is a (direct or transitive) superclass or
superinterface. Recall that the set of such classes is needed by CHA when
handling a virtual call "x.m(...)" when x is of type X. The number in
hier corresponds to the size of the set returned by method
possibleReceiverClasses in class Hierarchy. At present, this method is
implemented incorrectly, and therefore the info in the file is wrong. After
you complete your implementation, the results in this file will be
correct.
- rmethods: This file contains the set of all non-library methods
reachable from "main" (plus the appropriate < clinit > and "finalize"
methods). So, the file describes the nodes in the call graph. At present, the
incomplete CHA implementation does not find all reachable methods, and
therefore the info written to rmethods is wrong.
- calls: Contains info about all calls in all methods from
rmethods. This is essentially the set of call graph edges. The format
of the file is as follows:
- Line "===== Method X" indicates the start of info for call sites inside
method X.
- Line "[S] X" indicates a "simple" call — i.e. a call through
specialinvoke or staticinvoke. For any such call, the static target and the
run-time target are the same.
- Line "[C] X,a,b" indicates a "complex" call — i.e. a call through
virtualinvoke and interfaceinvoke. Such a call can have several run-time
target methods; all such targets are listed immediately below the line.
Number "a" is the number of the possible classes of the receiver object;
number "b" is the number of possible run-time target methods (of course, a
is always greater than or equal to b). Since CHA is not fully implemented,
the set of target methods is currently incorrect.
There are
two other output files hier_all and rmethods_all; ignore them for
now.
Implement CHA
Complete the implementation of CHA, as described here.
Check Correctness
Compare the output of CHA with the call graphs you
constructed manually during phase 1. Make sure that they are the same — i.e. the
call graph nodes (file rmethods) and edges (file calls) are
computed correctly.
Submit the results
Email to milanova@cs.rpi.edu all the source code,
plus all subdirectories with files hier, rmethods, calls,
hier_all, and rmethods_all. Since you are submitting by email,
please DO NOT include JIMPLEs, .class files, and the run script.
Additional Resources