I've landed the second pass at JI refactoring, this time eliminating most of the intermediate waste and duplicate logic for method selection and argument coercion. Before, incoming Ruby objects were first coerced to their default Java type (like Fixnum to Long), and stuffed into an array. That array was passed to the method lookup logic, which examined each method and each argument to find a match. The match was cached and the method returned. Then the list of arguments was passed to the method, which went through each of them again and narrowed them to the actual target type on the target method.

So, for example, if you were calling a method that takes int with a Fixnum:

1. Fixnum is coerced into a Long object and put into Object[]
2. Object[] is passed to method selection and your method is found
3. Object[] is passed into your method and Long is converted to Integer
4. Method is called

This path, under the new code:

1. Fixnum is passed directly to method selection logic, with no Object[], and your method is found. Argument counts up to 3 are passed straight through the process without extra boxing.
2. Fixnum is converted directly to Integer, based on the found method.
3. Integer is boxed into Object[] for reflection and your method is invoked.

For numeric types, this should greatly improve JI performance. It's also a lot easier code to cope with.

More to come.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to