@Ryiah
I also said
The important takeaway is that Unity does this on a level with much more control, i.e. it classifies the objects early without having to actually use reflection any more, even the calls themselves are likely pointer bound.
I for one care about such internals especially when architectural decisions depend on it. As someone who understands System.Reflection API very well, this information on its own would make me wary of how things operate under the hood.
With the above article in mind, I am still wary, but of something else entirely.
Nobody said it does anything on its own. But there are a lot of security implications and safeguards when you’re circumventing the paths that are intentionally more optimal.
It doesn’t do this blindly. It is thus very slow.
Here’s one topic about its performance (I’m lazy to look for more, and there are plenty more)
Feel free to browse all the answers, and keep in mind that these users aren’t necessarily game developers. On average, reflection, when used lightly and tactfully, isn’t that much slower, and you can do a lot with it, however a heavy load is likely to destroy any notion of performance, generate tons of garbage, and ultimately you need to be mindful of the types involved, or the signatures you call, wrap and unwrap arguments, create arrays, and do all kinds of things just to be able to clear the safe guards – and if you don’t do it yourself (in case you’re thinking “this guy sounds like he never used reflection before”), reflection compounds will actually do this for you, like for instance, the way Activator API works does exactly what I described.
This is exactly what Unity (and we) want to avoid, so they avoid it altogether. They “sniff” the “messaging” methods, they classify the objects, then mindlessly call entire batches. And even then, as you can see in that article, there is a lot of stuff going on, the call itself being the cheapest thing, so it can’t be truly mindless, and we should keep messaging to a minimum.
I think that the OPs question is very important for everybody to understand the underlying system better, and that it deserves a highly detailed answer. I’m still not entirely satisfied with it, and if I come across more info, I’ll remember to share.