< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page
@@ -181,10 +181,42 @@
      }
    }
  }
  #endif
  
+ // Array of RegMask, one per returned values (inline type instances can
+ // be returned as multiple return values, one per field)
+ RegMask* Matcher::return_values_mask(const TypeTuple* range) {
+   uint cnt = range->cnt() - TypeFunc::Parms;
+   if (cnt == 0) {
+     return NULL;
+   }
+   RegMask* mask = NEW_RESOURCE_ARRAY(RegMask, cnt);
+   BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, cnt);
+   VMRegPair* vm_parm_regs = NEW_RESOURCE_ARRAY(VMRegPair, cnt);
+ 
+   for (uint i = 0; i < cnt; i++) {
+     sig_bt[i] = range->field_at(i+TypeFunc::Parms)->basic_type();
+   }
+ 
+   int regs = SharedRuntime::java_return_convention(sig_bt, vm_parm_regs, cnt);
+   assert(regs > 0, "should have been tested during graph construction");
+   for (uint i = 0; i < cnt; i++) {
+     mask[i].Clear();
+ 
+     OptoReg::Name reg1 = OptoReg::as_OptoReg(vm_parm_regs[i].first());
+     if (OptoReg::is_valid(reg1)) {
+       mask[i].Insert(reg1);
+     }
+     OptoReg::Name reg2 = OptoReg::as_OptoReg(vm_parm_regs[i].second());
+     if (OptoReg::is_valid(reg2)) {
+       mask[i].Insert(reg2);
+     }
+   }
+ 
+   return mask;
+ }
  
  //---------------------------match---------------------------------------------
  void Matcher::match( ) {
    if( MaxLabelRootDepth < 100 ) { // Too small?
      assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");

@@ -196,33 +228,22 @@
  #ifdef _LP64
    // Pointers take 2 slots in 64-bit land
    _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
  #endif
  
-   // Map a Java-signature return type into return register-value
-   // machine registers for 0, 1 and 2 returned values.
-   const TypeTuple *range = C->tf()->range();
-   if( range->cnt() > TypeFunc::Parms ) { // If not a void function
-     // Get ideal-register return type
-     uint ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
-     // Get machine return register
-     uint sop = C->start()->Opcode();
-     OptoRegPair regs = return_value(ireg);
- 
-     // And mask for same
-     _return_value_mask = RegMask(regs.first());
-     if( OptoReg::is_valid(regs.second()) )
-       _return_value_mask.Insert(regs.second());
-   }
+   // Map Java-signature return types into return register-value
+   // machine registers.
+   const TypeTuple *range = C->tf()->range_cc();
+   _return_values_mask = return_values_mask(range);
  
    // ---------------
    // Frame Layout
  
    // Need the method signature to determine the incoming argument types,
    // because the types determine which registers the incoming arguments are
    // in, and this affects the matched code.
-   const TypeTuple *domain = C->tf()->domain();
+   const TypeTuple *domain = C->tf()->domain_cc();
    uint             argcnt = domain->cnt() - TypeFunc::Parms;
    BasicType *sig_bt        = NEW_RESOURCE_ARRAY( BasicType, argcnt );
    VMRegPair *vm_parm_regs  = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
    _parm_regs               = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
    _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );

@@ -503,10 +524,11 @@
    // Add in the incoming argument area
    OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
    for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
      C->FIRST_STACK_mask().Insert(i);
    }
+ 
    // Add in all bits past the outgoing argument area
    guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
              "must be able to represent all call arguments in reg mask");
    OptoReg::Name init = _out_arg_limit;
    for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {

@@ -744,16 +766,15 @@
    assert( start, "Expect a start node" );
  
    // Input RegMask array shared by all Returns.
    // The type for doubles and longs has a count of 2, but
    // there is only 1 returned value
-   uint ret_edge_cnt = TypeFunc::Parms + ((C->tf()->range()->cnt() == TypeFunc::Parms) ? 0 : 1);
+   uint ret_edge_cnt = C->tf()->range_cc()->cnt();
    RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
-   // Returns have 0 or 1 returned values depending on call signature.
-   // Return register is specified by return_value in the AD file.
-   if (ret_edge_cnt > TypeFunc::Parms)
-     ret_rms[TypeFunc::Parms+0] = _return_value_mask;
+   for (i = TypeFunc::Parms; i < ret_edge_cnt; i++) {
+     ret_rms[i] = _return_values_mask[i-TypeFunc::Parms];
+   }
  
    // Input RegMask array shared by all Rethrows.
    uint reth_edge_cnt = TypeFunc::Parms+1;
    RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
    // Rethrow takes exception oop only, but in the argument 0 slot.

@@ -816,11 +837,11 @@
        default          : ShouldNotReachHere();
      }
    }
  
    // Next unused projection number from Start.
-   int proj_cnt = C->tf()->domain()->cnt();
+   int proj_cnt = C->tf()->domain_cc()->cnt();
  
    // Do all the save-on-entry registers.  Make projections from Start for
    // them, and give them a use at the exit points.  To the allocator, they
    // look like incoming register arguments.
    for( i = 0; i < _last_Mach_Reg; i++ ) {

@@ -1088,11 +1109,15 @@
                m->as_MachMemBar()->set_adr_type(n->adr_type());
              }
            } else {                  // Nothing the matcher cares about
              if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
                // Convert to machine-dependent projection
-               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );
+               RegMask* mask = NULL;
+               if (n->in(0)->is_Call() && n->in(0)->as_Call()->tf()->returns_inline_type_as_fields()) {
+                 mask = return_values_mask(n->in(0)->as_Call()->tf()->range_cc());
+               }
+               m = n->in(0)->as_Multi()->match(n->as_Proj(), this, mask);
                NOT_PRODUCT(record_new2old(m, n);)
                if (m->in(0) != NULL) // m might be top
                  collect_null_checks(m, n);
              } else {                // Else just a regular 'ol guy
                m = n->clone();       // So just clone into new-space

@@ -1227,11 +1252,11 @@
    const TypeTuple *domain;
    ciMethod*        method = NULL;
    bool             is_method_handle_invoke = false;  // for special kill effects
    if( sfpt->is_Call() ) {
      call = sfpt->as_Call();
-     domain = call->tf()->domain();
+     domain = call->tf()->domain_cc();
      cnt = domain->cnt();
  
      // Match just the call, nothing else
      MachNode *m = match_tree(call);
      if (C->failing())  return NULL;

@@ -1315,17 +1340,20 @@
    if( call != NULL && call->is_CallNative() )
      out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call, call->as_CallNative()->_shadow_space_bytes);
  
  
    // Do the normal argument list (parameters) register masks
-   int argcnt = cnt - TypeFunc::Parms;
+   // Null entry point is a special cast where the target of the call
+   // is in a register.
+   int adj = (call != NULL && call->entry_point() == NULL) ? 1 : 0;
+   int argcnt = cnt - TypeFunc::Parms - adj;
    if( argcnt > 0 ) {          // Skip it all if we have no args
      BasicType *sig_bt  = NEW_RESOURCE_ARRAY( BasicType, argcnt );
      VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
      int i;
      for( i = 0; i < argcnt; i++ ) {
-       sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
+       sig_bt[i] = domain->field_at(i+TypeFunc::Parms+adj)->basic_type();
      }
      // V-call to pick proper calling convention
      call->calling_convention( sig_bt, parm_regs, argcnt );
  
  #ifdef ASSERT

@@ -1362,11 +1390,11 @@
      // Return results now can have 2 bits returned.
      // Compute max over all outgoing arguments both per call-site
      // and over the entire method.
      for( i = 0; i < argcnt; i++ ) {
        // Address of incoming argument mask to fill in
-       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
+       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms+adj];
        VMReg first = parm_regs[i].first();
        VMReg second = parm_regs[i].second();
        if(!first->is_valid() &&
           !second->is_valid()) {
          continue;               // Avoid Halves

@@ -1380,16 +1408,18 @@
            rm->Insert(r);
          }
        }
        // Grab first register, adjust stack slots and insert in mask.
        OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
-       if (OptoReg::is_valid(reg1))
+       if (OptoReg::is_valid(reg1)) {
          rm->Insert( reg1 );
+       }
        // Grab second register (if any), adjust stack slots and insert in mask.
        OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
-       if (OptoReg::is_valid(reg2))
+       if (OptoReg::is_valid(reg2)) {
          rm->Insert( reg2 );
+       }
      } // End of for all arguments
    }
  
    // Compute the max stack slot killed by any call.  These will not be
    // available for debug info, and will be used to adjust FIRST_STACK_mask

@@ -1401,11 +1431,11 @@
      // Kill the outgoing argument area, including any non-argument holes and
      // any legacy C-killed slots.  Use Fat-Projections to do the killing.
      // Since the max-per-method covers the max-per-call-site and debug info
      // is excluded on the max-per-method basis, debug info cannot land in
      // this killed area.
-     uint r_cnt = mcall->tf()->range()->cnt();
+     uint r_cnt = mcall->tf()->range_sig()->cnt();
      MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
      if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
        C->record_method_not_compilable("unsupported outgoing calling sequence");
      } else {
        for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)

@@ -1422,11 +1452,11 @@
      jvms->set_map(sfpt);
    }
  
    // Debug inputs begin just after the last incoming parameter
    assert((mcall == NULL) || (mcall->jvms() == NULL) ||
-          (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain()->cnt()), "");
+          (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain_cc()->cnt()), "");
  
    // Add additional edges.
    if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
      // For these calls we can not add MachConstantBase in expand(), as the
      // ins are not complete then.

@@ -2105,11 +2135,11 @@
        bool mem_op = false;
        int mem_addr_idx = MemNode::Address;
        if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
          continue;
        }
-       for (int i = n->req() - 1; i >= 0; --i) { // For my children
+       for (int i = n->len() - 1; i >= 0; --i) { // For my children
          Node* m = n->in(i); // Get ith input
          if (m == NULL) {
            continue;  // Ignore NULLs
          }
          if (clone_node(n, m, mstack)) {

@@ -2394,10 +2424,17 @@
        n->set_req(2, pair2);
        n->del_req(4);
        n->del_req(3);
        break;
      }
+     case Op_ClearArray: {
+       Node* pair = new BinaryNode(n->in(2), n->in(3));
+       n->set_req(2, pair);
+       n->set_req(3, n->in(4));
+       n->del_req(4);
+       break;
+     }
      case Op_CopySignD:
      case Op_SignumF:
      case Op_SignumD: {
        Node* pair = new BinaryNode(n->in(2), n->in(3));
        n->set_req(2, pair);
< prev index next >