1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-07-07 20:34:25 +00:00
CC-Tweaked/projects/core
Jonathan Coates 71669cf49c
Replace ASM generation with MethodHandles
This is the second time I've rewritten our class generation in a little
over a month. Oh dear!

Back in d562a051c7 we started using method
handles inside our generated ASM, effectively replacing a direct call
with .invokeExact on a constant method handle.

This goes one step further and removes our ASM entirely, building up a
MethodHandle that checks arguments and then wraps the return value.
Rather than generating a class, we just return a new LuaFunction
instance that invokeExacts the method handle.

This is definitely slower than what we had before, but in the order of
8ns vs 12ns (in the worst case, sometimes they're much more comparable),
so I'm not too worried in practice.

However, generation of the actual method is now a bit faster. I've not
done any proper benchmarking, but it's about 20-30% faster.

This also gives us a bit more flexibility in the future, for instance
uisng bound MethodHandles in generation (e.g. for instance methods on
GenericSources). Not something I'm planning on doing right now, but is
an option.
2023-10-11 20:05:37 +01:00
..
src Replace ASM generation with MethodHandles 2023-10-11 20:05:37 +01:00
build.gradle.kts Replace ASM generation with MethodHandles 2023-10-11 20:05:37 +01:00