Re: Calculating Methods' Local Variable Sizes at Runtime

Eugene Kuleshov <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
  So you want to calculate something at runtime before method call and 
after the method call. For your scenario, primitive types are obvious 
and for a non-primitive types the easiest would be to write a static 
helper method, which you call for every parameter and non-primitive 
method return value. All param and return types you can retrieve from 
the called method signature and then generate code to call your static 
method. You may have to create some temporary variables in order to get 
the parameter values off the stack, but your transformation sould not 
change state of the stack at the point original method is called.

  Hope that helps.

  regards,
  Eugene


Nemo Caviani wrote:
> Hello All,
>
> I am a newbie to ASM and I would appreciate your help with the 
> following matter. 
>
> I have load-time instrumented my bytecode. I keep all sorts of 
> information for my classes and methods to measure CPU time, memory 
> usage, etc. Now, what I need to do is to calculate the actual amount 
> of data that is passed from one method to another through the input 
> parameters and also its return value of the method.
>
> This is in particular important for me as it enables me to measure the 
> actual amount of data that arrays and link lists take when they are 
> passed as arguments to a method or when they are returned from methods.
>
> I have checked the visitLocalVariable method, but I am not sure how I 
> can relate the name and the description of a local variable to its 
> actual data size in the local stack memory, especially when it is not 
> a basic type like INT or BOOLEAN.
>
> I also looked into visitFrame which seems to have more details about 
> the variables of a method. However, overwriting visitFrame results in 
> a VerifyError as it seems like I need to calculate the stack size for 
> the method manually, which I don't know how.
>
> I highly appreciate any help from you guys.
>
> thanks a lot,
> Nemo
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.