hotspot/src/share/vm/opto/coalesce.hpp
author coleenp
Mon, 14 Jan 2013 11:01:39 -0500
changeset 15194 a35093d73168
parent 7397 5b173b4ca846
child 17013 22a05c7f3314
permissions -rw-r--r--
8006005: Fix constant pool index validation and alignment trap for method parameter reflection Summary: This patch addresses an alignment trap due to the storage format of method parameters data in constMethod. It also adds code to validate constant pool indexes for method parameters data. Reviewed-by: jrose, dholmes Contributed-by: eric.mccorkle@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, 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: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
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: 1
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_OPTO_COALESCE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OPTO_COALESCE_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 "opto/phase.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class LoopTree;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class LRG;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class LRG_List;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class Matcher;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class PhaseIFG;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class PhaseCFG;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//------------------------------PhaseCoalesce----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class PhaseCoalesce : public Phase {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  PhaseChaitin &_phc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // Coalesce copies
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  PhaseCoalesce( PhaseChaitin &chaitin ) : Phase(Coalesce), _phc(chaitin) { }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  virtual void verify() = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Coalesce copies
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  void coalesce_driver( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Coalesce copies in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  virtual void coalesce( Block *b ) = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Attempt to coalesce live ranges defined by these 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  void combine_these_two( Node *n1, Node *n2 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  LRG &lrgs( uint lidx ) { return _phc.lrgs(lidx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Dump internally name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  void dump( Node *n ) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Dump whole shebang
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  void dump() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
//------------------------------PhaseAggressiveCoalesce------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// Aggressively, pessimistic coalesce copies.  Aggressive means ignore graph
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// colorability; perhaps coalescing to the point of forcing a spill.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
// Pessimistic means we cannot coalesce if 2 live ranges interfere.  This
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// implies we do not hit a fixed point right away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class PhaseAggressiveCoalesce : public PhaseCoalesce {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  uint _unique;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Coalesce copies
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  PhaseAggressiveCoalesce( PhaseChaitin &chaitin ) : PhaseCoalesce(chaitin) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  virtual void verify() { };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // Aggressively coalesce copies in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  virtual void coalesce( Block *b );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Where I fail to coalesce, manifest virtual copies as the Real Thing
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  void insert_copies( Matcher &matcher );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // Copy insertion needs some smarts in case live ranges overlap
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  void insert_copy_with_overlap( Block *b, Node *copy, uint dst_name, uint src_name );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//------------------------------PhaseConservativeCoalesce----------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// Conservatively, pessimistic coalesce copies.  Conservative means do not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
// coalesce if the resultant live range will be uncolorable.  Pessimistic
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
// means we cannot coalesce if 2 live ranges interfere.  This implies we do
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// not hit a fixed point right away.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
class PhaseConservativeCoalesce : public PhaseCoalesce {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  IndexSet _ulr;               // Union live range interferences
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // Coalesce copies
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  PhaseConservativeCoalesce( PhaseChaitin &chaitin );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  virtual void verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Conservatively coalesce copies in this block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  virtual void coalesce( Block *b );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // Coalesce this chain of copies away
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  bool copy_copy( Node *dst_copy, Node *src_copy, Block *b, uint bindex );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  void union_helper( Node *lr1_node, Node *lr2_node, uint lr1, uint lr2, Node *src_def, Node *dst_copy, Node *src_copy, Block *b, uint bindex );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  uint compute_separating_interferences(Node *dst_copy, Node *src_copy, Block *b, uint bindex, RegMask &rm, uint rm_size, uint reg_degree, uint lr1, uint lr2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void update_ifg(uint lr1, uint lr2, IndexSet *n_lr1, IndexSet *n_lr2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   115
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   116
#endif // SHARE_VM_OPTO_COALESCE_HPP