hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/sparc/SPARCFrame.java
author rbackman
Tue, 05 May 2015 16:50:25 +0200
changeset 30590 14f7f48c1377
parent 13728 882756847a04
permissions -rw-r--r--
8064458: OopMap class could be more compact Reviewed-by: kvn, bdelsart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
     2
 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
1
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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 764
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 764
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 764
diff changeset
    21
 * questions.
1
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.sparc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import sun.jvm.hotspot.asm.sparc.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import sun.jvm.hotspot.code.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.compiler.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.debugger.cdbg.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.oops.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.runtime.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.runtime.posix.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.utilities.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
/** Specialization of and implementation of abstract methods of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    Frame class for the SPARC CPU. (FIXME: this is as quick a port as
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    possible to get things running; will have to do a better job right
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    away.) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
public class SPARCFrame extends Frame {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // The pc value is the raw return address, plus 8 (pcReturnOffset()).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // the value of sp and youngerSP that is stored in this object
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // is always, always, always the value that would be found in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // register (or window save area) while the target VM was executing.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // The caller of the constructor will alwasy know if has a biased or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // unbiased version of the stack pointer and can convert real (unbiased)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // value via a helper routine we supply.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // Whenever we return sp or youngerSP values we do not return the internal
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // value but the real (unbiased) pointers since these are the true, usable
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  // memory addresses. The outlier case is that of the null pointer. The current
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // mechanism makes null pointers always look null whether biased or not.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // This seems to cause no problems. In theory null real pointers could be biased
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // just like other values however this has impact on things like addOffsetTo()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // to be able to take an Address that represents null and add an offset to it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // This doesn't seem worth the bother and the impact on the rest of the code
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // when the biasSP and unbiasSP can make this invisible.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // The general rule in this code is that when we have a variable like FP, youngerSP, SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // that these are real (i.e. unbiased) addresses. The instance variables in a Frame are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  // always raw values. The other rule is that it except for the frame constructors and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // the unBiasSP helper all methods accept parameters that are real addresses.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  /** Optional next-younger SP (used to locate O7, the PC) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  private Address raw_youngerSP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  /** Intepreter adjusts the stack pointer to make all locals contiguous */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  private long    interpreterSPAdjustmentOffset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  /** Number of stack entries for longs */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  private static final int WORDS_PER_LONG = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  /** Normal SPARC return is 2 words past PC */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  public static final int PC_RETURN_OFFSET = 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  /** Size of each block, in order of increasing address */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  public static final int REGISTER_SAVE_WORDS   = 16;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // FIXME: read these from the remote process
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  //#ifdef _LP64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  //    callee_aggregate_return_pointer_words        =  0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  //#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  //    callee_aggregate_return_pointer_words        =  1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  //#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  public static final int CALLEE_AGGREGATE_RETURN_POINTER_WORDS     = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  public static final int CALLEE_REGISTER_ARGUMENT_SAVE_AREA_WORDS  = 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // offset of each block, in order of increasing address:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  public static final int REGISTER_SAVE_WORDS_SP_OFFSET             = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  public static final int CALLEE_AGGREGATE_RETURN_POINTER_SP_OFFSET = REGISTER_SAVE_WORDS_SP_OFFSET + REGISTER_SAVE_WORDS;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  public static final int CALLEE_REGISTER_ARGUMENT_SAVE_AREA_SP_OFFSET = (CALLEE_AGGREGATE_RETURN_POINTER_SP_OFFSET +
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                                                                          CALLEE_AGGREGATE_RETURN_POINTER_WORDS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  public static final int MEMORY_PARAMETER_WORD_SP_OFFSET              = (CALLEE_REGISTER_ARGUMENT_SAVE_AREA_SP_OFFSET +
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                                                                          CALLEE_REGISTER_ARGUMENT_SAVE_AREA_WORDS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  public static final int VARARGS_OFFSET                               = MEMORY_PARAMETER_WORD_SP_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.sparc.SPARCFrame.DEBUG") != null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  public static Address unBiasSP(Address raw_sp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    if (raw_sp != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      return raw_sp.addOffsetTo(VM.getVM().getStackBias());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  public static Address biasSP(Address real_sp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    if (real_sp != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        System.out.println("biasing realsp: " + real_sp + " biased: " + real_sp.addOffsetTo(-VM.getVM().getStackBias()) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      return real_sp.addOffsetTo(-VM.getVM().getStackBias());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
        System.out.println("biasing null realsp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
      return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // This is used to find the younger sp for a thread thatn has stopped but hasn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // conveniently told us the information where we can find the pc or the frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // containing the pc that corresponds to last_java_sp. This method will walk
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // the frames trying to find the frame which we contains the data we need.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  public static Address findYoungerSP(Address top, Address find) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    // top and find are unBiased sp values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    // we return an unBiased value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    Address findRaw = biasSP(find);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    if (top == null || find == null || findRaw == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
      throw new RuntimeException("bad values for findYoungerSP top: " + top + " find: " + find);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    // It would be unusual to find more than 20 native frames before we find the java frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    // we are looking for.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    final int maxFrames = 20;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    Address search = top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    Address next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    Address pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
      System.out.println("findYoungerSP top: " + top + " find: " + find + " findRaw: " + findRaw);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    while ( count != maxFrames && search != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      next = search.getAddressAt(SPARCRegisters.I6.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      pc = search.getAddressAt(SPARCRegisters.I7.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        System.out.println("findYoungerSP next: " + next + " pc: " + pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      if (next.equals(findRaw)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
        return search;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      search = unBiasSP(next);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
      System.out.println("findYoungerSP: never found younger, top: " + top + " find: " + find);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  public Address getSP()              {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      System.out.println("getSP raw: " + raw_sp + " unbiased: " + unBiasSP(raw_sp));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    return  unBiasSP(raw_sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  public Address getID()              {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    return getSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  public Address getYoungerSP()       {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
      System.out.println("getYoungerSP: " + raw_youngerSP + " unbiased: " + unBiasSP(raw_youngerSP));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    return unBiasSP(raw_youngerSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  /** This constructor relies on the fact that the creator of a frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
      has flushed register windows which the frame will refer to, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
      that those register windows will not be reloaded until the frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
      is done reading and writing the stack.  Moreover, if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
      "younger_pc" argument points into the register save area of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
      next younger frame (though it need not), the register window for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      that next younger frame must also stay flushed.  (The caller is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
      responsible for ensuring this.) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  public SPARCFrame(Address raw_sp, Address raw_youngerSP, boolean youngerFrameIsInterpreted) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    super();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      System.out.println("Constructing frame(1) raw_sp: " + raw_sp + " raw_youngerSP: " + raw_youngerSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      Assert.that((unBiasSP(raw_sp).andWithMask(VM.getVM().getAddressSize() - 1) == null),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
                   "Expected raw sp likely got real sp, value was " + raw_sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      if (raw_youngerSP != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
        Assert.that((unBiasSP(raw_youngerSP).andWithMask(VM.getVM().getAddressSize() - 1) == null),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
                    "Expected raw youngerSP likely got real youngerSP, value was " + raw_youngerSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    this.raw_sp = raw_sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    this.raw_youngerSP = raw_youngerSP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    if (raw_youngerSP == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      // make a deficient frame which doesn't know where its PC is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      pc = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      Address youngerSP = unBiasSP(raw_youngerSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
      pc = youngerSP.getAddressAt(SPARCRegisters.I7.spOffsetInSavedWindow()).addOffsetTo(PC_RETURN_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
      if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
        Assert.that(youngerSP.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
                    equals(raw_sp),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
                    "youngerSP must be valid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    if (youngerFrameIsInterpreted) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      long IsavedSP = SPARCRegisters.IsavedSP.spOffsetInSavedWindow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      // compute adjustment to this frame's SP made by its interpreted callee
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
      interpreterSPAdjustmentOffset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
      Address savedSP = unBiasSP(getYoungerSP().getAddressAt(IsavedSP));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
      if (savedSP == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
        if ( DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
          System.out.println("WARNING: IsavedSP was null for frame " + this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
        interpreterSPAdjustmentOffset = savedSP.minus(getSP());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
      interpreterSPAdjustmentOffset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    if ( pc != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      // Look for a deopt pc and if it is deopted convert to original pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      CodeBlob cb = VM.getVM().getCodeCache().findBlob(pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
      if (cb != null && cb.isJavaMethod()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
        NMethod nm = (NMethod) cb;
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   236
        if (pc.equals(nm.deoptHandlerBegin())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
          // adjust pc if frame is deoptimized.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
          pc = this.getUnextendedSP().getAddressAt(nm.origPCOffset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
          deoptimized = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  /** Make a deficient frame which doesn't know where its PC is (note
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      no youngerSP argument) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  public SPARCFrame(Address raw_sp, Address pc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    super();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
      System.out.println("Constructing frame(2) raw_sp: " + raw_sp );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    this.raw_sp = raw_sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
      Assert.that((unBiasSP(raw_sp).andWithMask(VM.getVM().getAddressSize() - 1) == null),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
                   "Expected raw sp likely got real sp, value was " + raw_sp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    raw_youngerSP = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    this.pc = pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    interpreterSPAdjustmentOffset = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  /** Only used internally */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  private SPARCFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  public Object clone() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    SPARCFrame frame = new SPARCFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    frame.raw_sp = raw_sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    frame.pc = pc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    frame.raw_youngerSP = raw_youngerSP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    frame.interpreterSPAdjustmentOffset = interpreterSPAdjustmentOffset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    frame.deoptimized = deoptimized;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    return frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  public boolean equals(Object arg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    if (arg == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    if (!(arg instanceof SPARCFrame)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    SPARCFrame other = (SPARCFrame) arg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    return (AddressOps.equal(getSP(), other.getSP()) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
            AddressOps.equal(getFP(), other.getFP()) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
            AddressOps.equal(getPC(), other.getPC()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  public int hashCode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    if (raw_sp == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
      return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
    return raw_sp.hashCode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  public String toString() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    Address fp = getFP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    Address sp = getSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    Address youngerSP = getYoungerSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    return "sp: " + (sp == null? "null" : sp.toString()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
         ", younger_sp: " + (youngerSP == null? "null" : youngerSP.toString()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
         ", fp: " + (fp == null? "null" : fp.toString()) +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
         ", pc: " + (pc == null? "null" : pc.toString());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  /** <P> Identifies a signal handler frame on the stack. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      <P> There are a few different algorithms for doing this, and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
      they vary from platform to platform. For example, based on a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
      conversation with Dave Dice, Solaris/x86 will be substantially
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
      simpler to handle than Solaris/SPARC because the signal handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      frame can be identified because of a program counter == -1. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      <P> The dbx group provided code and advice on these topics; the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      code below evolved from theirs, but is not correct/robust.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
      Without going into too many details, it seems that looking for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      the incoming argument to the sigacthandler frame (which is what
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      this code identifies) is not guaranteed to be stable across
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
      versions of Solaris, since that function is supplied by
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      libthread and is not guaranteed not to clobber I2 before it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      calls __sighndlr later. From discussions, it sounds like a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      robust algorithm which wouldn't require traversal of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
      ucontext chain (used by dbx, but which Dave Dice thinks isn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
      robust in the face of libthread -- need to follow up) would be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
      to be able to properly identify the __sighndlr frame, then get
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      I2 and treat that as a ucontext. To identify __sighndlr we would
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      need to look up that symbol in the remote process and look for a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      program counter within a certain (small) distance. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
      <P> If the underlying Debugger supports CDebugger interface, we
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
      take the approach of __sighnldr symbol. This approach is more robust
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      compared to the original hueristic approach. Of course, if there
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
      is no CDebugger support, we fallback to the hueristic approach. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      <P> The current implementation seems to work with Solaris 2.8.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
      A nice property of this system is that if we find a core file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
      this algorithm doesn't work on, we can change the code and try
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
      again, so I'm putting this in as the current mechanism for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
      finding signal handler frames on Solaris/SPARC. </P> */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  public boolean isSignalHandlerFrameDbg() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    CDebugger cdbg = VM.getVM().getDebugger().getCDebugger();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    if (cdbg != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      LoadObject dso = cdbg.loadObjectContainingPC(getPC());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      if (dso != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
        ClosestSymbol cs = dso.closestSymbolToPC(getPC());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
        if (cs != null && cs.getName().equals("__sighndlr")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
          return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
          return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
      if (getYoungerSP() == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        //      System.err.println("  SPARCFrame.isSignalHandlerFrameDbg: youngerSP = " + getYoungerSP());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
      Address i2 = getSP().getAddressAt(SPARCRegisters.I2.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
      if (i2 == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
      Address fp = getFP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
      // My (mistaken) understanding of the dbx group's code was that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
      // the signal handler frame could be identified by testing the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
      // incoming argument to see whether it was a certain distance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
      // below the frame pointer; in fact, their code did substantially
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
      // more than this (traversal of the ucontext chain, which this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
      // code can't do because the topmost ucontext is not currently
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      // available via the proc_service APIs in dbx). The current code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      // appears to work, but is probably not robust.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
      int MAJOR_HACK_OFFSET = 8;  // Difference between expected location of the ucontext and reality
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
      // System.err.println("  SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      //                          ", fp = " + fp + ", raw_youngerSP = " + getYoungerSP());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
      boolean res = i2.equals(fp.addOffsetTo(VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      if (res) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
        // Qualify this with another test (FIXME: this is a gross heuristic found while testing)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
        Address sigInfoAddr = getSP().getAddressAt(SPARCRegisters.I5.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
        if (sigInfoAddr == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
          System.err.println("Frame with fp = " + fp + " looked like a signal handler frame but wasn't");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
          res = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
      return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  public int getSignalNumberDbg() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
    // From looking at the stack trace in dbx, it looks like the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    // siginfo* comes into sigacthandler in I5. It would be much more
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
    // robust to look at the __sighndlr frame instead, but we can't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    // currently identify that frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    Address sigInfoAddr = getSP().getAddressAt(SPARCRegisters.I5.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    // Read si_signo out of siginfo*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    return (int) sigInfoAddr.getCIntegerAt(0, 4, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  public String getSignalNameDbg() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    return POSIXSignals.getSignalName(getSignalNumberDbg());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  public boolean isInterpretedFrameValid() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
      Assert.that(isInterpretedFrame(), "Not an interpreted frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
    // These are reasonable sanity checks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    if (getFP() == null || (getFP().andWithMask(2 * VM.getVM().getAddressSize() - 1)) != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    if (getSP() == null || (getSP().andWithMask(2 * VM.getVM().getAddressSize() - 1)) != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    if (getFP().addOffsetTo(INTERPRETER_FRAME_VM_LOCAL_WORDS * VM.getVM().getAddressSize()).lessThan(getSP())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    }
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   422
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   423
    Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0);
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   424
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   425
    if (VM.getVM().getObjectHeap().isValidMethod(methodHandle) == false) {
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   426
      return false;
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   427
    }
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   428
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    // These are hacks to keep us out of trouble.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    // The problem with these is that they mask other problems
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    if (getFP().lessThanOrEqual(getSP())) {        // this attempts to deal with unsigned comparison above
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    if (getFP().minus(getSP()) > 4096 * VM.getVM().getAddressSize()) {  // stack frames shouldn't be large.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    // FIXME: this is not atomic with respect to GC and is unsuitable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    // for use in a non-debugging, or reflective, system. Need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    // figure out how to express this.
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   440
    Address bcx =  addressOfInterpreterFrameBCX().getAddressAt(0);
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   441
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   442
    Method method;
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   443
    try {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   444
      method = (Method)Metadata.instantiateWrapperFor(methodHandle);
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   445
    } catch (UnknownOopException ex) {
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   446
       return false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    }
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   448
    int  bci = bcpToBci(bcx, method);
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   449
    //validate bci
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   450
    if (bci < 0) return false;
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   451
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  // Accessors:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  /** Accessors */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  public long frameSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    return (getSenderSP().minus(getSP()) / VM.getVM().getAddressSize());
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 Address getLink() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
    return unBiasSP(getFP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  // FIXME: not implementable yet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  //  public void setLink(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  //    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  //      Assert.that(getLink().equals(addr), "frame nesting is controlled by hardware");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  public Frame sender(RegisterMap regMap, CodeBlob cb) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    SPARCRegisterMap map = (SPARCRegisterMap) regMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
      Assert.that(map != null, "map must be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
    // Default is we don't have to follow them. The sender_for_xxx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    // will update it accordingly
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    map.setIncludeArgumentOops(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   487
    if (isEntryFrame()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
      return senderForEntryFrame(map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    Address youngerSP = getSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    Address sp        = getSenderSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    boolean isInterpreted = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    // FIXME: this is a hack to get stackwalking to work in the face
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    // of a signal like a SEGV. For debugging purposes it's important
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    // that (a) we are able to traverse the stack if we take a signal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    // and (b) that we get the correct program counter in this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    // situation. If we are not using alternate signal stacks then (a)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    // seems to work all the time (on SPARC), but (b) is violated for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    // the frame just below the signal handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    // The mechanism for finding the ucontext is not robust. In
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
    // addition, we may find that we need to be able to fetch more
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    // registers from the ucontext than just the program counter,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
    // since the register windows on the stack are "stale". This will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
    // require substantial restructuring of this frame code, so has
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
    // been avoided for now.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    // It is difficult to find a clean solution for mixing debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    // situations with VM frame traversal. One could consider
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    // implementing generic frame traversal in the dbx style and only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    // using the VM's stack walking mechanism on a per-frame basis,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
    // for example to traverse Java-level activations in a compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
    // frame. However, this will probably not interact well with the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    // mechanism for finding oops on the stack.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    if (VM.getVM().isDebugging()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
      // If we are a signal handler frame, use a trick: make the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
      // youngerSP of the caller frame point to the top of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
      // ucontext's contained register set. This should allow fetching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      // of the registers for the frame just below the signal handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      // frame in the usual fashion.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      if (isSignalHandlerFrameDbg()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
        if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
          System.out.println("SPARCFrame.sender: found signal handler frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
        // Try to give a valid SP and PC for a "deficient frame" since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
        // we don't have a real register save area; making this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
        // work by reading its information from a ucontext as well as
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
        // a register save area is a major undertaking and has been
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
        // deferred for now. It is very important that the PC is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
        // correct, which is why we don't just fall through to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
        // other code (which would read the PC from the stale register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
        // window and thereby fail to get the actual location of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
        // fault).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
        long offset = getMContextAreaOffsetInUContext();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
        Address fp = sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
        // System.out.println("  FP: " + fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
        fp = fp.addOffsetTo(getUContextOffset() + getMContextAreaOffsetInUContext());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
        // System.out.println("  start of mcontext: " + fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
        // FIXME: put these elsewhere. These are the register numbers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
        // in /usr/include/sys/regset.h. They might belong in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
        // SPARCReigsters.java, but we currently don't have that list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
        // of numbers in the SA code (because all of the registers are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
        // listed as instances of SPARCRegister) and it appears that
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
        // our numbering of the registers and this one don't match up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
        int PC_OFFSET_IN_GREGSET = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
        int SP_OFFSET_IN_GREGSET = 17;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
        raw_sp = fp.getAddressAt(VM.getVM().getAddressSize() * SP_OFFSET_IN_GREGSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
        Address pc = fp.getAddressAt(VM.getVM().getAddressSize() * PC_OFFSET_IN_GREGSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
        return new SPARCFrame(raw_sp, pc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   559
    // Note:  The version of this operation on any platform with callee-save
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   560
    //        registers must update the register map (if not null).
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   561
    //        In order to do this correctly, the various subtypes of
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   562
    //        of frame (interpreted, compiled, glue, native),
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   563
    //        must be distinguished.  There is no need on SPARC for
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   564
    //        such distinctions, because all callee-save registers are
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   565
    //        preserved for all frames via SPARC-specific mechanisms.
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   566
    //
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   567
    //        *** HOWEVER, *** if and when we make any floating-point
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   568
    //        registers callee-saved, then we will have to copy over
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   569
    //        the RegisterMap update logic from the Intel code.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   571
    // The constructor of the sender must know whether this frame is interpreted so it can set the
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   572
    // sender's _interpreter_sp_adjustment field.
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   573
    if (VM.getVM().getInterpreter().contains(pc)) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   574
      isInterpreted = true;
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   575
      map.makeIntegerRegsUnsaved();
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   576
      map.shiftWindow(sp, youngerSP);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   577
    } else {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   578
      // Find a CodeBlob containing this frame's pc or elide the lookup and use the
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   579
      // supplied blob which is already known to be associated with this frame.
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   580
      cb = VM.getVM().getCodeCache().findBlob(pc);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   581
      if (cb != null) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   582
        // Update the location of all implicitly saved registers
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   583
        // as the address of these registers in the register save
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   584
        // area (for %o registers we use the address of the %i
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   585
        // register in the next younger frame)
764
67578bc37423 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 1
diff changeset
   586
        map.shiftWindow(sp, youngerSP);
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   587
        if (map.getUpdateMap()) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   588
          if (cb.callerMustGCArguments()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
            map.setIncludeArgumentOops(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
          }
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   591
          if (cb.getOopMaps() != null) {
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 13728
diff changeset
   592
            ImmutableOopMapSet.updateRegisterMap(this, cb, map, VM.getVM().isDebugging());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
      }
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   596
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
    return new SPARCFrame(biasSP(sp), biasSP(youngerSP), isInterpreted);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  protected boolean hasSenderPD() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
      // FIXME: should not happen!!!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
      if (getSP() == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
      if ( unBiasSP(getSP().getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow())) == null ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
    } catch (RuntimeException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
      if (DEBUG) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
        System.out.println("Bad frame " + this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
      throw e;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  // Return address:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  public Address getSenderPC() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
    return addressOfI7().getAddressAt(0).addOffsetTo(PC_RETURN_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
  // FIXME: currently unimplementable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  // inline void     frame::set_sender_pc(address addr) { *I7_addr() = addr - pc_return_offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
  public Address getUnextendedSP() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    return getSP().addOffsetTo(interpreterSPAdjustmentOffset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  public Address getSenderSP() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    return getFP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  /** Given the next-younger sp for a given frame's sp, compute the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
      frame. We need the next-younger sp, because its register save
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
      area holds the flushed copy of its I7, which is the PC of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
      frame we are interested in. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  public SPARCFrame afterSave() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
    return new SPARCFrame(biasSP(getYoungerSP()), null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  /** Accessors for the instance variables */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  public Address getFP() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
    Address sp = getSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
    if (sp == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
      System.out.println("SPARCFrame.getFP(): sp == null");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
    Address fpAddr = sp.addOffsetTo(SPARCRegisters.FP.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
      Address fp = unBiasSP(fpAddr.getAddressAt(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
      if (fp == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
        System.out.println("SPARCFrame.getFP(): fp == null (&fp == " + fpAddr + ")");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
      return fp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
    } catch (RuntimeException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
      System.out.println("SPARCFrame.getFP(): is bad (&fp == " + fpAddr + " sp = " + sp + ")");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
      return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  private Address addressOfFPSlot(int index) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
    return getFP().addOffsetTo(index * VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
  // FIXME: temporarily elided
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  //  // All frames
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  //  intptr_t*  fp_addr_at(int index) const   { return &fp()[index];    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  //  intptr_t*  sp_addr_at(int index) const   { return &sp()[index];    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  //  intptr_t    fp_at(     int index) const   { return *fp_addr_at(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
  //  intptr_t    sp_at(     int index) const   { return *sp_addr_at(index); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  // private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  //  inline address* I7_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
  //  inline address* O7_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
  //  inline address* I0_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  //  inline address* O0_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
  // public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
  //  // access to SPARC arguments and argument registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  //  intptr_t*     register_addr(Register reg) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  //    return sp_addr_at(reg.sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  //  intptr_t* memory_param_addr(int param_ix, bool is_in) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  //    int offset = callee_register_argument_save_area_sp_offset + param_ix;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  //    if (is_in)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
  //      return fp_addr_at(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  //    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  //      return sp_addr_at(offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  //  intptr_t*        param_addr(int param_ix, bool is_in) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  //    if (param_ix >= callee_register_argument_save_area_words)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  //      return memory_param_addr(param_ix, is_in);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
  //    else if (is_in)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
  //      return register_addr(Argument(param_ix, true).as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
  //    else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  //      // the registers are stored in the next younger frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  //      // %%% is this really necessary?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  //      frame next_younger = after_save();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
  //      return next_younger.register_addr(Argument(param_ix, true).as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  // Interpreter frames:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  /** 2 words, also used to save float regs across  calls to C */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  public static final int INTERPRETER_FRAME_D_SCRATCH_FP_OFFSET           = -2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  public static final int INTERPRETER_FRAME_L_SCRATCH_FP_OFFSET           = -4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  /** For native calls only */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  public static final int INTERPRETER_FRAME_PADDING_OFFSET                = -5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  /** For native calls only */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
  public static final int INTERPRETER_FRAME_MIRROR_OFFSET                 = -6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
  /** Should be same as above, and should be zero mod 8 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  public static final int INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET           = -6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  public static final int INTERPRETER_FRAME_VM_LOCAL_WORDS                = -INTERPRETER_FRAME_VM_LOCALS_FP_OFFSET;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
  /** Interpreter frame set-up needs to save 2 extra words in outgoing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
      param area for class and jnienv arguments for native stubs (see
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
      nativeStubGen_sparc.cpp) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
  public static final int INTERPRETER_FRAME_EXTRA_OUTGOING_ARGUMENT_WORDS = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
  // FIXME: elided for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  //  // the compiler frame has many of the same fields as the interpreter frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  //  // %%%%% factor out declarations of the shared fields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  //  enum compiler_frame_fixed_locals {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  //       compiler_frame_d_scratch_fp_offset          = -2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  //       compiler_frame_vm_locals_fp_offset          = -2, // should be same as above
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  //       compiler_frame_vm_local_words = -compiler_frame_vm_locals_fp_offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
  //  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
  // private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  //  // where LcpoolCache is saved:
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   744
  //  ConstantPoolCache** interpreter_frame_cpoolcache_addr() const {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   745
  //    return (ConstantPoolCache**)sp_addr_at( LcpoolCache.sp_offset_in_saved_window());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  //  // where Lmonitors is saved:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  //  BasicObjectLock**  interpreter_frame_monitors_addr() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
  //    return (BasicObjectLock**) sp_addr_at( Lmonitors.sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
  //  intptr_t** interpreter_frame_esp_addr() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
  //    return (intptr_t**)sp_addr_at( Lesp.sp_offset_in_saved_window());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
  //  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
  //  inline void interpreter_frame_set_tos_address(intptr_t* x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  //  // next two fns read and write Lmonitors value,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  // private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  //  BasicObjectLock* interpreter_frame_monitors()           const  { return *interpreter_frame_monitors_addr(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
  //  void interpreter_frame_set_monitors(BasicObjectLock* monitors) {        *interpreter_frame_monitors_addr() = monitors; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  //#ifndef CORE
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  //inline oop *frame::pd_compiled_argument_to_location(VMReg::Name reg, RegisterMap reg_map, int arg_size) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  //  COMPILER1_ONLY(return (oop *) (arg_size - 1 - reg + sp() + memory_parameter_word_sp_offset);   )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
  //  COMPILER2_ONLY(return oopmapreg_to_location(reg, &reg_map); )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  //}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  //#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
  // FIXME: NOT FINISHED
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
  public Address addressOfInterpreterFrameLocals() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
    return getSP().addOffsetTo(SPARCRegisters.Llocals.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
  // FIXME: this is not atomic with respect to GC and is unsuitable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  // for use in a non-debugging, or reflective, system.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  private Address addressOfInterpreterFrameBCX() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    // %%%%% reinterpreting Lbcp as a bcx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
    return getSP().addOffsetTo(SPARCRegisters.Lbcp.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  public int getInterpreterFrameBCI() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
    // FIXME: this is not atomic with respect to GC and is unsuitable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
    // for use in a non-debugging, or reflective, system. Need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
    // figure out how to express this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
    Address bcp = addressOfInterpreterFrameBCX().getAddressAt(0);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   787
    Address methodHandle = addressOfInterpreterFrameMethod().getAddressAt(0);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   788
    Method method = (Method)Metadata.instantiateWrapperFor(methodHandle);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
    return bcpToBci(bcp, method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   790
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   791
489c9b5090e2 Initial load
duke
parents:
diff changeset
   792
  public Address addressOfInterpreterFrameExpressionStack() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   793
    return addressOfInterpreterFrameMonitors().addOffsetTo(-1 * VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   794
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   795
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  public int getInterpreterFrameExpressionStackDirection() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
    return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
  /** Top of expression stack */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
  public Address addressOfInterpreterFrameTOS() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
    return getSP().getAddressAt(SPARCRegisters.Lesp.spOffsetInSavedWindow()).addOffsetTo(VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
  /** Expression stack from top down */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
  public Address addressOfInterpreterFrameTOSAt(int slot) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
    return addressOfInterpreterFrameTOS().addOffsetTo(slot * VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
  public Address getInterpreterFrameSenderSP() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
      Assert.that(isInterpretedFrame(), "interpreted frame expected");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
    return getFP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
  // FIXME: elided for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
  //inline void frame::interpreter_frame_set_tos_address( intptr_t* x ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
  //  *interpreter_frame_esp_addr() = x - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
  //}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
  // Monitors:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  private Address addressOfInterpreterFrameMonitors() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
    return getSP().addOffsetTo(SPARCRegisters.Lmonitors.spOffsetInSavedWindow()).getAddressAt(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
  // Monitors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  public BasicObjectLock interpreterFrameMonitorBegin() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
    int roundedVMLocalWords = Bits.roundTo(INTERPRETER_FRAME_VM_LOCAL_WORDS, WORDS_PER_LONG);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
    return new BasicObjectLock(addressOfFPSlot(-1 * roundedVMLocalWords));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  public BasicObjectLock interpreterFrameMonitorEnd() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    return new BasicObjectLock(addressOfInterpreterFrameMonitors());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
  public int interpreterFrameMonitorSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
    return Bits.roundTo(BasicObjectLock.size(), WORDS_PER_LONG * (int) VM.getVM().getAddressSize());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
  // FIXME: elided for now
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  // // monitor elements
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  // // in keeping with Intel side: end is lower in memory than begin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
  // // and beginning element is oldest element
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  // // Also begin is one past last monitor.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
  // inline BasicObjectLock* frame::interpreter_frame_monitor_begin()       const  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
  //   int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words, WordsPerLong);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
  //   return (BasicObjectLock *)fp_addr_at(-rounded_vm_local_words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
  // inline BasicObjectLock* frame::interpreter_frame_monitor_end()         const  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
  //   return interpreter_frame_monitors();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  // inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
  //   interpreter_frame_set_monitors(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
  // inline int frame::interpreter_frame_monitor_size() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
  //   return round_to(BasicObjectLock::size(), WordsPerLong);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  public Address addressOfInterpreterFrameMethod() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
    return getSP().addOffsetTo(SPARCRegisters.Lmethod.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  public Address addressOfInterpreterFrameCPCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
    return getSP().addOffsetTo(SPARCRegisters.LcpoolCache.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
  // Entry frames:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
  public JavaCallWrapper getEntryFrameCallWrapper() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
    // Note: adjust this code if the link argument in StubGenerator::call_stub() changes!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    SPARCArgument link = new SPARCArgument(0, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
    return (JavaCallWrapper) VMObjectFactory.newObject(JavaCallWrapper.class,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
                                                       getSP().getAddressAt(link.asIn().asRegister().spOffsetInSavedWindow()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
  // inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
  //   // note: adjust this code if the link argument in StubGenerator::call_stub() changes!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  //   const Argument link = Argument(0, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  //   return (JavaCallWrapper*)sp()[link.as_in().as_register().sp_offset_in_saved_window()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  // }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  // Safepoints:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  protected Address addressOfSavedOopResult() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
    return addressOfO0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  protected Address addressOfSavedReceiver() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
    return addressOfO0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
  // Internals only below this point
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  private Address addressOfI7() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
    return getSP().addOffsetTo(SPARCRegisters.I7.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  private Address addressOfO7() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
    return afterSave().addressOfI7();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  private Address addressOfI0() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
    return getSP().addOffsetTo(SPARCRegisters.I0.spOffsetInSavedWindow());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  private Address addressOfO0() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
    return afterSave().addressOfI0();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  private static boolean addressesEqual(Address a1, Address a2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
    if ((a1 == null) && (a2 == null)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
      return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    if ((a1 == null) || (a2 == null)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
      return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
    return (a1.equals(a2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  private Frame senderForEntryFrame(RegisterMap regMap) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
    SPARCRegisterMap map = (SPARCRegisterMap) regMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
      Assert.that(map != null, "map must be set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
    // Java frame called from C; skip all C frames and return top C
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
    // frame of that chunk as the sender
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
    JavaCallWrapper jcw = getEntryFrameCallWrapper();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
      Assert.that(!entryFrameIsFirst(), "next Java fp must be non zero");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
      Assert.that(jcw.getLastJavaSP().greaterThan(getSP()), "must be above this frame on stack");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
    Address lastJavaSP = jcw.getLastJavaSP();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
    Address lastJavaPC = jcw.getLastJavaPC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
    map.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   960
    map.makeIntegerRegsUnsaved();
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   961
    map.shiftWindow(lastJavaSP, null);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
      Assert.that(map.getIncludeArgumentOops(), "should be set by clear");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
    if (lastJavaPC != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
      return new SPARCFrame(biasSP(lastJavaSP), lastJavaPC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
      Address youngerSP  = getNextYoungerSP(lastJavaSP, getSP());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
      return new SPARCFrame(biasSP(lastJavaSP), biasSP(youngerSP), false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  private static Address getNextYoungerSP(Address oldSP, Address youngSP) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
    Address sp = getNextYoungerSPOrNull(oldSP, youngSP, null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
    if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
      Assert.that(sp != null, "missed the SP");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
    return sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
  private static Address getNextYoungerSPOrNull(Address oldSP, Address youngSP, Address sp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
    if (youngSP == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
      // FIXME
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
      throw new RuntimeException("can not handle null youngSP in debugging system (seems to require register window flush)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
    if (sp == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
      sp = youngSP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
    Address previousSP = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
    /** Minimum frame size is 16 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
    int maxFrames = (int) (oldSP.minus(sp) / (16 * VM.getVM().getAddressSize()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
    while(!sp.equals(oldSP) && spIsValid(oldSP, youngSP, sp)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
      if (maxFrames-- <= 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
        // too many frames have gone by; invalid parameters given to this function
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
      previousSP = sp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
      sp = unBiasSP(sp.getAddressAt(SPARCRegisters.FP.spOffsetInSavedWindow()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
    return (sp.equals(oldSP) ? previousSP : null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  private static boolean spIsValid(Address oldSP, Address youngSP, Address sp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
    long mask = VM.getVM().getAddressSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
    mask = 2 * mask - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
    return ((sp.andWithMask(mask) == null) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
            (sp.lessThanOrEqual(oldSP)) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
            (sp.greaterThanOrEqual(youngSP)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
  // FIXME: this is a hopefully temporary hack (not sure what is going on)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
  public long getUContextOffset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
    // FIXME: there is something I clearly don't understand about the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
    // way the signal handler frame is laid out, because I shouldn't need this extra offset
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
    int MAJOR_HACK_OFFSET = 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
    //    System.out.println("  SPARCFrame.isSignalHandlerFrameDbg: I2 = " + i2 + ", fp = " + fp + ", youngerSP = " + youngerSP);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
    return VM.getVM().getAddressSize() * (REGISTER_SAVE_WORDS + MAJOR_HACK_OFFSET);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  public long getMContextAreaOffsetInUContext() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
    // From dbx-related sources:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
    // /*
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
    //  * struct sigframe is declaredf in the kernel sources in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
    //  * .../uts/sun4c/os/machdep.c/sendsig()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
    //  * unfortunately we only get a pointer to the 'uc' passed
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
    //  * to the sighandler so we need to do this stuff to get
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
    //  * to 'rwin'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
    //  * Have to do it like this to take account of alignment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
    //  */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
    // static struct sigframe {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
    //     struct rwindow rwin;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
    //     ucontext_t uc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
    // } sf_help;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
    // From /usr/include/sys/ucontext.h:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
    // #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
    // struct   ucontext {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
    // #else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
    // struct   __ucontext {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
    // #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
    //  uint_t          uc_flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
    //  ucontext_t      *uc_link;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
    //  sigset_t        uc_sigmask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
    //  stack_t         uc_stack;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
    //  mcontext_t      uc_mcontext;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
    // #ifdef   __sparcv9
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
    //  long            uc_filler[4];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
    // #else    /* __sparcv9 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
    //  long            uc_filler[23];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
    // #endif   /* __sparcv9 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
    // };
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
    // This walks to the start of the gregs in the mcontext_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
    // (first entry in that data structure). Really should read
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
    // this from header file.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
    // Also not sure exactly how alignment works...maybe should read these offsets from the target VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
    // (When you have a hammer, everything looks like a nail)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
    long offset = VM.getVM().alignUp(4, VM.getVM().getAddressSize());   // uc_flags
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
    offset      = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // uc_link plus
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
                                                                        // doubleword alignment for structs?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
    offset     += 16 +                                                  // uc_sigmask
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
                   2 * VM.getVM().getAddressSize() + 4;                 // uc_stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
    offset      = VM.getVM().alignUp(offset + VM.getVM().getAddressSize(), 8); // doubleword alignment for structs?
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
    //    System.out.println("SPARCFrame.getMContextAreaOffsetInUContext: offset = " + offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
    return offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
}