On Feb 5, 2009, at 2:04 AM, Rémi Forax wrote: > BTW, the Java code of bound method can be simplified. > In my opinion, a bound method handle is a direct method handle plus an > object at argument zero.
Yes. That is true, because there is no (net) stack motion, as the MH which is the receiver of the MH.invoke call is replaced by the bound receiver of the target method, and the other arguments do not need to be moved at all (on the JVM interpreter stack, or probably in any register-based calling sequence). I suppose we can call this pattern "receiver replacement"; it is probably a typical elegance of bound method pointers in all sorts of systems, such as (I'm guessing) C#. I made MHs.bind into a standard method mainly for convenience (to simplify otherwise tricky use cases). On the other hand, the more general MHs.insertArgument optimizes the (common) case of receiver replacement, so MHs.bind and MHs.insertArgument are interchangeable for their overlapping usages. At least, it's supposed to work this way. If the Java code (in jdk/meth.patch) does not enable this optimization, it's a bug. The JVM code also has special paths to support receiver replacement efficiently; see the flag OptimizeMethodHandles in hotspot/meth.patch. -- John _______________________________________________ mlvm-dev mailing list [email protected] http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
