hotspot/src/share/vm/runtime/registerMap.hpp
author dholmes
Mon, 16 Nov 2015 14:47:21 -0500
changeset 34142 5a9fb81665b3
parent 29180 50369728b00e
child 40010 e32d5e545789
permissions -rw-r--r--
8141024: [Solaris] Obsolete UseAltSigs Reviewed-by: dcubed, ddmitriev
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 22551
diff changeset
     2
 * Copyright (c) 2002, 2014, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_RUNTIME_REGISTERMAP_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "code/vmreg.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class JavaThread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// RegisterMap
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// A companion structure used for stack traversal. The RegisterMap contains
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// misc. information needed in order to do correct stack traversal of stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// frames.  Hence, it must always be passed in as an argument to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// frame::sender(RegisterMap*).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// In particular,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//   1) It provides access to the thread for which the stack belongs.  The
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
//      thread object is needed in order to get sender of a deoptimized frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
//   2) It is used to pass information from a callee frame to its caller
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//      frame about how the frame should be traversed.  This is used to let
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//      the caller frame take care of calling oops-do of out-going
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
//      arguments, when the callee frame is not instantiated yet.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
//      happens, e.g., when a compiled frame calls into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
//      resolve_virtual_call.  (Hence, it is critical that the same
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
//      RegisterMap object is used for the entire stack walk.  Normally,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//      this is hidden by using the StackFrameStream.)  This is used when
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//      doing follow_oops and oops_do.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
//   3) The RegisterMap keeps track of the values of callee-saved registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
//      from frame to frame (hence, the name).  For some stack traversal the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
//      values of the callee-saved registers does not matter, e.g., if you
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 8921
diff changeset
    58
//      only need the static properties such as frame type, pc, and such.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
//      Updating of the RegisterMap can be turned off by instantiating the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
//      register map as: RegisterMap map(thread, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class RegisterMap : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    typedef julong LocationValidType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    reg_count = ConcreteRegisterImpl::number_of_registers,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    location_valid_type_size = sizeof(LocationValidType)*8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  intptr_t*    _location[reg_count];    // Location of registers (intptr_t* looks better than address in the debugger)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  LocationValidType _location_valid[location_valid_size];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool        _include_argument_oops;   // Should include argument_oop marked locations for compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  JavaThread* _thread;                  // Reference to current thread
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  bool        _update_map;              // Tells if the register map need to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
                                        // updated when traversing the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  void check_location_valid();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  void check_location_valid() {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  RegisterMap(JavaThread *thread, bool update_map = true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  RegisterMap(const RegisterMap* map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  address location(VMReg reg) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    int index = reg->value() / location_valid_type_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    assert(0 <= reg->value() && reg->value() < reg_count, "range check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    assert(0 <= index && index < location_valid_size, "range check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      return (address) _location[reg->value()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      return pd_location(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void set_location(VMReg reg, address loc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    int index = reg->value() / location_valid_type_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    assert(0 <= reg->value() && reg->value() < reg_count, "range check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    assert(0 <= index && index < location_valid_size, "range check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    assert(_update_map, "updating map that does not need updating");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    _location[reg->value()] = (intptr_t*) loc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    check_location_valid();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // Called by an entry frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  void clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  bool include_argument_oops() const      { return _include_argument_oops; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void set_include_argument_oops(bool f)  { _include_argument_oops = f; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  JavaThread *thread() const { return _thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool update_map()    const { return _update_map; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void print() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // the following contains the definition of pd_xxx methods
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   123
#ifdef TARGET_ARCH_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   124
# include "registerMap_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   125
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   126
#ifdef TARGET_ARCH_sparc
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   127
# include "registerMap_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   128
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   129
#ifdef TARGET_ARCH_zero
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   130
# include "registerMap_zero.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   131
#endif
8107
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
   132
#ifdef TARGET_ARCH_arm
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
   133
# include "registerMap_arm.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
   134
#endif
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
   135
#ifdef TARGET_ARCH_ppc
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
   136
# include "registerMap_ppc.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 7397
diff changeset
   137
#endif
29180
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 25715
diff changeset
   138
#ifdef TARGET_ARCH_aarch64
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 25715
diff changeset
   139
# include "registerMap_aarch64.hpp"
50369728b00e 8064611: AARCH64: Changes to HotSpot shared code
aph
parents: 25715
diff changeset
   140
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   141
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   143
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   144
#endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP