comparison src/share/vm/opto/callnode.cpp @ 74:2a9af0b9cb1c

6674600: (Escape Analysis) Optimize memory graph for instance's fields Summary: EA gives opportunite to do more aggressive memory optimizations. Reviewed-by: never, jrose
author kvn
date Thu, 20 Mar 2008 15:11:44 -0700
parents 6dbf1a175d6b
children 885ed790ecf0
comparison
equal deleted inserted replaced
73:a8880a78d355 74:2a9af0b9cb1c
623 uint CallNode::match_edge(uint idx) const { 623 uint CallNode::match_edge(uint idx) const {
624 return 0; 624 return 0;
625 } 625 }
626 626
627 // 627 //
628 // Determine whether the call could modify a memory value of the 628 // Determine whether the call could modify the field of the specified
629 // specified address type 629 // instance at the specified offset.
630 // 630 //
631 bool CallNode::may_modify(const TypePtr *addr_t, PhaseTransform *phase) { 631 bool CallNode::may_modify(const TypePtr *addr_t, PhaseTransform *phase) {
632 const TypeOopPtr *adrInst_t = addr_t->isa_oopptr(); 632 const TypeOopPtr *adrInst_t = addr_t->isa_oopptr();
633 633
634 // if not an InstPtr or not an instance type, assume the worst 634 // if not an InstPtr or not an instance type, assume the worst
636 return true; 636 return true;
637 } 637 }
638 Compile *C = phase->C; 638 Compile *C = phase->C;
639 int offset = adrInst_t->offset(); 639 int offset = adrInst_t->offset();
640 assert(offset >= 0, "should be valid offset"); 640 assert(offset >= 0, "should be valid offset");
641 assert(addr_t->isa_instptr() || addr_t->isa_aryptr(), "only instances or arrays are expected"); 641 ciKlass* adr_k = adrInst_t->klass();
642 assert(adr_k->is_loaded() &&
643 adr_k->is_java_klass() &&
644 !adr_k->is_interface(),
645 "only non-abstract classes are expected");
642 646
643 int base_idx = C->get_alias_index(adrInst_t); 647 int base_idx = C->get_alias_index(adrInst_t);
648 int size = BytesPerLong; // If we don't know the size, assume largest.
649 if (adrInst_t->isa_instptr()) {
650 ciField* field = C->alias_type(base_idx)->field();
651 if (field != NULL) {
652 size = field->size_in_bytes();
653 }
654 } else {
655 assert(adrInst_t->isa_aryptr(), "only arrays are expected");
656 size = type2aelembytes(adr_k->as_array_klass()->element_type()->basic_type());
657 }
658
644 ciMethod * meth = is_CallStaticJava() ? as_CallStaticJava()->method() : NULL; 659 ciMethod * meth = is_CallStaticJava() ? as_CallStaticJava()->method() : NULL;
645 BCEscapeAnalyzer *bcea = (meth != NULL) ? meth->get_bcea() : NULL; 660 BCEscapeAnalyzer *bcea = (meth != NULL) ? meth->get_bcea() : NULL;
646 661
647 const TypeTuple * d = tf()->domain(); 662 const TypeTuple * d = tf()->domain();
648 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { 663 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) {
654 669
655 const TypeOopPtr *at_ptr = at->isa_oopptr(); 670 const TypeOopPtr *at_ptr = at->isa_oopptr();
656 if (!arg->is_top() && (t->isa_oopptr() != NULL || 671 if (!arg->is_top() && (t->isa_oopptr() != NULL ||
657 t->isa_ptr() && at_ptr != NULL)) { 672 t->isa_ptr() && at_ptr != NULL)) {
658 assert(at_ptr != NULL, "expecting an OopPtr"); 673 assert(at_ptr != NULL, "expecting an OopPtr");
659 // If we have found an argument matching adr_base_t, check if the field 674 ciKlass* at_k = at_ptr->klass();
660 // at the specified offset is modified. Since we don't know the size, 675 if ((adrInst_t->base() == at_ptr->base()) &&
661 // assume 8. 676 at_k->is_loaded() &&
662 int at_idx = C->get_alias_index(at_ptr->add_offset(offset)->isa_oopptr()); 677 at_k->is_java_klass() &&
663 if (base_idx == at_idx && 678 !at_k->is_interface()) {
664 (bcea == NULL || 679 // If we have found an argument matching addr_t, check if the field
665 bcea->is_arg_modified(i - TypeFunc::Parms, offset, 8))) { 680 // at the specified offset is modified.
666 return true; 681 int at_idx = C->get_alias_index(at_ptr->add_offset(offset)->isa_oopptr());
682 if (base_idx == at_idx &&
683 (bcea == NULL ||
684 bcea->is_arg_modified(i - TypeFunc::Parms, offset, size))) {
685 return true;
686 }
667 } 687 }
668 } 688 }
669 } 689 }
670 return false; 690 return false;
671 } 691 }