001/*
002 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package jdk.internal.jvmci.code.stack;
024
025import jdk.internal.jvmci.meta.*;
026
027public interface InspectedFrame {
028
029    /**
030     * Returns the value of the local at the given index. Currently only works for object values.
031     * This value is a copy iff {@link #isVirtual(int)} is true.
032     */
033    Object getLocal(int index);
034
035    /**
036     * Returns whether the local at the given index is a virtual object, and therefore the object
037     * returned by {@link #getLocal(int)} is a copy.
038     */
039    boolean isVirtual(int index);
040
041    /**
042     * Returns true if the stack frame is a compiled stack frame and there are virtual objects
043     * anywhere in the current state of the compiled method. This can return true even if
044     * {@link #isVirtual(int)} return false for all locals.
045     */
046    boolean hasVirtualObjects();
047
048    /**
049     * This method will materialize all virtual objects, deoptimize the stack frame and make sure
050     * that subsequent execution of the deoptimized frame uses the materialized values.
051     */
052    void materializeVirtualObjects(boolean invalidateCode);
053
054    /**
055     * @return the current bytecode index
056     */
057    int getBytecodeIndex();
058
059    /**
060     * @return the current method
061     */
062    ResolvedJavaMethod getMethod();
063
064    /**
065     * Checks if the current method is equal to the given method. This is semantically equivalent to
066     * {@code method.equals(getMethod())}, but can be implemented more efficiently.
067     */
068    boolean isMethod(ResolvedJavaMethod method);
069}