Le 25/04/2010 18:01, Jochen Theodorou a écrit :
Rémi Forax wrote:
[...]
For more details see
http://wiki.jvmlangsummit.com/DinnerAtPiatti
(search for section invalidation)
true I fully forgot about invalidation... so how would I do it? most
probably a boolean in the call site that is not volatile and gets
flagged from outside if a meta class change happened. On each usage of
the call site this flag would be checked to see if the call site is
still valid.
Invalidation trashes the call site, you have to rebuilt it.
The fear I have here is that we need to store the call sites in a way
that I can access. With invokedynamic this is one thing, without, it
is a entirely different matter. Without invokedynamic I have to
maintain a list of call sites with each entry being removable from
memory once needed. Currently this kind of structure is in the class
itself. If the class collected, the call site is along with it. If I
need global call site entries I have two points referencing call
sites. Well, I can work using phantom references I guess.
I don't think it's possible to do invalidation without the proper
support by the VM.
When an invalidation is requested, all threads run until each one of
them reach a safepoint,
when all threads wait, callsites in the bytecode can be reset.
Because Linkage.invalidation() is always called under a lock,
there is no publication problem if the bootstrap method lookups
for metaclass info under the same lock.
Example:
- a metaclass change:
synchronized(metaclass_lock) {
Linkage.invalidateAll();
metaclass.change_method(...);
}
- a bootstrap method:
CallSite boostrap(Class<?> declaringClass, String name, MethodType type) {
CallSite callsite = ...
MethodHandle target;
synchronized(metaclass_lock) {
target = metaclass.lookup_member(...);
}
callsite.setTarget(target);
return callsite;
}
because you only do synchronization in bootstrap method and
this method is not called often (once and once by invalidation)
you should not have performance problem.
I don't see how to emulate this.
If someone find I will be happy to implement the solution in the backport :)
I should try it out at least.
bye blackdrag
Rémi
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.