hotspot/src/share/vm/compiler/oopMap.hpp
author kvn
Wed, 22 Jul 2009 15:48:51 -0700
changeset 3275 bd2023eeea0a
parent 953 202a1f972a92
child 3795 6227ff014cfe
permissions -rw-r--r--
6826736: CMS: core dump with -XX:+UseCompressedOops Summary: Fix deoptimization code and OopMapSet::all_do() to check for oop = narrow_oop_base. Reviewed-by: jcoomes, phh, ysr, never
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
3275
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   236
  // Methods oops_do() and all_do() filter out NULL oops and
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   237
  // oop == Universe::narrow_oop_base() before passing oops
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   238
  // to closures.
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   239
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // Iterates through frame for a compiled method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  static void oops_do            (const frame* fr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
                                  const RegisterMap* reg_map, OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  static void update_register_map(const frame* fr, RegisterMap *reg_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // Iterates through frame for a compiled method for dead ones and values, too
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  static void all_do(const frame* fr, const RegisterMap* reg_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
                     OopClosure* oop_fn,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
                     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
   249
                     OopClosure* value_fn);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // Printing
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   252
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  void print() const { print_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
class OopMapStream : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  CompressedReadStream* _stream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  int _mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  int _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  int _position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  bool _valid_omv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  OopMapValue _omv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  void find_next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  OopMapStream(OopMap* oop_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  OopMapStream(OopMap* oop_map, int oop_types_mask);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  bool is_done()                        { if(!_valid_omv) { find_next(); } return !_valid_omv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  void next()                           { find_next(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  OopMapValue current()                 { return _omv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
// Derived pointer support. This table keeps track of all derived points on a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// stack.  It is cleared before each scavenge/GC.  During the traversal of all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// oops, it is filled in with references to all locations that contains a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// derived oop (assumed to be very few).  When the GC is complete, the derived
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
// pointers are updated based on their base pointers new value and an offset.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
class DerivedPointerTable : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
   static GrowableArray<DerivedPointerEntry*>* _list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
   static bool _active;                      // do not record pointers for verify pass etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  static void clear();                       // Called before scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  static void add(oop *derived, oop *base);  // Called during scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  static void update_pointers();             // Called after  scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  static bool is_empty()                     { return _list == NULL || _list->is_empty(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  static bool is_active()                    { return _active; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  static void set_active(bool value)         { _active = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// A utility class to temporarily "deactivate" the DerivedPointerTable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
// (Note: clients are responsible for any MT-safety issues)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
class DerivedPointerTableDeactivate: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  DerivedPointerTableDeactivate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    _active = DerivedPointerTable::is_active();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      DerivedPointerTable::set_active(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  ~DerivedPointerTableDeactivate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    assert(!DerivedPointerTable::is_active(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
           "Inconsistency: not MT-safe");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      DerivedPointerTable::set_active(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
#endif // COMPILER2