OptimisticBuiltins.java revision 1036:f0b5e3900a10
1189136Sdas/* 2189136Sdas * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 3189136Sdas * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4189136Sdas * 5189136Sdas * This code is free software; you can redistribute it and/or modify it 6189136Sdas * under the terms of the GNU General Public License version 2 only, as 7189136Sdas * published by the Free Software Foundation. Oracle designates this 8189136Sdas * particular file as subject to the "Classpath" exception as provided 9189136Sdas * by Oracle in the LICENSE file that accompanied this code. 10189136Sdas * 11189136Sdas * This code is distributed in the hope that it will be useful, but WITHOUT 12189136Sdas * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13189136Sdas * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14189136Sdas * version 2 for more details (a copy is included in the LICENSE file that 15189136Sdas * accompanied this code). 16189136Sdas * 17189136Sdas * You should have received a copy of the GNU General Public License version 18189136Sdas * 2 along with this work; if not, write to the Free Software Foundation, 19189136Sdas * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20189136Sdas * 21189136Sdas * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22189136Sdas * or visit www.oracle.com if you need additional information or have any 23189136Sdas * questions. 24189136Sdas */ 25189136Sdas 26189136Sdaspackage jdk.nashorn.internal.runtime; 27189136Sdas 28189136Sdasimport jdk.nashorn.internal.objects.annotations.SpecializedFunction; 29189136Sdasimport jdk.nashorn.internal.objects.annotations.SpecializedFunction.LinkLogic; 30189136Sdas 31189136Sdas/** 32189136Sdas * This is an interface for classes that need custom linkage logic. This means Native objects 33189136Sdas * that contain optimistic native methods, that need special/extra rules for linking, guards and 34189136Sdas * SwitchPointing, known and internal to the Native object for its linkage 35189136Sdas */ 36189136Sdaspublic interface OptimisticBuiltins { 37189136Sdas 38189136Sdas /** 39189136Sdas * Return an instance of the linking logic we need for a particular LinkLogic 40 * subclass, gotten from the compile time annotation of a specialized builtin method 41 * No assumptions can be made about the lifetime of the instance. The receiver may 42 * keep it as a perpetual final instance field or create new linking logic depending 43 * on its current state for each call, depending on if the global state has changed 44 * or other factors 45 * 46 * @param clazz linking logic class 47 * @return linking logic instance for this class 48 */ 49 public SpecializedFunction.LinkLogic getLinkLogic(final Class<? extends LinkLogic> clazz); 50 51 /** 52 * Does this link logic vary depending on which instance we are working with. 53 * Then we have to sort out certain primitives, as they are created as new 54 * objects in the wrapFilter by JavaScript semantics. An example of instance only 55 * assumptions are switchPoints per instance, as in NativeArray. NativeString is 56 * fine, as it's only static. 57 * 58 * TODO: finer granularity on this, on the function level so certain functions 59 * are forbidden only. Currently we don't have enough specialization to bump into this 60 * 61 * @return true if there are per instance assumptions for the optimism 62 */ 63 public boolean hasPerInstanceAssumptions(); 64 65} 66