Re: Re: Calculating Methods' Local Variable Sizes at Runtime
Nemo Caviani <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Thanks Eugene for the reply. yes, using visitLocalVariable I am able to identify the set of parameters passed to a method. What I can't figure out is how to get the actual values for these parameters off the stack to calculate their real sizes. I can figure out their names and their types from the method signature, and for the primitive types a lookup table can give me the size of their memory usage. What I don't know, is how to get the actual size of non-primitive parameters. If the nonprimitive type contains an array or a list, the length of the array or the list also size becomes a critical factor in figuring out the amount of space it uses. so if you or anyone in the list can give me a clue on how to access the actual value of a parameter from the local stack and calculate its size, that would be a great help to me indeed. thanks a lot, Nemo On Mon, Mar 29, 2010 at 5:42 AM, Eugene Kuleshov <[email protected]>wrote: > > 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 >> > > > > -- > 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 > >
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