Hi Jochen,

I’m not an expert on the implementation of switch points, but my understanding 
is that they don’t appear in the dynamically compiled machine code at all. They 
use the safe point mechanism of the VM (the same thing that does the 
stop-the-world in the garbage collectors) for which polling instructions are 
already there anyway.

http://chrisseaton.com/rubytruffle/icooolps15-safepoints/safepoints.pdf 
<http://chrisseaton.com/rubytruffle/icooolps15-safepoints/safepoints.pdf>

See figure 6 (no significant difference in runtime with switch points there or 
not), and figure 9 (machine code contains no trace of them). So switch points 
aren’t just fast - they don’t take any time at all. (Ignore the references to 
Truffle if you aren’t using that.)

I don’t think any of this would change no matter how many of them you have.

I’m sure they do have an impact on interpreter performance, of course, where 
they can’t be optimised away.

I suppose it could conceivably be the case that a great many switch points may 
start to upset the compiler in terms of things like inlining budgets? I’m not 
sure, but seems unlikely.

Chris

> On 5 Oct 2016, at 13:37, Jochen Theodorou <blackd...@gmx.org> wrote:
> 
> Hi all,
> 
> I am constructing a new meta class system for Groovy (ok, I say that for 
> several years already, but bear with me) and I was wondering about the actual 
> performance of switchpoints.
> 
> In my current scenario I would need a way to say a certain group of meta 
> classes got updated and the method for this callsite needs potentially be 
> reselected.
> 
> So if I have class A, class B and then I have a meta class for Object and one 
> for A.
> 
> If the meta class for A is changed, all handles operating on instances of A 
> may have to reselect. the handles for B and Object need not to be affected. 
> If the meta class for Object changes, I need to invalidate all the handles 
> for A, B and Object.
> 
> Doing this with switchpoints means probably one switchpoint per metaclass and 
> a small number of meta classes per class (in total 3 in my example). This 
> would mean my MethodHandle would have to get through a bunch of switchpoints, 
> before it can do the actual method invocation. And while switchpoints might 
> be fast it does not sound good to me.
> 
> Or I can do one switchpoint for all methodhandles in the system, which makes 
> me wonder if after a meta class change the callsite ever gets Jitted again. 
> The later performance penalty is actually also not very attractive to me.
> 
> So what is the way to go here? Or is there an even better way?
> 
> bye Jochen
> 
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev@openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to