hotspot/agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java
author cfang
Thu, 20 Aug 2009 12:42:57 -0700
changeset 3686 69c1b5228547
parent 3600 27aa4477d039
child 4095 6e0acfda1d47
permissions -rw-r--r--
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit Summary: use PcDesc to keep record of the reexecute bit instead of using DebugInfoStreams Reviewed-by: kvn, never, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
     2
 * Copyright 2000-2009 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.runtime.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
/** PcDescs map a physical PC (given as offset from start of nmethod)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    to the corresponding source scope and byte code index. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
public class PCDesc extends VMObject {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  private static CIntegerField pcOffsetField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  private static CIntegerField scopeDecodeOffsetField;
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    39
  private static CIntegerField pcFlagsField;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    VM.registerVMInitializedObserver(new Observer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
        public void update(Observable o, Object data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
          initialize(VM.getVM().getTypeDataBase());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
      });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  private static void initialize(TypeDataBase db) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    Type type = db.lookupType("PcDesc");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    pcOffsetField          = type.getCIntegerField("_pc_offset");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset");
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    54
    pcFlagsField           = type.getCIntegerField("_flags");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  public PCDesc(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    super(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // FIXME: add additional constructor probably needed for ScopeDesc::sender()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  public int getPCOffset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    return (int) pcOffsetField.getValue(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  public int getScopeDecodeOffset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    return ((int) scopeDecodeOffsetField.getValue(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  public Address getRealPC(NMethod code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    return code.instructionsBegin().addOffsetTo(getPCOffset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
3686
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    75
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    76
  public boolean getReexecute() {
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    77
    int flags = (int)pcFlagsField.getValue(addr);
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    78
    return ((flags & 0x1)== 1); //first is the reexecute bit
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    79
  }
69c1b5228547 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 3600
diff changeset
    80
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  public void print(NMethod code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    printOn(System.out, code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  public void printOn(PrintStream tty, NMethod code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    tty.println("PCDesc(" + getRealPC(code) + "):");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    for (ScopeDesc sd = code.getScopeDescAt(getRealPC(code));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
         sd != null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
         sd = sd.sender()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
      tty.print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      sd.getMethod().printValueOn(tty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      tty.print("  @" + sd.getBCI());
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 1
diff changeset
    93
      tty.print("  reexecute=" + sd.getReexecute());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      tty.println();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
}