Class CallSiteGenerator
java.lang.Object
org.codehaus.groovy.runtime.callsite.CallSiteGenerator
Generates specialized call-site classes for the classic (non-indy) call-site cache.
Prefer invokedynamic call sites for new code. Planned for deprecation/removal in a future Groovy version.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConstructorcompilePogoMethod(CachedMethod cachedMethod) Loads a pogo call-site class forcachedMethodthrough the loader cached for its declaring class, and returns the constructor that accepts the parent site, meta class, meta method, parameter types, and reflective constructor.static ConstructorcompilePojoMethod(CachedMethod cachedMethod) Loads a pojo call-site class forcachedMethodthrough the loader cached for its declaring class, and returns the constructor that accepts the parent site, meta class, meta method, parameter types, and reflective constructor.static ConstructorcompileStaticMethod(CachedMethod cachedMethod) Loads a static call-site class forcachedMethodthrough the loader cached for its declaring class, and returns the constructor that accepts the parent site, meta class, meta method, parameter types, and reflective constructor.static voidgenCallWithFixedParams(org.objectweb.asm.ClassWriter cw, String name, String superClass, CachedMethod cachedMethod, String receiverType) Writes a fixed-arity call method forcachedMethodwhen it has four parameters or fewer.static voidgenCallXxxWithArray(org.objectweb.asm.ClassWriter cw, String name, String superClass, CachedMethod cachedMethod, String receiverType) Writes the array form of a call method forcachedMethod.static byte[]genPogoMetaMethodSite(CachedMethod cachedMethod, org.objectweb.asm.ClassWriter cw, String name) Writes a PogoMetaMethodSite subclass intocw.static byte[]genPojoMetaMethodSite(CachedMethod cachedMethod, org.objectweb.asm.ClassWriter cw, String name) Writes a PojoMetaMethodSite subclass intocw.static byte[]genStaticMetaMethodSite(CachedMethod cachedMethod, org.objectweb.asm.ClassWriter cw, String name) Writes a StaticMetaMethodSite subclass intocw.static booleanisCompilable(CachedMethod method) Returns whethermethodcan be compiled to a direct call site.
-
Method Details
-
genCallWithFixedParams
public static void genCallWithFixedParams(org.objectweb.asm.ClassWriter cw, String name, String superClass, CachedMethod cachedMethod, String receiverType) Writes a fixed-arity call method forcachedMethodwhen it has four parameters or fewer. Wider methods are skipped. The generated method checks that the call is still valid, invokes the target, turns a void result into null, boxes a primitive result, and falls back to the default call path when the guard fails. -
genCallXxxWithArray
public static void genCallXxxWithArray(org.objectweb.asm.ClassWriter cw, String name, String superClass, CachedMethod cachedMethod, String receiverType) Writes the array form of a call method forcachedMethod. Arguments are unpacked from theObject[]parameter, then invoked, boxed, and guarded the same way as the fixed-arity form. -
genPogoMetaMethodSite
public static byte[] genPogoMetaMethodSite(CachedMethod cachedMethod, org.objectweb.asm.ClassWriter cw, String name) Writes a PogoMetaMethodSite subclass intocw. Dots innamebecome slashes in the internal class name. The class declares a public static__constructor__field and does not initialize it. It also defines array and fixed-aritycallandcallCurrentmethods for Groovy object and plain object receivers.- Returns:
- the generated class bytes
-
genPojoMetaMethodSite
public static byte[] genPojoMetaMethodSite(CachedMethod cachedMethod, org.objectweb.asm.ClassWriter cw, String name) Writes a PojoMetaMethodSite subclass intocw. Dots innamebecome slashes in the internal class name. The class declares a public static__constructor__field and does not initialize it. It also defines array and fixed-aritycallmethods for a plain object receiver.- Returns:
- the generated class bytes
-
genStaticMetaMethodSite
public static byte[] genStaticMetaMethodSite(CachedMethod cachedMethod, org.objectweb.asm.ClassWriter cw, String name) Writes a StaticMetaMethodSite subclass intocw. Dots innamebecome slashes in the internal class name. The class declares a public static__constructor__field and does not initialize it. It also defines array and fixed-aritycallandcallStaticmethods.- Returns:
- the generated class bytes
-
compilePogoMethod
Loads a pogo call-site class forcachedMethodthrough the loader cached for its declaring class, and returns the constructor that accepts the parent site, meta class, meta method, parameter types, and reflective constructor. -
compilePojoMethod
Loads a pojo call-site class forcachedMethodthrough the loader cached for its declaring class, and returns the constructor that accepts the parent site, meta class, meta method, parameter types, and reflective constructor. -
compileStaticMethod
Loads a static call-site class forcachedMethodthrough the loader cached for its declaring class, and returns the constructor that accepts the parent site, meta class, meta method, parameter types, and reflective constructor. -
isCompilable
Returns whethermethodcan be compiled to a direct call site. The declaring class, the method, and every parameter type must be public,AndroidSupportmust not report an Android runtime, and encoding the method name as a class name must leave it unchanged.
-