2007/7/4, Charles Oliver Nutter <[EMAIL PROTECTED]>:
dreamhead wrote: > Hi, Charlie! > > MethodIndex in compiler is worth considering. > > The following code is from invokeDynamic of StandardASMCompiler. > int index = MethodIndex.getIndex(name); > ... > if (index != 0) { > invokeUtilityMethod("doInvokeDynamicIndexed", callSigIndexed); > > In new MethodIndex, index is always greater than 0 (except ""), so > doInvokeDynamicIndexed is always invoked, right? I want to if it is > meaningful.Yes, this is a side effect of having indices dynamically generated, and it does mean that the indexed version is always called. I'm not sure if that's a problem though.
This problem comes from getIndex of MethodIndex and the index is increased when get new index. I think it is easy to modify by limiting the size of indexes. If there are only some fixed indexes, thread-safe is also OK. But you're right, it always works. :)
> On the other hand, the index is only meaningful in current JRuby > instance. I mean the index of "example" could be 123 in current JRuby > instance, but it could be 456 in another JRuby instance. So when it's > saved into Class file, it could meaningless when it's loaded again. > > If I'm wrong, feel free to tell me. I believe the important indicies will be specific to a given JRuby version, but not necessarily a given JRuby instance. The keys used to generate the STI table and switch are sorted first, and should be the same from run to run, so they should generate indices in the same order. However, I don't like trusting this...you'll notice there's one or two FIXMEs in the code that relate to this problem. I really don't want to have to generate a static list of methods, but it seems like we need a better way to generate the indices that's not going to change from version to version, especially if we want to AOT compile code and have it run across at least a couple JRuby version. Note that the current design will be fine in interpreted and JIT modes. It's mainly AOT that would be a problem. - Charlie
Yes, the fixed indexes is related to JRuby version, in fact, MethodIndex version. But there are a lot of non-fixed indexes in JRuby that is what I mean. The non-fixed indexes will be different when you run scripts in different JRuby instances that is AOT as you said. I know in most cases, the invocation will be forwarded to call without index. As I said, the fix size of index could make it easy in both interpreted and compilation mode. Of course, it'll be related to MethodIndex version if you write into class file. Ye Zheng -- Everything is simple! --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
