src/share/vm/runtime/registerMap.hpp

changeset 0
f90c822e73f8
child 1
2d8a650513c2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/registerMap.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,156 @@
     1.4 +/*
     1.5 + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP
    1.29 +#define SHARE_VM_RUNTIME_REGISTERMAP_HPP
    1.30 +
    1.31 +#include "code/vmreg.hpp"
    1.32 +#include "utilities/globalDefinitions.hpp"
    1.33 +#ifdef TARGET_ARCH_x86
    1.34 +# include "register_x86.hpp"
    1.35 +#endif
    1.36 +#ifdef TARGET_ARCH_sparc
    1.37 +# include "register_sparc.hpp"
    1.38 +#endif
    1.39 +#ifdef TARGET_ARCH_zero
    1.40 +# include "register_zero.hpp"
    1.41 +#endif
    1.42 +#ifdef TARGET_ARCH_arm
    1.43 +# include "register_arm.hpp"
    1.44 +#endif
    1.45 +#ifdef TARGET_ARCH_ppc
    1.46 +# include "register_ppc.hpp"
    1.47 +#endif
    1.48 +
    1.49 +class JavaThread;
    1.50 +
    1.51 +//
    1.52 +// RegisterMap
    1.53 +//
    1.54 +// A companion structure used for stack traversal. The RegisterMap contains
    1.55 +// misc. information needed in order to do correct stack traversal of stack
    1.56 +// frames.  Hence, it must always be passed in as an argument to
    1.57 +// frame::sender(RegisterMap*).
    1.58 +//
    1.59 +// In particular,
    1.60 +//   1) It provides access to the thread for which the stack belongs.  The
    1.61 +//      thread object is needed in order to get sender of a deoptimized frame.
    1.62 +//
    1.63 +//   2) It is used to pass information from a callee frame to its caller
    1.64 +//      frame about how the frame should be traversed.  This is used to let
    1.65 +//      the caller frame take care of calling oops-do of out-going
    1.66 +//      arguments, when the callee frame is not instantiated yet.  This
    1.67 +//      happens, e.g., when a compiled frame calls into
    1.68 +//      resolve_virtual_call.  (Hence, it is critical that the same
    1.69 +//      RegisterMap object is used for the entire stack walk.  Normally,
    1.70 +//      this is hidden by using the StackFrameStream.)  This is used when
    1.71 +//      doing follow_oops and oops_do.
    1.72 +//
    1.73 +//   3) The RegisterMap keeps track of the values of callee-saved registers
    1.74 +//      from frame to frame (hence, the name).  For some stack traversal the
    1.75 +//      values of the callee-saved registers does not matter, e.g., if you
    1.76 +//      only need the static properies such as frame type, pc, and such.
    1.77 +//      Updating of the RegisterMap can be turned off by instantiating the
    1.78 +//      register map as: RegisterMap map(thread, false);
    1.79 +
    1.80 +class RegisterMap : public StackObj {
    1.81 + public:
    1.82 +    typedef julong LocationValidType;
    1.83 +  enum {
    1.84 +    reg_count = ConcreteRegisterImpl::number_of_registers,
    1.85 +    location_valid_type_size = sizeof(LocationValidType)*8,
    1.86 +    location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
    1.87 +  };
    1.88 + private:
    1.89 +  intptr_t*    _location[reg_count];    // Location of registers (intptr_t* looks better than address in the debugger)
    1.90 +  LocationValidType _location_valid[location_valid_size];
    1.91 +  bool        _include_argument_oops;   // Should include argument_oop marked locations for compiler
    1.92 +  JavaThread* _thread;                  // Reference to current thread
    1.93 +  bool        _update_map;              // Tells if the register map need to be
    1.94 +                                        // updated when traversing the stack
    1.95 +
    1.96 +#ifdef ASSERT
    1.97 +  void check_location_valid();
    1.98 +#else
    1.99 +  void check_location_valid() {}
   1.100 +#endif
   1.101 +
   1.102 + public:
   1.103 +  debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
   1.104 +  RegisterMap(JavaThread *thread, bool update_map = true);
   1.105 +  RegisterMap(const RegisterMap* map);
   1.106 +
   1.107 +  address location(VMReg reg) const {
   1.108 +    int index = reg->value() / location_valid_type_size;
   1.109 +    assert(0 <= reg->value() && reg->value() < reg_count, "range check");
   1.110 +    assert(0 <= index && index < location_valid_size, "range check");
   1.111 +    if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
   1.112 +      return (address) _location[reg->value()];
   1.113 +    } else {
   1.114 +      return pd_location(reg);
   1.115 +    }
   1.116 +  }
   1.117 +
   1.118 +  void set_location(VMReg reg, address loc) {
   1.119 +    int index = reg->value() / location_valid_type_size;
   1.120 +    assert(0 <= reg->value() && reg->value() < reg_count, "range check");
   1.121 +    assert(0 <= index && index < location_valid_size, "range check");
   1.122 +    assert(_update_map, "updating map that does not need updating");
   1.123 +    _location[reg->value()] = (intptr_t*) loc;
   1.124 +    _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
   1.125 +    check_location_valid();
   1.126 +  }
   1.127 +
   1.128 +  // Called by an entry frame.
   1.129 +  void clear();
   1.130 +
   1.131 +  bool include_argument_oops() const      { return _include_argument_oops; }
   1.132 +  void set_include_argument_oops(bool f)  { _include_argument_oops = f; }
   1.133 +
   1.134 +  JavaThread *thread() const { return _thread; }
   1.135 +  bool update_map()    const { return _update_map; }
   1.136 +
   1.137 +  void print_on(outputStream* st) const;
   1.138 +  void print() const;
   1.139 +
   1.140 +  // the following contains the definition of pd_xxx methods
   1.141 +#ifdef TARGET_ARCH_x86
   1.142 +# include "registerMap_x86.hpp"
   1.143 +#endif
   1.144 +#ifdef TARGET_ARCH_sparc
   1.145 +# include "registerMap_sparc.hpp"
   1.146 +#endif
   1.147 +#ifdef TARGET_ARCH_zero
   1.148 +# include "registerMap_zero.hpp"
   1.149 +#endif
   1.150 +#ifdef TARGET_ARCH_arm
   1.151 +# include "registerMap_arm.hpp"
   1.152 +#endif
   1.153 +#ifdef TARGET_ARCH_ppc
   1.154 +# include "registerMap_ppc.hpp"
   1.155 +#endif
   1.156 +
   1.157 +};
   1.158 +
   1.159 +#endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP

mercurial