hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java
author xdono
Tue, 28 Jul 2009 12:12:40 -0700
changeset 3261 c7d5aae8d3f7
parent 2341 caadacf15616
child 5547 f4b087cbb361
permissions -rw-r--r--
6862919: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 07/09 Reviewed-by: tbell, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3261
c7d5aae8d3f7 6862919: Update copyright year
xdono
parents: 2341
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.runtime;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.types.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
/** Very minimal port for now to get frames working */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
public class StubRoutines {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  private static AddressField      callStubReturnAddressField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  private static AddressField      callStubCompiledReturnAddressField;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  static {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    VM.registerVMInitializedObserver(new Observer() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
        public void update(Observable o, Object data) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
          initialize(VM.getVM().getTypeDataBase());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
      });
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  private static synchronized void initialize(TypeDataBase db) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    Type type = db.lookupType("StubRoutines");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    callStubReturnAddressField = type.getAddressField("_call_stub_return_address");
2341
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    49
    // Only some platforms have specific return from compiled to call_stub
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    try {
2341
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    51
      type = db.lookupType("StubRoutines::x86");
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    52
      if (type != null) {
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    53
        callStubCompiledReturnAddressField = type.getAddressField("_call_stub_compiled_return");
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    54
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    } catch (RuntimeException re) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      callStubCompiledReturnAddressField = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    }
2341
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    58
    if (callStubCompiledReturnAddressField == null && VM.getVM().getCPU().equals("x86")) {
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    59
      throw new InternalError("Missing definition for _call_stub_compiled_return");
caadacf15616 6822333: _call_stub_compiled_return address handling in SA is broken causing jstack to hang occasionally
never
parents: 1
diff changeset
    60
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  public StubRoutines() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  public boolean returnsToCallStub(Address returnPC) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    Address addr = callStubReturnAddressField.getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    boolean result = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    if (addr == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
      result = (addr == returnPC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      result = addr.equals(returnPC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    if (result || callStubCompiledReturnAddressField == null ) return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    // Could be a return to compiled code return point
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    addr = callStubCompiledReturnAddressField.getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    if (addr == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      return (addr == returnPC);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      return (addr.equals(returnPC));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
}