1.1 --- a/src/share/vm/opto/graphKit.cpp Wed Sep 24 15:34:06 2008 -0400 1.2 +++ b/src/share/vm/opto/graphKit.cpp Tue Sep 30 15:53:55 2008 -0700 1.3 @@ -587,7 +587,7 @@ 1.4 #ifdef ASSERT 1.5 _bci = kit->bci(); 1.6 Parse* parser = kit->is_Parse(); 1.7 - int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->pre_order(); 1.8 + int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo(); 1.9 _block = block; 1.10 #endif 1.11 } 1.12 @@ -596,7 +596,7 @@ 1.13 #ifdef ASSERT 1.14 assert(kit->bci() == _bci, "bci must not shift"); 1.15 Parse* parser = kit->is_Parse(); 1.16 - int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->pre_order(); 1.17 + int block = (parser == NULL || parser->block() == NULL) ? -1 : parser->block()->rpo(); 1.18 assert(block == _block, "block must not shift"); 1.19 #endif 1.20 kit->set_map(_map); 1.21 @@ -1049,10 +1049,19 @@ 1.22 //-------------------------load_array_length----------------------------------- 1.23 Node* GraphKit::load_array_length(Node* array) { 1.24 // Special-case a fresh allocation to avoid building nodes: 1.25 - Node* alen = AllocateArrayNode::Ideal_length(array, &_gvn); 1.26 - if (alen != NULL) return alen; 1.27 - Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes()); 1.28 - return _gvn.transform( new (C, 3) LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS)); 1.29 + AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(array, &_gvn); 1.30 + Node *alen; 1.31 + if (alloc == NULL) { 1.32 + Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes()); 1.33 + alen = _gvn.transform( new (C, 3) LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS)); 1.34 + } else { 1.35 + alen = alloc->Ideal_length(); 1.36 + Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_aryptr(), &_gvn); 1.37 + if (ccast != alen) { 1.38 + alen = _gvn.transform(ccast); 1.39 + } 1.40 + } 1.41 + return alen; 1.42 } 1.43 1.44 //------------------------------do_null_check---------------------------------- 1.45 @@ -2847,20 +2856,18 @@ 1.46 assert(just_allocated_object(control()) == javaoop, "just allocated"); 1.47 1.48 #ifdef ASSERT 1.49 - { // Verify that the AllocateNode::Ideal_foo recognizers work: 1.50 - Node* kn = alloc->in(AllocateNode::KlassNode); 1.51 - Node* ln = alloc->in(AllocateNode::ALength); 1.52 - assert(AllocateNode::Ideal_klass(rawoop, &_gvn) == kn, 1.53 - "Ideal_klass works"); 1.54 - assert(AllocateNode::Ideal_klass(javaoop, &_gvn) == kn, 1.55 - "Ideal_klass works"); 1.56 + { // Verify that the AllocateNode::Ideal_allocation recognizers work: 1.57 + assert(AllocateNode::Ideal_allocation(rawoop, &_gvn) == alloc, 1.58 + "Ideal_allocation works"); 1.59 + assert(AllocateNode::Ideal_allocation(javaoop, &_gvn) == alloc, 1.60 + "Ideal_allocation works"); 1.61 if (alloc->is_AllocateArray()) { 1.62 - assert(AllocateArrayNode::Ideal_length(rawoop, &_gvn) == ln, 1.63 - "Ideal_length works"); 1.64 - assert(AllocateArrayNode::Ideal_length(javaoop, &_gvn) == ln, 1.65 - "Ideal_length works"); 1.66 + assert(AllocateArrayNode::Ideal_array_allocation(rawoop, &_gvn) == alloc->as_AllocateArray(), 1.67 + "Ideal_allocation works"); 1.68 + assert(AllocateArrayNode::Ideal_array_allocation(javaoop, &_gvn) == alloc->as_AllocateArray(), 1.69 + "Ideal_allocation works"); 1.70 } else { 1.71 - assert(ln->is_top(), "no length, please"); 1.72 + assert(alloc->in(AllocateNode::ALength)->is_top(), "no length, please"); 1.73 } 1.74 } 1.75 #endif //ASSERT 1.76 @@ -3109,25 +3116,20 @@ 1.77 // (This happens via a non-constant argument to inline_native_newArray.) 1.78 // In any case, the value of klass_node provides the desired array type. 1.79 const TypeInt* length_type = _gvn.find_int_type(length); 1.80 - const TypeInt* narrow_length_type = NULL; 1.81 const TypeOopPtr* ary_type = _gvn.type(klass_node)->is_klassptr()->as_instance_type(); 1.82 if (ary_type->isa_aryptr() && length_type != NULL) { 1.83 // Try to get a better type than POS for the size 1.84 ary_type = ary_type->is_aryptr()->cast_to_size(length_type); 1.85 - narrow_length_type = ary_type->is_aryptr()->size(); 1.86 - if (narrow_length_type == length_type) 1.87 - narrow_length_type = NULL; 1.88 } 1.89 1.90 Node* javaoop = set_output_for_allocation(alloc, ary_type, raw_mem_only); 1.91 1.92 - // Cast length on remaining path to be positive: 1.93 - if (narrow_length_type != NULL) { 1.94 - Node* ccast = new (C, 2) CastIINode(length, narrow_length_type); 1.95 - ccast->set_req(0, control()); 1.96 - _gvn.set_type_bottom(ccast); 1.97 - record_for_igvn(ccast); 1.98 - if (map()->find_edge(length) >= 0) { 1.99 + // Cast length on remaining path to be as narrow as possible 1.100 + if (map()->find_edge(length) >= 0) { 1.101 + Node* ccast = alloc->make_ideal_length(ary_type, &_gvn); 1.102 + if (ccast != length) { 1.103 + _gvn.set_type_bottom(ccast); 1.104 + record_for_igvn(ccast); 1.105 replace_in_map(length, ccast); 1.106 } 1.107 }