src/jdk/nashorn/internal/runtime/linker/Bootstrap.java

Print this page




  40 import jdk.internal.dynalink.linker.LinkerServices;
  41 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
  42 import jdk.nashorn.internal.codegen.RuntimeCallSite;
  43 import jdk.nashorn.internal.runtime.options.Options;
  44 
  45 /**
  46  * This class houses bootstrap method for invokedynamic instructions generated by compiler.
  47  */
  48 public final class Bootstrap {
  49     /** Reference to the seed boostrap function */
  50     public static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "bootstrap", CallSite.class, Lookup.class, String.class, MethodType.class, int.class);
  51 
  52     // do not create me!!
  53     private Bootstrap() {
  54     }
  55 
  56     private static final DynamicLinker dynamicLinker;
  57     static {
  58         final DynamicLinkerFactory factory = new DynamicLinkerFactory();
  59         factory.setPrioritizedLinkers(new NashornLinker(), new NashornPrimitiveLinker(), new NashornStaticClassLinker(),
  60                 new JSObjectLinker(), new ReflectionCheckLinker());
  61         factory.setFallbackLinkers(new BeansLinker(), new NashornBottomLinker());
  62         factory.setSyncOnRelink(true);
  63         final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1);
  64         if (relinkThreshold > -1) {
  65             factory.setUnstableRelinkThreshold(relinkThreshold);
  66         }
  67         dynamicLinker = factory.createLinker();
  68     }
  69 
  70     /**
  71      * Create a call site and link it for Nashorn. This version of the method conforms to the invokedynamic bootstrap
  72      * method expected signature and is referenced from Nashorn generated bytecode as the bootstrap method for all
  73      * invokedynamic instructions.
  74      * @param lookup MethodHandle lookup. Ignored as Nashorn only uses public lookup.
  75      * @param opDesc Dynalink dynamic operation descriptor.
  76      * @param type   Method type.
  77      * @param flags  flags for call type, trace/profile etc.
  78      * @return CallSite with MethodHandle to appropriate method or null if not found.
  79      */
  80     public static CallSite bootstrap(final Lookup lookup, final String opDesc, final MethodType type, final int flags) {




  40 import jdk.internal.dynalink.linker.LinkerServices;
  41 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
  42 import jdk.nashorn.internal.codegen.RuntimeCallSite;
  43 import jdk.nashorn.internal.runtime.options.Options;
  44 
  45 /**
  46  * This class houses bootstrap method for invokedynamic instructions generated by compiler.
  47  */
  48 public final class Bootstrap {
  49     /** Reference to the seed boostrap function */
  50     public static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "bootstrap", CallSite.class, Lookup.class, String.class, MethodType.class, int.class);
  51 
  52     // do not create me!!
  53     private Bootstrap() {
  54     }
  55 
  56     private static final DynamicLinker dynamicLinker;
  57     static {
  58         final DynamicLinkerFactory factory = new DynamicLinkerFactory();
  59         factory.setPrioritizedLinkers(new NashornLinker(), new NashornPrimitiveLinker(), new NashornStaticClassLinker(),
  60                 new JSObjectLinker(), new NioBufferLinker(), new ReflectionCheckLinker());
  61         factory.setFallbackLinkers(new BeansLinker(), new NashornBottomLinker());
  62         factory.setSyncOnRelink(true);
  63         final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1);
  64         if (relinkThreshold > -1) {
  65             factory.setUnstableRelinkThreshold(relinkThreshold);
  66         }
  67         dynamicLinker = factory.createLinker();
  68     }
  69 
  70     /**
  71      * Create a call site and link it for Nashorn. This version of the method conforms to the invokedynamic bootstrap
  72      * method expected signature and is referenced from Nashorn generated bytecode as the bootstrap method for all
  73      * invokedynamic instructions.
  74      * @param lookup MethodHandle lookup. Ignored as Nashorn only uses public lookup.
  75      * @param opDesc Dynalink dynamic operation descriptor.
  76      * @param type   Method type.
  77      * @param flags  flags for call type, trace/profile etc.
  78      * @return CallSite with MethodHandle to appropriate method or null if not found.
  79      */
  80     public static CallSite bootstrap(final Lookup lookup, final String opDesc, final MethodType type, final int flags) {