src/hotspot/share/opto/divnode.hpp
author dlong
Wed, 17 Jan 2018 14:25:47 -0800
changeset 48595 5d699d81c10c
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
permissions -rw-r--r--
8194988: 8 Null pointer dereference defect groups related to MultiNode::proj_out() Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
48595
5d699d81c10c 8194988: 8 Null pointer dereference defect groups related to MultiNode::proj_out()
dlong
parents: 47216
diff changeset
     2
 * Copyright (c) 1997, 2018, 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_DIVNODE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OPTO_DIVNODE_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/multnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/node.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "opto/opcodes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "opto/type.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// Portions of code courtesy of Clifford Click
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// Optimization - Graph Style
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
//------------------------------DivINode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Integer division
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// On processors which don't naturally support this special case (e.g., x86),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// the matcher or runtime system must take care of this.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class DivINode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    47
  virtual Node* Identity(PhaseGVN* phase);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    49
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  virtual const Type *bottom_type() const { return TypeInt::INT; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  virtual uint ideal_reg() const { return Op_RegI; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//------------------------------DivLNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// Long division
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class DivLNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    60
  virtual Node* Identity(PhaseGVN* phase);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    62
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  virtual const Type *bottom_type() const { return TypeLong::LONG; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  virtual uint ideal_reg() const { return Op_RegL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
//------------------------------DivFNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
// Float division
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
class DivFNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  DivFNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    73
  virtual Node* Identity(PhaseGVN* phase);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    75
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  virtual const Type *bottom_type() const { return Type::FLOAT; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  virtual uint ideal_reg() const { return Op_RegF; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
//------------------------------DivDNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// Double division
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
class DivDNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  DivDNode( Node *c, Node *dividend, Node *divisor ) : Node(c,dividend, divisor) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    86
  virtual Node* Identity(PhaseGVN* phase);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    88
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  virtual const Type *bottom_type() const { return Type::DOUBLE; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  virtual uint ideal_reg() const { return Op_RegD; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
//------------------------------ModINode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
// Integer modulus
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
class ModINode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
    99
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  virtual const Type *bottom_type() const { return TypeInt::INT; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  virtual uint ideal_reg() const { return Op_RegI; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
//------------------------------ModLNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
// Long modulus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
class ModLNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
   111
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  virtual const Type *bottom_type() const { return TypeLong::LONG; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  virtual uint ideal_reg() const { return Op_RegL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
//------------------------------ModFNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
// Float Modulus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
class ModFNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  ModFNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
   123
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  virtual const Type *bottom_type() const { return Type::FLOAT; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  virtual uint ideal_reg() const { return Op_RegF; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
//------------------------------ModDNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// Double Modulus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
class ModDNode : public Node {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  ModDNode( Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
   134
  virtual const Type* Value(PhaseGVN* phase) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  virtual const Type *bottom_type() const { return Type::DOUBLE; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  virtual uint ideal_reg() const { return Op_RegD; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
//------------------------------DivModNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
// Division with remainder result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
class DivModNode : public MultiNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  DivModNode( Node *c, Node *dividend, Node *divisor );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    div_proj_num =  0,      // quotient
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    mod_proj_num =  1       // remainder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  virtual int Opcode() const;
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
   150
  virtual Node* Identity(PhaseGVN* phase) { return this; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; }
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 25930
diff changeset
   152
  virtual const Type* Value(PhaseGVN* phase)  const { return bottom_type(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  virtual uint hash() const { return Node::hash(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  virtual bool is_CFG() const  { return false; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  virtual uint ideal_reg() const { return NotAMachineReg; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
48595
5d699d81c10c 8194988: 8 Null pointer dereference defect groups related to MultiNode::proj_out()
dlong
parents: 47216
diff changeset
   157
  ProjNode* div_proj() { return proj_out_or_null(div_proj_num); }
5d699d81c10c 8194988: 8 Null pointer dereference defect groups related to MultiNode::proj_out()
dlong
parents: 47216
diff changeset
   158
  ProjNode* mod_proj() { return proj_out_or_null(mod_proj_num); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
//------------------------------DivModINode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// Integer division with remainder result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
class DivModINode : public DivModNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  DivModINode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  virtual const Type *bottom_type() const { return TypeTuple::INT_PAIR; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  virtual Node *match( const ProjNode *proj, const Matcher *m );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  // Make a divmod and associated projections from a div or mod.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 7397
diff changeset
   171
  static DivModINode* make(Node* div_or_mod);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
//------------------------------DivModLNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
// Long division with remainder result.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
class DivModLNode : public DivModNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  DivModLNode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  virtual int Opcode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  virtual const Type *bottom_type() const { return TypeTuple::LONG_PAIR; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  virtual Node *match( const ProjNode *proj, const Matcher *m );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // Make a divmod and associated projections from a div or mod.
25930
eae8b7490d2c 8054033: Remove unused references to Compile*
thartmann
parents: 7397
diff changeset
   184
  static DivModLNode* make(Node* div_or_mod);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   186
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   187
#endif // SHARE_VM_OPTO_DIVNODE_HPP