< prev index next >

src/hotspot/share/opto/subnode.cpp

Print this page




 942   // Normalize comparisons between Java mirrors into comparisons of the low-
 943   // level klass, where a dependent load could be shortened.
 944   //
 945   // The new pattern has a nice effect of matching the same pattern used in the
 946   // fast path of instanceof/checkcast/Class.isInstance(), which allows
 947   // redundant exact type check be optimized away by GVN.
 948   // For example, in
 949   //   if (x.getClass() == Foo.class) {
 950   //     Foo foo = (Foo) x;
 951   //     // ... use a ...
 952   //   }
 953   // a CmpPNode could be shared between if_acmpne and checkcast
 954   {
 955     Node* k1 = isa_java_mirror_load(phase, in(1));
 956     Node* k2 = isa_java_mirror_load(phase, in(2));
 957     Node* conk2 = isa_const_java_mirror(phase, in(2));
 958 
 959     if (k1 && (k2 || conk2)) {
 960       Node* lhs = k1;
 961       Node* rhs = (k2 != NULL) ? k2 : conk2;
 962       this->set_req(1, lhs);
 963       this->set_req(2, rhs);









 964       return this;
 965     }
 966   }
 967 
 968   // Constant pointer on right?
 969   const TypeKlassPtr* t2 = phase->type(in(2))->isa_klassptr();
 970   if (t2 == NULL || !t2->klass_is_exact())
 971     return NULL;
 972   // Get the constant klass we are comparing to.
 973   ciKlass* superklass = t2->klass();
 974 
 975   // Now check for LoadKlass on left.
 976   Node* ldk1 = in(1);
 977   if (ldk1->is_DecodeNKlass()) {
 978     ldk1 = ldk1->in(1);
 979     if (ldk1->Opcode() != Op_LoadNKlass )
 980       return NULL;
 981   } else if (ldk1->Opcode() != Op_LoadKlass )
 982     return NULL;
 983   // Take apart the address of the LoadKlass:




 942   // Normalize comparisons between Java mirrors into comparisons of the low-
 943   // level klass, where a dependent load could be shortened.
 944   //
 945   // The new pattern has a nice effect of matching the same pattern used in the
 946   // fast path of instanceof/checkcast/Class.isInstance(), which allows
 947   // redundant exact type check be optimized away by GVN.
 948   // For example, in
 949   //   if (x.getClass() == Foo.class) {
 950   //     Foo foo = (Foo) x;
 951   //     // ... use a ...
 952   //   }
 953   // a CmpPNode could be shared between if_acmpne and checkcast
 954   {
 955     Node* k1 = isa_java_mirror_load(phase, in(1));
 956     Node* k2 = isa_java_mirror_load(phase, in(2));
 957     Node* conk2 = isa_const_java_mirror(phase, in(2));
 958 
 959     if (k1 && (k2 || conk2)) {
 960       Node* lhs = k1;
 961       Node* rhs = (k2 != NULL) ? k2 : conk2;
 962 #if INCLUDE_SHENANDOAHGC
 963       PhaseIterGVN* igvn = phase->is_IterGVN();
 964       if (UseShenandoahGC && igvn != NULL) {
 965         set_req_X(1, lhs, igvn);
 966         set_req_X(2, rhs, igvn);
 967       } else
 968 #endif
 969       {
 970         set_req(1, lhs);
 971         set_req(2, rhs);
 972       }
 973       return this;
 974     }
 975   }
 976 
 977   // Constant pointer on right?
 978   const TypeKlassPtr* t2 = phase->type(in(2))->isa_klassptr();
 979   if (t2 == NULL || !t2->klass_is_exact())
 980     return NULL;
 981   // Get the constant klass we are comparing to.
 982   ciKlass* superklass = t2->klass();
 983 
 984   // Now check for LoadKlass on left.
 985   Node* ldk1 = in(1);
 986   if (ldk1->is_DecodeNKlass()) {
 987     ldk1 = ldk1->in(1);
 988     if (ldk1->Opcode() != Op_LoadNKlass )
 989       return NULL;
 990   } else if (ldk1->Opcode() != Op_LoadKlass )
 991     return NULL;
 992   // Take apart the address of the LoadKlass:


< prev index next >