< 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     return new CmpPNode(a, b);
4539   } else if ((ta != NULL && ta->is_value_based()) || (tb != NULL && tb->is_value_based())) {
4540     // We statically know that one operand is a value. Therefore,
4541     // new acmp will only return true if both operands are NULL.
4542     if ((ta != NULL && !TypePtr::NULL_PTR->higher_equal(ta)) ||
4543         (tb != NULL && !TypePtr::NULL_PTR->higher_equal(tb))) {
4544       // One operand is never NULL, fold to constant false
4545       return new CmpINode(phase->intcon(0), phase->intcon(1));
4546     } else {
4547       // Check if both operands are null by or'ing the oops
4548       a = phase->transform(new CastP2XNode(NULL, a));
4549       b = phase->transform(new CastP2XNode(NULL, b));
4550       a = phase->transform(new OrXNode(a, b));
4551       return new CmpXNode(a, phase->MakeConX(0));
4552     }
4553   } else if (ta == NULL || !ta->can_be_value_based() || tb == NULL || !tb->can_be_value_based()) {
4554     // Use old acmp
4555     return new CmpPNode(a, b);
4556   }
4557   // Use new acmp
4558   return NULL;
4559 }
4560 
4561 // Auxiliary method to support randomized stressing/fuzzing.
4562 //
4563 // This method can be called the arbitrary number of times, with current count
4564 // as the argument. The logic allows selecting a single candidate from the
4565 // running list of candidates as follows:
4566 //    int count = 0;
4567 //    Cand* selected = null;
4568 //    while(cand = cand->next()) {
4569 //      if (randomized_select(++count)) {
4570 //        selected = cand;
4571 //      }
4572 //    }
4573 //
4574 // Including count equalizes the chances any candidate is "selected".
4575 // This is useful when we don't have the complete list of candidates to choose
4576 // from uniformly. In this case, we need to adjust the randomicity of the
4577 // selection, or else we will end up biasing the selection towards the latter
4578 // candidates.
4579 //
4580 // Quick back-envelope calculation shows that for the list of n candidates


< prev index next >