< prev index next >

src/share/vm/opto/parse1.cpp

Print this page




 801       ret_type = TypeOopPtr::BOTTOM;
 802     }
 803     if ((_caller->has_method() || tf()->returns_value_type_as_fields()) &&
 804         ret_type->isa_valuetypeptr() &&
 805         ret_type->is_valuetypeptr()->klass() != C->env()->___Value_klass()) {
 806       // When inlining or with multiple return values: return value
 807       // type as ValueTypeNode not as oop
 808       ret_type = ret_type->is_valuetypeptr()->value_type();
 809     }
 810     int         ret_size = type2size[ret_type->basic_type()];
 811     Node*       ret_phi  = new PhiNode(region, ret_type);
 812     gvn().set_type_bottom(ret_phi);
 813     _exits.ensure_stack(ret_size);
 814     assert((int)(tf()->range_sig()->cnt() - TypeFunc::Parms) == ret_size, "good tf range");
 815     assert(method()->return_type()->size() == ret_size, "tf agrees w/ method");
 816     _exits.set_argument(0, ret_phi);  // here is where the parser finds it
 817     // Note:  ret_phi is not yet pushed, until do_exits.
 818   }
 819 }
 820 
 821 // Helper function to create a ValueTypeNode from its fields passed as
 822 // arguments. Fields are passed in order of increasing offsets.
 823 Node* Compile::create_vt_node(Node* n, ciValueKlass* vk, ciValueKlass* base_vk, int base_offset, int base_input, bool in) {
 824   assert(base_offset >= 0, "offset in value type always positive");
 825   PhaseGVN& gvn = *initial_gvn();
 826   ValueTypeNode* vt = ValueTypeNode::make(gvn, vk);
 827   for (uint i = 0; i < vt->field_count(); i++) {
 828     ciType* field_type = vt->field_type(i);
 829     int offset = base_offset + vt->field_offset(i) - (base_offset > 0 ? vk->first_field_offset() : 0);
 830     if (field_type->is_valuetype()) {
 831       ciValueKlass* embedded_vk = field_type->as_value_klass();
 832       Node* embedded_vt = create_vt_node(n, embedded_vk, base_vk, offset, base_input, in);
 833       vt->set_field_value(i, embedded_vt);
 834     } else {
 835       int j = 0; int extra = 0;
 836       for (; j < base_vk->nof_nonstatic_fields(); j++) {
 837         ciField* f = base_vk->nonstatic_field_at(j);
 838         if (offset == f->offset()) {
 839           assert(f->type() == field_type, "inconsistent field type");
 840           break;
 841         }
 842         BasicType bt = f->type()->basic_type();
 843         if (bt == T_LONG || bt == T_DOUBLE) {
 844           extra++;
 845         }
 846       }
 847       assert(j != base_vk->nof_nonstatic_fields(), "must find");
 848       Node* parm = NULL;
 849       if (n->is_Start()) {
 850         assert(in, "return from start?");
 851         parm = gvn.transform(new ParmNode(n->as_Start(), base_input + j + extra));
 852       } else {
 853         if (in) {
 854           assert(n->is_Call(), "nothing else here");
 855           parm = n->in(base_input + j + extra);
 856         } else {
 857           parm = gvn.transform(new ProjNode(n->as_Call(), base_input + j + extra));
 858         }
 859       }
 860       vt->set_field_value(i, parm);
 861       // Record all these guys for later GVN.
 862       record_for_igvn(parm);
 863     }
 864   }
 865   return gvn.transform(vt);
 866 }
 867 
 868 //----------------------------build_start_state-------------------------------
 869 // Construct a state which contains only the incoming arguments from an
 870 // unknown caller.  The method & bci will be NULL & InvocationEntryBci.
 871 JVMState* Compile::build_start_state(StartNode* start, const TypeFunc* tf) {
 872   int        arg_size_sig = tf->domain_sig()->cnt();
 873   int        max_size = MAX2(arg_size_sig, (int)tf->range_cc()->cnt());
 874   JVMState*  jvms     = new (this) JVMState(max_size - TypeFunc::Parms);
 875   SafePointNode* map  = new SafePointNode(max_size, NULL);
 876   record_for_igvn(map);
 877   assert(arg_size_sig == TypeFunc::Parms + (is_osr_compilation() ? 1 : method()->arg_size()), "correct arg_size");
 878   Node_Notes* old_nn = default_node_notes();
 879   if (old_nn != NULL && has_method()) {
 880     Node_Notes* entry_nn = old_nn->clone(this);
 881     JVMState* entry_jvms = new(this) JVMState(method(), old_nn->jvms());
 882     entry_jvms->set_offsets(0);
 883     entry_jvms->set_bci(entry_bci());
 884     entry_nn->set_jvms(entry_jvms);
 885     set_default_node_notes(entry_nn);
 886   }
 887   PhaseGVN& gvn = *initial_gvn();
 888   uint j = 0;
 889   for (uint i = 0; i < (uint)arg_size_sig; i++) {
 890     assert(j >= i, "less actual arguments than in the signature?");
 891     if (ValueTypePassFieldsAsArgs) {
 892       if (i < TypeFunc::Parms) {
 893         assert(i == j, "no change before the actual arguments");
 894         Node* parm = gvn.transform(new ParmNode(start, i));
 895         map->init_req(i, parm);
 896         // Record all these guys for later GVN.
 897         record_for_igvn(parm);
 898         j++;
 899       } else {
 900         // Value type arguments are not passed by reference: we get an
 901         // argument per field of the value type. Build ValueTypeNodes
 902         // from the value type arguments.
 903         const Type* t = tf->domain_sig()->field_at(i);
 904         if (t->isa_valuetypeptr() && t->is_valuetypeptr()->klass() != C->env()->___Value_klass()) {
 905           ciValueKlass* vk = t->is_valuetypeptr()->value_type()->value_klass();
 906           Node* vt = create_vt_node(start, vk, vk, 0, j, true);
 907           map->init_req(i, gvn.transform(vt));
 908           j += vk->value_arg_slots();
 909         } else {
 910           Node* parm = gvn.transform(new ParmNode(start, j));
 911           map->init_req(i, parm);
 912           // Record all these guys for later GVN.
 913           record_for_igvn(parm);
 914           j++;
 915         }
 916       }
 917     } else {
 918      Node* parm = gvn.transform(new ParmNode(start, i));
 919      // Check if parameter is a value type pointer
 920      if (gvn.type(parm)->isa_valuetypeptr()) {
 921        // Create ValueTypeNode from the oop and replace the parameter
 922        parm = ValueTypeNode::make(gvn, map->memory(), parm);
 923      }
 924      map->init_req(i, parm);
 925      // Record all these guys for later GVN.
 926      record_for_igvn(parm);




 801       ret_type = TypeOopPtr::BOTTOM;
 802     }
 803     if ((_caller->has_method() || tf()->returns_value_type_as_fields()) &&
 804         ret_type->isa_valuetypeptr() &&
 805         ret_type->is_valuetypeptr()->klass() != C->env()->___Value_klass()) {
 806       // When inlining or with multiple return values: return value
 807       // type as ValueTypeNode not as oop
 808       ret_type = ret_type->is_valuetypeptr()->value_type();
 809     }
 810     int         ret_size = type2size[ret_type->basic_type()];
 811     Node*       ret_phi  = new PhiNode(region, ret_type);
 812     gvn().set_type_bottom(ret_phi);
 813     _exits.ensure_stack(ret_size);
 814     assert((int)(tf()->range_sig()->cnt() - TypeFunc::Parms) == ret_size, "good tf range");
 815     assert(method()->return_type()->size() == ret_size, "tf agrees w/ method");
 816     _exits.set_argument(0, ret_phi);  // here is where the parser finds it
 817     // Note:  ret_phi is not yet pushed, until do_exits.
 818   }
 819 }
 820 















































 821 //----------------------------build_start_state-------------------------------
 822 // Construct a state which contains only the incoming arguments from an
 823 // unknown caller.  The method & bci will be NULL & InvocationEntryBci.
 824 JVMState* Compile::build_start_state(StartNode* start, const TypeFunc* tf) {
 825   int        arg_size_sig = tf->domain_sig()->cnt();
 826   int        max_size = MAX2(arg_size_sig, (int)tf->range_cc()->cnt());
 827   JVMState*  jvms     = new (this) JVMState(max_size - TypeFunc::Parms);
 828   SafePointNode* map  = new SafePointNode(max_size, NULL);
 829   record_for_igvn(map);
 830   assert(arg_size_sig == TypeFunc::Parms + (is_osr_compilation() ? 1 : method()->arg_size()), "correct arg_size");
 831   Node_Notes* old_nn = default_node_notes();
 832   if (old_nn != NULL && has_method()) {
 833     Node_Notes* entry_nn = old_nn->clone(this);
 834     JVMState* entry_jvms = new(this) JVMState(method(), old_nn->jvms());
 835     entry_jvms->set_offsets(0);
 836     entry_jvms->set_bci(entry_bci());
 837     entry_nn->set_jvms(entry_jvms);
 838     set_default_node_notes(entry_nn);
 839   }
 840   PhaseGVN& gvn = *initial_gvn();
 841   uint j = 0;
 842   for (uint i = 0; i < (uint)arg_size_sig; i++) {
 843     assert(j >= i, "less actual arguments than in the signature?");
 844     if (ValueTypePassFieldsAsArgs) {
 845       if (i < TypeFunc::Parms) {
 846         assert(i == j, "no change before the actual arguments");
 847         Node* parm = gvn.transform(new ParmNode(start, i));
 848         map->init_req(i, parm);
 849         // Record all these guys for later GVN.
 850         record_for_igvn(parm);
 851         j++;
 852       } else {
 853         // Value type arguments are not passed by reference: we get an
 854         // argument per field of the value type. Build ValueTypeNodes
 855         // from the value type arguments.
 856         const Type* t = tf->domain_sig()->field_at(i);
 857         if (t->isa_valuetypeptr() && t->is_valuetypeptr()->klass() != C->env()->___Value_klass()) {
 858           ciValueKlass* vk = t->is_valuetypeptr()->value_type()->value_klass();
 859           Node* vt = ValueTypeNode::make(gvn, start, vk, j, true);
 860           map->init_req(i, gvn.transform(vt));
 861           j += vk->value_arg_slots();
 862         } else {
 863           Node* parm = gvn.transform(new ParmNode(start, j));
 864           map->init_req(i, parm);
 865           // Record all these guys for later GVN.
 866           record_for_igvn(parm);
 867           j++;
 868         }
 869       }
 870     } else {
 871      Node* parm = gvn.transform(new ParmNode(start, i));
 872      // Check if parameter is a value type pointer
 873      if (gvn.type(parm)->isa_valuetypeptr()) {
 874        // Create ValueTypeNode from the oop and replace the parameter
 875        parm = ValueTypeNode::make(gvn, map->memory(), parm);
 876      }
 877      map->init_req(i, parm);
 878      // Record all these guys for later GVN.
 879      record_for_igvn(parm);


< prev index next >