src/share/vm/runtime/registerMap.hpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/registerMap.hpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,118 @@
     1.4 +/*
     1.5 + * Copyright 2002-2007 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +class JavaThread;
    1.29 +
    1.30 +//
    1.31 +// RegisterMap
    1.32 +//
    1.33 +// A companion structure used for stack traversal. The RegisterMap contains
    1.34 +// misc. information needed in order to do correct stack traversal of stack
    1.35 +// frames.  Hence, it must always be passed in as an argument to
    1.36 +// frame::sender(RegisterMap*).
    1.37 +//
    1.38 +// In particular,
    1.39 +//   1) It provides access to the thread for which the stack belongs.  The
    1.40 +//      thread object is needed in order to get sender of a deoptimized frame.
    1.41 +//
    1.42 +//   2) It is used to pass information from a callee frame to its caller
    1.43 +//      frame about how the frame should be traversed.  This is used to let
    1.44 +//      the caller frame take care of calling oops-do of out-going
    1.45 +//      arguments, when the callee frame is not instantiated yet.  This
    1.46 +//      happens, e.g., when a compiled frame calls into
    1.47 +//      resolve_virtual_call.  (Hence, it is critical that the same
    1.48 +//      RegisterMap object is used for the entire stack walk.  Normally,
    1.49 +//      this is hidden by using the StackFrameStream.)  This is used when
    1.50 +//      doing follow_oops and oops_do.
    1.51 +//
    1.52 +//   3) The RegisterMap keeps track of the values of callee-saved registers
    1.53 +//      from frame to frame (hence, the name).  For some stack traversal the
    1.54 +//      values of the callee-saved registers does not matter, e.g., if you
    1.55 +//      only need the static properies such as frame type, pc, and such.
    1.56 +//      Updating of the RegisterMap can be turned off by instantiating the
    1.57 +//      register map as: RegisterMap map(thread, false);
    1.58 +
    1.59 +class RegisterMap : public StackObj {
    1.60 + public:
    1.61 +    typedef julong LocationValidType;
    1.62 +  enum {
    1.63 +    reg_count = ConcreteRegisterImpl::number_of_registers,
    1.64 +    location_valid_type_size = sizeof(LocationValidType)*8,
    1.65 +    location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
    1.66 +  };
    1.67 + private:
    1.68 +  intptr_t*    _location[reg_count];    // Location of registers (intptr_t* looks better than address in the debugger)
    1.69 +  LocationValidType _location_valid[location_valid_size];
    1.70 +  bool        _include_argument_oops;   // Should include argument_oop marked locations for compiler
    1.71 +  JavaThread* _thread;                  // Reference to current thread
    1.72 +  bool        _update_map;              // Tells if the register map need to be
    1.73 +                                        // updated when traversing the stack
    1.74 +
    1.75 +#ifdef ASSERT
    1.76 +  void check_location_valid();
    1.77 +#else
    1.78 +  void check_location_valid() {}
    1.79 +#endif
    1.80 +
    1.81 + public:
    1.82 +  debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
    1.83 +  RegisterMap(JavaThread *thread, bool update_map = true);
    1.84 +  RegisterMap(const RegisterMap* map);
    1.85 +
    1.86 +  address location(VMReg reg) const {
    1.87 +    int index = reg->value() / location_valid_type_size;
    1.88 +    assert(0 <= reg->value() && reg->value() < reg_count, "range check");
    1.89 +    assert(0 <= index && index < location_valid_size, "range check");
    1.90 +    if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
    1.91 +      return (address) _location[reg->value()];
    1.92 +    } else {
    1.93 +      return pd_location(reg);
    1.94 +    }
    1.95 +  }
    1.96 +
    1.97 +  void set_location(VMReg reg, address loc) {
    1.98 +    int index = reg->value() / location_valid_type_size;
    1.99 +    assert(0 <= reg->value() && reg->value() < reg_count, "range check");
   1.100 +    assert(0 <= index && index < location_valid_size, "range check");
   1.101 +    assert(_update_map, "updating map that does not need updating");
   1.102 +    _location[reg->value()] = (intptr_t*) loc;
   1.103 +    _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
   1.104 +    check_location_valid();
   1.105 +  }
   1.106 +
   1.107 +  // Called by an entry frame.
   1.108 +  void clear();
   1.109 +
   1.110 +  bool include_argument_oops() const      { return _include_argument_oops; }
   1.111 +  void set_include_argument_oops(bool f)  { _include_argument_oops = f; }
   1.112 +
   1.113 +  JavaThread *thread() const { return _thread; }
   1.114 +  bool update_map()    const { return _update_map; }
   1.115 +
   1.116 +  void print_on(outputStream* st) const;
   1.117 +  void print() const;
   1.118 +
   1.119 +  // the following contains the definition of pd_xxx methods
   1.120 +# include "incls/_registerMap_pd.hpp.incl"
   1.121 +};

mercurial