src/hotspot/share/code/location.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 53149 259c36ef27df
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
     2
 * Copyright (c) 1997, 2019, 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: 1135
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1135
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: 1135
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
    25
#ifndef SHARE_CODE_LOCATION_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
    26
#define SHARE_CODE_LOCATION_HPP
7397
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 "asm/assembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "code/vmreg.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
53149
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
    31
class DebugInfoReadStream;
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
    32
class DebugInfoWriteStream;
259c36ef27df 8215731: Move forward class definitions out of globalDefinitions.hpp
coleenp
parents: 49621
diff changeset
    33
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// A Location describes a concrete machine variable location
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// (such as integer or floating point register or a stack-held
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// variable). Used when generating debug-information for nmethods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// Encoding:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    40
// bits (use low bits for best compression):
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    41
//  Type:   [3..0]
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    42
//  Where:  [4]
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    43
//  Offset: [31..5]
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
49373
47b5652f2928 8199283: Remove ValueObj class for allocation subclassing for compiler code
coleenp
parents: 47216
diff changeset
    45
class Location {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  enum Where {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    on_stack,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    in_register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  enum Type {
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    54
    invalid,                    // Invalid location
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    normal,                     // Ints, floats, double halves
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    oop,                        // Oop (please GC me!)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    int_in_long,                // Integer held in long register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    lng,                        // Long held in one register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    float_in_dbl,               // Float held in double register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    dbl,                        // Double held in one register
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    addr,                       // JSR return address
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    62
    narrowoop                   // Narrow Oop (please GC me!)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  enum {
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    68
    TYPE_MASK    = (juint) 0x0F,
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    69
    TYPE_SHIFT   = 0,
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    70
    WHERE_MASK   = (juint) 0x10,
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    71
    WHERE_SHIFT  = 4,
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    72
    OFFSET_MASK  = (juint) 0xFFFFFFE0,
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    73
    OFFSET_SHIFT = 5
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    76
  juint _value;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  // Create a bit-packed Location
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  Location(Where where_, Type type_, unsigned offset_) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    set(where_, type_, offset_);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    assert( where () == where_ , "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    assert( type  () == type_  , "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    assert( offset() == offset_, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  inline void set(Where where_, Type type_, unsigned offset_) {
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    87
    _value = (juint) ((where_  << WHERE_SHIFT) |
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    88
                      (type_   << TYPE_SHIFT)  |
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    89
                      ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // Stack location Factory.  Offset is 4-byte aligned; remove low bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Register location Factory
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // Default constructor
1135
9487203e5789 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 1
diff changeset
    99
  Location() { set(on_stack,invalid,0); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  // Bit field accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  Where where()  const { return (Where)       ((_value & WHERE_MASK)  >> WHERE_SHIFT);}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  Type  type()   const { return (Type)        ((_value & TYPE_MASK)   >> TYPE_SHIFT); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  bool is_register() const    { return where() == in_register; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  bool is_stack() const       { return where() == on_stack;    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  int stack_offset() const    { assert(where() == on_stack,    "wrong Where"); return offset()<<LogBytesPerInt; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  int register_number() const { assert(where() == in_register, "wrong Where"); return offset()   ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset())   ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Printing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  void print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Serialization of debugging information
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  Location(DebugInfoReadStream* stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void write_on(DebugInfoWriteStream* stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  static bool legal_offset_in_bytes(int offset_in_bytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   125
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53149
diff changeset
   126
#endif // SHARE_CODE_LOCATION_HPP