Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8148926

Call site profiling fails on braces-wrapped anonymous function

    Details

    • Subcomponent:
    • Resolved In Build:
      b105
    • CPU:
      x86_64
    • OS:
      windows_7

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.8.0_71"
        Java(TM) SE Runtime Environment (build 1.8.0_71-b15)
        Java HotSpot(TM) 64-Bit Server VM (build 25.71-b15, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows [Version 6.1.7601]

        A DESCRIPTION OF THE PROBLEM :
        When execution Nashorn with call site profiling enabled, scripts that directly invoke a braces-wrapped function literal will cause the engine to fail with an IllegalArgumentException / BootstrapMethodError during call site initialization. The same function literal invoked instead via the call or apply functions will not be affected by this problem.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Execute the following scripts with jjs --profile-callsites=true

        Script 1: (function(){ print('test');}())

        Script 2: (function(){ print('test');})()

        Script 3: (function(){ print('test');}).call(this);

        Script 4: (function(){ print('test');}.call(this));

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Script 1 through 4 are executed successfully and 'test' is printed to the console four times
        ACTUAL -
        Script 1 and 2 fail with an IllegalArgumentException / BootstrapMethodError
        Script 3 and 4 succeeed and print 'test' to the console twice

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
                at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
                at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
                at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
                at jdk.nashorn.internal.scripts.Script$2$\^shell\_.:program(<shell>:1)
                at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
                at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228)
                at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
                at jdk.nashorn.internal.runtime.Context.eval(Context.java:740)
                at jdk.nashorn.internal.runtime.Context.eval(Context.java:675)
                at jdk.nashorn.tools.Shell.readEvalPrint(Shell.java:442)
                at jdk.nashorn.tools.Shell.run(Shell.java:161)
                at jdk.nashorn.tools.Shell.main(Shell.java:136)
                at jdk.nashorn.tools.Shell.main(Shell.java:112)
        Caused by: java.lang.IllegalArgumentException: target and filter types do not match: (ScriptObject,ScriptObject)Object, (Object)Object
                at java.lang.invoke.MethodHandleStatics.newIllegalArgumentException(MethodHandleStatics.java:145)
                at java.lang.invoke.MethodHandles.filterArgumentChecks(MethodHandles.java:2631)
                at java.lang.invoke.MethodHandles.filterArgument(MethodHandles.java:2608)
                at java.lang.invoke.MethodHandles.filterArguments(MethodHandles.java:2601)
                at jdk.nashorn.internal.lookup.MethodHandleFactory$StandardMethodHandleFunctionality.filterArguments(MethodHandleFactory.java:383)
                at jdk.nashorn.internal.runtime.linker.LinkerCallSite$ProfilingLinkerCallSite.setTarget(LinkerCallSite.java:241)
                at jdk.internal.dynalink.support.AbstractRelinkableCallSite.initialize(AbstractRelinkableCallSite.java:115)
                at jdk.internal.dynalink.DynamicLinker.link(DynamicLinker.java:201)
                at jdk.nashorn.internal.runtime.linker.Bootstrap.bootstrap(Bootstrap.java:207)
                at java.lang.invoke.CallSite.makeSite(CallSite.java:294)
                ... 12 more

        REPRODUCIBILITY :
        This bug can be reproduced always.

        CUSTOMER SUBMITTED WORKAROUND :
        Use invocations via functions from Function prototype (call / apply) to execute braces-wrapped (anonymous) function literal.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  sundar Sundararajan Athijegannathan
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: