src/jdk/nashorn/internal/ir/TypeOverride.java

Wed, 08 May 2013 15:51:36 +0200

author
attila
date
Wed, 08 May 2013 15:51:36 +0200
changeset 254
d28180d97c61
parent 144
4be452026847
permissions
-rw-r--r--

8013912: Nashorn needs to reuse temporary symbols
Reviewed-by: jlaskey, lagergren

jlaskey@3 1 /*
jlaskey@7 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
jlaskey@3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jlaskey@3 4 *
jlaskey@3 5 * This code is free software; you can redistribute it and/or modify it
jlaskey@3 6 * under the terms of the GNU General Public License version 2 only, as
jlaskey@3 7 * published by the Free Software Foundation. Oracle designates this
jlaskey@3 8 * particular file as subject to the "Classpath" exception as provided
jlaskey@3 9 * by Oracle in the LICENSE file that accompanied this code.
jlaskey@3 10 *
jlaskey@3 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jlaskey@3 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jlaskey@3 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jlaskey@3 14 * version 2 for more details (a copy is included in the LICENSE file that
jlaskey@3 15 * accompanied this code).
jlaskey@3 16 *
jlaskey@3 17 * You should have received a copy of the GNU General Public License version
jlaskey@3 18 * 2 along with this work; if not, write to the Free Software Foundation,
jlaskey@3 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jlaskey@3 20 *
jlaskey@3 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jlaskey@3 22 * or visit www.oracle.com if you need additional information or have any
jlaskey@3 23 * questions.
jlaskey@3 24 */
jlaskey@3 25
jlaskey@3 26 package jdk.nashorn.internal.ir;
jlaskey@3 27
jlaskey@3 28 import jdk.nashorn.internal.codegen.types.Type;
jlaskey@3 29
jlaskey@3 30 /**
jlaskey@3 31 * A type override makes it possible to change the return type of a node, if we know
jlaskey@3 32 * that the linker can provide it directly. For example, an identity node that is
jlaskey@3 33 * in the scope, can very well look like an object to the compiler of the method it
jlaskey@3 34 * is in, but if someone does (int)x, it make senses to ask for it directly
jlaskey@3 35 * with an int getter instead of loading it as an object and explicitly converting it
jlaskey@3 36 * by using JSType.toInt32. Especially in scenarios where the field is already stored
jlaskey@3 37 * as a primitive, this will be much faster than the "object is all I see" scope
jlaskey@3 38 * available in the method
attila@144 39 * @param <T> the type of the node implementing the interface
jlaskey@3 40 */
jlaskey@3 41
attila@144 42 public interface TypeOverride<T extends Node> {
jlaskey@3 43 /**
jlaskey@3 44 * Set the override type
jlaskey@3 45 *
attila@254 46 * @param ts temporary symbols
attila@254 47 * @param lc the current lexical context
attila@254 48 * @param type the type
attila@144 49 * @return a node equivalent to this one except for the requested change.
jlaskey@3 50 */
attila@254 51 public T setType(final TemporarySymbols ts, final LexicalContext lc, final Type type);
jlaskey@3 52
jlaskey@3 53 /**
jlaskey@3 54 * Returns true if this node can have a callsite override, e.g. all scope ident nodes
jlaskey@3 55 * which lead to dynamic getters can have it, local variable nodes (slots) can't.
jlaskey@3 56 * Call nodes can have it unconditionally and so on
jlaskey@3 57 *
jlaskey@3 58 * @return true if it is possible to assign a type override to this node
jlaskey@3 59 */
jlaskey@3 60 public boolean canHaveCallSiteType();
jlaskey@3 61
jlaskey@3 62 }

mercurial