Class CallSiteGenerator

java.lang.Object
org.codehaus.groovy.runtime.callsite.CallSiteGenerator

public class CallSiteGenerator extends Object
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 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 for cachedMethod when 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 for cachedMethod. Arguments are unpacked from the Object[] 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 into cw. Dots in name become 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-arity call and callCurrent methods 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 into cw. Dots in name become 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-arity call methods 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 into cw. Dots in name become 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-arity call and callStatic methods.
      Returns:
      the generated class bytes
    • compilePogoMethod

      public static Constructor compilePogoMethod(CachedMethod cachedMethod)
      Loads a pogo call-site class for cachedMethod through 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

      public static Constructor compilePojoMethod(CachedMethod cachedMethod)
      Loads a pojo call-site class for cachedMethod through 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

      public static Constructor compileStaticMethod(CachedMethod cachedMethod)
      Loads a static call-site class for cachedMethod through 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

      public static boolean isCompilable(CachedMethod method)
      Returns whether method can be compiled to a direct call site. The declaring class, the method, and every parameter type must be public, AndroidSupport must not report an Android runtime, and encoding the method name as a class name must leave it unchanged.