hotspot/src/share/vm/compiler/oopMap.hpp
author jcoomes
Thu, 11 Dec 2008 12:05:08 -0800
changeset 1668 8ec481b8f514
parent 953 202a1f972a92
child 3275 bd2023eeea0a
permissions -rw-r--r--
6578152: fill_region_with_object has usability and safety issues Reviewed-by: apetrusenko, ysr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 360
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Interface for generating the frame map for compiled code.  A frame map
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// describes for a specific pc whether each register and frame stack slot is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
//   Oop         - A GC root for current frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
//   Value       - Live non-oop, non-float value: int, either half of double
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
//   Dead        - Dead; can be Zapped for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
//   CalleeXX    - Callee saved; also describes which caller register is saved
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//   DerivedXX   - A derived oop; original oop is described.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// OopMapValue describes a single OopMap entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class RegisterMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class DerivedPointerEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class OopMapValue: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  short _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  int value() const                                 { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  void set_value(int value)                         { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  short _content_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Constants
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 360
diff changeset
    49
  enum { type_bits                = 5,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
         register_bits            = BitsPerShort - type_bits };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  enum { type_shift               = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
         register_shift           = type_bits };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  enum { type_mask                = right_n_bits(type_bits),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
         type_mask_in_place       = type_mask << type_shift,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
         register_mask            = right_n_bits(register_bits),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
         register_mask_in_place   = register_mask << register_shift };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  enum oop_types {              // must fit in type_bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
         unused_value =0,       // powers of 2, for masking OopMapStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
         oop_value = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
         value_value = 2,
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
    64
         narrowoop_value = 4,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
         callee_saved_value = 8,
952
38812d18eec0 6684714: Optimize EA Connection Graph build performance
kvn
parents: 360
diff changeset
    66
         derived_oop_value= 16 };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg,t); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg,t); set_content_reg(reg2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  OopMapValue (CompressedReadStream* stream) { read_from(stream); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Archiving
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  void write_on(CompressedWriteStream* stream) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    stream->write_int(value());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    if(is_callee_saved() || is_derived_oop()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      stream->write_int(content_reg()->value());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  void read_from(CompressedReadStream* stream) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    set_value(stream->read_int());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    if(is_callee_saved() || is_derived_oop()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      set_content_reg(VMRegImpl::as_VMReg(stream->read_int(), true));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Querying
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  bool is_oop()               { return mask_bits(value(), type_mask_in_place) == oop_value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  bool is_value()             { return mask_bits(value(), type_mask_in_place) == value_value; }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
    92
  bool is_narrowoop()           { return mask_bits(value(), type_mask_in_place) == narrowoop_value; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  bool is_callee_saved()      { return mask_bits(value(), type_mask_in_place) == callee_saved_value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  bool is_derived_oop()       { return mask_bits(value(), type_mask_in_place) == derived_oop_value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void set_oop()              { set_value((value() & register_mask_in_place) | oop_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void set_value()            { set_value((value() & register_mask_in_place) | value_value); }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
    98
  void set_narrowoop()          { set_value((value() & register_mask_in_place) | narrowoop_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void set_callee_saved()     { set_value((value() & register_mask_in_place) | callee_saved_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void set_derived_oop()      { set_value((value() & register_mask_in_place) | derived_oop_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  VMReg reg() const { return VMRegImpl::as_VMReg(mask_bits(value(), register_mask_in_place) >> register_shift); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  oop_types type() const      { return (oop_types)mask_bits(value(), type_mask_in_place); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static bool legal_vm_reg_name(VMReg p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    return (p->value()  == (p->value() & register_mask));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  void set_reg_type(VMReg p, oop_types t) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    set_value((p->value() << register_shift) | t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    assert(reg() == p, "sanity check" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    assert(type() == t, "sanity check" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  VMReg content_reg() const       { return VMRegImpl::as_VMReg(_content_reg, true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  void set_content_reg(VMReg r)   { _content_reg = r->value(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // Physical location queries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  bool is_register_loc()      { return reg()->is_reg(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  bool is_stack_loc()         { return reg()->is_stack(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // Returns offset from sp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  int stack_offset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    assert(is_stack_loc(), "must be stack location");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    return reg()->reg2stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   129
  void print_on(outputStream* st) const;
198
8601165a33c3 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 1
diff changeset
   130
  void print() const { print_on(tty); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
class OopMap: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  friend class OopMapStream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  int  _pc_offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  int  _omv_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  int  _omv_data_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  unsigned char* _omv_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  CompressedWriteStream* _write_stream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  unsigned char* omv_data() const             { return _omv_data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  void set_omv_data(unsigned char* value)     { _omv_data = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  int omv_data_size() const                   { return _omv_data_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  void set_omv_data_size(int value)           { _omv_data_size = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  int omv_count() const                       { return _omv_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  void set_omv_count(int value)               { _omv_count = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  void increment_count()                      { _omv_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  CompressedWriteStream* write_stream() const { return _write_stream; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  void set_write_stream(CompressedWriteStream* value) { _write_stream = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  enum DeepCopyToken { _deep_copy_token };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  OopMap(DeepCopyToken, OopMap* source);  // used only by deep_copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  OopMap(int frame_size, int arg_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  // pc-offset handling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  int offset() const     { return _pc_offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  void set_offset(int o) { _pc_offset = o; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Check to avoid double insertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; })
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Construction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // slots to hold 4-byte values like ints and floats in the LP64 build.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  void set_oop  ( VMReg local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  void set_value( VMReg local);
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
   176
  void set_narrowoop(VMReg local);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  void set_dead ( VMReg local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void set_callee_saved( VMReg local, VMReg caller_machine_register );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  void set_derived_oop ( VMReg local, VMReg derived_from_local_register );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  int heap_size() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  void copy_to(address addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  OopMap* deep_copy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  bool has_derived_pointer() const PRODUCT_RETURN0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  bool legal_vm_reg_name(VMReg local) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
     return OopMapValue::legal_vm_reg_name(local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Printing
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   193
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void print() const { print_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
class OopMapSet : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  int _om_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  int _om_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  OopMap** _om_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  int om_count() const              { return _om_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  void set_om_count(int value)      { _om_count = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  void increment_count()            { _om_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  int om_size() const               { return _om_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  void set_om_size(int value)       { _om_size = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  OopMap** om_data() const          { return _om_data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  void set_om_data(OopMap** value)  { _om_data = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  void grow_om_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // returns the number of OopMaps in this OopMapSet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  int size() const            { return _om_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // returns the OopMap at a given index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // Collect OopMaps.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  void add_gc_map(int pc, OopMap* map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // Returns the only oop map. Used for reconstructing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  // Adapter frames during deoptimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  OopMap* singular_oop_map();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // returns OopMap in that is anchored to the pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  OopMap* find_map_at_offset(int pc_offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  int heap_size() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  void copy_to(address addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // Iterates through frame for a compiled method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  static void oops_do            (const frame* fr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
                                  const RegisterMap* reg_map, OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  static void update_register_map(const frame* fr, RegisterMap *reg_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // Iterates through frame for a compiled method for dead ones and values, too
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  static void all_do(const frame* fr, const RegisterMap* reg_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
                     OopClosure* oop_fn,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
                     void derived_oop_fn(oop* base, oop* derived),
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
   245
                     OopClosure* value_fn);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // Printing
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   248
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  void print() const { print_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
class OopMapStream : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  CompressedReadStream* _stream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  int _mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  int _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  int _position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  bool _valid_omv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  OopMapValue _omv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  void find_next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  OopMapStream(OopMap* oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  OopMapStream(OopMap* oop_map, int oop_types_mask);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  bool is_done()                        { if(!_valid_omv) { find_next(); } return !_valid_omv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  void next()                           { find_next(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  OopMapValue current()                 { return _omv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// Derived pointer support. This table keeps track of all derived points on a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
// stack.  It is cleared before each scavenge/GC.  During the traversal of all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
// oops, it is filled in with references to all locations that contains a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
// derived oop (assumed to be very few).  When the GC is complete, the derived
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
// pointers are updated based on their base pointers new value and an offset.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
class DerivedPointerTable : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
   static GrowableArray<DerivedPointerEntry*>* _list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
   static bool _active;                      // do not record pointers for verify pass etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  static void clear();                       // Called before scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  static void add(oop *derived, oop *base);  // Called during scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  static void update_pointers();             // Called after  scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  static bool is_empty()                     { return _list == NULL || _list->is_empty(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  static bool is_active()                    { return _active; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  static void set_active(bool value)         { _active = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
// A utility class to temporarily "deactivate" the DerivedPointerTable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
// (Note: clients are responsible for any MT-safety issues)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
class DerivedPointerTableDeactivate: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  DerivedPointerTableDeactivate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    _active = DerivedPointerTable::is_active();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      DerivedPointerTable::set_active(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  ~DerivedPointerTableDeactivate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    assert(!DerivedPointerTable::is_active(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
           "Inconsistency: not MT-safe");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      DerivedPointerTable::set_active(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
#endif // COMPILER2