< prev index next >

src/hotspot/share/opto/compile.cpp

Print this page




4490     for (uint next = 0; next < worklist.size(); ++next) {
4491       Node *n  = worklist.at(next);
4492       const Type* t = igvn.type_or_null(n);
4493       assert((t == NULL) || (t == t->remove_speculative()), "no more speculative types");
4494       if (n->is_Type()) {
4495         t = n->as_Type()->type();
4496         assert(t == t->remove_speculative(), "no more speculative types");
4497       }
4498       uint max = n->len();
4499       for( uint i = 0; i < max; ++i ) {
4500         Node *m = n->in(i);
4501         if (not_a_node(m))  continue;
4502         worklist.push(m);
4503       }
4504     }
4505     igvn.check_no_speculative_types();
4506 #endif
4507   }
4508 }
4509 























































4510 // Auxiliary method to support randomized stressing/fuzzing.
4511 //
4512 // This method can be called the arbitrary number of times, with current count
4513 // as the argument. The logic allows selecting a single candidate from the
4514 // running list of candidates as follows:
4515 //    int count = 0;
4516 //    Cand* selected = null;
4517 //    while(cand = cand->next()) {
4518 //      if (randomized_select(++count)) {
4519 //        selected = cand;
4520 //      }
4521 //    }
4522 //
4523 // Including count equalizes the chances any candidate is "selected".
4524 // This is useful when we don't have the complete list of candidates to choose
4525 // from uniformly. In this case, we need to adjust the randomicity of the
4526 // selection, or else we will end up biasing the selection towards the latter
4527 // candidates.
4528 //
4529 // Quick back-envelope calculation shows that for the list of n candidates




4490     for (uint next = 0; next < worklist.size(); ++next) {
4491       Node *n  = worklist.at(next);
4492       const Type* t = igvn.type_or_null(n);
4493       assert((t == NULL) || (t == t->remove_speculative()), "no more speculative types");
4494       if (n->is_Type()) {
4495         t = n->as_Type()->type();
4496         assert(t == t->remove_speculative(), "no more speculative types");
4497       }
4498       uint max = n->len();
4499       for( uint i = 0; i < max; ++i ) {
4500         Node *m = n->in(i);
4501         if (not_a_node(m))  continue;
4502         worklist.push(m);
4503       }
4504     }
4505     igvn.check_no_speculative_types();
4506 #endif
4507   }
4508 }
4509 
4510 Node* Compile::load_is_value_bit(PhaseGVN* phase, Node* oop) {
4511   // Load the klass pointer and check if it's odd, i.e., if it defines a value type
4512   // is_value = (klass & oop_metadata_odd_mask) >> LogKlassAlignmentInBytes
4513   Node* k_adr = phase->transform(new AddPNode(oop, oop, phase->MakeConX(oopDesc::klass_offset_in_bytes())));
4514   Node* klass = NULL;
4515   if (UseCompressedClassPointers) {
4516     klass = phase->transform(new LoadNKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT->make_narrowklass(), MemNode::unordered));
4517   } else {
4518     klass = phase->transform(new LoadKlassNode(NULL, immutable_memory(), k_adr, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT, MemNode::unordered));
4519   }
4520   const int mask = Universe::oop_metadata_odd_mask();
4521   Node* is_value = phase->transform(new CastP2XNode(NULL, klass));
4522   is_value = phase->transform(new AndXNode(is_value, phase->MakeConX(mask)));
4523   // Check if a shift is required for perturbation to affect aligned bits of oop
4524   if (mask == KlassPtrEvenOddMask && ObjectAlignmentInBytes <= KlassAlignmentInBytes) {
4525     assert((mask >> LogKlassAlignmentInBytes) == 1, "invalid shift");
4526     is_value = phase->transform(new URShiftXNode(is_value, phase->intcon(LogKlassAlignmentInBytes)));
4527   } else {
4528     assert(mask < ObjectAlignmentInBytes, "invalid mask");
4529   }
4530   return is_value;
4531 }
4532 
4533 Node* Compile::optimize_acmp(PhaseGVN* phase, Node* a, Node* b) {
4534   const TypeInstPtr* ta = phase->type(a)->isa_instptr();
4535   const TypeInstPtr* tb = phase->type(b)->isa_instptr();
4536   if (!UseNewAcmp || phase->type(a)->is_zero_type() || phase->type(b)->is_zero_type()) {
4537     // Use old acmp if new acmp is disabled or degraded to a null check
4538     if (Verbose && phase->is_IterGVN()) { tty->print_cr("\n# NULL CHECK"); }
4539     return new CmpPNode(a, b);
4540   } else if ((ta != NULL && ta->is_value_based()) || (tb != NULL && tb->is_value_based())) {
4541     // We statically know that one operand is a value. Therefore,
4542     // new acmp will only return true if both operands are NULL.
4543     if ((ta != NULL && !TypePtr::NULL_PTR->higher_equal(ta)) ||
4544         (tb != NULL && !TypePtr::NULL_PTR->higher_equal(tb))) {
4545       // One operand is never NULL, fold to constant false
4546       if (Verbose && !phase->is_IterGVN()) { tty->print_cr("\n# CONSTANT FALSE (parse time)"); } else if(Verbose) { tty->print_cr("\n# CONSTANT FALSE"); }
4547       return new CmpINode(phase->intcon(0), phase->intcon(1));
4548     } else {
4549       // Check if both operands are null by or'ing the oops
4550       a = phase->transform(new CastP2XNode(NULL, a));
4551       b = phase->transform(new CastP2XNode(NULL, b));
4552       a = phase->transform(new OrXNode(a, b));
4553       if (Verbose && !phase->is_IterGVN()) { tty->print_cr("\n# DOUBLE NULL CHECK (parse time)"); } else if (Verbose) { tty->print_cr("\n# DOUBLE NULL CHECK"); }
4554       return new CmpXNode(a, phase->MakeConX(0));
4555     }
4556   } else if (ta == NULL || !ta->can_be_value_based() || tb == NULL || !tb->can_be_value_based()) {
4557     // Use old acmp
4558     if (Verbose && phase->is_IterGVN()) { tty->print_cr("\n# OLD ACMP "); }
4559     return new CmpPNode(a, b);
4560   }
4561   // Use new acmp
4562   return NULL;
4563 }
4564 
4565 // Auxiliary method to support randomized stressing/fuzzing.
4566 //
4567 // This method can be called the arbitrary number of times, with current count
4568 // as the argument. The logic allows selecting a single candidate from the
4569 // running list of candidates as follows:
4570 //    int count = 0;
4571 //    Cand* selected = null;
4572 //    while(cand = cand->next()) {
4573 //      if (randomized_select(++count)) {
4574 //        selected = cand;
4575 //      }
4576 //    }
4577 //
4578 // Including count equalizes the chances any candidate is "selected".
4579 // This is useful when we don't have the complete list of candidates to choose
4580 // from uniformly. In this case, we need to adjust the randomicity of the
4581 // selection, or else we will end up biasing the selection towards the latter
4582 // candidates.
4583 //
4584 // Quick back-envelope calculation shows that for the list of n candidates


< prev index next >