< prev index next >

src/share/vm/opto/parse1.cpp

Print this page
rev 10494 : more
rev 10496 : more
rev 10513 : fix incremental inlining with value types


 773     if (ret_oop_type && !ret_oop_type->klass()->is_loaded()) {
 774       ret_type = TypeOopPtr::BOTTOM;
 775     }
 776     if (_caller->has_method() && ret_type->isa_valuetypeptr()) {
 777       // When inlining, return value type as ValueTypeNode not as oop
 778       ret_type = ret_type->is_valuetypeptr()->value_type();
 779     }
 780     int         ret_size = type2size[ret_type->basic_type()];
 781     Node*       ret_phi  = new PhiNode(region, ret_type);
 782     gvn().set_type_bottom(ret_phi);
 783     _exits.ensure_stack(ret_size);
 784     assert((int)(tf()->range()->cnt() - TypeFunc::Parms) == ret_size, "good tf range");
 785     assert(method()->return_type()->size() == ret_size, "tf agrees w/ method");
 786     _exits.set_argument(0, ret_phi);  // here is where the parser finds it
 787     // Note:  ret_phi is not yet pushed, until do_exits.
 788   }
 789 }
 790 
 791 // Helper function to create a ValueTypeNode from its fields passed as
 792 // arguments. Fields are passed in order of increasing offsets.
 793 static Node* create_vt_node(StartNode* start, ciValueKlass* vk, ciValueKlass* base_vk, int base_offset, int base_input, Compile* C) {
 794   assert(base_offset >= 0, "offset in value type always positive");
 795   PhaseGVN& gvn = *C->initial_gvn();
 796   ValueTypeNode* vt = ValueTypeNode::make(gvn, vk);
 797   for (uint i = 0; i < vt->field_count(); i++) {
 798     ciType* field_type = vt->get_field_type(i);
 799     int offset = base_offset + vt->get_field_offset(i) - (base_offset > 0 ? vk->first_field_offset() : 0);
 800     if (field_type->is_valuetype()) {
 801       ciValueKlass* embedded_vk = field_type->as_value_klass();
 802       Node* embedded_vt = create_vt_node(start, embedded_vk, base_vk, offset, base_input, C);
 803       vt->set_field_value(i, embedded_vt);
 804     } else {
 805       int j = 0; int extra = 0;
 806       for (; j < base_vk->nof_nonstatic_fields(); j++) {
 807         ciField* f = base_vk->nonstatic_field_at(j);
 808         if (offset == f->offset()) {
 809           assert(f->type() == field_type, "inconsistent field type");
 810           break;
 811         }
 812         BasicType bt = f->type()->basic_type();
 813         if (bt == T_LONG || bt == T_DOUBLE) {
 814           extra++;
 815         }
 816       }
 817       assert(j != base_vk->nof_nonstatic_fields(), "must find");
 818       Node* parm = gvn.transform(new ParmNode(start, base_input + j + extra));






 819       vt->set_field_value(i, parm);
 820       // Record all these guys for later GVN.
 821       C->record_for_igvn(parm);
 822     }
 823   }
 824   return gvn.transform(vt);
 825 }
 826 
 827 //----------------------------build_start_state-------------------------------
 828 // Construct a state which contains only the incoming arguments from an
 829 // unknown caller.  The method & bci will be NULL & InvocationEntryBci.
 830 JVMState* Compile::build_start_state(StartNode* start, const TypeFunc* tf) {
 831   int        arg_size_sig = tf->domain_sig()->cnt();
 832   int        max_size = MAX2(arg_size_sig, (int)tf->range()->cnt());
 833   JVMState*  jvms     = new (this) JVMState(max_size - TypeFunc::Parms);
 834   SafePointNode* map  = new SafePointNode(max_size, NULL);
 835   record_for_igvn(map);
 836   assert(arg_size_sig == TypeFunc::Parms + (is_osr_compilation() ? 1 : method()->arg_size()), "correct arg_size");
 837   Node_Notes* old_nn = default_node_notes();
 838   if (old_nn != NULL && has_method()) {
 839     Node_Notes* entry_nn = old_nn->clone(this);
 840     JVMState* entry_jvms = new(this) JVMState(method(), old_nn->jvms());
 841     entry_jvms->set_offsets(0);


 845   }
 846   PhaseGVN& gvn = *initial_gvn();
 847   uint j = 0;
 848   for (uint i = 0; i < (uint)arg_size_sig; i++) {
 849     assert(j >= i, "less actual arguments than in the signature?");
 850     if (ValueTypePassFieldsAsArgs) {
 851       if (i < TypeFunc::Parms) {
 852         assert(i == j, "no change before the actual arguments");
 853         Node* parm = gvn.transform(new ParmNode(start, i));
 854         map->init_req(i, parm);
 855         // Record all these guys for later GVN.
 856         record_for_igvn(parm);
 857         j++;
 858       } else {
 859         // Value type arguments are not passed by reference: we get an
 860         // argument per field of the value type. Build ValueTypeNodes
 861         // from the value type arguments.
 862         const Type* t = tf->domain_sig()->field_at(i);
 863         if (t->isa_valuetypeptr()) {
 864           ciValueKlass* vk = t->is_valuetypeptr()->value_type()->value_klass();
 865           Node* vt = create_vt_node(start, vk, vk, 0, j, C);
 866           map->init_req(i, gvn.transform(vt));
 867           int extra = 0;
 868           for (int k = 0; k < vk->nof_nonstatic_fields(); k++) {
 869             ciField* f = vk->nonstatic_field_at(k);
 870             BasicType bt = f->type()->basic_type();
 871             if (bt == T_LONG || bt == T_DOUBLE) {
 872               extra++;
 873             }
 874           }
 875           j += extra + vk->nof_nonstatic_fields();
 876         } else {
 877           Node* parm = gvn.transform(new ParmNode(start, j));
 878           map->init_req(i, parm);
 879           // Record all these guys for later GVN.
 880           record_for_igvn(parm);
 881           j++;
 882         }
 883       }
 884     } else {
 885      Node* parm = gvn.transform(new ParmNode(start, i));
 886      // Check if parameter is a value type pointer
 887      if (gvn.type(parm)->isa_valuetypeptr()) {
 888        // Create ValueTypeNode from the oop and replace the parameter
 889        parm = ValueTypeNode::make(gvn, map->memory(), parm);
 890      }
 891      map->init_req(i, parm);
 892      // Record all these guys for later GVN.
 893      record_for_igvn(parm);
 894      j++;
 895     }




 773     if (ret_oop_type && !ret_oop_type->klass()->is_loaded()) {
 774       ret_type = TypeOopPtr::BOTTOM;
 775     }
 776     if (_caller->has_method() && ret_type->isa_valuetypeptr()) {
 777       // When inlining, return value type as ValueTypeNode not as oop
 778       ret_type = ret_type->is_valuetypeptr()->value_type();
 779     }
 780     int         ret_size = type2size[ret_type->basic_type()];
 781     Node*       ret_phi  = new PhiNode(region, ret_type);
 782     gvn().set_type_bottom(ret_phi);
 783     _exits.ensure_stack(ret_size);
 784     assert((int)(tf()->range()->cnt() - TypeFunc::Parms) == ret_size, "good tf range");
 785     assert(method()->return_type()->size() == ret_size, "tf agrees w/ method");
 786     _exits.set_argument(0, ret_phi);  // here is where the parser finds it
 787     // Note:  ret_phi is not yet pushed, until do_exits.
 788   }
 789 }
 790 
 791 // Helper function to create a ValueTypeNode from its fields passed as
 792 // arguments. Fields are passed in order of increasing offsets.
 793 Node* Compile::create_vt_node(Node* n, ciValueKlass* vk, ciValueKlass* base_vk, int base_offset, int base_input) {
 794   assert(base_offset >= 0, "offset in value type always positive");
 795   PhaseGVN& gvn = *initial_gvn();
 796   ValueTypeNode* vt = ValueTypeNode::make(gvn, vk);
 797   for (uint i = 0; i < vt->field_count(); i++) {
 798     ciType* field_type = vt->get_field_type(i);
 799     int offset = base_offset + vt->get_field_offset(i) - (base_offset > 0 ? vk->first_field_offset() : 0);
 800     if (field_type->is_valuetype()) {
 801       ciValueKlass* embedded_vk = field_type->as_value_klass();
 802       Node* embedded_vt = create_vt_node(n, embedded_vk, base_vk, offset, base_input);
 803       vt->set_field_value(i, embedded_vt);
 804     } else {
 805       int j = 0; int extra = 0;
 806       for (; j < base_vk->nof_nonstatic_fields(); j++) {
 807         ciField* f = base_vk->nonstatic_field_at(j);
 808         if (offset == f->offset()) {
 809           assert(f->type() == field_type, "inconsistent field type");
 810           break;
 811         }
 812         BasicType bt = f->type()->basic_type();
 813         if (bt == T_LONG || bt == T_DOUBLE) {
 814           extra++;
 815         }
 816       }
 817       assert(j != base_vk->nof_nonstatic_fields(), "must find");
 818       Node* parm = NULL;
 819       if (n->is_Start()) {
 820         parm = gvn.transform(new ParmNode(n->as_Start(), base_input + j + extra));
 821       } else {
 822         assert(n->is_Call(), "nothing else here");
 823         parm = n->in(base_input + j + extra);
 824       }
 825       vt->set_field_value(i, parm);
 826       // Record all these guys for later GVN.
 827       record_for_igvn(parm);
 828     }
 829   }
 830   return gvn.transform(vt);
 831 }
 832 
 833 //----------------------------build_start_state-------------------------------
 834 // Construct a state which contains only the incoming arguments from an
 835 // unknown caller.  The method & bci will be NULL & InvocationEntryBci.
 836 JVMState* Compile::build_start_state(StartNode* start, const TypeFunc* tf) {
 837   int        arg_size_sig = tf->domain_sig()->cnt();
 838   int        max_size = MAX2(arg_size_sig, (int)tf->range()->cnt());
 839   JVMState*  jvms     = new (this) JVMState(max_size - TypeFunc::Parms);
 840   SafePointNode* map  = new SafePointNode(max_size, NULL);
 841   record_for_igvn(map);
 842   assert(arg_size_sig == TypeFunc::Parms + (is_osr_compilation() ? 1 : method()->arg_size()), "correct arg_size");
 843   Node_Notes* old_nn = default_node_notes();
 844   if (old_nn != NULL && has_method()) {
 845     Node_Notes* entry_nn = old_nn->clone(this);
 846     JVMState* entry_jvms = new(this) JVMState(method(), old_nn->jvms());
 847     entry_jvms->set_offsets(0);


 851   }
 852   PhaseGVN& gvn = *initial_gvn();
 853   uint j = 0;
 854   for (uint i = 0; i < (uint)arg_size_sig; i++) {
 855     assert(j >= i, "less actual arguments than in the signature?");
 856     if (ValueTypePassFieldsAsArgs) {
 857       if (i < TypeFunc::Parms) {
 858         assert(i == j, "no change before the actual arguments");
 859         Node* parm = gvn.transform(new ParmNode(start, i));
 860         map->init_req(i, parm);
 861         // Record all these guys for later GVN.
 862         record_for_igvn(parm);
 863         j++;
 864       } else {
 865         // Value type arguments are not passed by reference: we get an
 866         // argument per field of the value type. Build ValueTypeNodes
 867         // from the value type arguments.
 868         const Type* t = tf->domain_sig()->field_at(i);
 869         if (t->isa_valuetypeptr()) {
 870           ciValueKlass* vk = t->is_valuetypeptr()->value_type()->value_klass();
 871           Node* vt = create_vt_node(start, vk, vk, 0, j);
 872           map->init_req(i, gvn.transform(vt));
 873           j += vk->value_arg_slots();








 874         } else {
 875           Node* parm = gvn.transform(new ParmNode(start, j));
 876           map->init_req(i, parm);
 877           // Record all these guys for later GVN.
 878           record_for_igvn(parm);
 879           j++;
 880         }
 881       }
 882     } else {
 883      Node* parm = gvn.transform(new ParmNode(start, i));
 884      // Check if parameter is a value type pointer
 885      if (gvn.type(parm)->isa_valuetypeptr()) {
 886        // Create ValueTypeNode from the oop and replace the parameter
 887        parm = ValueTypeNode::make(gvn, map->memory(), parm);
 888      }
 889      map->init_req(i, parm);
 890      // Record all these guys for later GVN.
 891      record_for_igvn(parm);
 892      j++;
 893     }


< prev index next >