hotspot/src/share/vm/compiler/oopMap.hpp
author twisti
Thu, 08 Oct 2015 12:49:30 -1000
changeset 33160 c59f1676d27e
parent 33063 9e222337a81e
child 33589 7cbd1b2c139b
permissions -rw-r--r--
8136421: JEP 243: Java-Level JVM Compiler Interface Reviewed-by: ihse, alanb, roland, coleenp, iveresov, kvn, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
     2
 * Copyright (c) 1998, 2015, 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: 3795
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3795
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: 3795
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_COMPILER_OOPMAP_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_COMPILER_OOPMAP_HPP
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 "code/compressedStream.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
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "utilities/growableArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Interface for generating the frame map for compiled code.  A frame map
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// describes for a specific pc whether each register and frame stack slot is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//   Oop         - A GC root for current frame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//   Dead        - Dead; can be Zapped for debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//   CalleeXX    - Callee saved; also describes which caller register is saved
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//   DerivedXX   - A derived oop; original oop is described.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// OopMapValue describes a single OopMap entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class frame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class RegisterMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class DerivedPointerEntry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class OopMapValue: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  short _value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  int value() const                                 { return _value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  void set_value(int value)                         { _value = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  short _content_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Constants
33063
9e222337a81e 8136406: Remove ZapDeadCompiledLocals code
kvn
parents: 30774
diff changeset
    56
  enum { type_bits                = 4,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
         register_bits            = BitsPerShort - type_bits };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  enum { type_shift               = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
         register_shift           = type_bits };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  enum { type_mask                = right_n_bits(type_bits),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
         type_mask_in_place       = type_mask << type_shift,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
         register_mask            = right_n_bits(register_bits),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
         register_mask_in_place   = register_mask << register_shift };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  enum oop_types {              // must fit in type_bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
         unused_value =0,       // powers of 2, for masking OopMapStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
         oop_value = 1,
33063
9e222337a81e 8136406: Remove ZapDeadCompiledLocals code
kvn
parents: 30774
diff changeset
    70
         narrowoop_value = 2,
9e222337a81e 8136406: Remove ZapDeadCompiledLocals code
kvn
parents: 30774
diff changeset
    71
         callee_saved_value = 4,
9e222337a81e 8136406: Remove ZapDeadCompiledLocals code
kvn
parents: 30774
diff changeset
    72
         derived_oop_value= 8 };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg,t); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg,t); set_content_reg(reg2); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  OopMapValue (CompressedReadStream* stream) { read_from(stream); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Archiving
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  void write_on(CompressedWriteStream* stream) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    stream->write_int(value());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    if(is_callee_saved() || is_derived_oop()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
      stream->write_int(content_reg()->value());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  void read_from(CompressedReadStream* stream) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    set_value(stream->read_int());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    if(is_callee_saved() || is_derived_oop()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      set_content_reg(VMRegImpl::as_VMReg(stream->read_int(), true));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Querying
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  bool is_oop()               { return mask_bits(value(), type_mask_in_place) == oop_value; }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
    97
  bool is_narrowoop()           { return mask_bits(value(), type_mask_in_place) == narrowoop_value; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  bool is_callee_saved()      { return mask_bits(value(), type_mask_in_place) == callee_saved_value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  bool is_derived_oop()       { return mask_bits(value(), type_mask_in_place) == derived_oop_value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void set_oop()              { set_value((value() & register_mask_in_place) | oop_value); }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 347
diff changeset
   102
  void set_narrowoop()          { set_value((value() & register_mask_in_place) | narrowoop_value); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void set_callee_saved()     { set_value((value() & register_mask_in_place) | callee_saved_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  void set_derived_oop()      { set_value((value() & register_mask_in_place) | derived_oop_value); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  VMReg reg() const { return VMRegImpl::as_VMReg(mask_bits(value(), register_mask_in_place) >> register_shift); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  oop_types type() const      { return (oop_types)mask_bits(value(), type_mask_in_place); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  static bool legal_vm_reg_name(VMReg p) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return (p->value()  == (p->value() & register_mask));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void set_reg_type(VMReg p, oop_types t) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    set_value((p->value() << register_shift) | t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    assert(reg() == p, "sanity check" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    assert(type() == t, "sanity check" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  VMReg content_reg() const       { return VMRegImpl::as_VMReg(_content_reg, true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  void set_content_reg(VMReg r)   { _content_reg = r->value(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // Physical location queries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  bool is_register_loc()      { return reg()->is_reg(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  bool is_stack_loc()         { return reg()->is_stack(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Returns offset from sp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  int stack_offset() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    assert(is_stack_loc(), "must be stack location");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    return reg()->reg2stack();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   133
  void print_on(outputStream* st) const;
198
8601165a33c3 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 1
diff changeset
   134
  void print() const { print_on(tty); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
class OopMap: public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  friend class OopMapStream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
 private:
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   142
  int  _pc_offset; // offset in the code that this OopMap corresponds to
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   143
  int  _omv_count; // number of OopMapValues in the stream
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  CompressedWriteStream* _write_stream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // Accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  int omv_count() const                       { return _omv_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  void set_omv_count(int value)               { _omv_count = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  void increment_count()                      { _omv_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  CompressedWriteStream* write_stream() const { return _write_stream; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  void set_write_stream(CompressedWriteStream* value) { _write_stream = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  enum DeepCopyToken { _deep_copy_token };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  OopMap(DeepCopyToken, OopMap* source);  // used only by deep_copy
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  OopMap(int frame_size, int arg_count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  // pc-offset handling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  int offset() const     { return _pc_offset; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  void set_offset(int o) { _pc_offset = o; }
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   165
  int count() const { return _omv_count; }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   166
  int data_size() const  { return write_stream()->position(); }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   167
  address data() const { return write_stream()->buffer(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // Check to avoid double insertion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; })
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  // Construction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // slots to hold 4-byte values like ints and floats in the LP64 build.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  void set_oop  ( VMReg local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  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
   177
  void set_narrowoop(VMReg local);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void set_dead ( VMReg local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  void set_callee_saved( VMReg local, VMReg caller_machine_register );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  void set_derived_oop ( VMReg local, VMReg derived_from_local_register );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  int heap_size() const;
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   184
  void copy_data_to(address addr) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  OopMap* deep_copy();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   187
  bool has_derived_pointer() const PRODUCT_RETURN0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   188
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  bool legal_vm_reg_name(VMReg local) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
     return OopMapValue::legal_vm_reg_name(local);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Printing
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   194
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  void print() const { print_on(tty); }
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   196
  bool equals(const OopMap* other) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
class OopMapSet : public ResourceObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  int _om_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  int _om_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  OopMap** _om_data;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  int om_count() const              { return _om_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  void set_om_count(int value)      { _om_count = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  void increment_count()            { _om_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  int om_size() const               { return _om_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  void set_om_size(int value)       { _om_size = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  OopMap** om_data() const          { return _om_data; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  void set_om_data(OopMap** value)  { _om_data = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  void grow_om_data();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  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
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  OopMapSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // returns the number of OopMaps in this OopMapSet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  int size() const            { return _om_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // returns the OopMap at a given index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // Collect OopMaps.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  void add_gc_map(int pc, OopMap* map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // Returns the only oop map. Used for reconstructing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // Adapter frames during deoptimization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  OopMap* singular_oop_map();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // returns OopMap in that is anchored to the pc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  OopMap* find_map_at_offset(int pc_offset) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  int heap_size() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
3275
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   237
  // Methods oops_do() and all_do() filter out NULL oops and
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   238
  // oop == Universe::narrow_oop_base() before passing oops
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   239
  // to closures.
bd2023eeea0a 6826736: CMS: core dump with -XX:+UseCompressedOops
kvn
parents: 953
diff changeset
   240
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // Iterates through frame for a compiled method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  static void oops_do            (const frame* fr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
                                  const RegisterMap* reg_map, OopClosure* f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  static void update_register_map(const frame* fr, RegisterMap *reg_map);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  // Iterates through frame for a compiled method for dead ones and values, too
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  static void all_do(const frame* fr, const RegisterMap* reg_map,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
                     OopClosure* oop_fn,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
                     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
   250
                     OopClosure* value_fn);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  // Printing
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 198
diff changeset
   253
  void print_on(outputStream* st) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  void print() const { print_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   257
class ImmutableOopMapBuilder;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   258
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   259
class ImmutableOopMap {
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   260
  friend class OopMapStream;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   261
  friend class VMStructs;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   262
#ifdef ASSERT
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   263
  friend class ImmutableOopMapBuilder;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   264
#endif
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   265
private:
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   266
  int _count; // contains the number of entries in this OopMap
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   267
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   268
  address data_addr() const { return (address) this + sizeof(ImmutableOopMap); }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   269
public:
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   270
  ImmutableOopMap(const OopMap* oopmap);
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   271
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   272
  bool has_derived_pointer() const PRODUCT_RETURN0;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   273
  int count() const { return _count; }
30774
6745424a720f 8080692: lots of jstack tests failing in pit
rbackman
parents: 30628
diff changeset
   274
#ifdef ASSERT
6745424a720f 8080692: lots of jstack tests failing in pit
rbackman
parents: 30628
diff changeset
   275
  int nr_of_bytes() const; // this is an expensive operation, only used in debug builds
6745424a720f 8080692: lots of jstack tests failing in pit
rbackman
parents: 30628
diff changeset
   276
#endif
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   277
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   278
  // Printing
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   279
  void print_on(outputStream* st) const;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   280
  void print() const { print_on(tty); }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   281
};
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   282
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   283
class ImmutableOopMapSet;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   284
class ImmutableOopMap;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   285
class OopMapSet;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   286
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   287
class ImmutableOopMapPair {
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   288
  friend class VMStructs;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   289
private:
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   290
  int _pc_offset; // program counter offset from the beginning of the method
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   291
  int _oopmap_offset; // offset in the data in the ImmutableOopMapSet where the ImmutableOopMap is located
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   292
public:
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   293
  ImmutableOopMapPair(int pc_offset, int oopmap_offset) : _pc_offset(pc_offset), _oopmap_offset(oopmap_offset) {
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   294
    assert(pc_offset >= 0 && oopmap_offset >= 0, "check");
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   295
  }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   296
  const ImmutableOopMap* get_from(const ImmutableOopMapSet* set) const;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   297
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   298
  int pc_offset() const { return _pc_offset; }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   299
  int oopmap_offset() const { return _oopmap_offset; }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   300
};
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   301
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   302
class ImmutableOopMapSet {
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   303
  friend class VMStructs;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   304
private:
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   305
  int _count; // nr of ImmutableOopMapPairs in the Set
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   306
  int _size; // nr of bytes including ImmutableOopMapSet itself
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   307
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   308
  address data() const { return (address) this + sizeof(*this) + sizeof(ImmutableOopMapPair) * _count; }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   309
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   310
public:
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   311
  ImmutableOopMapSet(const OopMapSet* oopmap_set, int size) : _count(oopmap_set->size()), _size(size) {}
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   312
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   313
  ImmutableOopMap* oopmap_at_offset(int offset) const {
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   314
    assert(offset >= 0 && offset < _size, "must be within boundaries");
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   315
    address addr = data() + offset;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   316
    return (ImmutableOopMap*) addr;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   317
  }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   318
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   319
  ImmutableOopMapPair* get_pairs() const { return (ImmutableOopMapPair*) ((address) this + sizeof(*this)); }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   320
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   321
  static ImmutableOopMapSet* build_from(const OopMapSet* oopmap_set);
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   322
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   323
  const ImmutableOopMap* find_map_at_offset(int pc_offset) const;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   324
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   325
  const ImmutableOopMapPair* pair_at(int index) const { assert(index >= 0 && index < _count, "check"); return &get_pairs()[index]; }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   326
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   327
  int count() const { return _count; }
30628
3c15b4a3bf4d 8079797: assert(index >= 0 && index < _count) failed: check
rbackman
parents: 30590
diff changeset
   328
  int nr_of_bytes() const { return _size; }
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   329
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   330
  void print_on(outputStream* st) const;
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   331
  void print() const { print_on(tty); }
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   332
};
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
class OopMapStream : public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  CompressedReadStream* _stream;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  int _mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  int _size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  int _position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  bool _valid_omv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  OopMapValue _omv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  void find_next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
 public:
30590
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   345
  OopMapStream(OopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place);
14f7f48c1377 8064458: OopMap class could be more compact
rbackman
parents: 7397
diff changeset
   346
  OopMapStream(const ImmutableOopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  bool is_done()                        { if(!_valid_omv) { find_next(); } return !_valid_omv; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  void next()                           { find_next(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  OopMapValue current()                 { return _omv; }
30774
6745424a720f 8080692: lots of jstack tests failing in pit
rbackman
parents: 30628
diff changeset
   350
#ifdef ASSERT
6745424a720f 8080692: lots of jstack tests failing in pit
rbackman
parents: 30628
diff changeset
   351
  int stream_position() const           { return _stream->position(); }
6745424a720f 8080692: lots of jstack tests failing in pit
rbackman
parents: 30628
diff changeset
   352
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   355
class ImmutableOopMapBuilder {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   356
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   357
  class Mapping;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   358
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   359
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   360
  const OopMapSet* _set;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   361
  const OopMap* _empty;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   362
  const OopMap* _last;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   363
  int _empty_offset;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   364
  int _last_offset;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   365
  int _offset;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   366
  int _required;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   367
  Mapping* _mapping;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   368
  ImmutableOopMapSet* _new_set;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   369
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   370
  /* Used for bookkeeping when building ImmutableOopMaps */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   371
  class Mapping : public ResourceObj {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   372
  public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   373
    enum kind_t { OOPMAP_UNKNOWN = 0, OOPMAP_NEW = 1, OOPMAP_EMPTY = 2, OOPMAP_DUPLICATE = 3 };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   374
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   375
    kind_t _kind;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   376
    int _offset;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   377
    int _size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   378
    const OopMap* _map;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   379
    const OopMap* _other;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   380
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   381
    Mapping() : _kind(OOPMAP_UNKNOWN), _offset(-1), _size(-1), _map(NULL) {}
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   382
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   383
    void set(kind_t kind, int offset, int size, const OopMap* map = 0, const OopMap* other = 0) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   384
      _kind = kind;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   385
      _offset = offset;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   386
      _size = size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   387
      _map = map;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   388
      _other = other;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   389
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   390
  };
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   391
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   392
public:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   393
  ImmutableOopMapBuilder(const OopMapSet* set);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   394
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   395
  int heap_size();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   396
  ImmutableOopMapSet* build();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   397
  ImmutableOopMapSet* generate_into(address buffer);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   398
private:
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   399
  bool is_empty(const OopMap* map) const {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   400
    return map->count() == 0;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   401
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   402
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   403
  bool is_last_duplicate(const OopMap* map) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   404
    if (_last != NULL && _last->count() > 0 && _last->equals(map)) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   405
      return true;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   406
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   407
    return false;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   408
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   409
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   410
#ifdef ASSERT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   411
  void verify(address buffer, int size, const ImmutableOopMapSet* set);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   412
#endif
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   413
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   414
  bool has_empty() const {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   415
    return _empty_offset != -1;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   416
  }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   417
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   418
  int size_for(const OopMap* map) const;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   419
  void fill_pair(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   420
  int fill_map(ImmutableOopMapPair* pair, const OopMap* map, int offset, const ImmutableOopMapSet* set);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   421
  void fill(ImmutableOopMapSet* set, int size);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   422
};
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   423
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
// Derived pointer support. This table keeps track of all derived points on a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
// stack.  It is cleared before each scavenge/GC.  During the traversal of all
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
// oops, it is filled in with references to all locations that contains a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
// derived oop (assumed to be very few).  When the GC is complete, the derived
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
// pointers are updated based on their base pointers new value and an offset.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   430
#if defined(COMPILER2) || INCLUDE_JVMCI
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
class DerivedPointerTable : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
   static GrowableArray<DerivedPointerEntry*>* _list;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
   static bool _active;                      // do not record pointers for verify pass etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  static void clear();                       // Called before scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  static void add(oop *derived, oop *base);  // Called during scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  static void update_pointers();             // Called after  scavenge/GC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  static bool is_empty()                     { return _list == NULL || _list->is_empty(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  static bool is_active()                    { return _active; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  static void set_active(bool value)         { _active = value; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
// A utility class to temporarily "deactivate" the DerivedPointerTable.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
// (Note: clients are responsible for any MT-safety issues)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
class DerivedPointerTableDeactivate: public StackObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  bool _active;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  DerivedPointerTableDeactivate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    _active = DerivedPointerTable::is_active();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
      DerivedPointerTable::set_active(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  ~DerivedPointerTableDeactivate() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
    assert(!DerivedPointerTable::is_active(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
           "Inconsistency: not MT-safe");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    if (_active) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
      DerivedPointerTable::set_active(true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
};
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 33063
diff changeset
   466
#endif // COMPILER2 || INCLUDE_JVMCI
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   467
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   468
#endif // SHARE_VM_COMPILER_OOPMAP_HPP