Why the number of registers indicated in the invoke-kind/range instruction not matching with the number of argument types?

StackOverflow https://stackoverflow.com/questions/14301825

  •  15-01-2022
  •  | 
  •  

Question

in the following example bytecode:

 invoke-virtual/range {v0 .. v5}, Landroid/location/LocationManager;->requestLocationUpdates(Ljava/lang/String;JFLandroid/location/LocationListener;)V

The range of registers indicates registers v0,v1,v2,v3,v4,v5, are passed to the method, but why the number is not the same as the number of the types indicated, which is only 2??

Is there difference between invoke-kind/range and normal invoke-kind?

Was it helpful?

Solution

There are a total of 4 parameters mentioned in the parameter list, Ljava/lang/String;, J, F, and Landroid/location/LocationListener;. In addition, since is is a non-static method, there is an implied this parameter that occurs before the other paremeters. The final missing piece of the puzzle is that 'J' is a double, which is a 64-bit type - meaning it requires two registers.

So the parameters are:

this - v0
Ljava/lang/String; - v1
J - v1 and v2
F - v3
Landroid/location/LocationListener; - v4

OTHER TIPS

OK... those types are not separated by ,, which made it hard to distinguish for beginners: the Ljava/lang/String is the full class name, J is for long type, F is for float type,Landroid/location/LocationListener is for full class name. However, still not clear, for all the parameter types specified, plus the this type of object that the method is invoking on, the number is 5 parameter types, but why the range of the registers is specified to be 6?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top