[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: profiling questions
On Sunday 02 March 2003 12:59 pm, Chris Pickett wrote:
> I actually don't want to do anything if the variable has not been
> initialized, except to increment the store counter for that variable. I
> can't add code to initialize the variable before I test, because if I
> did it might give a false silent store when really it's just the
> initialization of a variable.
>
I think I understand what you mean. Here's how I would do that:
For each variable v in your program, add a boolean flag initialized_v as
variable.
For each local variable, add a statement at the beginning of its method that
sets initialized_v to false. For each field, add such a statement to the
constructor or initializer, before all other statements.
Add statements that set initialized_v to true wherever you find a statement
that defines v. You can then use initialized_v to do the test you described.
You may have to be careful with your Java compiler: I think Java compilers are
allowed to reuse local variables (which means that two variables in your Java
source might be one variable in the bytecode).
--
Sincerely,
Johannes.