comparison src/share/vm/opto/graphKit.cpp @ 366:8261ee795323

6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int") Summary: insert CastII nodes to narrow type of load_array_length() node Reviewed-by: never, kvn
author rasbold
date Wed, 17 Sep 2008 08:29:17 -0700
parents c792b641b8bd
children 194b8e3a2fc4
comparison
equal deleted inserted replaced
333:7484fa4b8825 366:8261ee795323
1047 } 1047 }
1048 1048
1049 //-------------------------load_array_length----------------------------------- 1049 //-------------------------load_array_length-----------------------------------
1050 Node* GraphKit::load_array_length(Node* array) { 1050 Node* GraphKit::load_array_length(Node* array) {
1051 // Special-case a fresh allocation to avoid building nodes: 1051 // Special-case a fresh allocation to avoid building nodes:
1052 Node* alen = AllocateArrayNode::Ideal_length(array, &_gvn); 1052 AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array, &_gvn);
1053 if (alen != NULL) return alen; 1053 Node *alen;
1054 Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes()); 1054 if (alloc == NULL) {
1055 return _gvn.transform( new (C, 3) LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS)); 1055 Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes());
1056 alen = _gvn.transform( new (C, 3) LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS));
1057 } else {
1058 alen = alloc->Ideal_length();
1059 Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_aryptr(), &_gvn);
1060 if (ccast != alen) {
1061 alen = _gvn.transform(ccast);
1062 }
1063 }
1064 return alen;
1056 } 1065 }
1057 1066
1058 //------------------------------do_null_check---------------------------------- 1067 //------------------------------do_null_check----------------------------------
1059 // Helper function to do a NULL pointer check. Returned value is 1068 // Helper function to do a NULL pointer check. Returned value is
1060 // the incoming address with NULL casted away. You are allowed to use the 1069 // the incoming address with NULL casted away. You are allowed to use the
2831 javaoop = _gvn.transform(javaoop); 2840 javaoop = _gvn.transform(javaoop);
2832 C->set_recent_alloc(control(), javaoop); 2841 C->set_recent_alloc(control(), javaoop);
2833 assert(just_allocated_object(control()) == javaoop, "just allocated"); 2842 assert(just_allocated_object(control()) == javaoop, "just allocated");
2834 2843
2835 #ifdef ASSERT 2844 #ifdef ASSERT
2836 { // Verify that the AllocateNode::Ideal_foo recognizers work: 2845 { // Verify that the AllocateNode::Ideal_allocation recognizers work:
2837 Node* kn = alloc->in(AllocateNode::KlassNode); 2846 assert(AllocateNode::Ideal_allocation(rawoop, &_gvn) == alloc,
2838 Node* ln = alloc->in(AllocateNode::ALength); 2847 "Ideal_allocation works");
2839 assert(AllocateNode::Ideal_klass(rawoop, &_gvn) == kn, 2848 assert(AllocateNode::Ideal_allocation(javaoop, &_gvn) == alloc,
2840 "Ideal_klass works"); 2849 "Ideal_allocation works");
2841 assert(AllocateNode::Ideal_klass(javaoop, &_gvn) == kn,
2842 "Ideal_klass works");
2843 if (alloc->is_AllocateArray()) { 2850 if (alloc->is_AllocateArray()) {
2844 assert(AllocateArrayNode::Ideal_length(rawoop, &_gvn) == ln, 2851 assert(AllocateArrayNode::Ideal_array_allocation(rawoop, &_gvn) == alloc->as_AllocateArray(),
2845 "Ideal_length works"); 2852 "Ideal_allocation works");
2846 assert(AllocateArrayNode::Ideal_length(javaoop, &_gvn) == ln, 2853 assert(AllocateArrayNode::Ideal_array_allocation(javaoop, &_gvn) == alloc->as_AllocateArray(),
2847 "Ideal_length works"); 2854 "Ideal_allocation works");
2848 } else { 2855 } else {
2849 assert(ln->is_top(), "no length, please"); 2856 assert(alloc->in(AllocateNode::ALength)->is_top(), "no length, please");
2850 } 2857 }
2851 } 2858 }
2852 #endif //ASSERT 2859 #endif //ASSERT
2853 2860
2854 return javaoop; 2861 return javaoop;
3093 // Cast to correct type. Note that the klass_node may be constant or not, 3100 // Cast to correct type. Note that the klass_node may be constant or not,
3094 // and in the latter case the actual array type will be inexact also. 3101 // and in the latter case the actual array type will be inexact also.
3095 // (This happens via a non-constant argument to inline_native_newArray.) 3102 // (This happens via a non-constant argument to inline_native_newArray.)
3096 // In any case, the value of klass_node provides the desired array type. 3103 // In any case, the value of klass_node provides the desired array type.
3097 const TypeInt* length_type = _gvn.find_int_type(length); 3104 const TypeInt* length_type = _gvn.find_int_type(length);
3098 const TypeInt* narrow_length_type = NULL;
3099 const TypeOopPtr* ary_type = _gvn.type(klass_node)->is_klassptr()->as_instance_type(); 3105 const TypeOopPtr* ary_type = _gvn.type(klass_node)->is_klassptr()->as_instance_type();
3100 if (ary_type->isa_aryptr() && length_type != NULL) { 3106 if (ary_type->isa_aryptr() && length_type != NULL) {
3101 // Try to get a better type than POS for the size 3107 // Try to get a better type than POS for the size
3102 ary_type = ary_type->is_aryptr()->cast_to_size(length_type); 3108 ary_type = ary_type->is_aryptr()->cast_to_size(length_type);
3103 narrow_length_type = ary_type->is_aryptr()->size();
3104 if (narrow_length_type == length_type)
3105 narrow_length_type = NULL;
3106 } 3109 }
3107 3110
3108 Node* javaoop = set_output_for_allocation(alloc, ary_type, raw_mem_only); 3111 Node* javaoop = set_output_for_allocation(alloc, ary_type, raw_mem_only);
3109 3112
3110 // Cast length on remaining path to be positive: 3113 // Cast length on remaining path to be as narrow as possible
3111 if (narrow_length_type != NULL) { 3114 if (map()->find_edge(length) >= 0) {
3112 Node* ccast = new (C, 2) CastIINode(length, narrow_length_type); 3115 Node* ccast = alloc->make_ideal_length(ary_type, &_gvn);
3113 ccast->set_req(0, control()); 3116 if (ccast != length) {
3114 _gvn.set_type_bottom(ccast); 3117 _gvn.set_type_bottom(ccast);
3115 record_for_igvn(ccast); 3118 record_for_igvn(ccast);
3116 if (map()->find_edge(length) >= 0) {
3117 replace_in_map(length, ccast); 3119 replace_in_map(length, ccast);
3118 } 3120 }
3119 } 3121 }
3120 3122
3121 return javaoop; 3123 return javaoop;