InstrumentAllocs
; it
has additional support for instrumenting the call instructions.
Here is a typical usage scenario of this package:
AllocationNumbering
object that assigns to
each allocation site a program-wide unique ID.
HCodeFactory
that provides the
instrumented version of the code (to do this, create an
InstrumentAllocs
object and next call its
codeFactory
method). In the instrumented code, each
allocation site is wrapped in code that increments the counter for the
corresponding unique ID.
HCodeFactory
for the uninstrumented code, the set of
roots and the initial method) and the AllocationNumbering
object.
AllocationNumbering
object. This gives both the
original, uninstrumented, HCodeFactory
, and the mapping
between allocation sites and unique IDs.
AllocationStatistics
object by
providing to its constructor the deserialized
AllocationNumbering
object and the name of the file
produced by the instrumentation. The resulting
AllocationStatistics
object provides, for each allocation
site, the number of times it was executed. It does this by computing
the jointure between the AllocationNumbering
mapping and
the mapping obtained by parsing the file produced by the
instrumentation.
Note: This scenario is complicated because we need to preserve the identity of the allocation sites between two different runs of FLEX: before and after the instrumented version if compiled and executed.
The above scenario is an ideal one. In practice, JVMs are buggy when
it comes to (de)serialization. Therefore, we designed an alternative
solution that uses textualization (a hacked-down way of
serializing the AllocationNumbering
map; don't bother
about its details). Here are the differences from the ideal solution:
AllocationNumbering
object by using the
AllocationNumberingStub.writeToFile
method.
AllocationStatistics
object by using the constructor that
requires the name of the file used for textualization
(internally, it will detextualize an
AllocationNumberingStub
object). Now, you should have a
nice, ready to use AllocationStatistics
object.
SAMain
(search for
AllocationNumbering
).
@author Alexandru SALCIANU (salcianu@MIT.EDU)
@author Brian Demsky (bdemsky@mit.edu)