hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Frame.java
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.runtime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.code.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.compiler.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.c1.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.interpreter.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.oops.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
import sun.jvm.hotspot.utilities.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
/** <P> A frame represents a physical stack frame (an activation).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    Frames can be C or Java frames, and the Java frames can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    interpreted or compiled. In contrast, vframes represent
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    source-level activations, so that one physical frame can
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    correspond to multiple source level frames because of inlining.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    <P> NOTE that this is not a VMObject and does not wrap an Address
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    -- this is an actual port of the VM's Frame code to Java. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    <P> NOTE also that this is incomplete -- just trying to get
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    reading of interpreted frames working for now, so all non-core and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    setter methods are removed for now. (FIXME) </P> */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
public abstract class Frame implements Cloneable {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  /** A raw stack pointer. The accessor getSP() will return a real (usable)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
      stack pointer (e.g. from Thread::last_Java_sp) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  protected Address raw_sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  /** Program counter (the next instruction after the call) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  protected Address pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  protected boolean deoptimized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  public Frame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    deoptimized = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    VM.registerVMInitializedObserver(new Observer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        public void update(Observable o, Object data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
          initialize(VM.getVM().getTypeDataBase());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  /** Size of constMethodOopDesc for computing BCI from BCP (FIXME: hack) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  private static long    constMethodOopDescSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  private static synchronized void initialize(TypeDataBase db) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    Type constMethodOopType = db.lookupType("constMethodOopDesc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // FIXME: not sure whether alignment here is correct or how to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    // force it (round up to address size?)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    constMethodOopDescSize = constMethodOopType.getSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  protected int bcpToBci(Address bcp, ConstMethod cm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    // bcp will be null for interpreter native methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    // in addition depending on where we catch the system the value can
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    // be a bcp or a bci.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    if (bcp == null) return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    long bci = bcp.minus(null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    if (bci >= 0 && bci < cm.getCodeSize()) return (int) bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    return (int) (bcp.minus(cm.getHandle()) - constMethodOopDescSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  protected int bcpToBci(Address bcp, Method m) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    return bcpToBci(bcp, m.getConstMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  public abstract Object clone();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  /** pc: Returns the pc at which this frame will continue normally.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      It must point at the beginning of the next instruction to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      execute. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  public Address getPC()              { return pc; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  public void    setPC(Address newpc) { pc = newpc; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  public boolean isDeoptimized()      { return deoptimized; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  public abstract Address getSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  public abstract Address getID();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  public abstract Address getFP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  /** testers -- platform dependent */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  public abstract boolean equals(Object arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  /** type testers */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  public boolean isInterpretedFrame()           { return VM.getVM().getInterpreter().contains(getPC()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  public boolean isJavaFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    if (isInterpretedFrame()) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    if (!VM.getVM().isCore()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      if (isCompiledFrame())    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  /** Java frame called from C? */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  public boolean isEntryFrame()                 { return VM.getVM().getStubRoutines().returnsToCallStub(getPC()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  public boolean isNativeFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    if (!VM.getVM().isCore()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      return (cb != null && cb.isNativeMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  public boolean isCompiledFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      Assert.that(!VM.getVM().isCore(), "noncore builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    return (cb != null && cb.isJavaMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  public boolean isGlueFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      Assert.that(!VM.getVM().isCore(), "noncore builds only");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    if (cb == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    if (cb.isRuntimeStub()) return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    else return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  /** oldest frame? (has no sender) FIXME: this is modified from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      C++ code to handle the debugging situation where we try to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
      traverse the stack for, for example, the signal thread, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
      don't find any valid Java frames. Would really like to put the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
      second half of the conditional in some sort of debugging-only if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      statement. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // *** FIXME: THE CALL TO isJavaFrame() IS WAY TOO EXPENSIVE!!!!! ***
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  public boolean isFirstFrame()                 { return ((isEntryFrame() && entryFrameIsFirst()) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
                                                          (!isJavaFrame() && !hasSenderPD()));       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  /** same for Java frame */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  public boolean isFirstJavaFrame()             { throw new RuntimeException("not yet implemented"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  /** This is an addition for debugging purposes on platforms which
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
      have the notion of signals. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  public abstract boolean isSignalHandlerFrameDbg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  /** If this is a signal handler frame (again, on a platform with a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      notion of signals), get the signal number. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  public abstract int getSignalNumberDbg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  /** If this is a signal handler frame (again, on a platform with a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      notion of signals), get the name of the signal. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  public abstract String getSignalNameDbg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  /** performs sanity checks on interpreted frames. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  public abstract boolean isInterpretedFrameValid();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  /** tells whether this frame is marked for deoptimization */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  public boolean shouldBeDeoptimized()          { throw new RuntimeException("not yet implemented"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  /** tells whether this frame can be deoptimized */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  public boolean canBeDeoptimized()             { throw new RuntimeException("not yet implemented"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  /** returns the sending frame */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  public abstract Frame sender(RegisterMap map, CodeBlob nm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  /** equivalent to sender(map, null) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  public Frame sender(RegisterMap map)          { return sender(map, null); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  /** returns the sender, but skips conversion frames */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  public Frame realSender(RegisterMap map) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    if (!VM.getVM().isCore()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      Frame result = sender(map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      while (result.isGlueFrame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        result = result.sender(map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      return sender(map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  /** Platform-dependent query indicating whether this frame has a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
      sender. Should return true if it is possible to call sender() at
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
      all on this frame. (This is currently only needed for the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      debugging system, if a stack trace is attempted for a Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      thread which has no Java frames, i.e., the signal thread; we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      have to know to stop traversal at the bottom frame.) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  protected abstract boolean hasSenderPD();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // All frames:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  // A low-level interface for vframes:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  /** Returns the address of the requested "slot" on the stack. Slots
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      are as wide as addresses, so are 32 bits wide on a 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      machine and 64 bits wide on a 64-bit machine. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  public Address   addressOfStackSlot(int slot)              { return getFP().addOffsetTo(slot * VM.getVM().getAddressSize()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  /** Fetches the OopHandle at the requested slot */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  public OopHandle getOopHandleAt(int slot)                  { return addressOfStackSlot(slot).getOopHandleAt(0);              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  /** Fetches the OopHandle at the slot, adjusted for compiler frames */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // FIXME: looks like this is only used for compiled frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  //  public OopHandle getOopHandleAtAdjusted(MethodOop method, int slot) { return addressOfStackSlot(slot).getOopHandleAt(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // FIXME: Not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  //  public void  setOopHandleAt(int slot, OopHandle value) { addressOfStackSlot(slot).setOopHandleAt(0, value);              }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  /** Fetches the (Java) int at the requested slot */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  public int       getIntAt(int slot)                        { return addressOfStackSlot(slot).getJIntAt(0);                   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // FIXME: Not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // public void setIntAt(int slot, int value)               { addressOfStackSlot(slot).setJIntAt(0, value);                   }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  /** returns the frame size in stack slots */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  public abstract long frameSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  /** Link (i.e., the pointer to the previous frame) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  public abstract Address getLink();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  //  public abstract void    setLink(Address addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  /** Return address */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  public abstract Address getSenderPC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // FIXME: currently unimplementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  //  public abstract void    setSenderPC(Address addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  /** The frame's original SP, before any extension by an interpreted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      callee; used for packing debug info into vframeArray objects and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      vframeArray lookup. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  public abstract Address getUnextendedSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  /** Returns the stack pointer of the calling frame */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  public abstract Address getSenderSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // Interpreter frames:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  public abstract Address addressOfInterpreterFrameLocals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  public Address addressOfInterpreterFrameLocal(int slot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    return addressOfInterpreterFrameLocals().getAddressAt(0).addOffsetTo(-slot * VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // FIXME: not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  //  void interpreter_frame_set_locals(intptr_t* locs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  // NOTE that the accessor "addressOfInterpreterFrameBCX" has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  // necessarily been eliminated. The byte code pointer is inherently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // an interior pointer to a Method (the bytecodes follow the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // methodOopDesc data structure) and therefore acquisition of it in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // this system can not be allowed. All accesses to interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // byte codes are via the byte code index (BCI).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  /** Byte code index. In the underlying frame, what is actually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
      stored is a byte code pointer (BCP), which is converted to a BCI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
      and back by the GC when methods are moved. In this system,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
      interior pointers are not allowed, so we must make the access to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      the interpreter frame's BCI atomic with respect to GC. This may
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
      mean implementation with an underlying call through native code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
      into the VM or a magic sequence in the compiler. (FIXME) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  public abstract int     getInterpreterFrameBCI();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // FIXME: not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // public abstract void setInterpreterFrameBCI(int bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // FIXME: elided for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  //  public abstract Address addressOfInterpreterCalleeReceiver(Symbol signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  /** Find receiver for an invoke when arguments are just pushed on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
      stack (i.e., callee stack-frame is not setup) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // FIXME: elided for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  //  public OopHandle getInterpreterCalleeReceiver(SymbolOop signature) { return addressOfInterpreterCalleeReceiver(signature).getOopHandleAt(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  // Expression stack (may go up or down, direction == 1 or -1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  public abstract Address addressOfInterpreterFrameExpressionStack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  public abstract int     getInterpreterFrameExpressionStackDirection();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  public Address addressOfInterpreterFrameExpressionStackSlot(int slot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    return addressOfInterpreterFrameExpressionStack().addOffsetTo(-slot * VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  /** Top of expression stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  public abstract Address addressOfInterpreterFrameTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  /** Expression stack from top down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  public abstract Address addressOfInterpreterFrameTOSAt(int slot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  /** FIXME: is this portable? */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  public int getInterpreterFrameExpressionStackSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    return (int) (1 + (getInterpreterFrameExpressionStackDirection() *
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
                       (addressOfInterpreterFrameTOS().minus(addressOfInterpreterFrameExpressionStack()))));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  public abstract Address getInterpreterFrameSenderSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // FIXME: not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  //  public abstract void    setInterpreterFrameSenderSP(Address senderSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  // BasicObjectLocks:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  public abstract BasicObjectLock interpreterFrameMonitorBegin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  public abstract BasicObjectLock interpreterFrameMonitorEnd();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  /** NOTE: this returns a size in BYTES in this system! */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  public abstract int     interpreterFrameMonitorSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  public          BasicObjectLock nextMonitorInInterpreterFrame(BasicObjectLock cur) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    return new BasicObjectLock(cur.address().addOffsetTo(interpreterFrameMonitorSize()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  public          BasicObjectLock previousMonitorInInterpreterFrame(BasicObjectLock cur) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    return new BasicObjectLock(cur.address().addOffsetTo(-1 * interpreterFrameMonitorSize()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // interpreter_frame_monitor_begin is higher in memory than interpreter_frame_monitor_end
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // Interpreter_frame_monitor_begin points to one element beyond the oldest one,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // interpreter_frame_monitor_end   points to the youngest one, or if there are none,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  //                                 it points to one beyond where the first element will be.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  // interpreter_frame_monitor_size  reports the allocation size of a monitor in the interpreter stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  //                                 this value is >= BasicObjectLock::size(), and may be rounded up
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  // FIXME: avoiding implementing this for now if possible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  //  public void interpreter_frame_set_monitor_end(BasicObjectLock* value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  //  public void interpreter_frame_verify_monitor(BasicObjectLock* value) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  // Tells whether the current interpreter_frame frame pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  // corresponds to the old compiled/deoptimized fp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  // The receiver used to be a top level frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  // public boolean interpreter_frame_equals_unpacked_fp(intptr_t* fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  // Method and constant pool cache:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  /** Current method */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  public abstract Address  addressOfInterpreterFrameMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  /** Current method */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  public Method            getInterpreterFrameMethod() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    return (Method) VM.getVM().getObjectHeap().newOop(addressOfInterpreterFrameMethod().getOopHandleAt(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  /** Current method */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // FIXME: not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  //  public void          setInterpreterFrameMethod(Method method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  /** Constant pool cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  public abstract Address  addressOfInterpreterFrameCPCache();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  /** Constant pool cache */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  public ConstantPoolCache getInterpreterFrameCPCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
    return (ConstantPoolCache) VM.getVM().getObjectHeap().newOop(addressOfInterpreterFrameCPCache().getOopHandleAt(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  // Entry frames:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  public abstract JavaCallWrapper getEntryFrameCallWrapper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  // FIXME: add
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  //  inline intptr_t* entry_frame_argument_at(int offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  /** Tells whether there is another chunk of Delta stack above */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  public boolean entryFrameIsFirst()            { return (getEntryFrameCallWrapper().getLastJavaSP() == null); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  // Safepoints:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  protected abstract Address addressOfSavedOopResult();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  protected abstract Address addressOfSavedReceiver();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  public OopHandle getSavedOopResult() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    return addressOfSavedOopResult().getOopHandleAt(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  // FIXME: not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  //  public void      setSavedOopResult(OopHandle obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  public OopHandle getSavedReceiver() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    return addressOfSavedReceiver().getOopHandleAt(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // FIXME: not yet implementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  //  public void      setSavedReceiver(OopHandle obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // Oop traversals:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  public void oopsInterpretedArgumentsDo(Symbol signature, boolean isStatic, AddressVisitor f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    ArgumentOopFinder finder = new ArgumentOopFinder(signature, isStatic, this, f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    finder.oopsDo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  /** Conversion from an VMReg::Name to physical stack location */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  public Address oopMapRegToLocation(VMReg reg, RegisterMap regMap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    VMReg stack0 = VM.getVM().getVMRegImplInfo().getStack0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    if (reg.lessThan(stack0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
      // If it is passed in a register, it got spilled in the stub frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
      return regMap.getLocation(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
      long spOffset = VM.getVM().getAddressSize() * reg.minus(stack0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      return getUnextendedSP().addOffsetTo(spOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  public void oopsDo(AddressVisitor oopVisitor, RegisterMap map) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    if (isInterpretedFrame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
      oopsInterpretedDo(oopVisitor, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    } else if (isEntryFrame()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
      oopsEntryDo(oopVisitor, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    } else if (VM.getVM().getCodeCache().contains(getPC())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
      oopsCodeBlobDo(oopVisitor, map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
      Assert.that(false, "should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  // Printing code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  public void printValue() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    printValueOn(System.out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  public void printValueOn(PrintStream tty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    //    FIXME;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  public void print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
    printOn(System.out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  public void printOn(PrintStream tty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    //    FIXME;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  public void interpreterFramePrintOn(PrintStream tty) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    //    FIXME;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  // Get/set typed locals from a frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  // Respects platform dependent word-ordering.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  // FIXME: avoiding implementing this for now if possible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  // Currently these work only for interpreted frames.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  // Todo: make these work for compiled frames.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  //  oop     get_local_object(jint slot) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  //  jint    get_local_int   (jint slot) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  //  jlong   get_local_long  (jint slot) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  //  jfloat  get_local_float (jint slot) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  //  jdouble get_local_double(jint slot) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  //  void set_local_object(jint slot, oop     obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  //  void set_local_int   (jint slot, jint    i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  //  void set_local_long  (jint slot, jlong   l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  //  void set_local_float (jint slot, jfloat  f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  //  void set_local_double(jint slot, jdouble d);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  // FIXME: add safepoint code, oops_do, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  // FIXME: NOT FINISHED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  // Internals only below this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  //   /** Helper method for better factored code in frame::sender */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  //   private frame sender_for_entry_frame(RegisterMap* map)        { throw new RuntimeException("not yet implemented"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  //   private frame sender_for_interpreter_frame(RegisterMap* map)  { throw new RuntimeException("not yet implemented"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  // Oop iteration (FIXME: NOT FINISHED)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  private static class InterpVisitor implements OopMapVisitor {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    private AddressVisitor addressVisitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    public InterpVisitor(AddressVisitor oopVisitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
      setAddressVisitor(oopVisitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    public void setAddressVisitor(AddressVisitor addressVisitor) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      this.addressVisitor = addressVisitor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    public void visitOopLocation(Address oopAddr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      addressVisitor.visitAddress(oopAddr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    public void visitDerivedOopLocation(Address baseOopAddr, Address derivedOopAddr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
      if (VM.getVM().isClientCompiler()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
        Assert.that(false, "should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      } else if (VM.getVM().isServerCompiler() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
                 VM.getVM().useDerivedPointerTable()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        Assert.that(false, "FIXME: add derived pointer table");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    public void visitValueLocation(Address valueAddr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   537
    public void visitNarrowOopLocation(Address compOopAddr) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   538
      addressVisitor.visitCompOopAddress(compOopAddr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  private void oopsInterpretedDo(AddressVisitor oopVisitor, RegisterMap map) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
      Assert.that(map != null, "map must be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    Method m = getInterpreterFrameMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
    int bci  = getInterpreterFrameBCI();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
    // FIXME: Seeing this sometimes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    if (VM.getVM().isDebugging()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
      if (bci < 0 || bci >= m.getCodeSize()) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
      //      Assert.that(VM.getVM().getUniverse().heap().isIn(m), "method must be valid oop");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      Assert.that((m.isNative() && (bci == 0)) || ((bci >= 0) && (bci < m.getCodeSize())), "invalid bci value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    // Handle the monitor elements in the activation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    // FIXME: monitor information not yet exposed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
    //    for (
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    //      BasicObjectLock* current = interpreter_frame_monitor_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
    //      current < interpreter_frame_monitor_begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
    //      current = next_monitor_in_interpreter_frame(current)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
    //    ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
    //#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
    //      interpreter_frame_verify_monitor(current);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
    //#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
    //      current->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
    //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    // process fixed part
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    oopVisitor.visitAddress(addressOfInterpreterFrameMethod());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
    oopVisitor.visitAddress(addressOfInterpreterFrameCPCache());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
    // FIXME: expose interpreterFrameMirrorOffset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
    //    if (m.isNative() && m.isStatic()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
    //      oopVisitor.visitAddress(getFP().addOffsetTo(interpreterFrameMirrorOffset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
    //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
    int maxLocals = (int) (m.isNative() ? m.getSizeOfParameters() : m.getMaxLocals());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    InterpreterFrameClosure blk = new InterpreterFrameClosure(this, maxLocals, (int) m.getMaxStack(), oopVisitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    // process locals & expression stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
    OopMapCacheEntry mask = m.getMaskFor(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
    mask.iterateOop(blk);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
    // process a callee's arguments if we are at a call site
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
    // (i.e., if we are at an invoke bytecode)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
    if (map.getIncludeArgumentOops() && !m.isNative()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
      BytecodeInvoke call = BytecodeInvoke.atCheck(m, bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
      if (call != null && getInterpreterFrameExpressionStackSize() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
        // we are at a call site & the expression stack is not empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
        // => process callee's arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
        //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
        // Note: The expression stack can be empty if an exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
        //       occured during method resolution/execution. In all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
        //       cases we empty the expression stack completely be-
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
        //       fore handling the exception (the exception handling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
        //       code in the interpreter calls a blocking runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
        //       routine which can cause this code to be executed).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
        //       (was bug gri 7/27/98)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
        oopsInterpretedArgumentsDo(call.signature(), call.isInvokestatic(), oopVisitor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  private void oopsEntryDo      (AddressVisitor oopVisitor, RegisterMap regMap) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  private void oopsCodeBlobDo   (AddressVisitor oopVisitor, RegisterMap regMap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    CodeBlob cb = VM.getVM().getCodeCache().findBlob(getPC());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
      Assert.that(cb != null, "sanity check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    if (cb.getOopMaps() != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
      OopMapSet.oopsDo(this, cb, regMap, oopVisitor, VM.getVM().isDebugging());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
      // FIXME: add in traversal of argument oops (skipping this for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
      // now until we have the other stuff tested)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    // FIXME: would add this in in non-debugging system
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    // If we see an activation belonging to a non_entrant nmethod, we mark it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
    //    if (cb->is_nmethod() && ((nmethod *)cb)->is_not_entrant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    //      ((nmethod*)cb)->mark_as_seen_on_stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  // FIXME: implement the above routines, plus add
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  // oops_interpreted_arguments_do and oops_compiled_arguments_do
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
// Only used internally, to iterate through oop slots in interpreted
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
// frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
class InterpreterFrameClosure implements OffsetClosure {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  // Used for debugging this code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  private static final boolean DEBUG = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  private Frame fr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  private AddressVisitor f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  private int maxLocals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
  private int maxStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  InterpreterFrameClosure(Frame fr, int maxLocals, int maxStack, AddressVisitor f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    this.fr = fr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    this.maxLocals = maxLocals;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
    this.maxStack = maxStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    this.f = f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  public void offsetDo(int offset) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
      System.err.println("Visiting offset " + offset + ", maxLocals = " + maxLocals +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
                         " for frame " + fr + ", method " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
                         fr.getInterpreterFrameMethod().getMethodHolder().getName().asString() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
                         fr.getInterpreterFrameMethod().getName().asString());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
    Address addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    if (offset < maxLocals) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
      addr = fr.addressOfInterpreterFrameLocal(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
      if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
        Assert.that(AddressOps.gte(addr, fr.getSP()), "must be inside the frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
      if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
        System.err.println("  Visiting local at addr " + addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
      f.visitAddress(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
      addr = fr.addressOfInterpreterFrameExpressionStackSlot(offset - maxLocals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
      if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
        System.err.println("  Address of expression stack slot: " + addr + ", TOS = " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
                           fr.addressOfInterpreterFrameTOS());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
      // In case of exceptions, the expression stack is invalid and the esp will be reset to express
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
      // this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
      boolean inStack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
      if (fr.getInterpreterFrameExpressionStackDirection() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
        inStack = AddressOps.lte(addr, fr.addressOfInterpreterFrameTOS());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
        inStack = AddressOps.gte(addr, fr.addressOfInterpreterFrameTOS());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
      if (inStack) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
        if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
          System.err.println("  In stack; visiting location.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
        f.visitAddress(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
      } else if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
        System.err.println("  *** WARNING: Address is out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
// Only used internally, to find arguments in interpreted frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
class ArgumentOopFinder extends SignatureInfo {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  private AddressVisitor f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  private int            offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  private boolean        isStatic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  private Frame          fr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  protected void set(int size, int type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
    offset -= size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
    if (type == BasicType.getTObject() || type == BasicType.getTArray()) oopOffsetDo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  private void oopOffsetDo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
    f.visitAddress(fr.addressOfInterpreterFrameTOSAt(offset));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  public ArgumentOopFinder(Symbol signature, boolean isStatic, Frame fr, AddressVisitor f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    super(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
    // compute size of arguments
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
    int argsSize = new ArgumentSizeComputer(signature).size() + (isStatic ? 0 : 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
      Assert.that(!fr.isInterpretedFrame() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
                  argsSize <= fr.getInterpreterFrameExpressionStackSize(), "args cannot be on stack anymore");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
    // initialize ArgumentOopFinder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
    this.f        = f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
    this.fr       = fr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
    this.offset   = argsSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
    this.isStatic = isStatic;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
  public void oopsDo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
    if (!isStatic) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
      --offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
      oopOffsetDo();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
    iterateParameters();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
}