3917 // Go over all type nodes that carry a speculative type, drop the |
3917 // Go over all type nodes that carry a speculative type, drop the |
3918 // speculative part of the type and enqueue the node for an igvn |
3918 // speculative part of the type and enqueue the node for an igvn |
3919 // which may optimize it out. |
3919 // which may optimize it out. |
3920 for (uint next = 0; next < worklist.size(); ++next) { |
3920 for (uint next = 0; next < worklist.size(); ++next) { |
3921 Node *n = worklist.at(next); |
3921 Node *n = worklist.at(next); |
3922 if (n->is_Type() && n->as_Type()->type()->isa_oopptr() != NULL && |
3922 if (n->is_Type()) { |
3923 n->as_Type()->type()->is_oopptr()->speculative() != NULL) { |
|
3924 TypeNode* tn = n->as_Type(); |
3923 TypeNode* tn = n->as_Type(); |
3925 const TypeOopPtr* t = tn->type()->is_oopptr(); |
3924 const Type* t = tn->type(); |
3926 bool in_hash = igvn.hash_delete(n); |
3925 const Type* t_no_spec = t->remove_speculative(); |
3927 assert(in_hash, "node should be in igvn hash table"); |
3926 if (t_no_spec != t) { |
3928 tn->set_type(t->remove_speculative()); |
3927 bool in_hash = igvn.hash_delete(n); |
3929 igvn.hash_insert(n); |
3928 assert(in_hash, "node should be in igvn hash table"); |
3930 igvn._worklist.push(n); // give it a chance to go away |
3929 tn->set_type(t_no_spec); |
3931 modified++; |
3930 igvn.hash_insert(n); |
|
3931 igvn._worklist.push(n); // give it a chance to go away |
|
3932 modified++; |
|
3933 } |
3932 } |
3934 } |
3933 uint max = n->len(); |
3935 uint max = n->len(); |
3934 for( uint i = 0; i < max; ++i ) { |
3936 for( uint i = 0; i < max; ++i ) { |
3935 Node *m = n->in(i); |
3937 Node *m = n->in(i); |
3936 if (not_a_node(m)) continue; |
3938 if (not_a_node(m)) continue; |
3940 // Drop the speculative part of all types in the igvn's type table |
3942 // Drop the speculative part of all types in the igvn's type table |
3941 igvn.remove_speculative_types(); |
3943 igvn.remove_speculative_types(); |
3942 if (modified > 0) { |
3944 if (modified > 0) { |
3943 igvn.optimize(); |
3945 igvn.optimize(); |
3944 } |
3946 } |
|
3947 #ifdef ASSERT |
|
3948 // Verify that after the IGVN is over no speculative type has resurfaced |
|
3949 worklist.clear(); |
|
3950 worklist.push(root()); |
|
3951 for (uint next = 0; next < worklist.size(); ++next) { |
|
3952 Node *n = worklist.at(next); |
|
3953 const Type* t = igvn.type(n); |
|
3954 assert(t == t->remove_speculative(), "no more speculative types"); |
|
3955 if (n->is_Type()) { |
|
3956 t = n->as_Type()->type(); |
|
3957 assert(t == t->remove_speculative(), "no more speculative types"); |
|
3958 } |
|
3959 uint max = n->len(); |
|
3960 for( uint i = 0; i < max; ++i ) { |
|
3961 Node *m = n->in(i); |
|
3962 if (not_a_node(m)) continue; |
|
3963 worklist.push(m); |
|
3964 } |
|
3965 } |
|
3966 igvn.check_no_speculative_types(); |
|
3967 #endif |
3945 } |
3968 } |
3946 } |
3969 } |
3947 |
3970 |
3948 // Auxiliary method to support randomized stressing/fuzzing. |
3971 // Auxiliary method to support randomized stressing/fuzzing. |
3949 // |
3972 // |