src/share/vm/code/location.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/code/location.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,124 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, 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_CODE_LOCATION_HPP
    1.29 +#define SHARE_VM_CODE_LOCATION_HPP
    1.30 +
    1.31 +#include "asm/assembler.hpp"
    1.32 +#include "code/vmreg.hpp"
    1.33 +#include "memory/allocation.hpp"
    1.34 +
    1.35 +// A Location describes a concrete machine variable location
    1.36 +// (such as integer or floating point register or a stack-held
    1.37 +// variable). Used when generating debug-information for nmethods.
    1.38 +//
    1.39 +// Encoding:
    1.40 +//
    1.41 +// bits (use low bits for best compression):
    1.42 +//  Type:   [3..0]
    1.43 +//  Where:  [4]
    1.44 +//  Offset: [31..5]
    1.45 +
    1.46 +class Location VALUE_OBJ_CLASS_SPEC {
    1.47 +  friend class VMStructs;
    1.48 + public:
    1.49 +  enum Where {
    1.50 +    on_stack,
    1.51 +    in_register
    1.52 +  };
    1.53 +
    1.54 +  enum Type {
    1.55 +    invalid,                    // Invalid location
    1.56 +    normal,                     // Ints, floats, double halves
    1.57 +    oop,                        // Oop (please GC me!)
    1.58 +    int_in_long,                // Integer held in long register
    1.59 +    lng,                        // Long held in one register
    1.60 +    float_in_dbl,               // Float held in double register
    1.61 +    dbl,                        // Double held in one register
    1.62 +    addr,                       // JSR return address
    1.63 +    narrowoop                   // Narrow Oop (please GC me!)
    1.64 +  };
    1.65 +
    1.66 +
    1.67 + private:
    1.68 +  enum {
    1.69 +    TYPE_MASK    = (juint) 0x0F,
    1.70 +    TYPE_SHIFT   = 0,
    1.71 +    WHERE_MASK   = (juint) 0x10,
    1.72 +    WHERE_SHIFT  = 4,
    1.73 +    OFFSET_MASK  = (juint) 0xFFFFFFE0,
    1.74 +    OFFSET_SHIFT = 5
    1.75 +  };
    1.76 +
    1.77 +  juint _value;
    1.78 +
    1.79 +  // Create a bit-packed Location
    1.80 +  Location(Where where_, Type type_, unsigned offset_) {
    1.81 +    set(where_, type_, offset_);
    1.82 +    assert( where () == where_ , "" );
    1.83 +    assert( type  () == type_  , "" );
    1.84 +    assert( offset() == offset_, "" );
    1.85 +  }
    1.86 +
    1.87 +  inline void set(Where where_, Type type_, unsigned offset_) {
    1.88 +    _value = (juint) ((where_  << WHERE_SHIFT) |
    1.89 +                      (type_   << TYPE_SHIFT)  |
    1.90 +                      ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
    1.91 +  }
    1.92 +
    1.93 + public:
    1.94 +
    1.95 +  // Stack location Factory.  Offset is 4-byte aligned; remove low bits
    1.96 +  static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
    1.97 +  // Register location Factory
    1.98 +  static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
    1.99 +  // Default constructor
   1.100 +  Location() { set(on_stack,invalid,0); }
   1.101 +
   1.102 +  // Bit field accessors
   1.103 +  Where where()  const { return (Where)       ((_value & WHERE_MASK)  >> WHERE_SHIFT);}
   1.104 +  Type  type()   const { return (Type)        ((_value & TYPE_MASK)   >> TYPE_SHIFT); }
   1.105 +  unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
   1.106 +
   1.107 +  // Accessors
   1.108 +  bool is_register() const    { return where() == in_register; }
   1.109 +  bool is_stack() const       { return where() == on_stack;    }
   1.110 +
   1.111 +  int stack_offset() const    { assert(where() == on_stack,    "wrong Where"); return offset()<<LogBytesPerInt; }
   1.112 +  int register_number() const { assert(where() == in_register, "wrong Where"); return offset()   ; }
   1.113 +
   1.114 +  VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset())   ; }
   1.115 +
   1.116 +  // Printing
   1.117 +  void print_on(outputStream* st) const;
   1.118 +
   1.119 +  // Serialization of debugging information
   1.120 +  Location(DebugInfoReadStream* stream);
   1.121 +  void write_on(DebugInfoWriteStream* stream);
   1.122 +
   1.123 +  // check
   1.124 +  static bool legal_offset_in_bytes(int offset_in_bytes);
   1.125 +};
   1.126 +
   1.127 +#endif // SHARE_VM_CODE_LOCATION_HPP

mercurial