src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/compile.cpp

Print this page
rev 5645 : 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
Summary: type methods shouldn't always operate on speculative part
Reviewed-by:


3876   } else {
3877     // Clear control input and let IGVN optimize expensive nodes if
3878     // OptimizeExpensiveOps is off.
3879     n->set_req(0, NULL);
3880   }
3881 }
3882 
3883 /**
3884  * Remove the speculative part of types and clean up the graph
3885  */
3886 void Compile::remove_speculative_types(PhaseIterGVN &igvn) {
3887   if (UseTypeSpeculation) {
3888     Unique_Node_List worklist;
3889     worklist.push(root());
3890     int modified = 0;
3891     // Go over all type nodes that carry a speculative type, drop the
3892     // speculative part of the type and enqueue the node for an igvn
3893     // which may optimize it out.
3894     for (uint next = 0; next < worklist.size(); ++next) {
3895       Node *n  = worklist.at(next);
3896       if (n->is_Type() && n->as_Type()->type()->isa_oopptr() != NULL &&
3897           n->as_Type()->type()->is_oopptr()->speculative() != NULL) {
3898         TypeNode* tn = n->as_Type();
3899         const TypeOopPtr* t = tn->type()->is_oopptr();


3900         bool in_hash = igvn.hash_delete(n);
3901         assert(in_hash, "node should be in igvn hash table");
3902         tn->set_type(t->remove_speculative());
3903         igvn.hash_insert(n);
3904         igvn._worklist.push(n); // give it a chance to go away
3905         modified++;
3906       }

3907       uint max = n->len();
3908       for( uint i = 0; i < max; ++i ) {
3909         Node *m = n->in(i);
3910         if (not_a_node(m))  continue;
3911         worklist.push(m);
3912       }
3913     }
3914     // Drop the speculative part of all types in the igvn's type table
3915     igvn.remove_speculative_types();
3916     if (modified > 0) {
3917       igvn.optimize();
3918     }













3919   }
3920 }
3921 
3922 // Auxiliary method to support randomized stressing/fuzzing.
3923 //
3924 // This method can be called the arbitrary number of times, with current count
3925 // as the argument. The logic allows selecting a single candidate from the
3926 // running list of candidates as follows:
3927 //    int count = 0;
3928 //    Cand* selected = null;
3929 //    while(cand = cand->next()) {
3930 //      if (randomized_select(++count)) {
3931 //        selected = cand;
3932 //      }
3933 //    }
3934 //
3935 // Including count equalizes the chances any candidate is "selected".
3936 // This is useful when we don't have the complete list of candidates to choose
3937 // from uniformly. In this case, we need to adjust the randomicity of the
3938 // selection, or else we will end up biasing the selection towards the latter


3876   } else {
3877     // Clear control input and let IGVN optimize expensive nodes if
3878     // OptimizeExpensiveOps is off.
3879     n->set_req(0, NULL);
3880   }
3881 }
3882 
3883 /**
3884  * Remove the speculative part of types and clean up the graph
3885  */
3886 void Compile::remove_speculative_types(PhaseIterGVN &igvn) {
3887   if (UseTypeSpeculation) {
3888     Unique_Node_List worklist;
3889     worklist.push(root());
3890     int modified = 0;
3891     // Go over all type nodes that carry a speculative type, drop the
3892     // speculative part of the type and enqueue the node for an igvn
3893     // which may optimize it out.
3894     for (uint next = 0; next < worklist.size(); ++next) {
3895       Node *n  = worklist.at(next);
3896       if (n->is_Type()) {

3897         TypeNode* tn = n->as_Type();
3898         const Type* t = tn->type();
3899         const Type* t_no_spec = t->remove_speculative();
3900         if (t_no_spec != t) {
3901           bool in_hash = igvn.hash_delete(n);
3902           assert(in_hash, "node should be in igvn hash table");
3903           tn->set_type(t_no_spec);
3904           igvn.hash_insert(n);
3905           igvn._worklist.push(n); // give it a chance to go away
3906           modified++;
3907         }
3908       }
3909       uint max = n->len();
3910       for( uint i = 0; i < max; ++i ) {
3911         Node *m = n->in(i);
3912         if (not_a_node(m))  continue;
3913         worklist.push(m);
3914       }
3915     }
3916     // Drop the speculative part of all types in the igvn's type table
3917     igvn.remove_speculative_types();
3918     if (modified > 0) {
3919       igvn.optimize();
3920     }
3921 #ifdef ASSERT
3922     worklist.clear();
3923     worklist.push(root());
3924     for (uint next = 0; next < worklist.size(); ++next) {
3925       Node *n  = worklist.at(next);
3926       const Type* t = igvn.type(n);
3927       assert(t == t->remove_speculative(), "no more speculative types");
3928       if (n->is_Type()) {
3929         t = n->as_Type()->type();
3930         assert(t == t->remove_speculative(), "no more speculative types");
3931       }
3932     }
3933 #endif
3934   }
3935 }
3936 
3937 // Auxiliary method to support randomized stressing/fuzzing.
3938 //
3939 // This method can be called the arbitrary number of times, with current count
3940 // as the argument. The logic allows selecting a single candidate from the
3941 // running list of candidates as follows:
3942 //    int count = 0;
3943 //    Cand* selected = null;
3944 //    while(cand = cand->next()) {
3945 //      if (randomized_select(++count)) {
3946 //        selected = cand;
3947 //      }
3948 //    }
3949 //
3950 // Including count equalizes the chances any candidate is "selected".
3951 // This is useful when we don't have the complete list of candidates to choose
3952 // from uniformly. In this case, we need to adjust the randomicity of the
3953 // selection, or else we will end up biasing the selection towards the latter
src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File