changeset 1472:7dd80d7f47c3

8139588: Remove concept of runtime context arguments, call site tokens, and link counts Reviewed-by: hannesw, sundar
author attila
date Mon, 19 Oct 2015 08:39:06 +0200
parents 33f2143b60a3
children 335632718c1e
files src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinker.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinkerFactory.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/AbstractJavaLinker.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/GuardingDynamicLinker.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/LinkRequest.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/LinkRequestImpl.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/RuntimeContextLinkRequestImpl.java src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/SimpleLinkRequest.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java
diffstat 16 files changed, 161 insertions(+), 409 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -87,16 +87,14 @@
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.invoke.MutableCallSite;
-import java.util.List;
 import java.util.Objects;
 import jdk.internal.dynalink.linker.GuardedInvocation;
 import jdk.internal.dynalink.linker.GuardingDynamicLinker;
 import jdk.internal.dynalink.linker.LinkRequest;
 import jdk.internal.dynalink.linker.LinkerServices;
-import jdk.internal.dynalink.support.LinkRequestImpl;
 import jdk.internal.dynalink.support.Lookup;
-import jdk.internal.dynalink.support.RuntimeContextLinkRequestImpl;
 import jdk.internal.dynalink.support.SimpleCallSiteDescriptor;
+import jdk.internal.dynalink.support.SimpleLinkRequest;
 
 /**
  * The linker for {@link RelinkableCallSite} objects. Users of it (scripting
@@ -164,7 +162,6 @@
 
     private final LinkerServices linkerServices;
     private final GuardedInvocationFilter prelinkFilter;
-    private final int runtimeContextArgCount;
     private final boolean syncOnRelink;
     private final int unstableRelinkThreshold;
 
@@ -173,19 +170,16 @@
      *
      * @param linkerServices the linkerServices used by the linker, created by the factory.
      * @param prelinkFilter see {@link DynamicLinkerFactory#setPrelinkFilter(GuardedInvocationFilter)}
-     * @param runtimeContextArgCount see {@link DynamicLinkerFactory#setRuntimeContextArgCount(int)}
+     * @param syncOnRelink see {@link DynamicLinkerFactory#setSyncOnRelink(boolean)}
+     * @param unstableRelinkThreshold see {@link DynamicLinkerFactory#setUnstableRelinkThreshold(int)}
      */
-    DynamicLinker(final LinkerServices linkerServices, final GuardedInvocationFilter prelinkFilter, final int runtimeContextArgCount,
+    DynamicLinker(final LinkerServices linkerServices, final GuardedInvocationFilter prelinkFilter,
             final boolean syncOnRelink, final int unstableRelinkThreshold) {
-        if(runtimeContextArgCount < 0) {
-            throw new IllegalArgumentException("runtimeContextArgCount < 0");
-        }
         if(unstableRelinkThreshold < 0) {
             throw new IllegalArgumentException("unstableRelinkThreshold < 0");
         }
         this.linkerServices = linkerServices;
         this.prelinkFilter = prelinkFilter;
-        this.runtimeContextArgCount = runtimeContextArgCount;
         this.syncOnRelink = syncOnRelink;
         this.unstableRelinkThreshold = unstableRelinkThreshold;
     }
@@ -250,10 +244,7 @@
         final CallSiteDescriptor callSiteDescriptor = callSite.getDescriptor();
         final boolean unstableDetectionEnabled = unstableRelinkThreshold > 0;
         final boolean callSiteUnstable = unstableDetectionEnabled && relinkCount >= unstableRelinkThreshold;
-        final LinkRequest linkRequest =
-                runtimeContextArgCount == 0 ?
-                        new LinkRequestImpl(callSiteDescriptor, callSite, relinkCount, callSiteUnstable, arguments) :
-                        new RuntimeContextLinkRequestImpl(callSiteDescriptor, callSite, relinkCount, callSiteUnstable, arguments, runtimeContextArgCount);
+        final LinkRequest linkRequest = new SimpleLinkRequest(callSiteDescriptor, callSiteUnstable, arguments);
 
         GuardedInvocation guardedInvocation = linkerServices.getGuardedInvocation(linkRequest);
 
@@ -262,18 +253,6 @@
             throw new NoSuchDynamicMethodException(callSiteDescriptor.toString());
         }
 
-        // If our call sites have a runtime context, and the linker produced a context-stripped invocation, adapt the
-        // produced invocation into contextual invocation (by dropping the context...)
-        if(runtimeContextArgCount > 0) {
-            final MethodType origType = callSiteDescriptor.getMethodType();
-            final MethodHandle invocation = guardedInvocation.getInvocation();
-            if(invocation.type().parameterCount() == origType.parameterCount() - runtimeContextArgCount) {
-                final List<Class<?>> prefix = origType.parameterList().subList(1, runtimeContextArgCount + 1);
-                final MethodHandle guard = guardedInvocation.getGuard();
-                guardedInvocation = guardedInvocation.dropArguments(1, prefix);
-            }
-        }
-
         // Make sure we filter the invocation before linking it into the call site. This is typically used to match the
         // return type of the invocation to the call site.
         guardedInvocation = prelinkFilter.filter(guardedInvocation, linkRequest, linkerServices);
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinkerFactory.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinkerFactory.java	Mon Oct 19 08:39:06 2015 +0200
@@ -125,7 +125,6 @@
 
     private List<? extends GuardingDynamicLinker> prioritizedLinkers;
     private List<? extends GuardingDynamicLinker> fallbackLinkers;
-    private int runtimeContextArgCount = 0;
     private boolean syncOnRelink = false;
     private int unstableRelinkThreshold = DEFAULT_UNSTABLE_RELINK_THRESHOLD;
     private GuardedInvocationFilter prelinkFilter;
@@ -208,23 +207,6 @@
     }
 
     /**
-     * Sets the number of arguments in the call sites that represent the stack context of the language runtime creating
-     * the linker. If the language runtime uses no context information passed on stack, then it should be zero
-     * (the default value). If it is set to nonzero value, then every dynamic call site emitted by this runtime must
-     * have the argument list of the form: {@code (this, contextArg1[, contextArg2[, ...]], normalArgs)}. It is
-     * advisable to only pass one context-specific argument, though, of an easily recognizable, runtime specific type
-     * encapsulating the runtime thread local state.
-     *
-     * @param runtimeContextArgCount the number of language runtime context arguments in call sites.
-     */
-    public void setRuntimeContextArgCount(final int runtimeContextArgCount) {
-        if(runtimeContextArgCount < 0) {
-            throw new IllegalArgumentException("runtimeContextArgCount < 0");
-        }
-        this.runtimeContextArgCount = runtimeContextArgCount;
-    }
-
-    /**
      * Sets whether the linker created by this factory will invoke {@link MutableCallSite#syncAll(MutableCallSite[])}
      * after a call site is relinked. Defaults to false. You probably want to set it to true if your runtime supports
      * multithreaded execution of dynamically linked code.
@@ -364,7 +346,7 @@
         }
 
         return new DynamicLinker(new LinkerServicesImpl(new TypeConverterFactory(typeConverters,
-                autoConversionStrategy), composite, internalObjectsFilter), prelinkFilter, runtimeContextArgCount,
+                autoConversionStrategy), composite, internalObjectsFilter), prelinkFilter,
                 syncOnRelink, unstableRelinkThreshold);
     }
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/AbstractJavaLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/AbstractJavaLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -342,9 +342,8 @@
     @Override
     public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
             throws Exception {
-        final LinkRequest ncrequest = request.withoutRuntimeContext();
         // BeansLinker already checked that the name is at least 2 elements long and the first element is "dyn".
-        final CallSiteDescriptor callSiteDescriptor = ncrequest.getCallSiteDescriptor();
+        final CallSiteDescriptor callSiteDescriptor = request.getCallSiteDescriptor();
         final String op = callSiteDescriptor.getNameToken(CallSiteDescriptor.OPERATOR);
         // Either dyn:callMethod:name(this[,args]) or dyn:callMethod(this,name[,args]).
         if("callMethod" == op) {
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/GuardingDynamicLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/GuardingDynamicLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -102,9 +102,7 @@
      * invocation can also have a switch point for asynchronous invalidation of the linkage, as well as a
      * {@link Throwable} subclass that describes an expected exception condition that also triggers relinking (often it
      * is faster to rely on an infrequent but expected {@link ClassCastException} than on an always evaluated
-     * {@code instanceof} guard). If the linker does not recognize any native language runtime contexts in arguments, or
-     * does recognize its own, but receives a call site descriptor without its recognized context in the arguments, it
-     * should invoke {@link LinkRequest#withoutRuntimeContext()} and link for that. While the linker must produce an
+     * {@code instanceof} guard). While the linker must produce an
      * invocation with parameter types matching those in the call site descriptor of the link request, it should not try
      * to match the return type expected at the call site except when it can do it with only the conversions that lose
      * neither precision nor magnitude, see {@link LinkerServices#asTypeLosslessReturn(java.lang.invoke.MethodHandle,
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/LinkRequest.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/LinkRequest.java	Mon Oct 19 08:39:06 2015 +0200
@@ -99,17 +99,6 @@
     public CallSiteDescriptor getCallSiteDescriptor();
 
     /**
-     * Returns the call site token for the call site being linked. This token is an opaque object that is guaranteed to
-     * have different identity for different call sites, and is also guaranteed to not become weakly reachable before
-     * the call site does and to become weakly reachable some time after the call site does. This makes it ideal as a
-     * candidate for a key in a weak hash map in which a linker might want to keep per-call site linking state (usually
-     * profiling information).
-     *
-     * @return the call site token for the call site being linked.
-     */
-    public Object getCallSiteToken();
-
-    /**
      * Returns the arguments for the invocation being linked. The returned array is a clone; modifications to it won't
      * affect the arguments in this request.
      *
@@ -125,17 +114,6 @@
     public Object getReceiver();
 
     /**
-     * Returns the number of times this callsite has been linked/relinked. This can be useful if you want to
-     * change e.g. exception based relinking to guard based relinking. It's probably not a good idea to keep,
-     * for example, expensive exception throwing relinkage based on failed type checks/ClassCastException in
-     * a nested callsite tree where the exception is thrown repeatedly for the common case. There it would be
-     * much more performant to use exact type guards instead.
-     *
-     * @return link count for call site
-     */
-    public int getLinkCount();
-
-    /**
      * Returns true if the call site is considered unstable, that is, it has been relinked more times than was
      * specified in {@link DynamicLinkerFactory#setUnstableRelinkThreshold(int)}. Linkers should use this as a
      * hint to prefer producing linkage that is more stable (its guard fails less frequently), even if that assumption
@@ -146,18 +124,6 @@
     public boolean isCallSiteUnstable();
 
     /**
-     * Returns a request stripped from runtime context arguments. Some language runtimes will include runtime-specific
-     * context parameters in their call sites as few arguments between 0th argument "this" and the normal arguments. If
-     * a linker does not recognize such contexts at all, or does not recognize the call site as one with its own
-     * context, it can ask for the alternative link request with context parameters and arguments removed, and link
-     * against it instead.
-     *
-     * @return the context-stripped request. If the link request does not have any language runtime specific context
-     * parameters, the same link request is returned.
-     */
-    public LinkRequest withoutRuntimeContext();
-
-    /**
      * Returns a request identical to this one with call site descriptor and arguments replaced with the ones specified.
      *
      * @param callSiteDescriptor the new call site descriptor
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/LinkRequestImpl.java	Mon Oct 19 08:30:03 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file, and Oracle licenses the original version of this file under the BSD
- * license:
- */
-/*
-   Copyright 2009-2013 Attila Szegedi
-
-   Licensed under both the Apache License, Version 2.0 (the "Apache License")
-   and the BSD License (the "BSD License"), with licensee being free to
-   choose either of the two at their discretion.
-
-   You may not use this file except in compliance with either the Apache
-   License or the BSD License.
-
-   If you choose to use this file in compliance with the Apache License, the
-   following notice applies to you:
-
-       You may obtain a copy of the Apache License at
-
-           http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing, software
-       distributed under the License is distributed on an "AS IS" BASIS,
-       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-       implied. See the License for the specific language governing
-       permissions and limitations under the License.
-
-   If you choose to use this file in compliance with the BSD License, the
-   following notice applies to you:
-
-       Redistribution and use in source and binary forms, with or without
-       modification, are permitted provided that the following conditions are
-       met:
-       * Redistributions of source code must retain the above copyright
-         notice, this list of conditions and the following disclaimer.
-       * Redistributions in binary form must reproduce the above copyright
-         notice, this list of conditions and the following disclaimer in the
-         documentation and/or other materials provided with the distribution.
-       * Neither the name of the copyright holder nor the names of
-         contributors may be used to endorse or promote products derived from
-         this software without specific prior written permission.
-
-       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-       IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-       TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-       PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-       BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-       BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-       OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-       ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package jdk.internal.dynalink.support;
-
-import jdk.internal.dynalink.CallSiteDescriptor;
-import jdk.internal.dynalink.linker.LinkRequest;
-
-/**
- * Default implementation of the {@link LinkRequest}, representing a link request to a call site that passes no language
- * runtime specific native context arguments on the stack.
- */
-public class LinkRequestImpl implements LinkRequest {
-
-    private final CallSiteDescriptor callSiteDescriptor;
-    private final Object callSiteToken;
-    private final Object[] arguments;
-    private final boolean callSiteUnstable;
-    private final int linkCount;
-
-    /**
-     * Creates a new link request.
-     *
-     * @param callSiteDescriptor the descriptor for the call site being linked
-     * @param callSiteToken the opaque token for the call site being linked.
-     * @param linkCount how many times this callsite has been linked/relinked
-     * @param callSiteUnstable true if the call site being linked is considered unstable
-     * @param arguments the arguments for the invocation
-     */
-    public LinkRequestImpl(final CallSiteDescriptor callSiteDescriptor, final Object callSiteToken, final int linkCount, final boolean callSiteUnstable, final Object... arguments) {
-        this.callSiteDescriptor = callSiteDescriptor;
-        this.callSiteToken = callSiteToken;
-        this.linkCount = linkCount;
-        this.callSiteUnstable = callSiteUnstable;
-        this.arguments = arguments;
-    }
-
-    @Override
-    public Object[] getArguments() {
-        return arguments != null ? arguments.clone() : null;
-    }
-
-    @Override
-    public Object getReceiver() {
-        return arguments != null && arguments.length > 0 ? arguments[0] : null;
-    }
-
-    @Override
-    public CallSiteDescriptor getCallSiteDescriptor() {
-        return callSiteDescriptor;
-    }
-
-    @Override
-    public Object getCallSiteToken() {
-        return callSiteToken;
-    }
-
-    @Override
-    public boolean isCallSiteUnstable() {
-        return callSiteUnstable;
-    }
-
-    @Override
-    public int getLinkCount() {
-        return linkCount;
-    }
-
-    @Override
-    public LinkRequest withoutRuntimeContext() {
-        return this;
-    }
-
-    @Override
-    public LinkRequest replaceArguments(final CallSiteDescriptor newCallSiteDescriptor, final Object[] newArguments) {
-        return new LinkRequestImpl(newCallSiteDescriptor, callSiteToken, linkCount, callSiteUnstable, newArguments);
-    }
-}
--- a/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/RuntimeContextLinkRequestImpl.java	Mon Oct 19 08:30:03 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file, and Oracle licenses the original version of this file under the BSD
- * license:
- */
-/*
-   Copyright 2009-2013 Attila Szegedi
-
-   Licensed under both the Apache License, Version 2.0 (the "Apache License")
-   and the BSD License (the "BSD License"), with licensee being free to
-   choose either of the two at their discretion.
-
-   You may not use this file except in compliance with either the Apache
-   License or the BSD License.
-
-   If you choose to use this file in compliance with the Apache License, the
-   following notice applies to you:
-
-       You may obtain a copy of the Apache License at
-
-           http://www.apache.org/licenses/LICENSE-2.0
-
-       Unless required by applicable law or agreed to in writing, software
-       distributed under the License is distributed on an "AS IS" BASIS,
-       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-       implied. See the License for the specific language governing
-       permissions and limitations under the License.
-
-   If you choose to use this file in compliance with the BSD License, the
-   following notice applies to you:
-
-       Redistribution and use in source and binary forms, with or without
-       modification, are permitted provided that the following conditions are
-       met:
-       * Redistributions of source code must retain the above copyright
-         notice, this list of conditions and the following disclaimer.
-       * Redistributions in binary form must reproduce the above copyright
-         notice, this list of conditions and the following disclaimer in the
-         documentation and/or other materials provided with the distribution.
-       * Neither the name of the copyright holder nor the names of
-         contributors may be used to endorse or promote products derived from
-         this software without specific prior written permission.
-
-       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-       IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-       TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-       PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-       BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-       BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-       OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-       ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-package jdk.internal.dynalink.support;
-
-import jdk.internal.dynalink.CallSiteDescriptor;
-import jdk.internal.dynalink.linker.LinkRequest;
-
-/**
- * A link request implementation for call sites that pass language runtime specific context arguments on the stack. The
- * context specific arguments should be the first "n" arguments.
- */
-public class RuntimeContextLinkRequestImpl extends LinkRequestImpl {
-
-    private final int runtimeContextArgCount;
-    private LinkRequestImpl contextStrippedRequest;
-
-    /**
-     * Creates a new link request.
-     *
-     * @param callSiteDescriptor the descriptor for the call site being linked
-     * @param callSiteToken the opaque token for the call site being linked.
-     * @param arguments the arguments for the invocation
-     * @param linkCount number of times callsite has been linked/relinked
-     * @param callSiteUnstable true if the call site being linked is considered unstable
-     * @param runtimeContextArgCount the number of the leading arguments on the stack that represent the language
-     * runtime specific context arguments.
-     * @throws IllegalArgumentException if runtimeContextArgCount is less than 1.
-     */
-    public RuntimeContextLinkRequestImpl(final CallSiteDescriptor callSiteDescriptor, final Object callSiteToken,
-            final int linkCount, final boolean callSiteUnstable, final Object[] arguments, final int runtimeContextArgCount) {
-        super(callSiteDescriptor, callSiteToken, linkCount, callSiteUnstable, arguments);
-        if(runtimeContextArgCount < 1) {
-            throw new IllegalArgumentException("runtimeContextArgCount < 1");
-        }
-        this.runtimeContextArgCount = runtimeContextArgCount;
-    }
-
-    @Override
-    public LinkRequest withoutRuntimeContext() {
-        if(contextStrippedRequest == null) {
-            final CallSiteDescriptor desc = getCallSiteDescriptor();
-            contextStrippedRequest =
-                    new LinkRequestImpl(desc.changeMethodType(desc.getMethodType().dropParameterTypes(1, runtimeContextArgCount + 1)),
-                            getCallSiteToken(), getLinkCount(), isCallSiteUnstable(), getTruncatedArguments());
-        }
-        return contextStrippedRequest;
-    }
-
-    @Override
-    public LinkRequest replaceArguments(final CallSiteDescriptor callSiteDescriptor, final Object[] arguments) {
-        return new RuntimeContextLinkRequestImpl(callSiteDescriptor, getCallSiteToken(), getLinkCount(), isCallSiteUnstable(), arguments,
-                runtimeContextArgCount);
-    }
-
-    private Object[] getTruncatedArguments() {
-        final Object[] args = getArguments();
-        final Object[] newargs = new Object[args.length - runtimeContextArgCount];
-        newargs[0] = args[0]; // "this" remains at the 0th position
-        System.arraycopy(args, runtimeContextArgCount + 1, newargs, 1, newargs.length - 1);
-        return newargs;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/SimpleLinkRequest.java	Mon Oct 19 08:39:06 2015 +0200
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+   Copyright 2009-2013 Attila Szegedi
+
+   Licensed under both the Apache License, Version 2.0 (the "Apache License")
+   and the BSD License (the "BSD License"), with licensee being free to
+   choose either of the two at their discretion.
+
+   You may not use this file except in compliance with either the Apache
+   License or the BSD License.
+
+   If you choose to use this file in compliance with the Apache License, the
+   following notice applies to you:
+
+       You may obtain a copy of the Apache License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing, software
+       distributed under the License is distributed on an "AS IS" BASIS,
+       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+       implied. See the License for the specific language governing
+       permissions and limitations under the License.
+
+   If you choose to use this file in compliance with the BSD License, the
+   following notice applies to you:
+
+       Redistribution and use in source and binary forms, with or without
+       modification, are permitted provided that the following conditions are
+       met:
+       * Redistributions of source code must retain the above copyright
+         notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above copyright
+         notice, this list of conditions and the following disclaimer in the
+         documentation and/or other materials provided with the distribution.
+       * Neither the name of the copyright holder nor the names of
+         contributors may be used to endorse or promote products derived from
+         this software without specific prior written permission.
+
+       THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+       IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+       TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+       PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+       BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+       BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+       OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+       ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.internal.dynalink.support;
+
+import jdk.internal.dynalink.CallSiteDescriptor;
+import jdk.internal.dynalink.linker.LinkRequest;
+
+/**
+ * Default simple implementation of {@link LinkRequest}.
+ */
+public class SimpleLinkRequest implements LinkRequest {
+
+    private final CallSiteDescriptor callSiteDescriptor;
+    private final Object[] arguments;
+    private final boolean callSiteUnstable;
+
+    /**
+     * Creates a new link request.
+     *
+     * @param callSiteDescriptor the descriptor for the call site being linked
+     * @param callSiteUnstable true if the call site being linked is considered unstable
+     * @param arguments the arguments for the invocation
+     */
+    public SimpleLinkRequest(final CallSiteDescriptor callSiteDescriptor, final boolean callSiteUnstable, final Object... arguments) {
+        this.callSiteDescriptor = callSiteDescriptor;
+        this.callSiteUnstable = callSiteUnstable;
+        this.arguments = arguments;
+    }
+
+    @Override
+    public Object[] getArguments() {
+        return arguments != null ? arguments.clone() : null;
+    }
+
+    @Override
+    public Object getReceiver() {
+        return arguments != null && arguments.length > 0 ? arguments[0] : null;
+    }
+
+    @Override
+    public CallSiteDescriptor getCallSiteDescriptor() {
+        return callSiteDescriptor;
+    }
+
+    @Override
+    public boolean isCallSiteUnstable() {
+        return callSiteUnstable;
+    }
+
+    @Override
+    public LinkRequest replaceArguments(final CallSiteDescriptor newCallSiteDescriptor, final Object[] newArguments) {
+        return new SimpleLinkRequest(newCallSiteDescriptor, callSiteUnstable, newArguments);
+    }
+}
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeObject.java	Mon Oct 19 08:39:06 2015 +0200
@@ -44,7 +44,7 @@
 import jdk.internal.dynalink.linker.GuardedInvocation;
 import jdk.internal.dynalink.linker.GuardingDynamicLinker;
 import jdk.internal.dynalink.linker.LinkRequest;
-import jdk.internal.dynalink.support.LinkRequestImpl;
+import jdk.internal.dynalink.support.SimpleLinkRequest;
 import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.lookup.Lookup;
 import jdk.nashorn.internal.objects.annotations.Attribute;
@@ -834,8 +834,8 @@
     }
 
     private static LinkRequest createLinkRequest(final String operation, final MethodType methodType, final Object source) {
-        return new LinkRequestImpl(NashornCallSiteDescriptor.get(MethodHandles.publicLookup(), operation,
-                methodType, 0), null, 0, false, source);
+        return new SimpleLinkRequest(NashornCallSiteDescriptor.get(MethodHandles.publicLookup(), operation,
+                methodType, 0), false, source);
     }
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -96,9 +96,8 @@
 
     @Override
     public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
-        final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
-        final Object self = requestWithoutContext.getReceiver();
-        final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
+        final Object self = request.getReceiver();
+        final CallSiteDescriptor desc = request.getCallSiteDescriptor();
         checkJSObjectClass();
 
         if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -67,9 +67,8 @@
 
     @Override
     public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
-        final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
-        final Object self = requestWithoutContext.getReceiver();
-        final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
+        final Object self = request.getReceiver();
+        final CallSiteDescriptor desc = request.getCallSiteDescriptor();
 
         if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
             // We only support standard "dyn:*[:*]" operations
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Mon Oct 19 08:39:06 2015 +0200
@@ -47,7 +47,7 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import jdk.internal.dynalink.beans.StaticClass;
-import jdk.internal.dynalink.support.LinkRequestImpl;
+import jdk.internal.dynalink.support.SimpleLinkRequest;
 import jdk.nashorn.internal.runtime.Context;
 import jdk.nashorn.internal.runtime.ECMAException;
 import jdk.nashorn.internal.runtime.ScriptFunction;
@@ -188,9 +188,9 @@
      */
     public static MethodHandle getConstructor(final Class<?> sourceType, final Class<?> targetType, final MethodHandles.Lookup lookup) throws Exception {
         final StaticClass adapterClass = getAdapterClassFor(new Class<?>[] { targetType }, null, lookup);
-        return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(
+        return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new SimpleLinkRequest(
                 NashornCallSiteDescriptor.get(lookup, "dyn:new",
-                        MethodType.methodType(targetType, StaticClass.class, sourceType), 0), null, 0, false,
+                        MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false,
                         adapterClass, null)).getInvocation(), adapterClass);
     }
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -86,9 +86,8 @@
 
     @Override
     public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
-        final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
-        final Object self = requestWithoutContext.getReceiver();
-        final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
+        final Object self = request.getReceiver();
+        final CallSiteDescriptor desc = request.getCallSiteDescriptor();
 
         if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
             // We only support standard "dyn:*[:*]" operations
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -61,10 +61,8 @@
     }
 
     @Override
-    public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices)
+    public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
             throws Exception {
-        final LinkRequest request = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context
-
         final Object self = request.getReceiver();
         final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor) request.getCallSiteDescriptor();
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -59,8 +59,7 @@
     }
 
     @Override
-    public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception {
-        final LinkRequest request = linkRequest.withoutRuntimeContext(); // Nashorn has no runtime context
+    public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
         final Object self = request.getReceiver();
         if (self.getClass() != StaticClass.class) {
             return null;
@@ -83,7 +82,7 @@
                 // Change this link request into a link request on the adapter class.
                 final Object[] args = request.getArguments();
                 args[0] = JavaAdapterFactory.getAdapterClassFor(new Class<?>[] { receiverClass }, null,
-                        NashornCallSiteDescriptor.getLookupPrivileged(linkRequest.getCallSiteDescriptor()));
+                        NashornCallSiteDescriptor.getLookupPrivileged(request.getCallSiteDescriptor()));
                 final LinkRequest adapterRequest = request.replaceArguments(request.getCallSiteDescriptor(), args);
                 final GuardedInvocation gi = checkNullConstructor(delegate(linkerServices, adapterRequest), receiverClass);
                 // Finally, modify the guard to test for the original abstract class.
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java	Mon Oct 19 08:30:03 2015 +0200
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java	Mon Oct 19 08:39:06 2015 +0200
@@ -115,7 +115,7 @@
         }
     }
 
-    private static void checkLinkRequest(final LinkRequest origRequest) {
+    private static void checkLinkRequest(final LinkRequest request) {
         final Global global = Context.getGlobal();
         final ClassFilter cf = global.getClassFilter();
         if (cf != null) {
@@ -124,11 +124,10 @@
 
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            final LinkRequest requestWithoutContext = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context
-            final Object self = requestWithoutContext.getReceiver();
+            final Object self = request.getReceiver();
             // allow 'static' access on Class objects representing public classes of non-restricted packages
             if ((self instanceof Class) && Modifier.isPublic(((Class<?>)self).getModifiers())) {
-                final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
+                final CallSiteDescriptor desc = request.getCallSiteDescriptor();
                 if(desc.tokenizeOperators().contains("getProp")) {
                     if (desc.getNameTokenCount() > CallSiteDescriptor.NAME_OPERAND &&
                         "static".equals(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND))) {