hotspot/src/share/vm/opto/intrinsicnode.hpp
changeset 33628 09241459a8b8
parent 23528 8f1a7f5e8066
child 35551 36ef3841fb34
equal deleted inserted replaced
33627:c5b7455f846e 33628:09241459a8b8
     1 /*
     1 /*
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    33 // The 2nd slow-half of a subtype check.  Scan the subklass's 2ndary superklass
    33 // The 2nd slow-half of a subtype check.  Scan the subklass's 2ndary superklass
    34 // array for an instance of the superklass.  Set a hidden internal cache on a
    34 // array for an instance of the superklass.  Set a hidden internal cache on a
    35 // hit (cache is checked with exposed code in gen_subtype_check()).  Return
    35 // hit (cache is checked with exposed code in gen_subtype_check()).  Return
    36 // not zero for a miss or zero for a hit.
    36 // not zero for a miss or zero for a hit.
    37 class PartialSubtypeCheckNode : public Node {
    37 class PartialSubtypeCheckNode : public Node {
    38   public:
    38  public:
    39   PartialSubtypeCheckNode(Node* c, Node* sub, Node* super) : Node(c,sub,super) {}
    39   PartialSubtypeCheckNode(Node* c, Node* sub, Node* super) : Node(c,sub,super) {}
    40   virtual int Opcode() const;
    40   virtual int Opcode() const;
    41   virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; }
    41   virtual const Type* bottom_type() const { return TypeRawPtr::BOTTOM; }
    42   virtual uint ideal_reg() const { return Op_RegP; }
    42   virtual uint ideal_reg() const { return Op_RegP; }
    43 };
    43 };
    44 
    44 
    45 //------------------------------StrIntrinsic-------------------------------
    45 //------------------------------StrIntrinsic-------------------------------
    46 // Base class for Ideal nodes used in String instrinsic code.
    46 // Base class for Ideal nodes used in String intrinsic code.
    47 class StrIntrinsicNode: public Node {
    47 class StrIntrinsicNode: public Node {
    48   public:
    48  public:
       
    49   // Possible encodings of the two parameters passed to the string intrinsic.
       
    50   // 'L' stands for Latin1 and 'U' stands for UTF16. For example, 'LU' means that
       
    51   // the first string is Latin1 encoded and the second string is UTF16 encoded.
       
    52   typedef enum ArgEncoding { LL, LU, UL, UU, none } ArgEnc;
       
    53 
       
    54  protected:
       
    55   // Encoding of strings. Used to select the right version of the intrinsic.
       
    56   const ArgEncoding _encoding;
       
    57   virtual uint size_of() const;
       
    58 
       
    59  public:
    49   StrIntrinsicNode(Node* control, Node* char_array_mem,
    60   StrIntrinsicNode(Node* control, Node* char_array_mem,
    50                    Node* s1, Node* c1, Node* s2, Node* c2):
    61                    Node* s1, Node* c1, Node* s2, Node* c2, ArgEncoding encoding):
    51   Node(control, char_array_mem, s1, c1, s2, c2) {
    62   Node(control, char_array_mem, s1, c1, s2, c2), _encoding(encoding) {
    52   }
    63   }
    53 
    64 
    54   StrIntrinsicNode(Node* control, Node* char_array_mem,
    65   StrIntrinsicNode(Node* control, Node* char_array_mem,
    55                    Node* s1, Node* s2, Node* c):
    66                    Node* s1, Node* s2, Node* c, ArgEncoding encoding):
    56   Node(control, char_array_mem, s1, s2, c) {
    67   Node(control, char_array_mem, s1, s2, c), _encoding(encoding) {
    57   }
    68   }
    58 
    69 
    59   StrIntrinsicNode(Node* control, Node* char_array_mem,
    70   StrIntrinsicNode(Node* control, Node* char_array_mem,
    60                    Node* s1, Node* s2):
    71                    Node* s1, Node* s2, ArgEncoding encoding):
    61   Node(control, char_array_mem, s1, s2) {
    72   Node(control, char_array_mem, s1, s2), _encoding(encoding) {
    62   }
    73   }
    63 
    74 
    64   virtual bool depends_only_on_test() const { return false; }
    75   virtual bool depends_only_on_test() const { return false; }
    65   virtual const TypePtr* adr_type() const { return TypeAryPtr::CHARS; }
    76   virtual const TypePtr* adr_type() const { return TypeAryPtr::BYTES; }
    66   virtual uint match_edge(uint idx) const;
    77   virtual uint match_edge(uint idx) const;
    67   virtual uint ideal_reg() const { return Op_RegI; }
    78   virtual uint ideal_reg() const { return Op_RegI; }
    68   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    79   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
    69   virtual const Type *Value(PhaseTransform *phase) const;
    80   virtual const Type* Value(PhaseTransform* phase) const;
       
    81   ArgEncoding encoding() const { return _encoding; }
    70 };
    82 };
    71 
    83 
    72 //------------------------------StrComp-------------------------------------
    84 //------------------------------StrComp-------------------------------------
    73 class StrCompNode: public StrIntrinsicNode {
    85 class StrCompNode: public StrIntrinsicNode {
    74   public:
    86  public:
    75   StrCompNode(Node* control, Node* char_array_mem,
    87   StrCompNode(Node* control, Node* char_array_mem,
    76               Node* s1, Node* c1, Node* s2, Node* c2):
    88               Node* s1, Node* c1, Node* s2, Node* c2, ArgEncoding encoding):
    77   StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {};
    89   StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2, encoding) {};
    78   virtual int Opcode() const;
    90   virtual int Opcode() const;
    79   virtual const Type* bottom_type() const { return TypeInt::INT; }
    91   virtual const Type* bottom_type() const { return TypeInt::INT; }
    80 };
    92 };
    81 
    93 
    82 //------------------------------StrEquals-------------------------------------
    94 //------------------------------StrEquals-------------------------------------
    83 class StrEqualsNode: public StrIntrinsicNode {
    95 class StrEqualsNode: public StrIntrinsicNode {
    84   public:
    96  public:
    85   StrEqualsNode(Node* control, Node* char_array_mem,
    97   StrEqualsNode(Node* control, Node* char_array_mem,
    86                 Node* s1, Node* s2, Node* c):
    98                 Node* s1, Node* s2, Node* c, ArgEncoding encoding):
    87   StrIntrinsicNode(control, char_array_mem, s1, s2, c) {};
    99   StrIntrinsicNode(control, char_array_mem, s1, s2, c, encoding) {};
    88   virtual int Opcode() const;
   100   virtual int Opcode() const;
    89   virtual const Type* bottom_type() const { return TypeInt::BOOL; }
   101   virtual const Type* bottom_type() const { return TypeInt::BOOL; }
    90 };
   102 };
    91 
   103 
    92 //------------------------------StrIndexOf-------------------------------------
   104 //------------------------------StrIndexOf-------------------------------------
    93 class StrIndexOfNode: public StrIntrinsicNode {
   105 class StrIndexOfNode: public StrIntrinsicNode {
    94   public:
   106  public:
    95   StrIndexOfNode(Node* control, Node* char_array_mem,
   107   StrIndexOfNode(Node* control, Node* char_array_mem,
    96                  Node* s1, Node* c1, Node* s2, Node* c2):
   108                  Node* s1, Node* c1, Node* s2, Node* c2, ArgEncoding encoding):
    97   StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2) {};
   109   StrIntrinsicNode(control, char_array_mem, s1, c1, s2, c2, encoding) {};
    98   virtual int Opcode() const;
   110   virtual int Opcode() const;
    99   virtual const Type* bottom_type() const { return TypeInt::INT; }
   111   virtual const Type* bottom_type() const { return TypeInt::INT; }
   100 };
   112 };
   101 
   113 
       
   114 //------------------------------StrIndexOfChar-------------------------------------
       
   115 class StrIndexOfCharNode: public StrIntrinsicNode {
       
   116  public:
       
   117   StrIndexOfCharNode(Node* control, Node* char_array_mem,
       
   118                      Node* s1, Node* c1, Node* c, ArgEncoding encoding):
       
   119   StrIntrinsicNode(control, char_array_mem, s1, c1, c, encoding) {};
       
   120   virtual int Opcode() const;
       
   121   virtual const Type* bottom_type() const { return TypeInt::INT; }
       
   122 };
       
   123 
       
   124 //--------------------------StrCompressedCopy-------------------------------
       
   125 class StrCompressedCopyNode: public StrIntrinsicNode {
       
   126  public:
       
   127   StrCompressedCopyNode(Node* control, Node* arymem,
       
   128                         Node* s1, Node* s2, Node* c):
       
   129   StrIntrinsicNode(control, arymem, s1, s2, c, none) {};
       
   130   virtual int Opcode() const;
       
   131   virtual const Type* bottom_type() const { return TypeInt::INT; }
       
   132   virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; }
       
   133   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
       
   134 };
       
   135 
       
   136 //--------------------------StrInflatedCopy---------------------------------
       
   137 class StrInflatedCopyNode: public StrIntrinsicNode {
       
   138  public:
       
   139   StrInflatedCopyNode(Node* control, Node* arymem,
       
   140                       Node* s1, Node* s2, Node* c):
       
   141   StrIntrinsicNode(control, arymem, s1, s2, c, none) {};
       
   142   virtual int Opcode() const;
       
   143   virtual const Type* bottom_type() const { return Type::MEMORY; }
       
   144   virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; }
       
   145   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
       
   146 };
       
   147 
   102 //------------------------------AryEq---------------------------------------
   148 //------------------------------AryEq---------------------------------------
   103 class AryEqNode: public StrIntrinsicNode {
   149 class AryEqNode: public StrIntrinsicNode {
   104   public:
   150  public:
   105   AryEqNode(Node* control, Node* char_array_mem, Node* s1, Node* s2):
   151   AryEqNode(Node* control, Node* char_array_mem,
   106   StrIntrinsicNode(control, char_array_mem, s1, s2) {};
   152             Node* s1, Node* s2, ArgEncoding encoding):
       
   153   StrIntrinsicNode(control, char_array_mem, s1, s2, encoding) {};
       
   154   virtual int Opcode() const;
       
   155   virtual const Type* bottom_type() const { return TypeInt::BOOL; }
       
   156 };
       
   157 
       
   158 //------------------------------HasNegatives---------------------------------
       
   159 class HasNegativesNode: public StrIntrinsicNode {
       
   160  public:
       
   161   HasNegativesNode(Node* control, Node* char_array_mem, Node* s1, Node* c1):
       
   162   StrIntrinsicNode(control, char_array_mem, s1, c1, none) {};
   107   virtual int Opcode() const;
   163   virtual int Opcode() const;
   108   virtual const Type* bottom_type() const { return TypeInt::BOOL; }
   164   virtual const Type* bottom_type() const { return TypeInt::BOOL; }
   109 };
   165 };
   110 
   166 
   111 
   167 
   112 //------------------------------EncodeISOArray--------------------------------
   168 //------------------------------EncodeISOArray--------------------------------
   113 // encode char[] to byte[] in ISO_8859_1
   169 // encode char[] to byte[] in ISO_8859_1
   114 class EncodeISOArrayNode: public Node {
   170 class EncodeISOArrayNode: public Node {
   115   public:
   171  public:
   116   EncodeISOArrayNode(Node *control, Node* arymem, Node* s1, Node* s2, Node* c): Node(control, arymem, s1, s2, c) {};
   172   EncodeISOArrayNode(Node* control, Node* arymem, Node* s1, Node* s2, Node* c): Node(control, arymem, s1, s2, c) {};
   117   virtual int Opcode() const;
   173   virtual int Opcode() const;
   118   virtual bool depends_only_on_test() const { return false; }
   174   virtual bool depends_only_on_test() const { return false; }
   119   virtual const Type* bottom_type() const { return TypeInt::INT; }
   175   virtual const Type* bottom_type() const { return TypeInt::INT; }
   120   virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; }
   176   virtual const TypePtr* adr_type() const { return TypePtr::BOTTOM; }
   121   virtual uint match_edge(uint idx) const;
   177   virtual uint match_edge(uint idx) const;
   122   virtual uint ideal_reg() const { return Op_RegI; }
   178   virtual uint ideal_reg() const { return Op_RegI; }
   123   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   179   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
   124   virtual const Type *Value(PhaseTransform *phase) const;
   180   virtual const Type* Value(PhaseTransform* phase) const;
   125 };
   181 };
   126 
   182 
   127 #endif // SHARE_VM_OPTO_INTRINSICNODE_HPP
   183 #endif // SHARE_VM_OPTO_INTRINSICNODE_HPP